private void btnOK_Click(object sender, EventArgs e)
        {
            //change desk state
            DeskInfoBLL dkBll = new DeskInfoBLL();
            bool dkFlag = dkBll.UpdateDeskStateByDeskId(this.ID, 1);
            //add an order
            OrderInfoBLL orBll = new OrderInfoBLL();
            OrderInfo or = new OrderInfo();
            or.SubTime = System.DateTime.Now;
            or.OrderMoney = 0;
            or.DelFlag = 0;
            or.OrderState = 1;
            or.Remark = txtPersonCount.Text + txtDescription.Text;
            or.SubBy = 1;
            int orderId = orBll.AddOrderInfo(or);

            //add R_Order_Desk
            R_Order_DeskBLL rodBll = new R_Order_DeskBLL();
            R_Order_Desk rod = new R_Order_Desk();
            rod.DeskId = this.ID;
            rod.OrderId = orderId;
            bool rodFlag = rodBll.AddROrderDesk(rod);

            if(dkFlag && rodFlag)
            {
                MessageBox.Show("开单成功");
                if(ckbMeal.Checked)
                {
                    MyEventArgs mea = new MyEventArgs();
                    //deskName
                    mea.Name = labDeskName.Text;
                    //Order Id
                    mea.Temp = orderId;
                    FrmAddMoney 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
            {
                MessageBox.Show("开单失败");
            }
        }
        public void SetText(object sender, EventArgs e)
        {
            MyEventArgs mea = e as MyEventArgs;
            DeskInfo dk = mea.Obj as DeskInfo;
            //store deskId
            this.deskId = dk.DeskId;
            //DeskName
            labDeskName.Text = dk.DeskName;
            OrderInfoBLL bll = new OrderInfoBLL();
            //OrderId
            int orderId = bll.GetOrderIdByDeskId(dk.DeskId);
            labOrderId.Text = orderId.ToString();
            //get sum money
            decimal money = bll.GetSumMoney(orderId);
            labMoney.Text = money.ToString();
            lblMoney.Text = money.ToString();

        }
 //
 private void btnOk_Click(object sender, EventArgs e)
 {
     OrderInfoBLL bll = new OrderInfoBLL();
     if(!string.IsNullOrEmpty(labSumMoney.Text)&&labSumMoney.Text !="0")
     {
         bll.UpdateMoney(Convert.ToDecimal(labSumMoney.Text),Convert.ToInt32(labOrderId.Text));
     }
 }
        private void btnMoney_Click(object sender, EventArgs e)
        {
            TabPage tp = tabControl1.SelectedTab;
            ListView lv = tp.Controls[0] as ListView;

            if (lv.SelectedItems.Count <= 0)
            {
                MessageBox.Show("请选中");
                return;
            }

            //desk State
            if ((lv.SelectedItems[0].Tag as DeskInfo).DeskState != 1)
            {
                MessageBox.Show("请选择要开单的餐桌");
                return;
            }

            //注册事件
            FrmAddMoney fam = new FrmAddMoney();
            this.evtFrmMoney += new EventHandler(fam.SetText);
            MyEventArgs mea = new MyEventArgs();
            mea.Name = (lv.SelectedItems[0].Tag as DeskInfo).DeskName;
            OrderInfoBLL bll = new OrderInfoBLL();
            mea.Temp = bll.GetOrderIdByDeskId((lv.SelectedItems[0].Tag as DeskInfo).DeskId);
            //窗体传值
            if(this.evtFrmMoney != null)
            {
                this.evtFrmMoney(this, mea);
                fam.FormClosed += new FormClosedEventHandler(fbi_FormClosed);
                fam.ShowDialog();
            }
        }
 //Pay the bill
 private void btnAccounts_Click(object sender, EventArgs e)
 {
     MemberInfo mem = cmbMemmber.SelectedItem as MemberInfo;
     if(string.IsNullOrEmpty(txtMoney.Text))
     {
         MessageBox.Show("请输入钱");
         return;
     }
     if(Convert.ToDecimal(txtMoney.Text) < Convert.ToDecimal(lblMoney.Text))
     {
         MessageBox.Show("就这点钱? 搞笑呢");
         return;
     }
     OrderInfo order = new OrderInfo();
     //deskState in DeskInfo table
     DeskInfoBLL bll = new DeskInfoBLL();
     bool deskFlag = bll.UpdateDeskStateByDeskId(this.deskId, 0);
     //non-member
     if(cmbMemmber.SelectedIndex != 0)
     {
         order.OrderMemId = mem.MemmberId;
         order.DisCount = Convert.ToDecimal(mem.MemDiscount);
         //after pay in member money
         decimal money = mem.MemMoney - Convert.ToDecimal(lblMoney.Text);
         MemberInfoBLL mbll = new MemberInfoBLL();
         //if(money < 0)
         //{
         
         //}
         //Member money in MemmberInfo table
         bool memFlag = mbll.UpdateMoneyByMemId(mem.MemmberId, money);
     }
     order.EndTime = System.DateTime.Now;
     order.OrderId = Convert.ToInt32(labOrderId.Text);
     order.OrderMoney = Convert.ToDecimal(lblMoney.Text);
     OrderInfoBLL obll = new OrderInfoBLL();
     bool orderFlag = obll.UpdateOrderInfoMoney(order);
     lblSpareMoney.Text = (Convert.ToDecimal(txtMoney.Text) - Convert.ToDecimal(lblMoney.Text)).ToString();
     if(deskFlag && orderFlag)
     {
         MessageBox.Show("结账成功");
     }
     else
     {
         MessageBox.Show("失败");
     }
 }