private void frmDesk_Load(object sender, EventArgs e) { SetUIChanges(); commonCodeBLL = new CommonCodeBLL(); deskBLL = new DeskBLL(); sDeskLocation = "DeskLocation"; LoadTabFromTable(); }
private void frmMoveTable_Load(object sender, EventArgs e) { SetUIChanges(); ToUpper(); // commonCodeBLL = new CommonCodeBLL(); deskBLL = new DeskBLL(); sDeskLocation = "DeskLocation"; tabToTable.TabPages.Clear(); LoadTabFromTable(); }
private void data_Desk_CellClick(object sender, DataGridViewCellEventArgs e) { if (data_Desk.Rows.Count <= 0) { return; } if (e.RowIndex >= 0) { _iDeskId = int.Parse(data_Desk.Rows[e.RowIndex].Cells["DesKId"].Value.ToString()); txtDeskNo.Text = data_Desk.Rows[e.RowIndex].Cells["DeskNo"].Value.ToString(); //txtDeskLocation.Text = data_Desk.Rows[e.RowIndex].Cells["DeskLocation"].Value.ToString(); cboLocation.SelectedValue = data_Desk.Rows[e.RowIndex].Cells["DeskLocationId"].Value.ToString(); rtxtDescription.Text = data_Desk.Rows[e.RowIndex].Cells["Description"].Value.ToString(); txtDeskSeat.Text = data_Desk.Rows[e.RowIndex].Cells["NoOfSeat"].Value.ToString(); cboStatus.SelectedValue = data_Desk.Rows[e.RowIndex].Cells["StatusId"].Value.ToString(); if (e.ColumnIndex == 9) { if (int.Parse(data_Desk.Rows[e.RowIndex].Cells["IsUsing"].Value.ToString()) == 1) { CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("TableFull_CanNotDel"), Common.clsLanguages.GetResource("Information"), Common.Config.CUSTOM_MESSAGEBOX_ICON.Information, Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK); return; } //AreYouSureWanToDeleteDesk if (CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("AreYouSureWanToDeleteDesk") + " " + txtDeskNo.Text + " ?", Common.clsLanguages.GetResource("Information"), Common.Config.CUSTOM_MESSAGEBOX_ICON.Information, Common.Config.CUSTOM_MESSAGEBOX_BUTTON.YESNO) == DialogResult.Yes) { data_Desk.Rows.RemoveAt(e.RowIndex); desk.DeskId = _iDeskId.ToString(); deskBLL = new DeskBLL(); deskBLL.Delete(desk); if (deskBLL.Res) { CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("DeleteSuccess"), Common.clsLanguages.GetResource("Information"), Common.Config.CUSTOM_MESSAGEBOX_ICON.Information, Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK); Reset(); LoadDesk(1); } } } } }
//private void LoadDesk() { // DataTable dt = deskBLL.GetLists(""); // int i = 0; // foreach(DataRow r in dt.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["DeskLocation"].Value = r["DeskLocation"]; // data_Desk.Rows[i].Cells["StatusId"].Value = r["Status"]; // //get Name of status // CommonCode cm = new CommonCode(); // cm.CommonId = r["Status"].ToString(); // deskBLL.GetStatusName(cm); // DataSet ds = deskBLL.Ds; // data_Desk.Rows[i].Cells["Status"].Value = ds.Tables[0].Rows[0]["StrValue1"].ToString(); // i++; // } //} private void LoadStatus() { deskBLL = new DeskBLL(); CommonCode cm = new CommonCode(); cm.CommonTypeId = "DeskType"; DataTable St = new DataTable(); St = deskBLL.GetStatus(cm); Dictionary <string, string> test = new Dictionary <string, string>(); test.Add("", VVPosS.Common.clsLanguages.GetResource("Status_null")); foreach (DataRow r in St.Rows) { test.Add(r["CommonId"].ToString(), r["StrValue1"].ToString()); } cboStatus.DataSource = new BindingSource(test, null); cboStatus.ValueMember = "Key"; cboStatus.DisplayMember = "Value"; }
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()); } }