数据库课程设计 银行储蓄管理系统.doc
《数据库课程设计 银行储蓄管理系统.doc》由会员分享,可在线阅读,更多相关《数据库课程设计 银行储蓄管理系统.doc(14页珍藏版)》请在沃文网上搜索。
1、需求分析: 在对软件工程相关知识学习之后,我们对设计软件有了基本的认识和一些应用技能。在数据库的课程设计中,我们计划做一个小型的银行储蓄管理系统,包括了基本的存取转,和管理员对日常工作的管理功能。功能设计: (1).客户:包括存款,取款,转账,查询余额,查看流水,密码修改功能 (2).管理员:新增用户,删除用户,查看用户,员工绩效,VIP用户判别,储备金预警分析。3.功能流程图:详细设计:1.E-R图模型2.根据E-R图设计关系表 (1).银行信息表(bank)字段名字段类型及长度允许空主键 说明Bid nchar(9) no PK银行号Bname nchar(20) no银行名Bmoney
2、numeric(20,3) no银行余额 (2).客户信息表(custom)字段名字段类型及长度允许空主键 说明Cid nchar(9) no PK 客户IDCname nchar(10) no 客户姓名Cpass nchar(10) no 密码Ctime nchar(20) no 注册时间Bid nchar(9) no 所在银行行号 外码(Bank(Bid)Crmoney numeric(10,3) no 账户余额Cphone nchar(11) no 客户电话 (3).员工(管理员)表(staff)字段名字段类型及长度允许空主键 说明Sid nchar(9) no PK 员工IDSname
3、 nchar(10) no 员工姓名Spass nchar(10) no 登陆密码SItime nchar(20) no 入行时间Sphone nchar(11) no 联系电话 (4).流水信息表字段名字段类型及长度允许空主键 说明Oid nchar(9) no PK 流水号Cid nchar(9) no 客户ID 外码(Custom(Cid)Bid nchar(9) no 银行ID 外码(Bank(Bid)Sid nchar(9) no 员工ID 外码(Staff(Sid)Otype smallint no 操作类型Otime nchar(20) no 操作时间Omoney numeric
4、(10,3) yes 交易金额OBmoney numeric(10,3) yes 上次余额OAmoney numeric(10,3) yes 账户余额三个实体:bank,staff,custom一个联系:operate关系图:SQL语句:/*建表*/create table Bank(Bid nchar(9) primary key, Bname nchar(20) not null, Bmoney numeric(20,3) not null)create table Custom( Cid nchar(9) not null, Cname nchar(10) not null, Cpass
5、 nchar(10) not null, Ctype smallint not null, Ctime nchar(20) not null, Ccode nchar(18) not null, Bid nchar(9) not null, Crmoney numeric(10,3) not null, Cphone nchar(11) not null, primary key(Cid), foreign key(Bid) references Bank(Bid) /*在客户表中以Bank表的主码作为一个外键,并对他进行级联更新*/ on update cascade, )create ta
6、ble Staff(Sid nchar(9) primary key, /*在列级定义主码*/ Sname nchar(10) not null, Spass nchar(10) not null, SItime nchar(20) not null, Sphone nchar(11) not null)create table Operate(Oid nchar(9) not null, Cid nchar(9) not null, Bid nchar(9) not null, Sid nchar(9) not null, Otype nchar(10) not null, Otime nc
7、har(20) not null, Oflag smallint not null, Omoney numeric(10,3), OBmoney numeric(10,3), OAmoney numeric(10,3), primary key(Oid,Cid,Sid), foreign key (Cid) references Custom(Cid) /*以用户表主码为一个外键,进行级联删除*/ on delete cascade, foreign key(Sid) references Staff(Sid) /*以员工表的主码作为外键,当删除引起冲突的时候,拒绝删除*/ on delete
8、 no action, foreign key (Bid) references Bank(Bid) on update cascade)insert into Bank values(00001,中国银行小寨分行,10000)update Bank set Bname=中国银行经开分行 where Bid=00002select * from Bank;delete from Bank where Bid=1 or Bid=2;insert into Custom values(6505001,花花,111,0,2012/12/10/08:26:00,610424199310100002,0
9、0001,1500,14345678912)insert into Staff values(7985000,自助服务,111,2002/01/07,12331654613)delete from Custom where Bid=2; insert into Operate values(2406002,6505001,00001,7985001,哈哈,2012年12月18日14时12分,0,0,2900,2900)insert into Operate values(2406005,6505007,00001,7985001,嘿嘿,2012年12月18日14时12分,0,0,2900,29
10、00)select * from Custom;select * from Operate;select * from Staff;select * from Bank;delete from Operatedrop table Customdrop table Bankdrop table Staff;drop table Operate;select * from Bank;delete from Operate where Oid=6505001drop view BMoney;create view BMoneyasselect Omoneyfrom Operatewhere Ofla
11、g = 0 and Omoney2000 and Otype = 取款;create view BInMoneyasfrom Operatewhere Oflag = 0 and Omoney2000 and Otype=存款;create view VIPas select Ctypefrom Customwhere Ctype=1;select count(*) from BMoney;select count(*) from BInMoney;select count(*) from VIP;update Bank set Bmoney=10000 where Bid=00001;upd
12、ate Bank set Bmoney=+bmoney where Bid=+Bid+;update Bank set Bmoney=10200.000000 where Bid=00001程序代码:客户部分:a. void CClientDlg:OnButtonIn() /存款函数/ TODO: Add your control notification handler code hereCInDlg InDlg;if (InDlg.DoModal()=IDOK)double temp,temp1;ADOConn ado;CString sql = select * from Custom
13、where Cname=+Cname+;_RecordsetPtr ResultSet = ado.GetRecordSet(_bstr_t)sql); CString str = (LPCTSTR)(_bstr_t)ResultSet-GetCollect(Crmoney);CString bid = (LPCTSTR)(_bstr_t)ResultSet-GetCollect(Bid);CString str4 = (LPCTSTR)(_bstr_t)ResultSet-GetCollect(Cid);CString str2= str; /将交易前钱数暂存temp=atof(str);t
14、emp1=(double)InDlg.m_InNum;temp+=temp1;str.Format(%f,temp);CString str3 = str; /暂存交易后金额sql = update Custom set Crmoney=+str+ +where Cname=+Cname+;ado.ExecuteSQL(_bstr_t)sql);sql = select count(*) num from Operate;ResultSet = ado.GetRecordSet(_bstr_t)sql);int num = atoi(LPCTSTR)(_bstr_t)ResultSet-Get
15、Collect(num);str = 240600;CString Oid,Cid,Sid,Bid,Otime,Omoney,OAmoney,OBmoney;Oid.Format(%d,+num); Oid=str+Oid; Sid=7985001;Bid = bid; double temp2;sql = select * from Bank where Bid=+Bid+;ResultSet = ado.GetRecordSet(_bstr_t)sql);CString bmoney = (LPCTSTR)(_bstr_t)ResultSet-GetCollect(Bmoney);temp
16、2 = atof(bmoney); temp2+=temp1; bmoney.Format(%f,temp2);sql = update Bank set Bmoney=+bmoney+ where Bid=+Bid+;ado.ExecuteSQL(_bstr_t)sql);CString Otype = 存款;CString m_time; CTime time;time = CTime:GetCurrentTime();m_time = time.Format(%Y年%m月%d日 %X);Otime = m_time; int flag = 0;Omoney.Format(%f,temp1
17、); OAmoney = str2;OBmoney = str3;sql.Format(insert into Operate values(%s,%s,%s,%s,%s,%s,%d,%s,%s,%s),Oid,str4,Bid,Sid,Otype,m_time,flag,Omoney,OAmoney,OBmoney);ado.ExecuteSQL(_bstr_t)sql);ado.ExitConnect();b. void CClientDlg:OnButtonGet() /取款函数/ TODO: Add your control notification handler code here
18、CGetDlg GetDlg;if (GetDlg.DoModal()=IDOK)double temp,temp1;ADOConn ado; CString sql = select * from Custom where Cname=+Cname+;_RecordsetPtr ResultSet = ado.GetRecordSet(_bstr_t)sql);CString str = (LPCTSTR)(_bstr_t)ResultSet-GetCollect(Crmoney);CString bid = (LPCTSTR)(_bstr_t)ResultSet-GetCollect(Bi
19、d);CString str4 = (LPCTSTR)(_bstr_t)ResultSet-GetCollect(Cid);CString str2= str; /将交易前钱数暂存temp=atof(str);temp1=(double)GetDlg.m_GetNum;if (temptemp1)temp-=temp1; str.Format(%f,temp); CString str3 = str; /暂存交易后金额sql = update Custom set Crmoney=+str+ +where Cname=+Cname+;ado.ExecuteSQL(_bstr_t)sql);sq
20、l = select count(*) num from Operate;ResultSet = ado.GetRecordSet(_bstr_t)sql)int num = atoi(LPCTSTR)(_bstr_t)ResultSet-GetCollect(num);str = 240600;CString Oid,Cid,Sid,Bid,Otime,Omoney,OAmoney,OBmoney;Oid.Format(%d,+num);Oid=str+Oid; Sid=7985001Bid = bid; double temp2;sql = select * from Bank where
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
20 积分
下载 | 加入VIP,下载更划算! |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数据库课程设计 银行储蓄管理系统 数据库 课程设计 银行 储蓄 管理 系统