//确定开单 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("开单失败"); } }
/// <summary> /// 向中间表插入一条数据 /// </summary> /// <param name="rod">中间表对象</param> /// <returns></returns> public int AddROrderDesk(ROrderDesk rod) { string sql = "insert into R_Order_Desk(OrderId,DeskId) values(@OrderId,@DeskId)"; SQLiteParameter[] param = { new SQLiteParameter("@OrderId", rod.OrderId), new SQLiteParameter("@DeskId", rod.DeskId) }; return(SqliteHelper.ExecuteNonquery(sql, param)); }
//确定开单 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(); } }
/// <summary> /// 往中间表插入数据 /// </summary> /// <param name="rod">中间表对象</param> /// <returns></returns> public bool AddROrderDesk(ROrderDesk rod) { return(dal.AddROrderDesk(rod) > 0 ? true : false); }