private void AddOrUdDeak(DeskInfo dk, int temp)
 {
     this.Hide();
     FrmDeakAddOrModify fdam = FrmDeakAddOrModify.Single(dk, temp);
     fdam.FormClosed += new FormClosedEventHandler(fdam_FormClose);
     fdam.Show();
 }
        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);
            }
        }
 public static FrmDeakAddOrModify Single(DeskInfo dk, int temp)
 {
     if (instance == null || instance.IsDisposed)
     {
         instance = new FrmDeakAddOrModify(dk);
         Temp = temp;
     }
     return instance;
 }
 public bool AddOrUpdateDeskInfo(DeskInfo dk,int temp)
 {
     if (temp == 1)
     {
         return dkDal.AddDeskInfo(dk) > 0;
     }
     else if (temp == 2)
     {
         return dkDal.UpdateDeskInfo(dk) > 0;
     }
     return false;
 }
 private FrmDeakAddOrModify(DeskInfo dk)
 {
     InitializeComponent();
     LoadRoomInfoByDelFlag(0);
     if (dk != null)
     {
         //修改
         txtDeskName.Text = dk.DeskName;//餐桌的名字
         txtDeskRegion.Text = dk.DeskRegion;//描述
         txtDeskRemark.Text = dk.DeskRemark;//备注
         labId.Text = dk.DeskId.ToString();//餐桌的id
         //显示该餐桌的房间
         cmbRoom.SelectedValue = dk.RoomId;
     }
 }