2022年C餐饮管理系统课程设计方案.docx
精品学习资源运算机应用软件课程设计报告班级学号姓名指导老师完成日期 2021-12-25目录一、需求分析 21.1 数据需求 21.2 总体设计 21.3 流程图 3二、总体设计 42.1 登录窗体的设计 42.2 注册用户界面设计 52.3 主窗体设计 52.4 基础信息 62.4.1 基础信息 -桌台信息 62.4.2 基础信息 职工信息 72.5 帮忙工具 72.6 系统爱护 82.6.1 系统爱护 权限治理 82.6.2 系统爱护 添加用户 82.7 系统设置 92.7.1 系统设置 修改密码 92.7.2 系统设置 锁定系统 92.8 帮忙 102.9 快捷菜单 102.9.1 开台 102.9.2 点 加菜 112.9.3 消费查询 115.9.4 结账 11三、详细设计 123.1 登录部分代码 123.2 主界面的代码 14工程名称餐饮治理系统欢迎下载精品学习资源3.3 职工信息查询代码 183.4 桌台信息查询代码 213.5 帮忙工具 213.6 修改密码、添加用户、注册用户功能代码213.7 桌台基本信息(双击桌台图标后)代码243.8 开台部分代码 243.9 结账部分代码 263.10 点 加菜部分代码 283.11 消费查询部分代码 333.12 用户权限治理代码 33 四、单元测试与组装测试 35 五、总结 35六、参考文献 36一、需求分析随着餐饮业的不断进展,餐饮治理系统的内容对于决策者和治理者来说都特殊重要;本系统主要包括桌台显示、消费查询;人事档案及权限等几大部 分,具有良好的用户接口,使用便利,具有完善的查询,对爱护系统起到帮忙决策的作用,能准时、便利、灵动地进行查询、修改、删除等爱护性操作;餐饮治理系统有足够的储备容量,中意酒店每日营业的变动,另外,对于操作用户有确定的治理,并对用户的权限有确定的设置超级治理员拥有全部权限;经理除了系统爱护外,其他操纵都可以,一般用户只能实现帮忙工具的使用权限;1.1 数据需求Tb_food-储备食品的Tb_foodtype-储备食品的类别Tb_Waiter储备全部职员信息Tb_User-储备治理用户信息Tb_Room-储备餐厅桌台信息Tb_GuestFood储备消费信息1.2 总体设计餐饮治理系统欢迎下载精品学习资源基础信息帮忙工具系统爱护系统设置帮忙退出欢迎下载精品学习资源桌台点 加菜单天总营业额的查询1.3 流程图消 费 查结账桌职日计记权添修锁关退台员历算事限加改定于出信信器本管用密系系息息开台理户码统统欢迎下载精品学习资源二、总体设计2.1 登录窗体的设计欢迎下载精品学习资源用户信息 ER 图用户信息Tb_User欢迎下载精品学习资源点击登录进入主窗体,点击注册账号就进入注册用户界面欢迎下载精品学习资源系统编号ID用 户名Username用户 权限power用户密码UserPwd欢迎下载精品学习资源2.2 注册用户界面设计默认注册的用户类型只能是一般用户2.3 主窗体设计欢迎下载精品学习资源2.4 基础信息2.4.1 基础信息 -桌台信息可实现添加加、修改有增加、删除、查询 桌台信息的功能双击图标是桌台基本信息欢迎下载精品学习资源2.4.2 基础信息 职工信息2.5 帮忙工具2.5.1 帮忙工具 日历2.5.2 帮忙工具 运算器欢迎下载精品学习资源2.5.3 帮忙工具 记事本2.6 系统爱护2.6.1 系统爱护 权限治理2.6.2 系统爱护 添加用户欢迎下载精品学习资源2.7 系统设置2.7.1 系统设置 修改密码2.7.2 系统设置 锁定系统欢迎下载精品学习资源2.8 帮忙2.9 快捷菜单2.9.1 开台欢迎下载精品学习资源2.9.2 点 加菜2.9.3 消费查询5.9.4 结账欢迎下载精品学习资源三、详细设计3.1 登录部分代码namespace MyCyMS/登陆界面public partial class frmLogin :Formpublic int m=0;public frmLoginInitializeComponent;private void frmLogin_Load_1object sender, EventArgs e/ System.Windows.Forms.Control.Top.get;txtName.Focus;private void txtPwd_KeyPressobject sender, KeyPressEventArgs eif e.KeyChar = 13btnSubmit_Clicksender, e;/点击登录按钮private void btnSubmit_Clickobject sender, EventArgs eif txtName.Text = ""MessageBox.Show"请输入用户名 ", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning;elseSqlConnection conn = BaseClass.BaseClass.CyCon;conn.Open;SqlCommand cmd = new SqlCommand"select count* from tb_User whereUserName='" + txtName.Text + "' and UserPwd='" + txtPwd.Text + "'", conn;int i = Convert.ToInt32cmd.ExecuteScalar;if i > 0欢迎下载精品学习资源cmd = new SqlCommand"select * from tb_User where UserName='" + txtName.Text + "'", conn;SqlDataReader sdr = cmd.ExecuteReader;sdr.Read;string UserPower = sdr"power".ToString.Trim;conn.Close;frmMain main = new frmMain;main.power = UserPower;/ 记录登录用户的权限main.Names = txtName.Text;/ 用户名/frmChangePwd.n/ main.Times = DateTime.Now.ToShortDateString;/ 只输出日期main.Times = DateTime.Now.ToString;/ 记录登录时间main.Show;this.Hide;elsem+;if m >= 3btnSubmit.Enabled = false;MessageBox.Show"密码错误 3次,请退出 ." ;elseMessageBox.Show"用户名或密码错误 " ;private void btConcel_Clickobject sender, EventArgs eApplication.Exit;/点击注册账号 .i=2 表示这册用户界面private void button2_Clickobject sender, EventArgs efrmChangePwd a = new frmChangePwd;a.i = 2;a.ShowDialog;/假如点击用户名文本框 , 里面的文本清空 , 用户即可输出用户名private void txtName_Clickobject sender, EventArgs etxtName.Text = "";欢迎下载精品学习资源3.2 主界面的代码namespace MyCyMSpublic partial class frmMain : Formpublic frmMainInitializeComponent;public SqlDataReader sdr;public string powerpublic string Names;public string Times;private void frmMain_Loadobject sender, EventArgs eswitch powercase "0": toolStripStatusLabel12.Text = "超级治理员 " ; break ;case "1": toolStripStatusLabel12.Text = "经理" ; break ;case "2": toolStripStatusLabel12.Text = "一般用户 " ; break ;toolStripStatusLabel15.Text = Names;toolStripStatusLabel14.Text = Times;if power = "2"系统爱护 ToolStripMenuItem1.Enabled = false;基础信息 ToolStripMenuItem1.Enabled = false;if power = "1"系统爱护 ToolStripMenuItem1.Enabled = false;private void AddItemsstring rztif rzt = "使用 "lvDesk.Items.Addsdr"RoomName".ToString, 1;else欢迎下载精品学习资源lvDesk.Items.Addsdr"RoomName".ToString, 0;private void开台ToolStripMenuItem_Clickobject sender, EventArgs eif lvDesk.SelectedItems.Count .= 0string names = lvDesk.SelectedItems0.SubItems0.Text;frmOpen openroom = new frmOpen;openroom.name = names;openroom.ShowDialog;elseMessageBox.Show"请选择桌台 " ;private void点加菜 ToolStripMenuItem_Clickobject sender, EventArgs eif lvDesk.SelectedItems.Count .= 0string names = lvDesk.SelectedItems0.SubItems0.Text;frmJZD dc = new frmJZD;dc.RName = names;dc.ShowDialog;elseMessageBox.Show"请选择桌台 " ;private void结账ToolStripMenuItem_Clickobject sender, EventArgs eif lvDesk.SelectedItems.Count .= 0string names = lvDesk.SelectedItems0.SubItems0.Text;frmPayOff payoff = new frmPayOff;payoff.RName = names;payoff.ShowDialog;elseMessageBox.Show"请选择桌台 " ;private void frmMain_Activatedobject sender, EventArgs e欢迎下载精品学习资源lvDesk.Items.Clear;SqlConnection conn = BaseClass.BaseClass.CyCon;conn.Open;SqlCommand cmd = new SqlCommand"select * from tb_Room", conn;sdr = cmd.ExecuteReader;while sdr.Readstring zt = sdr"RoomZT".ToString.Trim;AddItemszt;conn.Close;private void消费查询 ToolStripMenuItem_Clickobject sender, EventArgs eif lvDesk.SelectedItems.Count .= 0string names = lvDesk.SelectedItems0.SubItems0.Text;frmSerch serch = new frmSerch;serch.RName = names;serch.ShowDialog;elseMessageBox.Show"请选择桌台 " ;private void lvDesk_DoubleClickobject sender, EventArgs efrmDetatles details = new frmDetatles;details.TableName = lvDesk.SelectedItems0.SubItems0.Text;details.ShowDialog;private void lvDesk_Clickobject sender, EventArgs estring names = lvDesk.SelectedItems0.SubItems0.Text;SqlConnection conn = BaseClass.BaseClass.CyCon;conn.Open;SqlCommand cmd = new SqlCommand"select * from tb_Room where RoomName='" + names+ "'", conn;SqlDataReader sdr = cmd.ExecuteReader;sdr.Read;string zt = sdr"RoomZT".ToString.Trim;sdr.Close;if zt = "使用"欢迎下载精品学习资源this.contextMenuStrip1.Items0.Enabled = false;this.contextMenuStrip1.Items1.Enabled = true;this.contextMenuStrip1.Items3.Enabled = true;this.contextMenuStrip1.Items5.Enabled = true;this.contextMenuStrip1.Items6.Enabled = true;if zt = "待用"this.contextMenuStrip1.Items0.Enabled = true;this.contextMenuStrip1.Items1.Enabled = false;this.contextMenuStrip1.Items3.Enabled = false;this.contextMenuStrip1.Items5.Enabled = false;this.contextMenuStrip1.Items6.Enabled = false;conn.Close;private void添加用户 ToolStripMenuItem1_Clickobject sender, EventArgs efrmChangePwd pwd = new frmChangePwd;/pwd.names = Names;pwd.i = 1;pwd.ShowDialog;private void退出ToolStripMenuItem1_Clickobject sender, EventArgs eif MessageBox.Show"确定退出本系统吗? ", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation = DialogResult.OKApplication.Exit;private void帮忙ToolStripMenuItem1_Clickobject sender, EventArgs efrmAbout ab = new frmAbout;ab.ShowDialog;private void锁定系统 ToolStripMenuItem1_Clickobject sender, EventArgs efrmLock m = new frmLock;m.ShowDialog;private void权限治理 ToolStripMenuItem1_Clickobject sender, EventArgs eusermanager power = new usermanager;power.ShowDialog;欢迎下载精品学习资源private void日历ToolStripMenuItem1_Clickobject sender, EventArgs efrmCalender calender = new frmCalender;calender.ShowDialog;private void运算器 ToolStripMenuItem1_Clickobject sender, EventArgs eSystem.Diagnostics.Process.Start"calc.exe";private void记事本 ToolStripMenuItem1_Clickobject sender, EventArgs eSystem.Diagnostics.Process.Start"notepad.exe";private void桌台信息 ToolStripMenuItem1_Clickobject sender, EventArgs efrmDesk desk = new frmDesk;desk.ShowDialog;private void职员信息 ToolStripMenuItem1_Clickobject sender, EventArgs efrmUser users = new frmUser;users.ShowDialog;3.3 职工信息查询代码namespace MyCyMSpublic partial class frmUser : Formpublic frmUserInitializeComponent;private void btQuery_Clickobject sender, EventArgs eBindData;private void BindDataSqlConnection conn = BaseClass.BaseClass.CyCon;SqlDataAdapter sda = new SqlDataAdapter"select ID,WaiterName姓名,CardNum 身份证号 ,WaiterNum服务员编号 ,Sex 性别,Age 年龄,Tell电话号码 from tb_Waiter order by ID ",conn ;欢迎下载精品学习资源DataSet ds = new DataSet;sda.Fillds;dataGridView1.DataSource = ds.Tables0;/修改按钮private void button1_Clickobject sender, EventArgs ebtReWrite.Enabled = false;btSave.Enabled = true;btConcle.Enabled = true;txtname.Enabled = false;txtAge.Enabled = true;txtIDcard.Enabled = true;txtWaiterNum.Enabled = true;txtTel.Enabled = true;cbSex.Enabled = true;private void btExit_Clickobject sender, EventArgs ethis.Close;private void btReWrite_Clickobject sender, EventArgs etxtname.Text = "";txtAge.Text = "";txtIDcard.Text = "";txtTel.Text = "";txtWaiterNum.Text = "";txtname.Enabled = true;txtAge.Enabled = true;txtIDcard.Enabled = true;txtWaiterNum.Enabled = true;txtTel.Enabled = true;cbSex.Enabled = true;btChange.Enabled = false;btDelete.Enabled = true;btSave.Enabled = true;private void btDelete_Clickobject sender, EventArgs eSqlConnection conn = BaseClass.BaseClass.CyCon;conn.Open;SqlCommand cmd = new SqlCommand"delete from tb_Waiter where ID='" + dataGridView1.SelectedCells0.Value.ToString + "'", conn;cmd.ExecuteNonQuery;conn.Close;欢迎下载精品学习资源BindData;private void btSave_Clickobject sender, EventArgs eSqlConnection conn = BaseClass.BaseClass.CyCon;conn.Open;SqlCommand cmd = new SqlCommand"select count* from tb_Waiter where WaiterName='" + txtname.Text + "'", conn;int i = Convert.ToInt32cmd.ExecuteScalar;if i > 0cmd = new SqlCommand"update tb_Waiter set WaiterName='" + txtname.Text + "',CardNum='" + txtIDcard.Text + "',WaiterNum='" + txtWaiterNum.Text + "',Sex='" + cbSex.SelectedItem.ToString + "',Age='" + txtAge.Text + "',Tell='" + txtTel.Text + "'where ID='" + dataGridView1.SelectedCells0.Value.ToString + "'", conn;cmd.ExecuteNonQuery;conn.Close; BindData;btReWrite.Enabled = true;btChange.Enabled = false;btSave.Enabled = false;btQuery.Enabled = true;btConcle.Enabled = false;btDelete.Enabled = false;btExit.Enabled = true;txtname.Enabled = false;elsecmd = new SqlCommand"insert into tb_WaiterWaiterName,CardNum,WaiterNum,Sex,Age,Tell values'" + txtname.Text + "','" + txtIDcard.Text + "','" + txtWaiterNum.Text + "','" + cbSex.SelectedItem.ToString + "','" +txtAge.Text + "','" + txtTel.Text + "'", conn;cmd.ExecuteNonQuery;conn.Close;BindData;btChange.Enabled = true;btReWrite.Enabled = true;btSave.Enabled = false;btQuery.Enabled = true;btConcle.Enabled = false;btDelete.Enabled = true;btExit.Enabled = true;txtname.Enabled = false;txtname.Enabled = false;欢迎下载精品学习资源private void frmUser_Loadobject sender, EventArgs ecbSex.SelectedIndex = 0;private void dataGridView1_CellClickobject sender, DataGridViewCellEventArgs e欢迎下载精品学习资源trytxtname.Text = dataGridView1.SelectedCells1.Value.ToString;txtIDcard.Text = dataGridView1.SelectedCells2.Value.ToString;txtWaiterNum.Text = dataGridView1.SelectedCells3.Value.ToString;cbSex.SelectedItem =欢迎下载精品学习资源dataGridView1.SelectedCells4.Value.ToString.Trim;txtAge.Text = dataGridView1.SelectedCells5.Value.ToString;txtTel.Text = dataGridView1.SelectedCells6.Value.ToString;btChange.Enabled = true;btDelete.Enabled = true;catch Exception errMessageBox.Show"不能单击单元格 " + err.ToString, "错误! " ;3.4 桌台信息查询代码与职工信息查询相像3.5 帮忙工具调用系统的日历,运算器、记事本功能3.6 修改密码、添加用户、注册用户功能代码这三部分共用一个界面,用代码把握不同部分的显示namespace MyCyMSpublic partial class frmChangePwd : Formstring connectionstring = "server=20210226-2024;uid=sa ;pwd=123;database=db_MrCy ;connect timeout=30";欢迎下载精品学习资源public SqlCommand cmd = new SqlCommand;public string dataTableName = "tb_User";public frmChangePwdInitializeComponent;public string names;public int i;private void btSave_Clickobject sender, EventArgs eSqlConnection conn = new SqlConnectionconnectionstring;cmd.CommandType = CommandType.Text;cmd.Connection = conn;string sql = "update tb_User set UserPwd='" + txtPwd1.Text.ToString;sql = sql + "' where username='" + txtUserName.Text.ToString + "'";cmd.CommandText = sql;if txtPwd1.Text = txtPwd2.Texttryconn.Open;if MessageBox.Show"的确要修改该记录吗? ", "提示",MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation = DialogResult.OKint n = cmd.ExecuteNonQuery;MessageBox.Show"修改用户密码成功! " ;catch Exception errMessageBox.Show"修改用户密码失败! " + err.ToString;else