//增加消费 private void button2_Click(object sender, EventArgs e) { // ListView lv = (ListView)tabMain.SelectedTab.Controls[0]; //房间对象 RoomInfo room = (RoomInfo)(tabMain.SelectedTab.Tag); if (lv.SelectedItems.Count <= 0) { msg.MsgDivShow("请选择要增加消费的餐桌", 1); return; } DeskInfo desk = (lv.SelectedItems[0].Tag as DeskInfo); if (desk.DeskState == 0)//因为只允许单选,所以是tiems[0]; { msg.MsgDivShow("您选择的开单后的餐桌", 1); return; } //根据餐桌的id查询对应餐桌订单的id OrderInfoBLL obll = new OrderInfoBLL(); object objOrderId = obll.GetOrderIdByDeskId(desk.DeskId); FrmAddConsumption fac = FrmAddConsumption.Single(desk.DeskName, Convert.ToInt32(objOrderId)); fac.FormClosed += f_FormClosed; fac.Show(); }
private void btnAddConsumption_Click(object sender, EventArgs e) { if (tabMain.TabCount <= 0) { md.MsgDivShow("sorry啊,店内装修,暂不营业", 1); return; } ListView lv = (ListView)tabMain.SelectedTab.Controls[0]; if (lv.SelectedItems.Count <= 0) { md.MsgDivShow("亲,请先选择餐桌哦", 1); return; } RoomInfo room = (RoomInfo)tabMain.SelectedTab.Tag; DeskInfo desk = (DeskInfo)lv.SelectedItems[0].Tag; if (desk.DeskState == 0) { md.MsgDivShow("亲,请选择开单后的餐桌哦", 1); return; } int orderID = new R_Order_DeskBLL().GetAliveOrderIdByDeskId((int)desk.DeskId); FrmAddConsumption fac = FrmAddConsumption.Single(orderID, desk.DeskName); //主窗体要刷新!因为如果不刷新,之前选中的状态还会存在,虽然你看不见。 //测试方法: //正常情况:选中餐桌→增加消费→关闭增加消费窗体→选中餐桌→增加消费 //bug情况:关闭增加消费窗体→增加消费(不用选中餐桌就能增加消费了) fac.FormClosed += fb_FormClosed; fac.Show(); }
//增加消费 private void btnAddConsumption_Click(object sender, EventArgs e) { // ListView lv = (ListView)(tabMain.SelectedTab.Controls[0]); //房间的对象 RoomInfo room = (RoomInfo)(tabMain.SelectedTab.Tag); //餐桌的对象 if (lv.SelectedItems.Count <= 0)//没选中餐桌 { md.MsgDivShow("请选中要增加消费的餐桌", 1); return; } DeskInfo dk = (lv.SelectedItems[0].Tag as DeskInfo); if (dk.DeskState == 0) { md.MsgDivShow("请选择开单后的餐桌进行增加消费", 1); return; } //根据餐桌的id查询该餐桌对应的订单的id OrderInfoBll orderBll = new OrderInfoBll(); object objOrderId = orderBll.GetOrderIdByDeskId(dk.DeskId); FrmAddConsumption fac = FrmAddConsumption.Single(dk.DeskName, Convert.ToInt32(objOrderId)); //增加消费之后=======刷新 fac.FormClosed += new FormClosedEventHandler(fbi_FormClosed); //!!!!!!!!!必须刷新 fac.Show(); //显示增加消费的窗体 }
//传餐桌的编号,传订单的id 查点的菜 数量 金额 public static FrmAddConsumption Single(string deskName, int orderId) { if (_instance == null || _instance.IsDisposed) { _instance = new FrmAddConsumption(deskName, orderId); } return(_instance); }
public static FrmAddConsumption Single(int orderID, string deskName) { if (instance == null || instance.IsDisposed) { instance = new FrmAddConsumption(orderID, deskName); } return(instance); }
//传餐桌的编号--传订单的id--查点的菜--数量--金额 public static FrmAddConsumption Single(string deskName, int orderId) { if (_instance == null || _instance.IsDisposed) { _instance = new FrmAddConsumption(deskName, orderId); } return _instance; }
private void Bind() { if (ckbMeal.Checked) { this.Hide(); //增加消费的窗体显示出来-传订单的id,根据订单的id 查菜单 消费数量 金额 //传餐桌的编号 FrmAddConsumption f = FrmAddConsumption.Single(labDeskName.Text, ordId); f.FormClosed += f_FormClosed; f.Show(); return; } this.Close(); }
private int ordId;//用来存储订单的id private void Bind() { if (ckbMeal.Checked) { this.Hide(); //增加消费的窗体显示出来----传订单的id--根据订单的id--查菜单--消费数量--金额 //-- 传餐桌的编号 FrmAddConsumption fac = FrmAddConsumption.Single(labDeskName.Text, ordId); //FrmAddConsumption fac = new FrmAddConsumption(); fac.FormClosed += new FormClosedEventHandler(fac_FormClosed); fac.Show(); return; } this.Close();//开单的窗体关闭 }
private void Bind() { if (ckbMeal.Checked) { //此时不能直接关闭,关闭就直接return了,fac就show不出来了,所以Hide()。 this.Hide(); //由于弹出了新窗体,没有在更新开单信息后,立即关闭窗体触发主窗体更新的事件 //可能会导致,用户在主窗体可以对已经修改状态而未显示已经修改状态的餐桌进行选择,并重复开单(一张桌子,两个开单)。 //流程图: //正常情况:在主窗体选择a桌子→顾客开单→开单界面(向数据库插入数据)→开单界面隐藏→添加消费界面→消费界面关闭→开单界面关闭→刷新主窗体 //bug情况:开单界面隐藏→添加消费界面→在主窗体选择a桌子→顾客开单→开单界面(再次向数据库插入数据)→开单界面隐藏→添加消费界面→ //修改:开单界面隐藏→刷新主窗体→添加消费界面→ main.LoadDeskBySelectedTab(tabMain.SelectedTab); FrmAddConsumption fac = FrmAddConsumption.Single(newOrderId, oldDesk.DeskName); fac.FormClosed += fac_FormClosed; fac.Show(); return; } this.Close(); }