private void btnBrowseBusityp_Click(object sender, EventArgs e) { IstabList wind = new IstabList(this.parent_window.main_form, this.sBusityp.Text.cleanString(), Istab.TABTYP.BUSITYP); if (wind.ShowDialog() == DialogResult.OK) { this.sBusityp.Text = wind.istab.typcod; this.lblBusityp_typdes.Text = wind.istab.typdes_th; this.sBusityp.Focus(); SendKeys.Send("{TAB}"); } else { this.sBusityp.Focus(); } }
private void BindingControlEventHandler() { this.dgvMember.DrawDgvRowBorder(); this.dgvUnGroup.DrawDgvRowBorder(); this.txtTypcod.textBox1.GotFocus += new EventHandler(this.SetControlFocused); this.txtTypdes.textBox1.GotFocus += new EventHandler(this.SetControlFocused); this.txtTypcod.label1.DoubleClick += delegate { if (this.current_group != null) { this.btnEdit.PerformClick(); } }; this.txtTypdes.label1.DoubleClick += delegate { if (this.current_group != null) { this.btnEdit.PerformClick(); } }; this.dgvMember.Resize += delegate { if (this.dgvMember.CurrentCell != null) { if (this.current_group != null) { this.dgvMember.FillLine(this.list_users.Where(u => u.usergroup == this.current_group.typcod).ToList<Users>().Count); return; } this.dgvMember.FillLine(0); } }; this.dgvUnGroup.Resize += delegate { this.dgvUnGroup.FillLine(this.list_users.Where(u => u.usergroup == string.Empty).ToList<Users>().Count); }; this.dgvMember.MouseClick += delegate(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { if (this.current_group == null) return; int row_index = this.dgvMember.HitTest(e.X, e.Y).RowIndex; if (row_index > -1) { this.FormReadF8(); this.dgvMember.Rows[row_index].Cells[0].Selected = true; ContextMenu c = new ContextMenu(); MenuItem m_add = new MenuItem("เพิ่ม <Alt+A>"); m_add.Click += delegate { this.ShowInlineForm(FORM_MODE.ADD_F8); this.FormAddF8(); }; c.MenuItems.Add(m_add); MenuItem m_remove = new MenuItem("นำออกจากกลุ่ม <Alt+D>"); m_remove.Click += delegate { this.RemoveFromGroup(); }; m_remove.Enabled = (this.dgvMember.Rows[row_index].Tag is Users ? true : false); c.MenuItems.Add(m_remove); c.Show(this.dgvMember, new Point(e.X, e.Y)); } } }; this.dgvMember.MouseDoubleClick += delegate(object sender, MouseEventArgs e) { if (this.current_group == null) return; int row_index = this.dgvMember.HitTest(e.X, e.Y).RowIndex; if (row_index > -1) { this.ShowInlineForm(FORM_MODE.ADD_F8); this.FormAddF8(); } }; this.dgvUnGroup.MouseClick += delegate(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { int row_index = this.dgvUnGroup.HitTest(e.X, e.Y).RowIndex; if (row_index > -1) { this.dgvUnGroup.Rows[row_index].Cells[0].Selected = true; ContextMenu c = new ContextMenu(); MenuItem m_sendto = new MenuItem("จัดเข้าในกลุ่ม..."); m_sendto.Click += delegate { IstabList gwind = new IstabList(this.main_form, "", Istab.TABTYP.USER_GROUP, list_group); gwind.btnAdd.Visible = false; gwind.btnEdit.Visible = false; if (gwind.ShowDialog() == DialogResult.OK) { string json_data = "{\"id\":" + ((Users)this.dgvUnGroup.Rows[this.dgvUnGroup.CurrentCell.RowIndex].Tag).id + ","; json_data += "\"usergroup\":\"" + gwind.istab.typcod + "\","; json_data += "\"rec_by\":\"" + this.main_form.G.loged_in_user_name + "\"}"; bool post_success = false; string err_msg = ""; this.FormProcessing(); BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += delegate { CRUDResult post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "users/change_group", json_data); ServerResult sr = JsonConvert.DeserializeObject<ServerResult>(post.data); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { post_success = true; } else { post_success = false; err_msg = sr.message; } }; worker.RunWorkerCompleted += delegate { if (post_success) { this.RefreshCurrentData(); this.FillForm(this.current_group); this.FormReadF7(); return; } this.FormReadF7(); MessageAlert.Show(err_msg, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR); }; worker.RunWorkerAsync(); } }; m_sendto.Enabled = (this.dgvUnGroup.Rows[row_index].Tag is Users ? true : false); c.MenuItems.Add(m_sendto); c.Show(this.dgvUnGroup, new Point(e.X, e.Y)); } } }; this.tabControl1.Deselecting += delegate(object sender, TabControlCancelEventArgs e) { if (this.form_mode != FORM_MODE.READ) { e.Cancel = true; if (this.focused_control != null) { this.focused_control.Focus(); } return; } if (this.current_group == null) { e.Cancel = true; return; } }; this.tabControl1.MouseClick += delegate(object sender, MouseEventArgs e) { if (this.form_mode != FORM_MODE.READ) { if (this.focused_control != null) { this.focused_control.Focus(); } return; } }; }
private void btnInquiryRest_Click(object sender, EventArgs e) { IstabList gwind = new IstabList(this.main_form, this.current_group.typcod, Istab.TABTYP.USER_GROUP, this.list_group); gwind.btnAdd.Visible = false; gwind.btnEdit.Visible = false; if (gwind.ShowDialog() == DialogResult.OK) { this.GetGroupByTypcod(gwind.istab.typcod); } }
private void btnBrowseArea_Click(object sender, EventArgs e) { this.txtArea.Focus(); IstabList wind = new IstabList(this.main_form, this.txtArea.Texts, Istab.TABTYP.AREA); if (wind.ShowDialog() == DialogResult.OK) { this.txtArea.Texts = wind.istab.typcod; this.lblArea_typdes.Text = wind.istab.typdes_th; } }
private void btnBrowseHowknown_Click(object sender, EventArgs e) { IstabList wind = new IstabList(this.main_form, this.txtHowknown.Text, Istab.TABTYP.HOWKNOWN); if (wind.ShowDialog() == DialogResult.OK) { this.txtHowknown.Texts = wind.istab.typcod; this.lblHowknownTypdes.Text = wind.istab.typdes_th; } this.txtHowknown.textBox1.Focus(); }
private void btnBrowseBusityp_Click(object sender, EventArgs e) { IstabList wind = new IstabList(this.main_form, this.txtBusityp.Text, Istab.TABTYP.BUSITYP); if (wind.ShowDialog() == DialogResult.OK) { this.txtBusityp.Texts = wind.istab.typcod; this.lblBusitypTypdes.Text = wind.istab.typdes_th; } this.txtBusityp.textBox1.Focus(); }
private void showInlineProblemForm(DataGridViewRow row, int column_index = 1, Problem pattern = null) { this.dgvProblem.Enabled = false; Problem prob = new Problem(); CustomDateTimePicker date = new CustomDateTimePicker(); date.Name = "inline_problem_date"; date.BringToFront(); date.Read_Only = false; date.BorderStyle = BorderStyle.None; date.textBox1.GotFocus += delegate { this.current_focused_control = date; this.toolStripInfo.Text = this.toolTip1.GetToolTip(date); }; toolTip1.SetToolTip(date, "<F6> = Show Calendar"); CustomTextBox name = new CustomTextBox(); name.Name = "inline_problem_name"; name.BringToFront(); name.Read_Only = false; name.BorderStyle = BorderStyle.None; name.textBox1.GotFocus += delegate { this.current_focused_control = name; this.toolStripInfo.Text = this.toolTip1.GetToolTip(name); }; CustomBrowseField probcod = new CustomBrowseField(); probcod.Name = "inline_problem_probcod"; probcod.BringToFront(); probcod._ReadOnly = false; probcod._MaxLength = 2; probcod.BorderStyle = BorderStyle.None; toolTip1.SetToolTip(probcod, "<F6> = Show Problem Code"); probcod._btnBrowse.Click += delegate { IstabList co = new IstabList(this.main_form, probcod._Text, Istab.TABTYP.PROBLEM_CODE); if (co.ShowDialog() == DialogResult.OK) { probcod._Text = co.istab.typcod; } }; CustomTextBoxMaskedWithLabel probdesc = new CustomTextBoxMaskedWithLabel(); probdesc.Name = "inline_problem_probdesc"; probdesc.BringToFront(); probdesc.BorderStyle = BorderStyle.None; probdesc.txtEdit.Enter += delegate { }; probdesc.txtEdit.GotFocus += delegate { if (this.main_form.data_resource.LIST_PROBLEM_CODE.Find(t => t.typcod == probcod._Text) == null) { SendKeys.Send("+{TAB}"); SendKeys.Send("{F6}"); return; } this.current_focused_control = probdesc; this.toolStripInfo.Text = this.toolTip1.GetToolTip(probdesc); }; if (row.Tag is Problem) // edit existing problem { this.FormEditItem(); prob = (Problem)row.Tag; } else // add new problem { this.FormAddItem(); if (pattern != null) prob = (pattern.probcod == "RG" && this.G.loged_in_user_level < GlobalVar.USER_LEVEL_ADMIN ? prob : pattern); } this.dgvProblem.Parent.Controls.Add(date); this.dgvProblem.Parent.Controls.Add(name); this.dgvProblem.Parent.Controls.Add(probcod); this.dgvProblem.Parent.Controls.Add(probdesc); this.dgvProblem.SendToBack(); this.setPositionInlineProblemForm(row); // specify value in each field date.TextsMysql = (row.Tag is Problem ? prob.date : DateTime.Now.ToMysqlDate()); name.Texts = prob.name; probcod._Text = prob.probcod; if (prob.probcod == "RG" && this.main_form.G.loged_in_user_level < GlobalVar.USER_LEVEL_ADMIN) { probcod.Visible = false; probdesc.StaticText = this.GetMachineCode(prob.probdesc); probdesc.EditableText = prob.probdesc.Substring(probdesc.StaticText.Length, prob.probdesc.Length - (probdesc.StaticText.Length)).Trim(); } else { probdesc.StaticText = ""; probdesc.EditableText = prob.probdesc; } if (column_index == 1) { date.Focus(); } else if (column_index == 2) { name.Focus(); } else if (column_index == 3) { if (probcod.Visible) probcod.Focus(); if (!probcod.Visible) probdesc.Focus(); } else if (column_index == 4) { probdesc.Focus(); } }
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (keyData == Keys.Tab && this.form_mode == FORM_MODE.READ) { DataInfo data_info = new DataInfo(); int max_id = 0; foreach (Serial s in this.serial_id_list) { if (s.id > max_id) { max_id = s.id; } } data_info.lblDataTable.Text = "Serial"; data_info.lblExpression.Text = (this.sortMode == SORT_SN ? this.sortMode : this.sortMode + "+sernum"); data_info.lblRecBy.Text = this.serial.users_name; data_info.lblRecDate.pickedDate(this.serial.chgdat); data_info.lblRecNo.Text = this.serial.id.ToString(); data_info.lblTotalRec.Text = max_id.ToString(); data_info.lblTime.ForeColor = Color.DarkGray; data_info.lblRecTime.BackColor = Color.WhiteSmoke; data_info.ShowDialog(); return true; } if (keyData == Keys.Tab && this.form_mode == FORM_MODE.READ_ITEM) { if (this.dgvProblem.Rows[this.dgvProblem.CurrentCell.RowIndex].Tag is Problem) { CRUDResult get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "problem/get_info&id=" + ((Problem)this.dgvProblem.Rows[this.dgvProblem.CurrentCell.RowIndex].Tag).id.ToString()); ServerResult sr = JsonConvert.DeserializeObject<ServerResult>(get.data); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { if (sr.problem.Count > 0) { DataInfo data_info = new DataInfo(); data_info.lblDataTable.Text = "Problem"; data_info.lblExpression.Text = "sernum+date"; data_info.lblRecBy.Text = sr.problem.First<Problem>().users_name; data_info.lblRecDate.pickedDate(sr.problem.First<Problem>().date); data_info.lblRecTime.Text = sr.problem.First<Problem>().time; data_info.lblRecNo.Text = sr.problem.First<Problem>().id.ToString(); data_info.lblTotalRec.Text = sr.message; data_info.ShowDialog(); } } } return true; } if (keyData == (Keys.Alt | Keys.A)) { if (this.form_mode == FORM_MODE.READ_ITEM) { Problem pattern = (this.dgvProblem.CurrentCell != null && this.dgvProblem.Rows[this.dgvProblem.CurrentCell.RowIndex].Tag is Problem ? (Problem)this.dgvProblem.Rows[this.dgvProblem.CurrentCell.RowIndex].Tag : null); int problem_count = (this.is_problem_im_only ? this.problem_im_only.Count : this.problem.Count); this.dgvProblem.Rows[problem_count].Cells[1].Selected = true; this.showInlineProblemForm(this.dgvProblem.Rows[problem_count], 1, pattern); return true; } else if (this.form_mode == FORM_MODE.READ) { this.toolStripAdd.PerformClick(); return true; } } if (keyData == (Keys.Alt | Keys.E)) { if (this.form_mode == FORM_MODE.READ_ITEM) { if (this.dgvProblem.Rows[this.dgvProblem.CurrentCell.RowIndex].Tag is Problem) { this.showInlineProblemForm(this.dgvProblem.Rows[this.dgvProblem.CurrentCell.RowIndex]); return true; } } else { this.toolStripEdit.PerformClick(); return true; } } if (keyData == Keys.Enter && (this.form_mode == FORM_MODE.ADD || this.form_mode == FORM_MODE.EDIT || this.form_mode == FORM_MODE.ADD_ITEM || this.form_mode == FORM_MODE.EDIT_ITEM)) { if (this.current_focused_control == this.dtVerextdat || this.current_focused_control.Name == "inline_problem_probdesc") { this.toolStripSave.PerformClick(); return true; } SendKeys.Send("{TAB}"); return true; } if (keyData == Keys.Escape) { //if (!(this.current_focused_control is CustomDateTimePicker)) // if current_focused_control is not CustomDateTimePicker //{ // if (!(this.current_focused_control is CustomComboBox)) // and if current_focused_control is not CustomComboBox // { // this.toolStripStop.PerformClick(); // this.current_focused_control = null; // return true; // } // else // { // if (!((CustomComboBox)this.current_focused_control).item_shown) // if CustomComboBox is currently not showing items. // { // this.toolStripStop.PerformClick(); // this.current_focused_control = null; // return true; // } // else // then if CustomComboBox is currently showing calendar just close the items portion. // { // SendKeys.Send("{F4}"); // return true; // } // } //} //else //{ // if (!((CustomDateTimePicker)this.current_focused_control).calendar_shown) // if CustomDateTimePicker is currently not showing calendar. // { // this.toolStripStop.PerformClick(); // this.current_focused_control = null; // return true; // } // // then if CustomDateTimePicker is currently showing calendar just close the calendar. //} //if (this.dtPurdat.dateTimePicker1.Focused || this.dtManual.dateTimePicker1.Focused || this.dtExpdat.dateTimePicker1.Focused || this.dtVerextdat.dateTimePicker1.Focused || (this.cbVerext.comboBox1.Focused && this.cbVerext.comboBox1.DroppedDown)) if (this.cbVerext.comboBox1.Focused && this.cbVerext.comboBox1.DroppedDown) { SendKeys.Send("{F4}"); return true; } this.toolStripStop.PerformClick(); return true; } if (keyData == Keys.F6) { if (this.current_focused_control != null) { if (this.current_focused_control == this.txtArea) { this.btnBrowseArea.PerformClick(); return true; } else if (this.current_focused_control == this.txtBusityp) { this.btnBrowseBusityp.PerformClick(); return true; } else if (this.current_focused_control == this.txtDealer) { this.btnBrowseDealer.PerformClick(); return true; } else if (this.current_focused_control == this.txtHowknown) { this.btnBrowseHowknown.PerformClick(); return true; } else if (this.current_focused_control == this.dtPurdat) { this.dtPurdat.dateTimePicker1.Focus(); SendKeys.Send("{F4}"); return true; } else if (this.current_focused_control == this.dtExpdat) { this.dtExpdat.dateTimePicker1.Focus(); SendKeys.Send("{F4}"); return true; } else if (this.current_focused_control == this.dtManual) { this.dtManual.dateTimePicker1.Focus(); SendKeys.Send("{F4}"); return true; } else if (this.current_focused_control == this.dtVerextdat) { this.dtVerextdat.dateTimePicker1.Focus(); SendKeys.Send("{F4}"); return true; } else if (this.current_focused_control == this.cbVerext) { SendKeys.Send("{F4}"); return true; } else if (this.current_focused_control.Name == "inline_problem_date" && (this.form_mode == FORM_MODE.ADD_ITEM || this.form_mode == FORM_MODE.EDIT_ITEM)) { Control[] ct = this.dgvProblem.Parent.Controls.Find("inline_problem_date", true); if (ct.Length > 0) { CustomDateTimePicker dt = (CustomDateTimePicker)ct[0]; dt.dateTimePicker1.Focus(); SendKeys.Send("{F4}"); return true; } } else if (this.current_focused_control.Name == "inline_problem_probcod" && (this.form_mode == FORM_MODE.ADD_ITEM || this.form_mode == FORM_MODE.EDIT_ITEM)) { Control[] ct = this.dgvProblem.Parent.Controls.Find("inline_problem_probcod", true); if (ct.Length > 0) { CustomTextBox probcod = (CustomTextBox)ct[0]; probcod.Focus(); IstabList wind = new IstabList(this.main_form, probcod.Texts, Istab.TABTYP.PROBLEM_CODE); if (wind.ShowDialog() == DialogResult.OK) { probcod.Texts = wind.istab.typcod; SendKeys.Send("{TAB}"); } return true; } } } } if (keyData == Keys.PageUp) { if (this.form_mode == FORM_MODE.READ) { this.toolStripPrevious.PerformClick(); return true; } } if (keyData == Keys.PageDown) { if (this.form_mode == FORM_MODE.READ) { this.toolStripNext.PerformClick(); return true; } } if (keyData == (Keys.Control | Keys.Home)) { this.toolStripFirst.PerformClick(); return true; } if (keyData == (Keys.Control | Keys.End)) { this.toolStripLast.PerformClick(); return true; } if (keyData == Keys.F3) { if (this.form_mode == FORM_MODE.READ) { this.tabControl1.SelectedTab = this.tabPage1; return true; } } if (keyData == Keys.F4) { if (this.form_mode == FORM_MODE.READ) { this.tabControl1.SelectedTab = this.tabPage2; return true; } } if (keyData == Keys.F5) { this.toolStripReload.PerformClick(); return true; } if (keyData == Keys.F8) { this.toolStripItem.PerformClick(); return true; } if (keyData == Keys.F9) { this.toolStripSave.PerformClick(); return true; } if (keyData == (Keys.Alt | Keys.D)) { if (this.form_mode == FORM_MODE.READ_ITEM) { this.deleteProblemData(); return true; } else { this.toolStripDelete.PerformClick(); return true; } } if (keyData == (Keys.Control | Keys.L)) { this.toolStripInquiryAll.PerformClick(); return true; } if (keyData == (Keys.Alt | Keys.L)) { this.toolStripInquiryRest.PerformClick(); return true; } if (keyData == (Keys.Alt | Keys.S)) { this.toolStripSearchSN.PerformClick(); return true; } if (keyData == (Keys.Alt | Keys.D2)) { this.toolStripSearchContact.PerformClick(); return true; } if (keyData == (Keys.Alt | Keys.D3)) { this.toolStripSearchCompany.PerformClick(); return true; } if (keyData == (Keys.Alt | Keys.D4)) { this.toolStripSearchDealer.PerformClick(); return true; } if (keyData == (Keys.Alt | Keys.D5)) { this.toolStripSearchOldnum.PerformClick(); return true; } if (keyData == (Keys.Alt | Keys.D6)) { this.toolStripSearchBusityp.PerformClick(); return true; } if (keyData == (Keys.Alt | Keys.D7)) { this.toolStripSearchArea.PerformClick(); return true; } if (keyData == Keys.F2) { this.btnSupportNote.PerformClick(); return true; } if (keyData == (Keys.Control | Keys.Alt | Keys.M)) { //MessageBox.Show("Control + Alt. + M"); this.toolStripInquiryMA.PerformClick(); } if (keyData == (Keys.Control | Keys.Alt | Keys.C)) { //MessageBox.Show("Control + Alt. + C"); this.toolStripInquiryCloud.PerformClick(); } return base.ProcessCmdKey(ref msg, keyData); }