{财务管理信用管理}信用卡在线管理系统
- 格式:docx
- 大小:359.67 KB
- 文档页数:42
{财务管理信用管理}信用卡在线管理系统一.需求分析1、课程设计名称及内容课程设计名称:信用卡在线管理系统设计内容:设计一个信用卡管理系统,实现基于网络管理信用卡信息。
2、任务和要求系统用户分为管理员、注册用户和普通用户。
a)提供注册功能,系统的访问者可以注册成为注册用户,注册信息包括卡号、密码和其他个人信息。
注册用户没有任何操作权限,必须经管理员审批通过后成为普通用户才有权操作。
新注册的用户,卡上初始金额为0。
b)普通用户可以执行现金转入、现金转出、个人信息修改、余额查询和交易记录查询功能。
c)用户可以录入转入金额和转出金额,当转出金额大于信用卡的余额时,须判断透支金额是否在本卡的信用额度内(信用额度由管理员设定),如果在则允许透支,否则拒绝支出。
d)当信用卡发生透支后,在20天内不计利息,20天后按每天1%计算利息,当透支金额+透支利息超过本卡的信用额度,则本卡自动转入“黑名单”(利息继续计算),不再允许进行现金转出操作。
e)普通用户可以随时查看卡内余额。
f)普通用户可以按时间段查看交易记录,包括转入、转出和透支情况。
g)管理员可以审核注册用户,设定用户信用额度,批准成为普通用户。
h)管理员可以查看系统内的黑名单,包括卡号和透支额度。
二.设计1.数据库设计思想:(1)数据库的设计:我们使用的数据库是MicrosoftSQL2005。
创建record和user表:createdatabasecard;usecard;createtablerecord(idintnotnullprimarykey,fromIdvarchar(100)notnull,toIdvarchar(50)notnull,moneyfloatnotnull,tradetimedatetime);createtableuser1(idvarchar(50)primarykeynotnull,passwordvarchar(50)notnull,namevarchar(100)notnull,typeint,moneyfloat,creditfloat,overdraftfloat,blacklistint);、交易表用户表(2)对数据库的操作Insert主要时用来对数据库进行插入操作,例如在record表中插入一条记录为,publicbooleaninsert(Recordrecord){Stringsql="insertintorecord(id,fromId,toId,money,tradetime)values(?,?,?,? ,?)";try{PreparedStatementpre=(sql);Calendarcalendar=();(());(1,());(2,());(3,());(4,());(5,());();returntrue;}catch(SQLExceptione){e.printStackTrace();}returnfalse;}Delete是多数据表中的记录加以删除,例如对user表中的记录删除操作为:publicbooleandelete(Useruser){Stringsql="deletefrom[user]whereid=?";try{PreparedStatementpre=(sql);(1,());();returntrue;}catch(SQLExceptione){e.printStackTrace();}returnfalse;}Update是对数据库中的信息加以修改!findAll是查找数据库中的所有记录!findById是通过用户给定的id好来对数据库进行扫描,查找出所有与输入的id相匹配的信息!同时也可以根据其他的关键字对数据库进行查找查找,例如是否是黑名单,是否已经有透支额了等等,具体的实现见代码!2.java程序的设计:主要以下几个包:--bean--User表示的是user表中的一条记录--Record表示的是record表中的一条记录--ChangePasswordBean是对修改密码时的所有属性的封装--zhucBean是在新用户注册时的一条记录,主要包括属性id,password,name;以及set和get方法!--dao--DBConnection用于连接数据库--RecordDAO接口是封装对数据表Record的操作--UserDAO接口是封装对数据表User的操作--exception--inputChangePasswordInfoNotRightException是用来显示输入的修改密码的出错的信息!--InputGetNumNotRightException是用户输入的取款金额不合法异常--InputSetNumNotRightException是用户输入的存款金额不合法异常--LoginInfoNotRightException是用户登陆是的不合法异常--imp--RecordDAOImp是对接口RecordDAO中的方法的实现。
--UserDAOImp是对接口UserDAO中方法的实现。
--service--ChangePasswordService是对修改密码服务中可能出现的不正常信息加以分类并且予以处理。
--GetService是对用户输入的取款信息的不正常信息加以分类并且予以处理。
--LoginService是对用户在登陆时输入信息的不正常信息加以分类并且予以处理。
--SetService是对用户输入的存款信息的不正常信息加以分类并且予以处理。
--view--ChangePasswordFrame是修改密码的操作界面。
--GetFrame是用户进行取款操作的界面。
--GuanlFram是管理员进行操作的界面。
--LoginView是登陆主界面。
--PtFram是普通用户的操作界面。
--SetFrame是用户进行存款操作的界面。
--zhucFram是新注册用户进行注册的界面。
a.登陆时主界面设计publicclass LoginView extends JFrame implements ActionListener{private JButtonadminLoginButton;private JButtonzhucButton;private JButtonloginButton;private JTextFieldidField;private JPasswordFieldpasswordField;private JLabelshowMessageLabel;private Stringtitle="登陆";private JPanelpanel=null;//protectedImageIconicon;public LoginView(){//窗口属性设置(250,80,550,600);//icon=newImageIcon("img/1.jpg");panel=new JPanel();(null);(250,80,600,650);//创建相应的组件adminLoginButton=new JButton("管理员登陆"); JLabelweleLabel=new JLabel("欢迎使用信用卡网上管理模拟系统"); showMessageLabel=new JLabel();JLabelnameLabel=new JLabel("账号"); JLabelpasswordLabel=new JLabel("密码");idField=new JTextField();passwordField=new JPasswordField();zhucButton=new JButton("注册");loginButton=new JButton("登陆");//(newImageIcon(().getImage("F:\\MyEclipse\\abcdefg\\atm\\"))); //组件属性设置(390,340,120,25);(100,500,500,30);(new Font("隶书",,30));(20,50,500,60);(170,240,60,30);(170,290,60,30);(205,240,180,25);(205,290,180,25);(205,340,60,25);(305,340,60,25);('*');//注册监听器(this);(this);(this);(this);//向面板中添加各个组件(adminLoginButton); (showMessageLabel);(weleLabel);(nameLabel);(passwordLabel);(idField);(passwordField);(zhucButton);(loginButton);(panel);(new WindowAdapter(){publicvoid windowClosing(WindowEvente){ (0);}});(false);(true);}/**事件处理*/publicvoid actionPerformed(ActionEvente){if((JButton)e.getSource()==zhucButton){new zhucFram("新用户注册界面");}elseif((JButton)e.getSource()==loginButton){ UserDAOImpuserDao=new UserDAOImp();Useruser=new User();LoginServiceloginService=new LoginService();(().trim());((()));Useruser1=(user);.println("user="+());try{(user1);//用户登陆成功后得主界面new PtFram("用户登陆成功后的操作界面",()).setVisible(true); (false);.println("ghghj");(null,"登陆成功!!","",_OPTION);}catch(LoginInfoNotRightExceptione1){e1.printStackTrace();.println(e.toString());(e.toString());}}elseif(e.getSource()==adminLoginButton){if("admin".equals(())&&"admin".equals((()))){//管理员注册成功后的主界面new GuanlFram("管理员登陆成功后的操作界面").setVisible(true); (false);}else{("账号错或者密码错,请查找后重新登陆!");(null);(null);}}}}主界面截图:b.注册新用户界面publicclass zhucFram extends JFrame implements ActionListener{ Boxbasebox,box1,box2;ButtonButton1,Button2;TextFieldNameTextField=new TextField(12); TextFieldidTextField=new TextField(12); JPasswordFieldpasswordTextField=new JPasswordField(12); JPasswordFieldrepasswordTextField=new JPasswordField(12); public zhucFram(Strings){super(s);Button1=new Button("确定");Button2=new Button("取消");box1=();box1.add(new Label("姓名"));box1.add((8));box1.add(new Label("卡号"));box1.add((8));box1.add(new Label("请输入密码"));box1.add((8));box1.add(new Label("请再输一遍"));box1.add((8));box1.add(Button1);box2=();box2.add(NameTextField);box2.add((8));box2.add(idTextField);box2.add((8));box2.add(passwordTextField);box2.add((8));box2.add(repasswordTextField);box2.add((8));box2.add(Button2);basebox=();(box1);((10));(box2);Button1.addActionListener(this);Button2.addActionListener(this); setLayout(new FlowLayout());add(basebox);setBounds(240,250,500,300);setVisible(true);}publicvoid actionPerformed(ActionEvente) {if(e.getSource()==Button1){StringuserName=(());StringuserId=(());StringuserPassword=(());StringtestPassword=(());if((testPassword)){try{Useruser1=new User();user1.setId(userId);user1.setName(userName);user1.setPassword(userPassword); UserDAOImpaddUser=new UserDAOImp(); boolean success=(user1);if(success)(null,"注册成功,请重新登陆","",_OPTION); else{(null,"注册失败!!","",_OPTION);}}catch(Throwablewww){();}}else{(null,"您输入的密码前后不符,请重新输入","",_OPTION); }}else{dispose();}}}用户注册界面截图:c.管理员登陆界面publicclass GuanlFram extends Frame implements ActionListener{ ButtonshenhButton=new Button("审核注册用户"); ButtonchakButton=new Button("查看系统内的黑名单");Button_return=new Button("返回");BoxbaseBox,box1;public GuanlFram(Strings){super(s);box1=();box1.add((10));box1.add(shenhButton);box1.add((10));box1.add(chakButton);box1.add((10));box1.add(_return);baseBox=();(box1);_(this);(this);(this);setLayout(new FlowLayout());add(baseBox);(new WindowAdapter(){publicvoid windowClosing(WindowEvente){ (0);}});setBounds(240,250,500,300);setVisible(true);}publicvoid actionPerformed(ActionEvente) {if(e.getSource()==shenhButton){//.println("新注册用户的信息"); UserDAOImpuserdao=new UserDAOImp(); Listlist=new UserDAOImp().findByType(0); final Frameframe=new Frame();TextAreatext=new TextArea(50,50);(new FlowLayout());(text);(240,250,500,300);//(_return);(true);(new WindowAdapter(){publicvoid windowClosing(WindowEvente){ (false);}});if(()==0)("系统现在没有新注册的用户");else{for(int i=0;i<();i++){Useruser=(User)(i);("卡号:"+());("\n密码:"+());("\n姓名:"+());("\n余额"+());("\n信用额度"+());("\n透支金额"+());("\n******************************");("\n此时系统已经将新注册用户提升为普通用户了!"); (1);("\n******************************");("\n系统已经将新注册用户的信用额度设置为1000元!"); (1000);(user);}}}elseif(e.getSource()==chakButton){//.println("进入系统黑名单界面");Listlist=new UserDAOImp().findByBlacklist(1);final Frameframe=new Frame();TextAreatext=new TextArea(50,50);(new FlowLayout());(text);(240,250,500,300);(true);(new WindowAdapter(){publicvoid windowClosing(WindowEvente){(false);}});if(()==0)("系统现在没有黑名单的用户"); else{for(int i=0;i<();i++){Useruser=(User)(i);("卡号:"+());("\n密码:"+());("\n姓名:"+());("\n余额:"+());("\n信用额度:"+());("\n透支金额:"+());("\n******************************"); }}}elseif(e.getSource()==_return){ new LoginView();dispose();}}}管理员登陆界面截图:e.普通用户登陆界面publicclass PtFram extends Frame implements ActionListener{ private Stringid;ButtongetButton=new Button("现金转出"); ButtonsetButton=new Button("现金转入"); ButtonchangeButton=new Button("个人信息修改"); ButtonserchButton=new Button("余额查询"); ButtonserchjiluButton=new Button("交易记录查询"); ButtonserchfhButton=new Button("返回"); BoxbaseBox,box1;public PtFram(Strings,Stringid){super(s);=id;box1=();box1.add((10));box1.add(getButton);box1.add((10));box1.add(setButton);box1.add((10));box1.add(changeButton);box1.add((10));box1.add(serchButton);box1.add((10));box1.add(serchjiluButton);box1.add((10));box1.add(serchfhButton);baseBox=();(box1);(this);(this);(this);(this);(this);(this);setLayout(new FlowLayout());add(baseBox);(new WindowAdapter(){publicvoid windowClosing(WindowEvente){ (0);}});setBounds(240,250,500,300);setVisible(true);}publicvoid actionPerformed(ActionEvente) {if(e.getSource()==getButton){.println("进入现金转出界面");new GetFrame(id).setVisible(true);}elseif(e.getSource()==setButton){.println("进入现金转入界面");new SetFrame(id).setVisible(true);}elseif(e.getSource()==changeButton){.println("进入信息修改界面");//Useruser=newUserDAOImp().update(id); new ChangePasswordFrame(id).setVisible(true); }elseif(e.getSource()==serchButton){.println("进入余额查询界面");Listlist=new UserDAOImp().findById(id); final Frameframe=new Frame(); TextAreatext=new TextArea(50,50);(new FlowLayout());(text);(240,250,500,300);(true);for(int i=0;i<();i++){Useruser=(User)(i);("卡号:"+());("\n密码:"+());("\n姓名:"+());("\n余额"+());("\n信用额度"+());("\n透支金额"+());("\n******************************");}(new WindowAdapter(){publicvoid windowClosing(WindowEvente){(false);}});}elseif(e.getSource()==serchjiluButton) {.println("进入交易记录查询界面");Listlist=new RecordDAOImp().findAll(); final Frameframe=new Frame(); TextAreatext=new TextArea(50,50);(new FlowLayout());(text);(240,250,500,300);(new WindowAdapter(){publicvoid windowClosing(WindowEvente){ (false);}});(true);for(int i=0;i<();i++){Recordrecord=(Record)(i);if("admin".equals(()))("\nid号为"+()+"的用户从系统取出金额");else("\nid号为"+()+"的用户"+"向系统输入金额");("\n交易金额"+());("\n交易时间"+());}}elseif(e.getSource()==serchfhButton){new LoginView();dispose();}}}普通用户登陆界面截图:f.取款界面publicclass GetFrame extends JFrame implements ActionListener{ private Stringid;private Stringtitle="取款";private Userpt;private JLabelshowMessageLabel=null;private JLabelinfoLabel=null;private JButtonresetButton=null;private JButtonensureButton=null;private JTextFieldinputGetCashNumField=null; public GetFrame(Stringid){=id;(null);(250,80,550,600);//创建组件showMessageLabel=new JLabel();infoLabel=new JLabel("请输入金额"); resetButton=new JButton("重置"); ensureButton=new JButton("确定"); inputGetCashNumField=new JTextField();//设置组件的属性(100,500,500,30);(100,250,100,35);(205,250,180,25);(205,300,60,25);(305,300,60,25);//注册组件(this);(this);//向面板中添加组件(infoLabel); (inputGetCashNumField); (ensureButton);(resetButton);(showMessageLabel);}publicvoid actionPerformed(ActionEvente){if(e.getSource()==ensureButton){ UserDAOImpgetCashDao=new UserDAOImp(); RecordDAOImprecorddao=new RecordDAOImp(); GetServicegetCashService=new GetService(); StringcashNum=();try{pt=(User)(id).get(0);(cashNum,(),(),());float getCashNum=(cashNum);double newBalance=()-getCashNum; UserclientOne=new User();clientOne=;if(newBalance<=0){(0);((-newBalance)+());}else{(newBalance);}(clientOne);.setText("取款成功!");//获取系统的当前时间,以作为用户的操作时间Calendarcalendar=();//(newDate());int year=();int month=(()+1);int day=();Datedate=new Date(year,month,day); Recordrecord=new Record();(date);(getCashNum);("admin");(id);(record);}catch(InputGetNumNotRightExceptionex){ .setText(());();}}elseif(e.getSource()==resetButton){("");}}}用户取款界面截图:g.存款界面publicclass SetFrame extends JFrame implements ActionListener{ private Stringtitle="存款";private Stringid;private Userclient;private JLabelshowMessageLabel=null;private JLabelinfoLabel=null;private JButtonresetButton=null;private JButtonensureButton=null;private JTextFieldinputsavingNumField=null;public SetFrame(Stringid){=id;(new BorderLayout());(250,80,550,600);//创建面板(null);(250,80,550,600);//创建组件showMessageLabel=new JLabel(); infoLabel=new JLabel("请输入金额"); resetButton=new JButton("重置"); ensureButton=new JButton("确定"); inputsavingNumField=new JTextField(); //设置组件的属性(100,500,500,30);(100,250,100,35);(205,250,180,25);(205,300,60,25);(305,300,60,25);//注册组件(this);(this);//向面板中添加组件(infoLabel); (inputsavingNumField); (ensureButton); (resetButton);(showMessageLabel);}publicvoid actionPerformed(ActionEvente){if(e.getSource()==ensureButton){ UserDAOImpsetCashDao=new UserDAOImp(); RecordDAOImprecorddao=new RecordDAOImp(); SetServicesavingService=new SetService(); StringsavingNum=();try{client=(User)(id).get(0);(savingNum);float setCashNum=(savingNum);double newBalance=()+setCashNum; UserclientOne=new User();clientOne=;if(()>0){if(()>setCashNum)(()-setCashNum);else{(setCashNum-());}}else(newBalance);(clientOne);.setText("存款成功!");//获取系统的当前时间,以作为用户的操作时间Calendarcalendar=();//(newDate());int year=();int month=(()+1);int day=();Datedate=new Date(year,month,day); Recordrecord=new Record();(date);(setCashNum);(id);("admin");(record);}catch(InputSetNumNotRightExceptionex){ .setText(());}}elseif(e.getSource()==resetButton){("");}}}用户存款界面截图:h.修改密码界面publicclass ChangePasswordFrame extends JFrame implements ActionListener{ private Stringid;private Userclient=new User();private JButtonresetButton;private JButtonsubmitButton;private JButtonbackButton;private JPasswordFieldoldPasswordField;private JPasswordFieldnewPasswordOneField;private JPasswordFieldnewPasswordTwoField;private JLabelshowMessageLabel;private Stringtitle="更改密码";public ChangePasswordFrame(Stringid){.setId(id);(250,80,550,600);(null);(250,80,550,600);//创建相应的组件showMessageLabel=new JLabel(); JLabeloldPasswordLabel=new JLabel("原密码"); JLabelnewPasswordOneLabel=new JLabel("新密码"); JLabelnewPasswordTwoLabel=new JLabel("再次输入新密码"); oldPasswordField=new JPasswordField(); newPasswordOneField=new JPasswordField(); newPasswordTwoField=new JPasswordField(); resetButton=new JButton("重置");submitButton=new JButton("提交");backButton=new JButton("退出");//组件属性设置(100,500,500,30);(100,190,100,30);(100,240,100,30);(100,290,100,30);(205,190,180,25);(205,240,180,25); (205,290,180,25);('*');('*');('*');(205,340,60,25); (305,340,60,25); (450,450,60,25);//注册监听器(this);(this);(this);//向面板中添加各个组件(showMessageLabel); (oldPasswordLabel); (newPasswordOneLabel); (newPasswordTwoLabel); (resetButton); (submitButton); (backButton); (oldPasswordField); (newPasswordOneField);}publicvoid actionPerformed(ActionEvente){if(e.getSource()==resetButton){(null);(null);(null);}elseif(e.getSource()==submitButton){UserDAOImpupdateDao=new UserDAOImp(); ChangePasswordBeanchangePasswordInfo=new ChangePasswordBean(); ChangePasswordServicechangePasswordService=new ChangePasswordService(); StringoldPassword=(());StringnewPasswordOne=(());StringnewPasswordTwo=(());(());(oldPassword);(newPasswordOne);(newPasswordTwo);try{client=(User)(id).get(0);(());UserclientOne=new User();clientOne=;(newPasswordOne);//只需换掉密码boolean success=(clientOne);if(!success){.setText("对不起!系统操作数据库失败!");}else.setText("更改密码成功!");}catch(InputChangePasswordInfoNotRightExceptionex){.setText(());();}}elseif(e.getSource()==backButton){(false);}}}修改密码界面i.余额查询*在输出系统黑名单用户时采用以下方法:Listlist=newUserDAOImp().findByBlacklist(1);//从数据库中扫描关键字为1即是黑名单的用户for(inti=0;i<();i++){…}//用循环来将黑名单用户的所有的信息输出!系统中其他地方的输出于此类似!三.调试及测试1、在调试及测试的过程中有很多的问题,开始时不知道如何区别系统的每个用户,后来用来以关键字用来区别时新注册用户还是ng普通用户,关键字为1时为普通用户,关键字为0时为新注册用户,在管理员进行审核时将新注册用户提升为普通用户!2、在进行存款操作时,一开始没有想到用户可能已经有透支额,直接将用户新存入的金额存入为他的剩余金额,后来出现错误,经过检查发现此问题,知道在存入金额时系统应该优先查看此用户是否有透支额,如果有则现将透支额还清,才可以将用户的此次的钱保存为他的剩余金额!3、在输出系统黑名单时也遇到同的问题,也采用相同的方法加以处理,用一个关键字来加以区别,当字为1时则为黑名单用户,如果关键字为0则不是黑名单用户!四.使用说明本系统对于不同权限的用户有不同的操作权限,新注册用户不能对系统进行操作,管理员可以管理员可以审核注册用户,设定用户信用额度,批准成为普通用户,也可以查看系统内的黑名单,包括卡号和透支额度。