java 记账系统_案例分享用java开发实现一个记账系统(代码全)

这是一个完整的Java记账系统实现,包括文件操作、业务处理和用户界面。代码包括FileIO类进行文件读写,Operation类处理增删改查操作,Tool类提供辅助功能,UI_t类展示图形界面。
摘要由CSDN通过智能技术生成

本文是纯代码,很全,用java开发实现的记账系统,由于时间原因也没有做过多的注解,如有不清楚的可以一起讨论,代码有不足之处也欢迎指出。

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

java语言写的android系统,用于个人账目管理,课程设计上写的欢迎下载 package moneymanager.moneymanager; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; /* * * 데이터베이스를 관리하는 클래스입니다. * */ public class DBAdapter { private static final String TAG = "NotesDbAdapter"; private DatabaseHelper mDbHelper; private SQLiteDatabase mDb; // 데이터베이스이름과 테블이름들을 정의 private static final String DATABASE_NAME = "MoneyManagerDB"; private static final int DATABASE_VERSION = 2; private static final String DATABASE_SETTING_TABLE = "SettingTbl"; private static final String DATABASE_BADGET_TABLE = "BadgetTbl"; private static final String DATABASE_PAYMENT_TABLE = "PaymentTbl"; // 테블안의 항목들을 정의 public static final String KEY_SETTINGTBL_ID = "ID"; public static final String KEY_SETTINGTBL_NAME = "Name"; public static final String KEY_SETTINGTBL_VALUE = "Value"; public static final String KEY_BADGETTBL_ID = "ID"; public static final String KEY_BADGETTBL_ITEM = "Item"; public static final String KEY_BADGETTBL_MONEY = "Money"; public static final String KEY_PAYMENTTBL_ID = "ID"; public static final String KEY_PAYMENTTBL_BADGETID = "BadgetID"; public static final String KEY_PAYMENTTBL_OUTDATE = "OutDate"; public static final String KEY_PAYMENTTBL_MONEY = "Money"; public static final String KEY_PAYMENTTBL_NOTE = "Note"; private final Context mCtx; private static class DatabaseHelper extends SQLiteOpenHelper { DatabaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { String strCreateTbl; // SettingTbl생성 strCreateTbl = "CREATE TABLE " + DATABASE_SETTING_TABLE + " (" + KEY_SETTINGTBL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_SETTINGTBL_NAME + " TEXT NOT NULL, " + KEY_SETTINGTBL_VALUE + " TEXT NOT NULL);"; db.execSQL(strCreateTbl); // BadgetTbl생성 strCreateTbl = "CREATE TABLE " + DATABASE_BADGET_TABLE + " (" + KEY_BADGETTBL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_BADGETTBL_ITEM + " TEXT NOT NULL, " + KEY_BADGETTBL_MONEY + " INTEGER NOT NULL);"; db.execSQL(strCreateTbl); // PaymentTbl생성 strCreateTbl = "CREATE TABLE " + DATABASE_PAYMENT_TABLE + " (" + KEY_PAYMENTTBL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_PAYMENTTBL_BADGETID + " INTEGER NOT NULL, " + KEY_PAYMENTTBL_OUTDATE + " TEXT NOT NULL, " + KEY_PAYMENTTBL_MONEY + " INTEGER NOT NULL, " + KEY_PAYMENTTBL_NOTE + " TEXT);"; db.execSQL(strCreateTbl); } ......
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值