private void btnOk_Click(object sender, EventArgs e) { if (CheckEmpty()) { DeskInfo desk = new DeskInfo(); //desk.RoomId = Convert.ToInt32(cmdRoom.Text); desk.DeskName = txtDeskName.Text; desk.DeskRegion = txtDeskRegion.Text; desk.DeskRemark = txtDeskRemark.Text; if (this.Tp == 1) { desk.DelFlag = 0; desk.DeskState = 0; desk.SubTime = System.DateTime.Now; desk.SubBy = 1; desk.RoomId = Convert.ToInt32(cmdRoom.SelectedIndex); } else if (this.Tp == 2) { desk.DeskId = Convert.ToInt32(labId.Text); //desk.RoomId = Convert.ToInt32(cmdRoom.SelectedIndex); } DeskInfoBLL bll = new DeskInfoBLL(); string msg = bll.SaveDesk(desk, this.Tp) ? "操作成功": "操作失败"; MessageBox.Show(msg); this.Close(); } }
private void btnDRoom_Click(object sender, EventArgs e) { //判断是否选择了删除的对象 if (dgvRoom.SelectedRows.Count <= 0) { md.MsgDivShow("请选择要注销的房间", 1); return; } //提示用户是否真的删除 if (MessageBox.Show("亲,真的要注销这个房间吗?", "注销提示", MessageBoxButtons.OKCancel) == DialogResult.OK) { RoomInfoBLL roomBll = new RoomInfoBLL(); RoomInfo room = (RoomInfo)dgvRoom.SelectedRows[0].DataBoundItem; DeskInfoBLL deskBll = new DeskInfoBLL(); if (deskBll.GetAliveDeskCountByRoomId((int)room.RoomId) > 0) { md.MsgDivShow("对不起,该房间内有餐桌,请先注销该房间内的餐桌哦~", 1); return; } //删除 string msg = roomBll.SoftDelete((int)room.RoomId) > 0 ? "操作成功" : "操作失败"; md.MsgDivShow(msg, 1); //刷新 LoadRoomByDelFlag(0); LoadRoomEvent(); LoadDeskEvent(GetTabPage()); return; } //提示取消删除 md.MsgDivShow("您已经取消了注销", 1); }
private void btnOk_Click(object sender, EventArgs e) { if (CheckEmpty()) { DeskInfoBLL dkBll = new DeskInfoBLL(); DeskInfo dk = new DeskInfo(); dk.DeskName = txtDeskName.Text; dk.DeskRegion = txtDeskRegion.Text; //描述信息 dk.DeskRemark = txtDeskRemark.Text; //备注 dk.RoomId = Convert.ToInt32(cmbRoom.SelectedValue); //房间的id if (Temp == 1) //新增 { dk.DelFlag = 0; dk.DeskState = 0;//空闲===1===就餐 dk.SubBy = 1; dk.SubTime = System.DateTime.Now; } else if (Temp == 2)//修改操作 { dk.DeskId = Convert.ToInt32(labId.Text); } md.MsgDivShow(dkBll.AddOrUpdateDeskInfo(dk, Temp) ? "操作成功" : "操作失败", 1, Bind); } }
//加载餐桌,tp表示的是哪个选项卡.p表示的是删除标识 private void LoadDeskInfoByDelFlag(TabPage tp)//, int p) { RoomInfo room = tp.Tag as RoomInfo; int roomId = Convert.ToInt32(room.RoomId); //获取房间的id ListView lv = tp.Controls[0] as ListView; //获取当前选项卡中的listview控件(东西) lv.Clear(); //清空 DeskInfoBLL bll = new DeskInfoBLL(); //通过房间的id获取该房间下的所有的餐桌 List <DeskInfo> list = bll.GetAllDeskInfoByRoomId(roomId);// for (int i = 0; i < list.Count; i++) { //if (list[i].DeskState==0) //{ // lv.Items.Add(list[i].DeskName, 0); //} //else if (list[i].DeskState==1) //{ // lv.Items.Add(list[i].DeskName, 1); //} lv.Items.Add(list[i].DeskName, Convert.ToInt32(list[i].DeskState)); lv.Items[i].Tag = list[i];//把餐桌的对象绑定到每个项的tag属性中 //else if (list[i].DeskState==2) //{ //} } }
//添加和修改 private void btnOk_Click(object sender, EventArgs e) { //先判断不能为空 if (IsCheck()) { //判断是新增还是修改 DeskInfo dk = new DeskInfo(); dk.DeskName = txtDeskName.Text; dk.DeskRegion = txtDeskRegion.Text; dk.DeskRemark = txtDeskRemark.Text; dk.RoomId = Convert.ToInt32(cmdRoom.SelectedValue); if (this.Tp == 3)//添加 { dk.DelFlag = 0; dk.DeskState = 0; dk.SubBy = 1; dk.SubTime = DateTime.Now; } else if (this.Tp == 4)//修改 { dk.DeskId = Convert.ToInt32(labId.Text); } DeskInfoBLL bll = new DeskInfoBLL(); string msg = bll.SaveDeskinfo(dk, this.Tp)?"操作成功":"操作失败"; MessageBox.Show(msg); this.Close(); } }
//确定开单 private void btnOK_Click(object sender, EventArgs e) { //开单用了三张表 //先改变餐桌的状态,需要餐桌的id DeskInfoBLL dkBll = new DeskInfoBLL(); bool dkFlag = dkBll.UpdateDeskStateByDeskId(this.ID, 1); //添加一个订单 OrderInfo order = new OrderInfo(); order.DelFlag = 0; order.OrderState = 1; order.Remark = txtPersonCount.Text + "," + txtDescription.Text; order.SubBy = 1; order.SubTime = System.DateTime.Now; OrderInfoBLL orderBll = new OrderInfoBLL(); //插入一条数据返回该数据的主键id int orderId = orderBll.AddOrderInfo(order); //再把订单的id和餐桌的id存到中间表中 ROrderDeskBLL rodBll = new ROrderDeskBLL(); ROrderDesk rod = new ROrderDesk(); rod.DeskId = this.ID; //餐桌的id rod.OrderId = orderId; //订单的id bool rodFlag = rodBll.AddROrderDesk(rod); if (dkFlag && rodFlag) { MessageBox.Show("开单成功"); this.Close(); } else { MessageBox.Show("开单失败"); } }
//删除房间的时候 private void button3_Click(object sender, EventArgs e) { //选中 if (dgvRoomInfo.SelectedRows.Count > 0) { if (DialogResult.OK == MessageBox.Show("是否删除", "删除", MessageBoxButtons.OKCancel)) { //开始删除 int id = Convert.ToInt32(dgvRoomInfo.SelectedRows[0].Cells[0].Value); DeskInfoBLL bll = new DeskInfoBLL(); //有正在使用的餐桌 if (Convert.ToInt32(bll.GetDeskState(id)) > 0) { MessageBox.Show("有餐桌正在使用不能删除"); } else { //删除房间,删除该房间下的餐桌 RoomInfoBLL rbll = new RoomInfoBLL(); //判断一个该房间下是否有餐桌,有就删,没有就直接删房间 if (bll.DeleteDesk(id) && rbll.DeleteRoomById(id)) { MessageBox.Show("操作成功"); LoadRoomInfoByDelFlag(0); LoadDeskInfoByDelFlag(0); } else { MessageBox.Show("操作失败"); } } } } }
//删除餐桌 private void btnDelete_Click(object sender, EventArgs e) { //判断是否有选中的行 if (dgvDeskInfo.SelectedRows.Count > 0) { //获取id int id = Convert.ToInt32(dgvDeskInfo.SelectedRows[0].Cells[0].Value); //餐桌的状态 1-使用 0-空闲 DeskInfoBLL bll = new DeskInfoBLL(); if (bll.SearchDeskById(id)) //空闲可以删除 { if (bll.DeleteDeskById(id)) { MessageBox.Show("操作成功"); LoadDeskInfoByDelFlag(0); } else { MessageBox.Show("操作失败"); } } else { MessageBox.Show("餐桌正在使用,不能删除"); } } else { MessageBox.Show("请选中行"); } }
//删除餐桌 private void btnDelete_Click(object sender, EventArgs e) { //先判断是否有选中的行 if (dgvDeskInfo.SelectedRows.Count > 0) { //获取Id int id = Convert.ToInt32(dgvDeskInfo.SelectedRows[0].Cells[0].Value); //餐桌的状态-- 1使用,0空闲 DeskInfoBLL bll = new DeskInfoBLL(); if (bll.SerachDeskById(id)) { if (bll.DeleteDeskById(id)) { MessageBox.Show("操作成功"); LoadDeskInfoByDelFlag(0); } else { MessageBox.Show("操作失败"); } } else { MessageBox.Show("餐桌正在使用,不能删除"); } } else { MessageBox.Show("请选中行");//测试本地提交,在vs端拉取 //多测试几次 //测试本地提交,在vs端拉取+2 //测试vs提交,在本地端拉取+3 } }
//房间的删除 private void button3_Click(object sender, EventArgs e) { if (dgvRoomInfo.SelectedRows.Count > 0) { if (DialogResult.OK == MessageBox.Show("您确定删除吗?", "删除", MessageBoxButtons.OKCancel)) { DeskInfoBLL bll = new DeskInfoBLL(); int roomId = Convert.ToInt32(dgvRoomInfo.SelectedRows[0].Cells[0].Value); //可以删除了,这个房间是否有餐桌,这个房间餐桌是否在被使用 if (bll.GetDeskInfoStateByRoomId(roomId)) { MessageBox.Show("房间下还有正在使用的餐桌,不能删除"); } else { //先删除餐桌,再删除房间 RoomInfoBLL rbll = new RoomInfoBLL(); if (bll.DeleteDeskInfoByRoomId(roomId) && rbll.DeleteRoomInfoByRoomId(roomId)) { MessageBox.Show("操作成功!"); LoadDeskInfoByDelFlag(0); LoadRoomInfoByDelFlag(0); } else { MessageBox.Show("操作失败!"); } } } } else { MessageBox.Show("请选中删除的行"); } }
private void btnDDesk_Click(object sender, EventArgs e) { //判断是否选择了删除的对象 if (dgvDesk.SelectedRows.Count <= 0) { md1.MsgDivShow("请选择要注销的餐桌", 1); return; } //提示用户是否真的删除 if (MessageBox.Show("亲,真的要注销这个餐桌吗?", "注销提示", MessageBoxButtons.OKCancel) == DialogResult.OK) { //删除 DeskInfoBLL dBll = new DeskInfoBLL(); DeskInfo d = (DeskInfo)dgvDesk.SelectedRows[0].DataBoundItem; string msg = dBll.SoftDelete((int)d.DeskId) > 0 ? "操作成功" : "操作失败"; md1.MsgDivShow(msg, 1); //刷新 LoadDeskByDelFlag(0); LoadDeskEvent(GetTabPage()); return; } //提示取消删除 md1.MsgDivShow("您已经取消了注销", 1); }
private void btnDRoom_Click(object sender, EventArgs e) { if (dgvRoom.SelectedRows.Count <= 0) { md.MsgDivShow("请选中要删除的房间", 1); return; } if (MessageBox.Show("确认删除该房间吗?", "删除房间", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK) { int id = ((RoomInfo)dgvRoom.SelectedRows[0].DataBoundItem).RoomId; //判断该房间下是否有餐桌,有餐桌就不删除该房间 DeskInfoBLL dkBll = new DeskInfoBLL(); if (dkBll.GetDeskInfoCountByRoomId(id) > 0) { md.MsgDivShow("对不起,该房间下有餐桌", 1); return; } //该房间下没有餐桌--可以删除选中的房间 RoomInfoBLL rBll = new RoomInfoBLL(); md.MsgDivShow(rBll.SoftDeleteRoomInfoByRoomId(id) ? "操作成功" : "操作失败", 1); LoadAllRoomInfoByDelFlag(0);//刷新 return; } md.MsgDivShow("您已经取消了删除该房间"); }
//加载餐桌 private void LoadAllDeskInfoByDelFlag(int p) { DeskInfoBLL dkBll = new DeskInfoBLL(); dgvDesk.AutoGenerateColumns = false; dgvDesk.DataSource = dkBll.GetAllDeskInfoByDelFlag(p); dgvDesk.ClearSelection();//清楚默认选中的行 }
private void LoadDeskInfoByDelFlag(int p) { DeskInfoBLL bll = new DeskInfoBLL(); dgvDeskInfo.AutoGenerateColumns = false; dgvDeskInfo.DataSource = bll.GetAllDeskInfoByDelFlag(p); dgvDeskInfo.SelectedRows[0].Selected = false; }
private void btnOK_Click(object sender, EventArgs e) { //餐桌的状态 var bllBk = new DeskInfoBLL(); var dkFlag = bllBk.UpdateDeskStateByDeskId(_id, 1); //添加一个订单 var odrBll = new OrderInfoBLL(); var odr = new OrderInfo(); odr.BeginTime = System.DateTime.Now; odr.SubTime = System.DateTime.Now; odr.DelFlag = 0; odr.OrderMoney = 0; odr.OrderState = 1; odr.Remark = txtPersonCount.Text + txtDescription.Text; odr.SubBy = 1; int orderId = odrBll.AddOrderInfo(odr); //添加一个中间表 var rodBll = new R_Order_DeskBLL(); var rod = new R_Order_Desk(); rod.DeskId = _id; rod.OrderId = orderId; var rodFlag = rodBll.AddROrderDesk(rod); if (dkFlag && rodFlag) { MessageBox.Show("开单成功"); if (ckbMeal.Checked) { var mea = new MyEventArgs(); mea.Name = labDeskName.Text; //餐桌编号 mea.Temp = orderId; //订单Id //窗体传值 var fam = new FrmAddMoney(); this.evtFrmMoney += new EventHandler(fam.SetText); if (this.evtFrmMoney != null) { this.evtFrmMoney(this, mea); fam.FormClosed += new FormClosedEventHandler(fam_FormClosed); fam.ShowDialog(); } } else { this.Close(); } } else { MessageBox.Show("开单失败"); } }
//删除 private void btnDelete_Click(object sender, EventArgs e) { if (dgvDeskInfo.SelectedRows.Count > 0) { //删除餐桌的时候要判断该餐桌是否被使用 int id = Convert.ToInt32(dgvDeskInfo.SelectedRows[0].Cells[0].Value); //省略了 DeskInfoBLL bll = new DeskInfoBLL(); string str = bll.DeleteDesk(id) ? "操作成功" : "操作失败"; MessageBox.Show(str); LoadDeskInfoByDelFlag(0); } }
//修改餐桌 private void btnUpdateDesk_Click(object sender, EventArgs e) { if (dgvDeskInfo.SelectedRows.Count > 0) { //获取选中餐桌的id int id = Convert.ToInt32(dgvDeskInfo.SelectedRows[0].Cells[0].Value); //根据餐桌的id查询该行数据,返回的是餐桌的对象 DeskInfoBLL bll = new DeskInfoBLL(); DeskInfo dk = bll.GetDeskInfoByDeskId(id); dk.DeskId = id; fea.obj = dk; ShowFrmChangeDesk(4); } }
//确定开单 private void btnOK_Click(object sender, EventArgs e) { //餐桌的id,改变餐桌的状态 DeskInfoBLL dkBll = new DeskInfoBLL(); bool dkResult = dkBll.UpdateDeskStateByDeskId(this.Id, 1);//餐桌开单了 //添加一个订单,需要备注,订单的状态,提交人,提交时间,删除标识 OrderInfo order = new OrderInfo(); order.Remark = txtPersonCount.Text + txtDescription.Text;//人数和描述(备注)直接存到备注信息里 order.SubBy = 1; order.SubTime = DateTime.Now; order.DelFlag = 0; order.OrderState = 1; //标识的是这个订单正在使用 OrderInfoBLL odBll = new OrderInfoBLL(); int orderId = odBll.GetOrderIdInsertOrderInfo(order); //插入一个订单的同时获取该订单的id //向中间表(订单和餐桌)插入 订单的id还有餐桌的id ROrderDeskBLL roddkBll = new ROrderDeskBLL(); ROrderDesk rod = new ROrderDesk(); rod.DeskId = this.Id; //餐桌id rod.OrderId = orderId; //订单id bool RoDResult = roddkBll.AddROrderDesk(rod); if (dkResult && RoDResult) { MessageBox.Show("开单成功"); this.Close(); } else { MessageBox.Show("开单失败"); } if (ckbMeal.Checked) { FrmAddMoney fam = new FrmAddMoney(); this.evt += new EventHandler(fam.SetTxt); FrmEventArgs fea = new FrmEventArgs(); fea.Name = labDeskName.Text; //餐桌的编号 fea.Temp = orderId; //订单的id if (this.evt != null) { this.evt(this, fea); } //增加消费的窗体关闭后,当前的开单窗体关闭 fam.FormClosed += new FormClosedEventHandler(fam_FormClosed); fam.ShowDialog(); } }
//加载餐桌 private void LoadDeskInfoBySelectedRoomId(TabPage tp) { var rm = tp.Tag as RoomInfo; var lv = tp.Controls[0] as ListView;//lv对象储存在tabPage中 lv.Clear(); var bll = new DeskInfoBLL(); var listDesk = bll.GetAllDeskInfoByRoomId((int)rm.RoomId); for (int i = 0; i < listDesk.Count; i++) { lv.Items.Add(listDesk[i].DeskName, (int)listDesk[i].DeskState); lv.Items[i].Tag = listDesk[i]; } }
private void btnAccounts_Click(object sender, EventArgs e) { OrderInfo order = new OrderInfo(); order.OrderId = Convert.ToInt32(labOrderId.Text); //订单的id order.EndTime = DateTime.Now; //订单中的结束时间 //如果选择会员 if (cmbMemmber.SelectedIndex == 0) { //不是会员 // order.DisCount = 10; } else { //是会员 //会员的余额更新 //如果是会员,那么要获取该会员的余额-当前消费的金额,更新到会员的表中 decimal memYuMoney = Convert.ToDecimal(labyeMoney.Text) - Convert.ToDecimal(lblMoney.Text); int memId = Convert.ToInt32(cmbMemmber.SelectedValue); MemmberInfoBLL bll = new MemmberInfoBLL(); bool memresult = bll.UpdateMoney(memId, memYuMoney); //更新会员的余额 order.OrderMemId = memId; //订单中的会员id order.DisCount = Convert.ToDecimal(lblDis.Text); //这个是订单中的会员折扣 } //更新餐桌的状态=0 //获取餐桌的id,更改餐桌的状态 DeskInfoBLL dkBll = new DeskInfoBLL(); bool result = dkBll.UpdateDeskStateByDeskId(this.Id, 0); //订单的状态=2 //获取订单的id更改订单的状态.更新这个订单最后花费多少钱,结束时间 order.OrderMoney = Convert.ToDecimal(lblMoney.Text);//这个订单花了多少钱 //窗体关闭 OrderInfoBLL obll = new OrderInfoBLL(); bool oresult = obll.UpdateOrderInfoMoney(order); if (result && oresult) { MessageBox.Show("结账成功"); this.Close(); } else { MessageBox.Show("结账失败"); } }
//加载餐桌 private void LoadDeskInfoByTabPage(TabPage tp) { //获取房间的id RoomInfo room = tp.Tag as RoomInfo; DeskInfoBLL bll = new DeskInfoBLL(); List <DeskInfo> listDesk = bll.GetDeskInfoByRoomId(Convert.ToInt32(room.RoomId)); ListView lv = tp.Controls[0] as ListView; lv.Clear(); for (int i = 0; i < listDesk.Count; i++) { //判断餐桌状态显示对象的图片 lv.Items.Add(listDesk[i].DeskName, Convert.ToInt32(listDesk[i].DeskState)); lv.Items[i].Tag = listDesk[i];//餐桌对象 } }
//根据房间的id显示里面的餐桌 private void LoadDeakInfoByTabpageSelect(TabPage tp) { RoomInfo room = (RoomInfo)tp.Tag; //获取房间对象 //获取tabpage控件中的listview控件 ListView lv = (ListView)tp.Controls[0]; //获取包含在控件内的控件 lv.Clear(); //清除 //根据房间Id查询该房间下所有的餐桌 DeskInfoBLL dkBll = new DeskInfoBLL(); List <DeskInfo> listDesk = dkBll.GetAllDeskInfoByRoomId(room.RoomId); for (int i = 0; i < listDesk.Count; i++) { lv.Items.Add(listDesk[i].DeskName, listDesk[i].DeskState); //用指定的文本和图像创建一个项并添加到集合中 lv.Items[i].Tag = listDesk[i]; //餐桌对象存起来 } }
private void btnDDesk_Click(object sender, EventArgs e) { //判断是否选中的要删除的餐桌 if (dgvDesk.SelectedRows.Count <= 0) { md1.MsgDivShow("请选中要删除的餐桌", 1); return; } if (MessageBox.Show("确定要删除该餐桌吗?", "删除餐桌", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK) { int id = ((DeskInfo)dgvDesk.SelectedRows[0].DataBoundItem).DeskId; DeskInfoBLL dkBll = new DeskInfoBLL(); md1.MsgDivShow(dkBll.SoftDeleteDeskByDeskId(id) ? "操作成功" : "操作失败", 1); LoadAllDeskInfoByDelFlag(0); return; } md1.MsgDivShow("您已经取消了删除该餐桌的操作", 1); }
//结账 private void btnAccounts_Click(object sender, EventArgs e) { //餐桌状态发生改变 DeskInfoBLL dkbll = new DeskInfoBLL(); bool dkResult = dkbll.UpdateDeskInfoStateByDeskId(Convert.ToInt32(labdkId.Text), 0); //订单状态发生改变 OrderInfoBll orderBll = new OrderInfoBll(); OrderInfo order = new OrderInfo(); order.EndTime = System.DateTime.Now; //当前的时间 order.OrderMoney = Convert.ToDouble(lblMoney.Text); //结账后的金额 order.OrderState = 2; //状态 order.OrderId = Convert.ToInt32(labOrderId.Text); if (cmbMember.SelectedIndex != 0) { //获取选中的会员对象 MemberInfo mem = (MemberInfo)cmbMember.SelectedItem; order.OrderMemberId = mem.MemberId; //会员的id order.DisCount = mem.MemDiscount; //折扣 //根据会员的id更新该会员的金额 MemberInfoBl memBll = new MemberInfoBl(); //得到会员的金额 double money = Convert.ToDouble(labyuMoney.Text) - Convert.ToDouble(lblMoney.Text); //更新会员余额 memBll.UpdateMemberMoneyById(mem.MemberId, money);//==不接收了 } //更新订单中的金额 bool orderResult = orderBll.UpdateOrderInfo(order); //会员结账----更改会员余额 //改变订单对应的订单和菜单的中间表中的菜的状态 R_Order_ProductBll ropBll = new R_Order_ProductBll(); bool ropResult = ropBll.UpdateR_Order_ProductDelFlagByOrderId(Convert.ToInt32(labOrderId.Text)); if (dkResult && orderResult & ropResult) { md.MsgDivShow("顾客结账成功", 1); } else { md.MsgDivShow("结账失败了", 1); } }
//修改餐桌 private void btnUpdateDesk_Click(object sender, EventArgs e) { if (dgvDeskInfo.SelectedRows.Count > 0) { //获取选中行的id.查询该id餐桌的信息 string id = dgvDeskInfo.SelectedRows[0].Cells[0].Value.ToString(); DeskInfoBLL bll = new DeskInfoBLL(); int deskId = Convert.ToInt32(id); DeskInfo dk = bll.GetDeskById(deskId); dk.DeskId = deskId; //对象传值 fea.Obj = dk; ShowFrmChangeDesk(4); } else { MessageBox.Show("请选中行"); } }
//修改餐桌 private void btnUpdateDesk_Click(object sender, EventArgs e) { if (dgvDeskInfo.SelectedRows.Count > 0) { int id = Convert.ToInt32(dgvDeskInfo.SelectedRows[0].Cells[0].Value); DeskInfo desk = new DeskInfo(); DeskInfoBLL bll = new DeskInfoBLL(); desk = bll.GetDeskInfoByDeskId(id); if (desk != null) { feas.obj = desk; desk.DeskId = id; ShowFrmChangeDesk(2); } } else { MessageBox.Show("请选择要修改的数据"); } }
public void LoadDeskBySelectedTab(TabPage tabPage) { if (tabPage == null) { return; } DeskInfoBLL dBll = new DeskInfoBLL(); RoomInfo room = (RoomInfo)tabPage.Tag; List <DeskInfo> desks = dBll.GetAllAliveDeskInfoByRoomId((int)room.RoomId); ListView lv = (ListView)tabPage.Controls[0]; //清空listview lv.Clear(); //为listview添加内容 for (int i = 0; i < desks.Count; i++) { lv.Items.Add(desks[i].DeskName, (int)desks[i].DeskState); lv.Items[i].Tag = desks[i]; } }
private void btnOk_Click(object sender, EventArgs e) { //顾客开单 //更新餐桌状态 DeskInfoBLL dbll = new DeskInfoBLL(); int deksId = Convert.ToInt32(labId.Text); bool isDesk = dbll.UpdateDeskInfoStateByDeskId(deksId, 1);//1标识正在使用 //生成订单 OrderInfoBLL obll = new OrderInfoBLL(); OrderInfo order = new OrderInfo(); order.BeginTime = DateTime.Now; order.DelFlag = 0; order.DisCount = 0; order.OrderMoney = 0; order.OrderState = 1;//表示已经开单 order.Remark = txtPersonCount.Text + "个人" + txtDescription.Text; order.SubBy = 1; order.SubTime = System.DateTime.Now; object obj = obll.AddOrderInfo(order);//返回的是刚刚插入的订单的主键id; //向中间表插入一条数据 R_Order_DeskBLL rodbll = new R_Order_DeskBLL(); R_Order_Desk rod = new R_Order_Desk(); rod.DeskId = deksId; rod.OrderId = Convert.ToInt32(obj); ordId = Convert.ToInt32(obj); bool isRod = rodbll.AddR_Order_Desk(rod); if (!isDesk || !isRod) { md.MsgDivShow("开单失败,请联系管理员", 1); return; } md.MsgDivShow("开单成功", 1, Bind); // md.MsgDivShow("开单成功",1,Bind); }
private void btnAccounts_Click(object sender, EventArgs e) { //更新餐桌状态 DeskInfoBLL dbll = new DeskInfoBLL(); bool dkResult = dbll.UpdateDeskInfoStateByDeskId(Convert.ToInt32(labdkId.Text), 0); //订单状态改变 OrderInfoBLL ordlbll = new OrderInfoBLL(); OrderInfo order = new OrderInfo(); order.EndTime = System.DateTime.Now; order.OrderMoney = Convert.ToDouble(lblMoney.Text); order.OrderState = 2; order.OrderId = Convert.ToInt32(labOrderId.Text); if (cmbMember.SelectedIndex != 0)//是会员 { MemberInfo mem = (MemberInfo)cmbMember.SelectedItem; order.OrderMemberId = mem.MemberId; order.DisCount = mem.MemDiscount;//状态 //根据会员的id更新会员的金额 double money = Convert.ToDouble(labyuMoney.Text) - Convert.ToDouble(lblMoney.Text); MemberInfoBLL membll = new MemberInfoBLL(); membll.UpdateMoneyByMemId(mem.MemberId, money); } bool ordResult = ordlbll.UpdateOrderInfo(order); //改变订单对应订单和菜单的中间表中的菜的状态 R_Order_ProductBLL ropbll = new R_Order_ProductBLL(); bool ropResult = ropbll.UpdateR_Order_ProductByOrderId(Convert.ToInt32(labOrderId.Text)); if (dkResult && ordResult && ropResult) { md.MsgDivShow("结账成功", 1, Bind); } else { md.MsgDivShow("结账失败了", 1); } }
private void btnOk_Click(object sender, EventArgs e) { //首先改变餐桌状态 DeskInfoBLL dkBll = new DeskInfoBLL(); bool dkFlag = dkBll.UpdateDeskInfoStateByDeskId(Convert.ToInt32(labId.Text), 1); //添加一个订单 返回该订单ID OrderInfo order = new OrderInfo(); order.BeginTime = System.DateTime.Now; //订单的开始时间 order.DelFlag = 0; //删除标识 order.DisCount = 0; //折扣==针对会员 order.OrderMoney = 0; //订单消费的金额默认值为0 order.OrderState = 1; //订单状态1===使用 order.Remark = txtPersonCount.Text + "个" + txtDescription.Text; //备注 order.SubBy = 1; //提交人默认1 order.SubTime = System.DateTime.Now; OrderInfoBll oBll = new OrderInfoBll(); //获得订单的id object orderIdObj = oBll.AddOrderInfo(order); //为餐桌和订单的中间表添加一条记录 R_Order_Desk rod = new R_Order_Desk(); rod.DeskId = Convert.ToInt32(labId.Text); //餐桌的id rod.OrderId = Convert.ToInt32(orderIdObj); //订单的id ordId = rod.OrderId; //存储订单的id R_Order_DeskBll rodBll = new R_Order_DeskBll(); bool rodFlag = rodBll.AddR_Order_Desk(rod); if (dkFlag && rodFlag) { md.MsgDivShow("开单成功", 1, Bind); } else { md.MsgDivShow("开单失败,请联系程序员", 1); return; } }