博客班级 | 软件工程node |
---|---|
做业要求 | 做业要求 |
做业目标 | 你理解的做业目标具体内容 |
学号 | 3180701218 |
编写一个ATM管理系统,语言不限,要求应包括如下主要功能:
(1)开户,销户
(2)查询帐户余额
(3)存款
(4)取款
(5)转帐(一个帐户转到另外一个帐户)等...
web
此次做业用SQL sever+VS2019写的,主要想复习一下去年学的SQL语言,再熟悉熟悉VS2019编写环境。sql
(1)首先创建ATM数据库和银行帐户信息表masge,信息表存有用户的姓名、银行卡号、身份证号、电话、密码、余额等信息。
数据库
create database ATM create table masge ( name char(10) not null--姓名, id char(18) primary key--身份证号, cnode char(19) not null unique--银行卡号, cal char(11) not null unique--电话号码, code char(50) not null,--这里银行卡和注册密码同样 balance int--余额 ) go
(2)ATM管理系统须要实现开户、注销、查询、存款、取款、转帐等功能,这里都使用存储过程来实现。
①开户
用户输入姓名、身份证号、银行卡号、电话号码、密码,并判断该用户是否已注册。其中result和msg是存储过程的输出变量,result是布尔变量,用做开户是否成功的标志;msg是字符串变量,存放开户是否成功的信息。学习
create proc login @name char(10), @id char(18), @cnode char(19), @cal char(11), @code char(50), @result bit out, @msg char(200) out as begin if exists(select id from masge where id=@id)begin select @result=0,@msg='用户已存在!' end else begin begin try insert into masge(name,id,cnode,cal,code) values(@name,@id,@cnode,@cal,@code) end try begin catch select @result=0,@msg=error_message() end catch end end go
②注销
测试
create proc logout @id char(18) as begin delete from masge where id=@id end go
③查询
ui
create proc inquire @id char(18), @balance int output as begin select @balance=balance from masge where id=@id end go
④存款
编码
create proc saves @id char(18), @balance int as begin update masge set balance=balance+@balance where id=@id end go
⑤取款
spa
create proc withdraw @id char(18), @m int as begin update masge set balance=balance-@m where id=@id end go
⑥转帐
这里使用了事务,若用户身份证号输入错误,事务回滚转,不执行帐操做;若是用户操做正确,继续执行。.net
create proc transfer @id char(18), @id_ char(18),--被转的帐户 @m int, @result bit out, @msg char(200) out as begin begin tran --开始事务 begin try if not exists(select * from masge where id=@id_)begin select @result=0,@msg='用户不存在' end else begin update masge set balance=balance-@m where id=@id update masge set balance=balance+@m where id=@id_ select @result=1,@msg='' end end try begin catch select @result=0,@msg=error_message() end catch if(@result=0)begin rollback tran --执行出错,回滚事务 end else begin commit tran --没有异常,提交事务 end end go
⑦登陆
create proc logon @id char(18), @code char(50), @result bit out,--返回值 @msg char(200) out--返回信息 as begin begin try if not exists(select id from masge where id=@id)begin select @result=0,@msg='用户不存在!' end else if not exists(select * from masge where code=@code and id=@id)begin select @result=0,@msg='密码错误!' end else begin select @result=1,@msg='' end end try begin catch select @result=0,@msg=error_message() end catch end go
VS2019链接SQL数据库,以及相关的网页项目操做,这里就很少说了,感兴趣的话能够看看下面up主的视频
SQL Server项目实战
①登陆与注册
②查询
③存款
④取款
⑤转帐
⑥注销
psp2.1 | 任务内容 | 计划完成须要的时间(min) | 实际完成须要的时间(min) |
Planning | 计划 | 10 | 10 |
Estimate | 估计这个任务须要多少时间, 并规划大体工做步骤 |
10 | 5 |
Development | 开发 | 100 | 120 |
Analysis | 需求分析(包括学习新技术) | 12 | 5 |
Design Spec | 生成设计文档 | 5 | 10 |
Design Review | 设计复审 | 5 | 5 |
Coding Standard | 代码规范 | 3 | 2 |
Design | 具体设计 | 10 | 20 |
Coding | 具体编码 | 36 | 50 |
Code Review | 代码复审 | 5 | 7 |
Test | 测试(自我测试,修改代码,提交修改) | 10 | 20 |
Reporting | 报告 | 9 | 6 |
Test Report | 测试报告 | 3 | 2 |
Size Measurement | 计算工做量 | 2 | 1 |
Postmortem & Process Improvement Plan | 过后总结,并提出过程改进计划 | 3 | 3 |
功能不太完善,因为时间缘由,该系统只能检测用户是否存在,没有判断输入的银行卡号和该人信息是否符合; 操做繁琐,该系统是在web窗体执行的,ASP.net项目中,点击Button,就会发生页面刷新,以前定义的全局变量的值就会消失,所以用户登陆时输入的身份证号没法保存,用户进行查询、转帐等操做时须要频繁输入身份证号。