信用卡在线管理系统文档格式.docx
《信用卡在线管理系统文档格式.docx》由会员分享,可在线阅读,更多相关《信用卡在线管理系统文档格式.docx(36页珍藏版)》请在冰豆网上搜索。
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=conn.prepareStatement(sql);
Calendarcalendar=Calendar.getInstance();
calendar.setTime(record.getTradetime());
pre.setInt(1,record.getId());
pre.setString(2,record.getFromId());
pre.setString(3,record.getToId());
pre.setDouble(4,record.getMoney());
pre.setDate(5,record.getTradetime());
pre.execute();
returntrue;
}catch(SQLExceptione){
e.printStackTrace();
}
returnfalse;
}
Delete是多数据表中的记录加以删除,例如对user表中的记录删除操作为:
publicbooleandelete(Useruser){
deletefrom[user]whereid=?
"
pre.setString(1,user.getId());
e.printStackTrace();
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.登陆时主界面设计
publicclassLoginViewextendsJFrameimplementsActionListener{
privateJButtonadminLoginButton;
privateJButtonzhucButton;
privateJButtonloginButton;
privateJTextFieldidField;
privateJPasswordFieldpasswordField;
privateJLabelshowMessageLabel;
privateStringtitle="
登陆"
privateJPanelpanel=null;
//protectedImageIconicon;
publicLoginView(){
//窗口属性设置
this.setBounds(250,80,550,600);
//icon=newImageIcon("
img/1.jpg"
panel=newJPanel();
panel.setLayout(null);
panel.setBounds(250,80,600,650);
//创建相应的组件
adminLoginButton=newJButton("
管理员登陆"
JLabelwelcomeLabel=newJLabel("
欢迎使用信用卡网上管理模拟系统"
showMessageLabel=newJLabel();
JLabelnameLabel=newJLabel("
账号"
JLabelpasswordLabel=newJLabel("
密码"
idField=newJTextField();
passwordField=newJPasswordField();
zhucButton=newJButton("
注册"
loginButton=newJButton("
//button.setIcon(newImageIcon(button.getToolkit().getImage("
F:
\\MyEclipse\\abcdefg\\atm\\icon.png"
)));
//组件属性设置
adminLoginButton.setBounds(390,340,120,25);
showMessageLabel.setBounds(100,500,500,30);
welcomeLabel.setFont(newFont("
隶书"
Font.BOLD,30));
welcomeLabel.setBounds(20,50,500,60);
nameLabel.setBounds(170,240,60,30);
passwordLabel.setBounds(170,290,60,30);
idField.setBounds(205,240,180,25);
passwordField.setBounds(205,290,180,25);
zhucButton.setBounds(205,340,60,25);
loginButton.setBounds(305,340,60,25);
passwordField.setEchoChar('
*'
//注册监听器
adminLoginButton.addActionListener(this);
zhucButton.addActionListener(this);
loginButton.addActionListener(this);
passwordField.addActionListener(this);
//向面板中添加各个组件
panel.add(adminLoginButton);
panel.add(showMessageLabel);
panel.add(welcomeLabel);
panel.add(nameLabel);
panel.add(passwordLabel);
panel.add(idField);
panel.add(passwordField);
panel.add(zhucButton);
panel.add(loginButton);
this.add(panel);
this.addWindowListener(newWindowAdapter(){
publicvoidwindowClosing(WindowEvente){
System.exit(0);
});
this.setResizable(false);
this.setVisible(true);
/*
*事件处理
*/
publicvoidactionPerformed(ActionEvente){
if((JButton)e.getSource()==zhucButton){
newzhucFram("
新用户注册界面"
elseif((JButton)e.getSource()==loginButton){
UserDAOImpuserDao=newUserDAOImp();
Useruser=newUser();
LoginServiceloginService=newLoginService();
user.setId(idField.getText().trim());
user.setPassword(String.valueOf(passwordField.getPassword()));
Useruser1=userDao.findByIdAndPassword(user);
System.out.println("
user="
+user.getPassword());
try{
loginService.checkLoginInfo(user1);
//用户登陆成功后得主界面
newPtFram("
用户登陆成功后的操作界面"
user.getId()).setVisible(true);
this.setVisible(false);
System.out.println("
ghghj"
JOptionPane.showMessageDialog(null,"
登陆成功!
!
"
JOptionPane.DEFAULT_OPTION);
}catch(LoginInfoNotRightExceptione1){
e1.printStackTrace();
System.out.println(e.toString());
showMessageLabel.setText(e.toString());
}
elseif(e.getSource()==adminLoginButton){
if("
admin"
.equals(idField.getText())&
&
.equals(String.valueOf(passwordField.getPassword()))){
//管理员注册成功后的主界面
newGuanlFram("
管理员登陆成功后的操作界面"
).setVisible(true);
else{
showMessageLabel.setText("
账号错或者密码错,请查找后重新登陆!
idField.setText(null);
passwordField.setText(null);
}
主界面截图:
b.注册新用户界面
publicclasszhucFramextendsJFrameimplementsActionListener{
Boxbasebox,box1,box2;
ButtonButton1,Button2;
TextFieldNameTextField=newTextField(12);
TextFieldidTextField=newTextField(12);
JPasswordFieldpasswordTextField=newJPasswordField(12);
JPasswordFieldrepasswordTextField=newJPasswordField(12);
publiczhucFram(Strings)
{
super(s);
Button1=newButton("
确定"
Button2=newButton("
取消"
box1=Box.createVerticalBox();
box1.add(newLabel("
姓名"
));
box1.add(Box.createVerticalStrut(8));
卡号"
请输入密码"
请再输一遍"
box1.add(Button1);
box2=Box.createVerticalBox();
box2.add(NameTextField);
box2.add(Box.createVerticalStrut(8));
box2.add(idTextField);
box2.add(passwordTextField);
box2.add(repasswordTextField);
box2.add(Button2);
basebox=Box.createHorizontalBox();
basebox.add(box1);
basebox.add(Box.createHorizontalStrut(10));
basebox.add(box2);
Button1.addActionListener(this);
Button2.addActionListener(this);
setLayout(newFlowLayout());
add(basebox);
setBounds(240,250,500,300);
setVisible(true);
publicvoidactionPerformed(ActionEvente)
if(e.getSource()==Button1)
StringuserName=String.valueOf(NameTextField.getText());
StringuserId=String.valueOf(idTextField.getText());
StringuserPassword=String.valueOf(passwordTextField.getPassword());
StringtestPassword=String.valueOf(repasswordTextField.getPassword());
if(userPassword.equals(testPassword)){
try{
Useruser1=newUser();
user1.setId(userId);
user1.setName(userName);
user1.setPassword(userPassword);
UserDAOImpaddUser=newUserDAOImp();
booleansuccess=addUser.insert(user1);
if(success)JOptionPane.showMessageDialog(null,"
注册成功,请重新登陆"
else{
JOptionPane.showMessageDialog(null,"
注册失败!
catch(Throwablewww){();
JOptionPane.showMessageDialog(null,"
您输入的密码前后不符,请重新输入"
else{dispose();
用户注册界面截图:
c.管理员登陆界面
publicclassGuanlFramextendsFrameimplementsActionListener{
ButtonshenhButton=newButton("
审核注册用户"
ButtonchakButton=newButton("
查看系统内的黑名单"
Button_return=newButton("
返回"
BoxbaseBox,box1;
publicGuanlFram(Strings)
box1.add(Box.createVerticalStrut(10));
box1.add(shenhButton);
box1.add(chakButton);
box1.add(_return);
baseBox=Box.createHorizontalBox();
baseBox.add(box1);
_return.addActionListener(this);
shenhButton.addActionListener(this);
chakButton.addActionListener(this);
add(baseBox);
this.addWindowListene