> Java > java지도 시간 > 사례 공유: Java를 사용하여 회계 시스템 개발 및 구현(전체 코드)

사례 공유: Java를 사용하여 회계 시스템 개발 및 구현(전체 코드)

php是最好的语言
풀어 주다: 2018-08-02 12:02:41
원래의
9474명이 탐색했습니다.

이 글은 자바로 개발되어 구현된 아주 완전한 코드입니다. 시간적인 문제로 인해 설명이 부족한 부분이 있으면 함께 논의해 보세요. 코드에서 지적해도 좋습니다.

java 회계 시스템

package com.ss.file;
import java.io.*;
public class FileIO {

	private String filename = "tally.txt";
	public FileIO() {
		File file = new File(filename);
		if(!file.exists()) {
			try {
				file.createNewFile();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
	public void write(String data,boolean mode) {
		try {
			FileWriter fw = new FileWriter(filename,mode);
			BufferedWriter bw = new BufferedWriter(fw);
			bw.write(data);
			bw.close();
			fw.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public String read() {
		FileReader fr;
		String line = "";
		String fileStr = "";
		try {
			fr = new FileReader(filename);//不能一行行的读
			BufferedReader br = new BufferedReader(fr);//可以一行行的读效率高
			while((line = br.readLine()) != null) {
				fileStr += line + "\n";
			}
			br.close();
			fr.close();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return fileStr;
	}
	public String getFilename() {
		return filename;
	}
	public void setFilename(String filename) {
		this.filename = filename;
	}

}
로그인 후 복사
package com.ss.oper;
import java.util.Vector;

import com.ss.file.FileIO;
import com.ss.util.Tool;
public class Operation {
	FileIO io = new FileIO();
	public void add(String data) {
		io.write(data, true);
	}
	public void delete(String data) {
		io.write(data, false);
	}
	public void update(String data) {
		io.write(data, false);
	}
	/*
	 * 全部查询
	 */
	public Vector select() {
		String str = io.read();
		Tool tool = new Tool();
		return tool.StringToVec(str);
	}
	/*
	 * 条件查询
	 */
	public Vector select(String type,String remark) {
		Vector vecData = new Vector();
		Vector vecAll = select();
		for(int i = 0;i < vecAll.size();i++) {
			Vector smallVec = (Vector)vecAll.get(i);
			boolean select = (smallVec.get(1).toString().equals(type) || type.equals(""))
					&&
					(smallVec.get(4).toString().equals(remark) || remark.equals(""));
			if(select) {
				vecData.add(smallVec);
			}
		}
		return vecData;
	}

}
로그인 후 복사
package com.ss.util;
import java.text.SimpleDateFormat;
import java.util.*;
 
import com.ss.file.FileIO;


public class Tool {
	public String getTime() {
		Date date = new Date();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String str = sdf.format(date);
		return str;
	}
	/*
	 * 将String转化成Vector类型
	 */
	public Vector StringToVec(String data) {
		Vector bigVec = new Vector();
		if(data != null && !data.equals("")) {
			String[] array = data.split("\n");
			for(int i=0;i<array.length;i++) {
				String[] a = array[i].split(",");
				Vector smallVec = new Vector();
				smallVec.add(a[0]);
				smallVec.add(a[1]);
				smallVec.add(a[2]);
				smallVec.add(a[3]);
				smallVec.add(a[4]);
				smallVec.add(a[5]);
				smallVec.add(a[6]);
				smallVec.add(a[7]);
				smallVec.add(a[8]);
				smallVec.add(a[9]);
				smallVec.add(a[10]);
				bigVec.add(smallVec);
				}
		}
		return bigVec;
	}
	/*
	 * 获取下一个流水账号
	 */
	public int getNewID() {
		int id = 1;
		FileIO io = new FileIO();
		String data = io.read();
		if(data != null && !data.equals("")) {
			Vector bigVec = StringToVec(data);
			Vector smallVecLast = (Vector)bigVec.get(bigVec.size()-1);
			String str = (String)smallVecLast.get(0);
			id = Integer.parseInt(str) + 1;
		}
		return id;
	}

}
로그인 후 복사
package com.ss.view;


import javax.swing.*;
import javax.swing.table.DefaultTableModel;
 
import com.ss.oper.Operation;
import com.ss.util.Tool;
import java.util.Vector;
import java.awt.*;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class UI_t  extends JFrame{

	private JComboBox<String> typeCom = new JComboBox<String>();
	private JComboBox<String> typeCom2 = new JComboBox<String>();
	private JTextField moneyText = new JTextField(); 
	private JTextField stateText = new JTextField();
	private JTextField tjText = new JTextField();
	
	private JTextField kehuText = new JTextField(); 
	private JTextField jishuText = new JTextField();
	private JTextField jsmoneyText = new JTextField();
	private JTextField jsfenchengText = new JTextField();
	private JTextField yingliText = new JTextField();
	private JTextField wanchengText = new JTextField();
	
	private JTable table = new JTable();
	private DefaultTableModel dtm = new DefaultTableModel();
	private Vector<String> colName = new Vector<String>();
	
	public UI_t(){
		super("个人账目管理系统");
		this.setBounds(300, 200, 1200, 800);
		init();
	}
	
	public void init(){
		JScrollPane p1 = new JScrollPane(setTable());
		final JSplitPane p2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT,setInfo(),p1);
		p2.addComponentListener(new ComponentListener(){
 
			@Override
			public void componentResized(ComponentEvent arg0) {
				p2.setpiderLocation(0.4);
				
			}
			@Override
			public void componentHidden(ComponentEvent arg0) {
				// TODO Auto-generated method stub
				
			}
 
			@Override
			public void componentMoved(ComponentEvent arg0) {
				// TODO Auto-generated method stub
				
			}
 
			@Override
			public void componentShown(ComponentEvent arg0) {
				// TODO Auto-generated method stub
				
			}
 
			});
		this.add(p2);
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new UI_t().setVisible(true);
	}
	
	public JPanel setInfo(){
		JPanel jp = new JPanel();
		jp.setLayout(null);
		JLabel label1 = new JLabel("类型");
		label1.setBounds(10, 50, 30, 30);
		jp.add(label1);
		
		typeCom.addItem("生旦净末丑");
		typeCom.addItem("齐怪了");
		typeCom.setBounds(50, 50, 60, 30);
		jp.add(typeCom);
		
		
		JLabel label2 = new JLabel("客户名");
		label2.setBounds(120, 50, 60, 30);
		jp.add(label2);	
		kehuText.setBounds(160, 50, 60, 30);
		jp.add(kehuText);
		
		JLabel jishulabel = new JLabel("技术名");
		jishulabel.setBounds(240, 50, 60, 30);
		jp.add(jishulabel);	
		jishuText.setBounds(280, 50, 60, 30);
		jp.add(jishuText);
		
		JLabel dingdanlabel = new JLabel("订单金额");
		dingdanlabel.setBounds(340, 50, 60, 30);
		jp.add(dingdanlabel);	
		moneyText.setBounds(400, 50, 60, 30);
		jp.add(moneyText);
		
		JLabel jsjiagelabel = new JLabel("技术价格");
		jsjiagelabel.setBounds(460, 50, 60, 30);
		jp.add(jsjiagelabel);	
		jsmoneyText.setBounds(520, 50, 60, 30);
		jp.add(jsmoneyText);
		
		JLabel jsfenchenglabel = new JLabel("技术分成");
		jsfenchenglabel.setBounds(580, 50, 60, 30);
		jp.add(jsfenchenglabel);	
		jsfenchengText.setBounds(640, 50, 60, 30);
		jp.add(jsfenchengText);
		
		JLabel yinglilabel = new JLabel("盈利");
		yinglilabel.setBounds(700, 50, 40, 30);
		jp.add(yinglilabel);
		yingliText.setBounds(740, 50, 60, 30);
		jp.add(yingliText);
		
		JLabel wanchenglabel = new JLabel("完成时间");
		wanchenglabel.setBounds(820, 50, 60, 30);
		jp.add(wanchenglabel);
		wanchengText.setBounds(880, 50, 60, 30);
		jp.add(wanchengText);
		
		JLabel statelabel4 = new JLabel("状态信息");
		statelabel4.setBounds(940, 50, 60, 30);
		stateText.setBounds(1000, 50, 40, 30);
		jp.add(statelabel4);
		jp.add(stateText);
		
		
		JButton addBut = new JButton("增加");
		addBut.setBounds(400, 100, 60, 30);
		jp.add(addBut);
		
		addBut.addMouseListener(new MouseListener() {
			@Override
			public void mouseReleased(MouseEvent arg0) {
				
				
			}
			@Override
			public void mousePressed(MouseEvent arg0) {
				// TODO Auto-generated method stub
				
			}
			@Override
			public void mouseExited(MouseEvent arg0) {
			
			}
			@Override
			public void mouseEntered(MouseEvent arg0) {
				
			}
			@Override
			public void mouseClicked(MouseEvent arg0) {
				String type = (String)typeCom.getSelectedItem();//返回当前所选项
				String kehuname=kehuText.getText();
				String jishuname=jishuText.getText();
				String dingdanmoney=moneyText.getText();
				String jishumoney=jsmoneyText.getText();
				String jishufencheng=jsfenchengText.getText();
				String yingli=yingliText.getText();
				String finnishdata=wanchengText.getText();
				
				String remark = stateText.getText();
				 
				Tool tool = new Tool();
				String kaishitime = tool.getTime();
				int id = tool.getNewID();
				//修改部分
				String data = id + "," + type + "," + kehuname + "," + jishuname + "," +dingdanmoney + ","+jishumoney + ","+jishufencheng + ","+yingli + ","+kaishitime+","+finnishdata+","+remark +"\n";
				Operation oper = new Operation();
				oper.add(data);
				select();
			}
		});
		
		JButton xgBut = new JButton("修改");
		xgBut.setBounds(500, 100, 60, 30);
		jp.add(xgBut);
		xgBut.addMouseListener(new MouseListener() {
			
			@Override
			public void mouseReleased(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mousePressed(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mouseExited(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mouseEntered(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mouseClicked(MouseEvent e) {
				String data = changeTableData();
				Operation oper = new Operation();
				oper.update(data);
				
			}
		});
		
		JButton deleteBut = new JButton("删除");
		deleteBut.setBounds(600, 100, 60, 30);
		jp.add(deleteBut);
		deleteBut.addMouseListener(new MouseListener() {
			
			@Override
			public void mouseReleased(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mousePressed(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mouseExited(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mouseEntered(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mouseClicked(MouseEvent e) {
				int i = table.getSelectedRow();
				dtm.removeRow(i);
				String data = changeTableData();
				Operation oper = new Operation();
				oper.delete(data);
				
			}
		});
		
		JLabel chaxunlabel = new JLabel("按店铺查询");
		chaxunlabel.setBounds(100, 200, 100, 30);
		jp.add(chaxunlabel);
		typeCom2.addItem("");
		typeCom2.addItem("生旦净末丑");
		typeCom2.addItem("齐怪了");
		typeCom2.setBounds(180, 200, 60, 30);
		jp.add(typeCom2);
		JLabel tianjiaolabel = new JLabel("按条件查询");
		tianjiaolabel.setBounds(280, 200, 100, 30);
		jp.add(tianjiaolabel);
		tjText.setBounds(380,200,100,30);
		jp.add(tjText);
		JButton selectBut = new JButton("查询");
		selectBut.setBounds(500, 200, 60, 30);
		jp.add(selectBut);
		selectBut.addMouseListener(new MouseListener() {
			
			@Override
			public void mouseReleased(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mousePressed(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mouseExited(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mouseEntered(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mouseClicked(MouseEvent e) {
				String type = (String) typeCom2.getSelectedItem();
				String remark = tjText.getText();
				Operation oper = new Operation();
				Vector data = oper.select(type,remark);
				dtm.setDataVector(data, colName);
				table.setModel(dtm);
			}
		});
		return jp;
	}
	public JTable setTable(){
		colName.add("流水账号");
		colName.add("类型");
		colName.add("客户名");
		colName.add("技术名");
		colName.add("订单金额");
		colName.add("技术价格");
		colName.add("技术分成");
		colName.add("盈利");
		colName.add("开始时间");
		colName.add("完成时间");
		colName.add("状态信息");
		Operation oper = new Operation();
		Vector data = oper.select();
		dtm.setDataVector(data, colName);
		table.setModel(dtm);
		return table;
	}
	/*
	 * 从文件中重新读取一遍数据相当于刷新
	 */
	public void select(){
		Operation oper = new Operation();
		Vector data = oper.select();
		dtm.setDataVector(data, colName);
		table.setModel(dtm); 
	}
	/*
	 * 获取表格内容
	 */
	public String changeTableData(){
		String data = "";
		int row = table.getRowCount();
		for(int i=0;i<row;i++){
			String line = "";
			for(int j=0;j<11;j++){
				line += dtm.getValueAt(i, j)+",";
			}
			line += "\n";
			data += line;
		}
		return data;
	}

	

}
로그인 후 복사

사례 공유: Java를 사용하여 회계 시스템 개발 및 구현(전체 코드)

관련 기사:

계정 비밀번호를 기억하는 JS 코드 구현 방법

게시 요청 전송을 위한 Java 예제 코드 공유

위 내용은 사례 공유: Java를 사용하여 회계 시스템 개발 및 구현(전체 코드)의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿