C#实现餐饮管理系统
程序员文章站
2023-12-12 09:13:52
本文实例为大家分享了c#实现餐饮管理系统的具体代码,供大家参考,具体内容如下
此系统采用c#语言的winfrom和ado.net技术搭建的简单的cs系统。
部分代码:...
本文实例为大家分享了c#实现餐饮管理系统的具体代码,供大家参考,具体内容如下
此系统采用c#语言的winfrom和ado.net技术搭建的简单的cs系统。
部分代码:
frmbook.cs
using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms; using dal; namespace catering { public partial class frmbook : form { public frmbook() { initializecomponent(); } public void getdata() { string filter = " where 1 = 1 "; if (txtname.text.trim() != "") { filter += " and name like '%" + txtname.text + "%'"; } bookentity book = new bookentity(); datatable dt = book.query(filter); this.datagridview1.datasource = dt; for (int i = 1; i < this.datagridview1.columns.count; i++) { this.datagridview1.columns[i].readonly = true; } } private void frmbook_load(object sender, eventargs e) { getdata(); } //全选 private void btnchose_click(object sender, eventargs e) { bool b = false; if (btnchose.text == "全 选") { b = true; btnchose.text = "取消全选"; } else { b = false; btnchose.text = "全 选"; } for (int i = 0; i < this.datagridview1.rows.count; i++) { datagridview1.rows[i].cells[0].value = b; } this.datagridview1.endedit(); this.datagridview1.currentcell = null; } //删除 private void btndelete_click(object sender, eventargs e) { datagridview1.endedit(); datagridview1.currentcell = null; datatable dt = (datatable)this.datagridview1.datasource; datarow[] drs = dt.select("选择=1"); if (drs.length == 0) { messagebox.show("请选择要删除的记录!"); return; } foreach (datarow dr in drs) { bookentity book = new bookentity(); book.id = convert.toint32(dr["编号"].tostring()); book.delete(); } messagebox.show("删除成功!"); getdata(); } //查询 private void btnsearch_click(object sender, eventargs e) { getdata(); } //双击修改 private void datagridview1_mousedoubleclick(object sender, mouseeventargs e) { if (this.datagridview1.currentrow.index > -1) { frmbookedit frm = new frmbookedit(); frm.startposition = formstartposition.centerscreen; frm.idno = datagridview1.currentrow.cells[1].value.tostring(); if (frm.showdialog() == dialogresult.ok) { getdata(); } } } } }
frmcontrol.cs
using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms; using dal; namespace catering { public partial class frmcontrol : form { public frmcontrol() { initializecomponent(); } private void frmcontrol_load(object sender, eventargs e) { #region 生成餐桌信息 tablenoentity table = new tablenoentity(); datatable dt = table.query(" order by dispalyindex "); int x = 46; int y = 66; int width = 150; int height = 95; //动态生成餐台 for (int i = 0; i < dt.rows.count; i = i + 5) { for (int j = 0; j < 5 && (i + j) < dt.rows.count; j++) { datarow dr = dt.rows[i + j]; //生成餐台图片控件 picturebox picturebox = new picturebox(); picturebox.contextmenustrip = this.contextmenustrip1; picturebox.image = image.fromfile(application.startuppath + "\\res\\绿.gif"); //判断是否有预定 bookentity book = new bookentity(); datatable dat = book.query(" where tableno ='" + dr["tableno"] + "' and booktime>getdate()"); if (dat.rows.count > 0) { picturebox.image = image.fromfile(application.startuppath + "\\res\\黄.gif"); } //判断是否在使用 ordersentity orders = new ordersentity(); datatable dats = orders.query(" where tableno ='" + dr["tableno"] + "' and payornot ='否'"); if (dats.rows.count > 0) { picturebox.image = image.fromfile(application.startuppath + "\\res\\红.gif"); } picturebox.location = new system.drawing.point(x, y); picturebox.name = "picturebox_" + dr["tableno"].tostring(); picturebox.size = new system.drawing.size(width, height); picturebox.tabstop = false; picturebox.visible = true; picturebox.sendtoback(); this.controls.add(picturebox); //生成餐台说明信息 label lbl = new label(); lbl.name = "lbl_" + dr["tableno"].tostring(); lbl.text = dr["tableno"].tostring() + " " + dr["sitcount"].tostring() + "座位"; lbl.font = new font("宋体", 10); lbl.backcolor = color.transparent; lbl.location = new point(25, 30); picturebox.controls.add(lbl); x = x + 200; } y = y + 150; x = 46; } #endregion } private void 预定toolstripmenuitem_click(object sender, eventargs e) { string name = contextmenustrip1.sourcecontrol.name; string[] str = name.split('_'); frmbookedit frm = new frmbookedit(); frm.startposition = formstartposition.centerscreen; frm.topmost = true; frm.id = str[1]; if (frm.showdialog() == dialogresult.ok) { ((picturebox)contextmenustrip1.sourcecontrol).image = image.fromfile(application.startuppath + "\\res\\黄.gif"); } } private void 结账toolstripmenuitem_click(object sender, eventargs e) { string name = contextmenustrip1.sourcecontrol.name; string[] str = name.split('_'); frmpayedit frm = new frmpayedit(); frm.startposition = formstartposition.centerscreen; //frm.topmost = true; frm.id = str[1]; if (frm.showdialog() == dialogresult.ok) { ((picturebox)contextmenustrip1.sourcecontrol).image = image.fromfile(application.startuppath + "\\res\\绿.gif"); } } private void 退订toolstripmenuitem_click(object sender, eventargs e) { } private void 点菜toolstripmenuitem1_click(object sender, eventargs e) { string name = contextmenustrip1.sourcecontrol.name; string[] str = name.split('_'); frmordersedit frm = new frmordersedit(); frm.startposition = formstartposition.centerscreen; frm.topmost = true; frm.id = str[1]; if (frm.showdialog() == dialogresult.ok) { ((picturebox)contextmenustrip1.sourcecontrol).image = image.fromfile(application.startuppath + "\\res\\红.gif"); } } private void btnrefesh_click(object sender, eventargs e) { } } }
源码下载:c#实现餐饮管理系统
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。