예제 #1
0
        public void LoadDesk(int page)
        {
            data_Desk.Rows.Clear();
            DataTable dtDesk   = new DataTable();
            int       totalRec = 0;

            desk.DeskId       = _iDeskId.ToString();
            desk.DeskNo       = txtDeskNo.Text;
            desk.DeskLocation = cboLocation.SelectedValue.ToString();
            desk.Description  = rtxtDescription.Text;
            desk.Status       = cboStatus.SelectedValue.ToString();
            desk.NoOfSeat     = txtDeskSeat.Text;
            dtDesk            = deskBLL.GetLists(desk, page, out totalRec);

            if (dtDesk != null)
            {
                int i = 0;
                foreach (DataRow r in dtDesk.Rows)
                {
                    data_Desk.Rows.Add();
                    data_Desk.Rows[i].Cells["STT"].Value            = i + 1;
                    data_Desk.Rows[i].Cells["DesKId"].Value         = r["DesKId"];
                    data_Desk.Rows[i].Cells["DeskNo"].Value         = r["DesKNo"];
                    data_Desk.Rows[i].Cells["Description"].Value    = r["Description"];
                    data_Desk.Rows[i].Cells["NoOfSeat"].Value       = r["NoOfSeat"];
                    data_Desk.Rows[i].Cells["DeskLocationId"].Value = r["DeskLocation"];
                    data_Desk.Rows[i].Cells["StatusId"].Value       = r["Status"];
                    data_Desk.Rows[i].Cells["IsUsing"].Value        = r["IsUsing"];
                    //get Name of status
                    CommonCode cm = new CommonCode();
                    cm.CommonTypeId = "DeskType";
                    cm.CommonId     = r["Status"].ToString();
                    DataTable dt1 = new DataTable();
                    dt1 = deskBLL.GetStatusName(cm);
                    data_Desk.Rows[i].Cells["Status"].Value = dt1.Rows[0]["StrValue1"].ToString();

                    //get Name of DeskLocation
                    CommonCode cm1 = new CommonCode();
                    cm1.CommonTypeId = "DeskLocation";
                    cm1.CommonId     = r["DeskLocation"].ToString();
                    DataTable dt2 = new DataTable();
                    dt2 = deskBLL.GetStatusName(cm1);
                    data_Desk.Rows[i].Cells["DeskLocation"].Value = dt2.Rows[0]["StrValue1"].ToString();

                    DataGridViewRow row = data_Desk.Rows[i];
                    row.Height = 40;

                    i++;
                }
            }
            else
            {
                CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("NotFoundData"),
                                                                 Common.clsLanguages.GetResource("Information"),
                                                                 Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                 Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                return;
            }
            this.linkNumber.Text = page.ToString();
            _iTotalRecord        = totalRec;
            _iCurrentPage        = page;
            // gShowDesk.Text = Common.clsLanguages.GetResource("TotalDeskFound") + " " + totalRec;
        }
예제 #2
0
        private void bntLuu_Click(object sender, EventArgs e)
        {
            try
            {
                // kiem tra du lieu
                if (!Kiemtra())
                {
                    return;
                }

                //insert du lieu vao data
                desk.DeskId       = _iDeskId.ToString();
                desk.DeskNo       = txtDeskNo.Text;
                desk.DeskLocation = cboLocation.SelectedValue.ToString();
                desk.Description  = rtxtDescription.Text;
                desk.Status       = cboStatus.SelectedValue.ToString();
                desk.NoOfSeat     = txtDeskSeat.Text;
                //kiem tra DeskNo co ton tai hay khong
                DataTable dt = new DataTable();
                deskBLL = new DeskBLL();
                dt      = deskBLL.GetLists("");
                if (dt != null || dt.Rows.Count > 0)
                {
                    DataRow[] r = dt.Select("DeskNo ='" + txtDeskNo.Text.Trim() + "'");
                    if (r == null || r.Length == 0)
                    {
                        desk.sCondition = "0";
                        //_bNew = true;
                    }
                    else
                    {
                        desk.sCondition = "1";
                        //_bNew = false;
                    }
                }
                //if deskid = 0 then Insert else Update
                if (desk.sCondition == "0" && _iDeskId == 0)
                {
                    deskBLL.Add(desk);
                }
                else if (desk.sCondition == "0" && _iDeskId != 0)
                {
                    deskBLL.Update(desk);
                }
                else if (desk.sCondition == "1" && _iDeskId == 0)
                {
                    if (CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("DeskNameAlreadyAreYouWantToUpdate"),
                                                                         Common.clsLanguages.GetResource("Information"),
                                                                         Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                         Common.Config.CUSTOM_MESSAGEBOX_BUTTON.YESNO) == DialogResult.Yes)
                    {
                        deskBLL.Update(desk);
                    }

                    else
                    {
                        return;
                    }
                }
                else if (desk.sCondition == "1" && _iDeskId != 0)
                {
                    DataTable dt1 = deskBLL.CheckExitByNameAndNotINId(txtDeskNo.Text.Trim(), _iDeskId);
                    if (dt1.Rows.Count > 0)
                    {
                        CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("NameAlreadyPleaseInputOther"),
                                                                         Common.clsLanguages.GetResource("Information"),
                                                                         Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                         Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);

                        return;
                    }
                    else
                    {
                        deskBLL.Update(desk);
                    }
                }

                /*else if (!_bNew)
                 * {
                 * if(_iDeskId==0){
                 *      if (CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("DeskNameAlreadyAreYouWantToUpdate"),
                 *                   Common.clsLanguages.GetResource("Information"),
                 *                   Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                 *                   Common.Config.CUSTOM_MESSAGEBOX_BUTTON.YESNO) == DialogResult.Yes)
                 *
                 *          deskBLL.Update(desk);
                 *
                 *      else return;
                 *  }
                 *
                 *
                 *  else
                 *  {
                 *      DataTable dt1 = deskBLL.CheckExitByNameAndNotINId(txtDeskNo.Text.Trim(), _iDeskId);
                 *     if(dt1.Rows.Count > 0){
                 *      CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("NameAlreadyPleaseInputOther"),
                 *                   Common.clsLanguages.GetResource("Information"),
                 *                   Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                 *                   Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                 *
                 *      return;
                 *     }
                 *     else deskBLL.Update(desk);
                 *
                 *  }
                 *
                 * }*/
                //else if (!_bNew && _iDeskId != 0)
                //{
                //     CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("NameAlreadyPleaseInputOther"),
                //                     Common.clsLanguages.GetResource("Information"),
                //                     Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                //                     Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);

                //     return;
                //}

                if (deskBLL.Res && _bNew && _iDeskId == 0)
                {
                    CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("AddSuccess"),
                                                                     Common.clsLanguages.GetResource("Information"),
                                                                     Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                     Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                    Reset();
                }
                else if (deskBLL.Res)
                {
                    CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("UpdateSuccess"),
                                                                     Common.clsLanguages.GetResource("Information"),
                                                                     Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                     Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                    Reset();
                }
                else if (!deskBLL.Res)
                {
                    CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("UpdateFailed"),
                                                                     Common.clsLanguages.GetResource("Error"),
                                                                     Common.Config.CUSTOM_MESSAGEBOX_ICON.Error,
                                                                     Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                }
                LoadDesk(1);
            }
            catch (Exception obj) {
                MessageBox.Show(obj.ToString());
            }
        }