餐厅消费管理系统民以食为天,学生餐厅就餐,在人流的高峰期拿着钱去就餐的话服务员忙着找零钱都非常不方便,再一点每个人吃饭时手里拿着钱也是不卫生的,餐厅管理系统是为方便管理学生就餐而设计的。首先餐厅只需一个收银员管理充钱和办理餐卡的信息管理,而不需要每个餐厅都自己配备一个专门找零钱工,并且也方便学校对学生在校的就餐情况的了解。本系统主要用C#语言为基础编程语言,运用MicrosoftVisualStudio2005设计前台界面,运用MicrosoftOfficeAccess2003作为后台数据库,运用c#设计与数据库连接的接口,方便简洁的操作就能很好的管理数据库系统。一、建立一个类:建立数据库库连接和数据库读取方法。publicOleDbConnectionconn(){OleDbConnectionmyco=newOleDbConnection();stringmystr=Provider=Microsoft.Jet.OLEDB.4.0;DataSource=|DataDirectory|\\学生信息.mdb;myco.ConnectionString=mystr;myco.Open();returnmyco;}publicboolsread(stringsql){conn();OleDbCommandmycmd=newOleDbCommand(sql,conn());OleDbDataReadermyreader=mycmd.ExecuteReader();if(myreader.Read())returntrue;elsereturnfalse;}二、建设登陆界面:账号和登录密码:登陆界面中的账号和密码都要和事先前建立的数据库相连接,要建立许多messagebox信息提示确保解决用户在登录所遇到的问题。publicpartialclass登陆界面:Form{public登陆界面(){InitializeComponent();}datada=newdata();privatevoid登陆_Click(objectsender,EventArgse){try{da.conn();stringpass;pass=select*from登陆where卡号='+账号.Text+'and密码='+密码.Text+';if(da.sread(pass)){this.DialogResult=DialogResult.OK;this.Close();}else{MessageBox.Show(用户名或密码错误,请重新输入!);密码.Clear();密码.Clear();密码.Focus();}}catch(Exceptionerror){MessageBox.Show(error.Message);};}privatevoid退出_Click(objectsender,EventArgse){this.Close();}privatevoidgroupBox2_Enter(objectsender,EventArgse){}privatevoidtimer1_Tick(objectsender,EventArgse){label3.Left=label3.Left-3;if(label3.Right0){label3.Left=this.Width;}}privatevoid账号_KeyPress(objectsender,KeyPressEventArgse){if(e.KeyChar==13){密码.Focus();}}privatevoid密码_KeyPress(objectsender,KeyPressEventArgse){if(e.KeyChar==13){登陆.Focus();}}}三、主页面:输入卡号就能查询用户的余额状况,和进行对用户充值和消费金额publicpartialclassindex:Form{publicindex(){InitializeComponent();}datada=newdata();privatevoid信息查询ToolStripMenuItem_Click(objectsender,EventArgse){Formf1=new信息查询();f1.ShowDialog();}privatevoid信息管理ToolStripMenuItem_Click(objectsender,EventArgse){Formf2=new信息管理();f2.ShowDialog();}privatevoidf_Load(objectsender,EventArgse){Formf1=new登陆界面();f1.ShowDialog();if(f1.DialogResult==DialogResult.OK){}else{this.Close();}}privatevoidbutton3_Click(objectsender,EventArgse){if(textBox3.Text==){MessageBox.Show(卡号为空请输入卡号!,信息提示!);}else{da.conn();stringsql=select卡号From信息where卡号='+textBox3.Text+';OleDbCommandmycmd=newOleDbCommand();mycmd.CommandText=sql;mycmd.Connection=da.conn();OleDbDataReadermyreader=mycmd.ExecuteReader();if(myreader.Read()){try{da.conn();stringmysql;mysql=select*from信息where卡号='+textBox3.Text+';OleDbCommandmycomd=newOleDbCommand();mycomd.CommandText=mysql;mycomd.Connection=da.conn();OleDbDataReadermyreaderq=mycomd.ExecuteReader();while(myreaderq.Read())textBox1.Text=myreaderq[8].ToString();}catch(Exceptionerror){MessageBox.Show(error.Message);}}else{textBox1.Clear();textBox3.Clear();MessageBox.Show(请核对一下没有此人!,信息提示!);}}}privatevoidbutton1_Click_1(objectsender,EventArgse){if(comboBox1.Text==){MessageBox.Show(请输入充值金额!,信息提示提示!,MessageBoxButtons.OK,MessageBoxIcon.Exclamation);}else{try{OleDbCommandmycomd=newOleDbCommand();da.conn();stringmysql;mysql=UPDATE信息SET余额=余额+'+Convert.ToInt32(comboBox1.Text)+'where卡号='+textBox3.Text+';mycomd.CommandText=mysql;mycomd.Connection=da.conn();mycomd.ExecuteNonQuery();MessageBox.Show(是否充值?,信息提示!,MessageBoxButtons.OKCancel,MessageBoxIcon.Question);}catch(Exceptionerror){MessageBox.Show(error.Message);}}}privatevoid信息修改ToolStripMenuItem_Click(objectsender,EventArgse){Formf3=new修改();f3.ShowDialog();}privatevoid帮助ToolStripMenuItem1_Click(objectsender,EventArgse){Formf4=new帮助();f4.ShowDialog();this.Close();}privatevoidbutton2_Click(objectsender,EventArgse){if(comboBox2.Text==){MessageBox.Show(请输入消费金额!,信息提示提示!,MessageBoxButtons.OK,MessageBoxIcon.Exclamation);}else{try{da.conn();OleDbCommandmycomd=newOleDbCommand();stringmysql;mysql=UPDATE信息SET余额=余额-'+Convert.ToInt32(comboBox2.Text)+'where卡号='+textBox3.Text+';mycomd.CommandText=mysql;mycomd.Connection=da.conn();mycomd.ExecuteNonQuery();MessageBox.Show(是否消费?,信息提示!,MessageBoxButtons.YesNo,MessageBoxIcon.Question);}catch(Exceptionerror){MessageBox.Show(error.Message);}}}四、信息查询:可以更具体更详细的查询学生的信息情况,publicpartialclass信息查询:Form{public信息查询(){InitializeComponent();}datada=newdata();privatevoidbutton1_Click(objectsender,EventArgse){try{if(textBox1.Text==){MessageBox.Show(卡号为空请输入卡号!,信息提示提示!,MessageBoxButtons.OK,MessageBoxIcon.Exclamation);}else{da.conn();stringsql=select卡号From信息where卡号='+textBox1.Text+';if(da.sread(sql)){da.conn();stringmysql1;mysql1=SELECT*FROM信息where卡号='+textBox1.Text+';OleDbDataAdaptermyda=newOleDbDataAdapter(mysql1,da.conn());DataSetmyds=newDataSet();myda.Fill(myds,信息);dataGridView1.DataSource=myds.Tables[信息];dataGridView1.Columns[0].AutoSizeMode=DataGridViewAutoSizeColumnMode.AllCells;dataGridView1.Columns[1].AutoSizeMode=DataGridViewAutoSizeColumnMode.AllCells;dataGridView1.Columns[2].AutoSizeMode=DataGridViewAutoSizeColumnMode.AllCells;dataGridView1.Columns[3].AutoSizeMode=DataGridViewAutoSizeColumnMode.AllCells;dataGridView1.Columns[4].AutoSizeMode=DataGridViewAutoSizeColumnMode.AllCells;dataGridView1.Columns[5].AutoSizeMode=DataGridViewAutoSizeCo