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(); } }
private void clearInlineProblemForm(Problem focused_problem_row = null) { if (this.form_mode == FORM_MODE.ADD_ITEM || this.form_mode == FORM_MODE.EDIT_ITEM || this.form_mode == FORM_MODE.PROCESSING) { int focus_row_index = this.dgvProblem.CurrentCell.RowIndex; this.FormReadItem(); if (this.dgvProblem.Parent.Controls.Find("inline_problem_date", true).Length > 0) this.dgvProblem.Parent.Controls.RemoveByKey("inline_problem_date"); if (this.dgvProblem.Parent.Controls.Find("inline_problem_name", true).Length > 0) this.dgvProblem.Parent.Controls.RemoveByKey("inline_problem_name"); if (this.dgvProblem.Parent.Controls.Find("inline_problem_probcod", true).Length > 0) this.dgvProblem.Parent.Controls.RemoveByKey("inline_problem_probcod"); if (this.dgvProblem.Parent.Controls.Find("inline_problem_probdesc", true).Length > 0) this.dgvProblem.Parent.Controls.RemoveByKey("inline_problem_probdesc"); this.dgvProblem.Rows[focus_row_index].Cells[1].Selected = true; this.current_focused_control = null; } }