C#与.NET 4.0数据库开发课程设计-ATM 交易管理系统.doc_第1页
C#与.NET 4.0数据库开发课程设计-ATM 交易管理系统.doc_第2页
C#与.NET 4.0数据库开发课程设计-ATM 交易管理系统.doc_第3页
C#与.NET 4.0数据库开发课程设计-ATM 交易管理系统.doc_第4页
C#与.NET 4.0数据库开发课程设计-ATM 交易管理系统.doc_第5页
已阅读5页,还剩26页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

课程设计报告课程名称: C#与.NET 4.0数据库开发 设计题目: ATM 交易管理系统 系 别: 信息科学系 专 业: 计算机科学与技术 学 号: 姓 名: 指导教师: 时 间:2011 2012 学年第 一 学期南京人口学院信息科学系课程设计题目 ATM交易管理系统课程设计目的及要求:课程设计目的(1)通过本次设计掌握使用c#语言中窗体的建立,各个控件的使用,以及界面的设计(2)进一步巩固所学的C#及数据库的相关理论知识,提高分析和解决实际问题的能力(3)初步掌握使用C#工具设计一个具体实例的方法,包括软件的设计,调试的全过程1.1系统的用户需求描述 随着计算机技术的发展,ATM越来越多的出现在人们的日常生活中,在ATM机上进行存、取款等业务可以大大减少银行工作人员的工作,提高银行效率,而且可以节省人们排队等候时间。所以ATM系统的开发可以很好的方便人们的生活。 通过ATM机,用户可以进行一些基本的功能实现,例如:存款、取款、查询余额、转账、修改账户密码等等。系统的总体功能如下图ATM系统用户功能用户注册功能用户注销注销功能注册信息存 款查询余额转 账取 款图1.2-1 ATM系统总体功能 2.1.1 课设任务(1)根据技术要求和现有开发环境,分析题目(2)选定设计方案(3)画出软件框架结构图,关键程序流程图(4)使用C#语言和.net框架,并结合数据库,实现软件(5)调试,修改并完善程序2.1.2 课设要求(1)ATM的运行界面,注册帐号(920(2)输入正确密码登入系统(3)实现存款、取款、余额查询等操作(4)实现注销账户功能2.2系统的设计通过本系统可以达到以下目标:(1)功能方面:取款、查询余额、转账、存款、(2)性能:可使用户在无任何经验的情况下进行操作ATM自助式服务(3)输入:用户通过键盘进行输入2.2.1 数据库的分析与设计 本次数据库是利用ACCESS建立,共包含两张表存取款表,用户个人信息表。具体如下: (1)存取款表(2)用户个人信息表2.2.2逻辑层次的设计本次课设的自动提款机模拟软件系统可以使用户进行登录、取款、转账、查询余额、修改密码、记录查询和交费等基本业务。ATM系统基本结构框图如图2.2.3程序设计用户进入系统后,点击用户登录进入登陆界面,在登录窗口中输入卡号和密码,判断卡号与密码是否正确,若卡号与密码正确则进入用户操作界面,并根据用户的相关操作给用户提供相应的服务。若卡号与密码不正确,弹出对话框提示用户确认卡号和密码错误后重新输入,若输入密码错误次数大于3次,则锁定该帐号。2.2.4 程序流程图软件设计程序流程图如图所示:2.3界面的设计及功能的实现根据个人业务界面所提供的按钮,用户可以进行取款,查询余额,转账,等操作,个人业务界面如图所示:(1)欢迎使用using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Media;using System.Data.SqlClient;namespace ATM自动取款机 public partial class 欢迎使用 : Form public 欢迎使用() InitializeComponent(); private void button1_Click(object sender, EventArgs e) this.Visible = false; new 新用户注册().Show(); private void button2_Click(object sender, EventArgs e) this.Visible = false; new 用户登录().Show(); private void button3_Click(object sender, EventArgs e) Application.Exit(); private void button4_Click_1(object sender, EventArgs e) this.Visible = false; new 欢迎使用().Show();private void button4_Click_2(object sender, EventArgs e) this.Visible = false; new 注销用户().Show(); (2)新用户注册namespace ATM自动取款机public partial class 新用户注册 : Form public 新用户注册() InitializeComponent(); private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) /this.Visible = false; /new 欢迎使用().Show(); private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) /Application.Exit(); private void button1_Click(object sender, EventArgs e) 欢迎使用 a = new 欢迎使用(); if (textBox1.Text = ) MessageBox.Show(用户名不能为空!); textBox1.Focus(); return; if (textBox7.Text = ) MessageBox.Show(身份证号不能为空!); textBox7.Focus(); return; if (textBox2.Text = ) MessageBox.Show(密码不能为空!); textBox2.Focus(); return; if (textBox3.Text = ) MessageBox.Show(住址信息不能为空!); textBox3.Focus(); return; if (textBox4.Text = ) MessageBox.Show(联系电话信息不能为空!); textBox4.Focus(); return; if (textBox5.Text = ) MessageBox.Show(开户金额不能为空!); textBox5.Focus(); return; if (textBox6.Text = ) MessageBox.Show(个人帐号不能为空!); linkLabel1.Focus(); return; if (textBox10.Text = ) MessageBox.Show(问题答案不能为空!); textBox10.Focus(); return; if (textBox12.Text = ) MessageBox.Show(问题答案不能为空!); textBox12.Focus(); return; if (comboBox1.Text = ) MessageBox.Show(问题答案不能为空!); comboBox1.Focus(); return; if (comboBox2.Text = ) MessageBox.Show(问题答案不能为空!); comboBox2.Focus(); return; if (textBox2.Visible != Regex.IsMatch(textBox2.Text, d6$) textBox2.Visible = true; MessageBox.Show(密码必须是6位数字,请重新输入!); textBox2.Text = ; textBox2.Focus(); return; if (textBox1.Visible != Regex.IsMatch(textBox1.Text, u4e00-u9fa52,$) textBox1.Visible = true; MessageBox.Show(姓名必须是两个汉字,请重新输入!); textBox1.Text = ; textBox1.Focus(); return; if (textBox3.Visible = Regex.IsMatch(textBox3.Text, d0,$) textBox3.Visible = true; MessageBox.Show(住址不能是数字,请重新输入!); textBox3.Text = ; textBox3.Focus(); return; if (textBox4.Visible != Regex.IsMatch(textBox4.Text, d6,$) textBox4.Visible = true; MessageBox.Show(联系电话至少是6位数字,请重新输入!); textBox4.Text = ; textBox4.Focus(); return; double khje = Convert.ToDouble(textBox5.Text); if (khje 10) MessageBox.Show(开户金额至少为10元,请重新输入!); textBox5.Text = ; textBox5.Focus(); return;/检验用户是否已注册 string connectionString = Properties.Settings.Default.ATMConnectionString; SqlConnection conn = new SqlConnection(connectionString); SqlCommand c = new SqlCommand(); c.CommandText = select * from 用户个人信息 where 个人帐号= + textBox6.Text + ; c.Connection = conn; conn.Open(); SqlDataReader r = c.ExecuteReader(); if (r.HasRows) MessageBox.Show(此账户已注册,请重新选号!); textBox1.Text = ; textBox1.Focus(); return; /检验用户是否已注册/ 检验无误,注册信息 string kk = DateTime.Today.ToLongDateString() + DateTime.Now.ToLongTimeString(); SqlConnection conn1 = new SqlConnection(Properties.Settings.Default.ATMConnectionString); SqlCommand cmd1 = new SqlCommand(insert into 用户个人信息 values( + textBox1.Text + , + textBox7.Text + , + textBox2.Text + , + textBox3.Text + , + textBox4.Text + , + kk + , + textBox5.Text + , + textBox6.Text + , + comboBox1.Text + , + textBox10.Text + , + comboBox2.Text + , + textBox12.Text + ), conn1); SqlCommand cmd2 = new SqlCommand(insert into 存取款 values( + textBox6.Text + , + label9.Text + , + textBox5.Text + , + kk + ), conn1); try conn1.Open(); cmd1.ExecuteNonQuery(); cmd2.ExecuteNonQuery(); conn1.Close(); catch (Exception f) MessageBox.Show(f.Message, 提示); return; MessageBox.Show(注册成功); / 检查无误,注册用户信息 private void button2_Click(object sender, EventArgs e) 欢迎使用 a = new 欢迎使用 (); this.Visible = false; new 欢迎使用().Show(); private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 欢迎使用 a = new 欢迎使用 (); int i0 = (int)DateTime.Today.Month; int i2 = (int)DateTime.Today.Day; int i3 = (int)DateTime.Now.Hour; int i4 = (int)DateTime.Now.Minute; int i5 = (int)DateTime.Now.Second; int i6 = (int)DateTime.Now.Millisecond; string i1 = string.Format(0 + 1 + 2 + 3 + 4 + 5 + 6, i6.ToString(d4), i0.ToString(d2), i2.ToString(d2), i3.ToString(d2), (int)DateTime.Today.Year, i4.ToString(d2), i5.ToString(d2) ); textBox6.Text = i1; (3)用户登录namespace ATM自动取款机public partial class 客户登录 : Form public 客户登录() InitializeComponent(); private void button2_Click(object sender, EventArgs e) 欢迎使用 a = new欢迎使用(); this.Visible = false; new欢迎使用().Show(); public static string s1; public static int cm; private void button1_Click(object sender, EventArgs e) if (cm 2) label6 .Text =你已登录失败,此账户已冻结” return; 欢迎使用a = new欢迎使用(); string connectionString = Properties.Settings.Default.ATMConnectionString; SqlConnection conn = new SqlConnection(connectionString); SqlCommand c = new SqlCommand(); c.CommandText = select * from 用户个人信息 where 个人帐号= + textBox1.Text + and 密码=+textBox2 .Text +; c.Connection = conn; conn.Open(); SqlDataReader r = c.ExecuteReader(); if (r.HasRows) s1 = textBox1.Text; this.Visible = false; new 个人业务().Show(); else label5 .Text =此用户不存在或密码错误; cm+; textBox1.Focus(); return; private void button3_Click(object sender, EventArgs e) 欢迎使用 a = new 欢迎使用(); textBox1.Text = ; textBox2.Text = ; private void textBox1_KeyPress(object sender, KeyPressEventArgs e) 欢迎使用 a = new 欢迎使用(); private void textBox2_KeyPress(object sender, KeyPressEventArgs e) 欢迎使用 a = new 欢迎使用(); private void 客户登录_Load(object sender, EventArgs e) (4)个人业务namespace ATM自动取款机 public partial class 个人业务 : Form public 个人业务() InitializeComponent(); public static string kl=取款; private void button1_Click(object sender, EventArgs e) this.Visible = false; new 查询余额().Show(); private void button2_Click(object sender, EventArgs e) this.Visible = false; new 转账().Show(); private void button5_Click(object sender, EventArgs e) this.Visible = false; new 欢迎使用().Show(); private void button3_Click(object sender, EventArgs e) this.Visible = false; new 取款().Show(); private void button4_Click(object sender, EventArgs e) this.Visible = false; new 取款().Show(); private void 个人业务_Load(object sender, EventArgs e) /MessageBox.Show(s2); (5)存款 namespace ATM自动取款机 public partial class 存款 : Form public 存款() InitializeComponent(); private void button4_Click(object sender, EventArgs e) 欢迎使用 a = new 欢迎使用(); private void button1_Click(object sender, EventArgs e) 欢迎使用a = new欢迎使用(); this.Visible = false; new欢迎使用().Show(); public static string s4 ; private void button2_Click(object sender, EventArgs e) if (textBox1.Text = ) label6.Text = 你还没输入存款金额; textBox1.Focus(); return; try int ckje = Convert.ToInt32(textBox1.Text); if (ckje % 100 != 0) label7.Text = 只能存整,不能存零; return; if (ckje 100) label6.Text = 一次最少存100元; textBox1.Text = ; textBox1.Focus(); return; if (ckje 5000) label6.Text = 一次最多存5000元; textBox1.Text = ; textBox1.Focus(); return; string kk = DateTime.Today.ToLongDateString() + DateTime.Now.ToLongTimeString(); SqlConnection connf = new SqlConnection(Properties.Settings.Default.ATMConnectionString); SqlCommand cmdf = new SqlCommand(insert into 存?取?款? values( + s4 + , + label5.Text + , + textBox1.Text + , + kk + ), connf); try connf.Open(); cmdf.ExecuteNonQuery(); label7.Text = 存款成功;connf.Close(); catch (Exception f) MessageBox.Show(f.Message); return; catch (Exception err) MessageBox.Show(你输入的信息格式不正确!,err .Message ); private void button3_Click(object sender, EventArgs e) 欢迎使用 a = new 欢迎使用(); this.Visible = false; new 个人业务().Show(); private void textBox1_KeyPress(object sender, KeyPressEventArgs e) 欢迎使用 a = new 欢迎使用(); label6.Text = ; label7.Text = ; private void textBox1_MouseDown(object sender, MouseEventArgs e) label6.Text = ; label7.Text = ; private void 存款_Load(object sender, EventArgs e) (6)取款namespace ATM自动取款机public partial class 取款 : Form public 取款() InitializeComponent(); public static string s3 ; public void qk(string money) string kk = DateTime.Today.ToLongDateString() + DateTime.Now.ToLongTimeString(); string connectionString9 = Properties.Settings.Default.ATMConnectionString; SqlConnection conn9 = new SqlConnection(connectionString9); SqlCommand c9 = new SqlCommand(); c9.Connection = conn9; conn9.Open(); c9.CommandText = select * from 存取款 where 个人帐号= + and 类型=取款; string pa = (string)c9.ExecuteScalar();/第一次取款 if (pa = null) try string connectionString6 = Properties.Settings.Default.ATMConnectionString; SqlConnection conn6 = new SqlConnection(connectionString6); SqlCommand c6 = new SqlCommand(); c6.Connection = conn6; conn6.Open(); c6.CommandText = select 金额 from 存取款 where 个人帐号= + s3 + and 类型=存款; double sum1 = Convert.ToDouble(c6.ExecuteScalar(); double k, l; k = Convert.ToDouble(money); l = Convert.ToDouble(sum1 - k); if (l 0) label6.Text = 余额不足; return; else SqlConnection connf = new SqlConnection(Properties.Settings.Default.ATMConnectionString); SqlCommand cmdf = new SqlCommand(insert into 存取款 values( + s3 + , + label5.Text + , + money + , + kk + ), connf); try connf.Open(); cmdf.ExecuteNonQuery(); label6.Text = 取款成功; connf.Close(); catch (Exception f) MessageBox.Show(f.Message); return; catch (Exception err) MessageBox.Show(err.Message);/return; else/第二次取款成功 string connectionString7 = Properties.Settings.Default.ATMConnectionString; SqlConnection conn7 = new SqlConnection(connectionString7); SqlCommand c7 = new SqlCommand(); c7.Connection = conn7; try conn7.Open(); c7.CommandText = select sum(金额) from 存取款 where 个人账号= + s3 + and 类型=存款; decimal sum7 = Convert.ToDecimal(c7.ExecuteScalar(); c7.CommandText = select sum(金额) from 存取款 where 个人帐号= + s3 + and 类型=取款; decimal sum8 = Convert.ToDecimal(c7.ExecuteScalar(); double w; w = Convert.ToDouble(sum7 - sum8); double t, u; t = Convert.ToDouble(money); u = Convert.ToDouble(w - t); if (u 0)/余额不足 label6.Text = 余额不足; return; else/余额可取时 SqlConnection connff = new SqlConnection(Properties.Settings.Default.ATMConnectionString); /insert into 存款values( + textBox1.Text + , + sdl + , + a + , + textBox3.Text + , + DateTime.Today.ToLongDateString() + DateTime.Now.ToLongTimeString() + ), connf); SqlCommand cmdff = new SqlCommand(insert into 存取款 values( + s3 + , + label5.Text + , + money + , + kk + ), connff); try connff.Open(); cmdff.ExecuteNonQuery(); connff.Close(); label6.Text = 存取款成功; catch (Exception f) MessageBox.Show(f.Message); return; catch (Exception err) MessageBox.Show(err.Message);/return; private void button1_Click(ob

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论