private void ShowInlineForm() { int row_index = this.dgv.CurrentCell.RowIndex; CustomComboBox inline_users_name = new CustomComboBox(); inline_users_name.Name = "inline_users_name"; inline_users_name.comboBox1.DropDownStyle = ComboBoxStyle.DropDown; inline_users_name.Read_Only = false; inline_users_name.BorderStyle = BorderStyle.None; foreach (Users u in this.users_list) { ComboboxItem item = new ComboboxItem(u.username + " : " + u.name, u.id, u.username); inline_users_name.AddItem(item); if (this.form_mode == FORM_MODE.EDIT_ITEM) { if (u.username == ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).users_name) { inline_users_name.comboBox1.SelectedItem = item; } } } inline_users_name.Leave += delegate { if (inline_users_name.comboBox1.Items.Cast<ComboboxItem>().Where(t => t.name.Length >= inline_users_name.comboBox1.Text.Length).Where(t => t.name.Substring(0, inline_users_name.comboBox1.Text.Length) == inline_users_name.comboBox1.Text).Count() > 0) { inline_users_name.comboBox1.SelectedItem = inline_users_name.comboBox1.Items.Cast<ComboboxItem>().Where(t => t.name.Length >= inline_users_name.comboBox1.Text.Length).Where(t => t.name.Substring(0, inline_users_name.comboBox1.Text.Length) == inline_users_name.comboBox1.Text).First(); } else { inline_users_name.comboBox1.Focus(); SendKeys.Send("{F6}"); } }; inline_users_name.comboBox1.SelectedIndex = (this.form_mode == FORM_MODE.EDIT_ITEM ? this.users_list.FindIndex(t => t.username == ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).users_name) : 0); this.dgv.Parent.Controls.Add(inline_users_name); CustomComboBox inline_leave_cause = new CustomComboBox(); inline_leave_cause.Name = "inline_leave_cause"; inline_leave_cause.Read_Only = false; inline_leave_cause.BorderStyle = BorderStyle.None; foreach (Istab i in this.leave_cause) { ComboboxItem item = new ComboboxItem(i.typdes_th, i.id, i.typcod); item.Tag = i; inline_leave_cause.AddItem(item); if (this.form_mode == FORM_MODE.EDIT_ITEM) { if (i.tabtyp == ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).event_type && i.typcod == ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).event_code) { inline_leave_cause.comboBox1.SelectedItem = item; } } } inline_leave_cause.comboBox1.SelectedIndex = (this.form_mode == FORM_MODE.EDIT_ITEM ? this.leave_cause.FindIndex(t => t.typcod == ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).event_code) : 0); this.dgv.Parent.Controls.Add(inline_leave_cause); CustomTimePicker inline_from_time = new CustomTimePicker(); inline_from_time.Name = "inline_from_time"; inline_from_time.Read_Only = false; inline_from_time.BorderStyle = BorderStyle.None; inline_from_time.Show_Second = false; this.dgv.Parent.Controls.Add(inline_from_time); inline_from_time.Time = (this.form_mode == FORM_MODE.EDIT_ITEM ? ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).from_time.TimeString2DateTime() : new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 8, 30, 0)); CustomTimePicker inline_to_time = new CustomTimePicker(); inline_to_time.Name = "inline_to_time"; inline_to_time.Read_Only = false; inline_to_time.BorderStyle = BorderStyle.None; inline_to_time.Show_Second = false; this.dgv.Parent.Controls.Add(inline_to_time); inline_to_time.Time = (this.form_mode == FORM_MODE.EDIT_ITEM ? ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).to_time.TimeString2DateTime() : (this.cde.date.Value.GetDayIntOfWeek() == 7 ? new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 12, 00, 0) : new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 17, 30, 0))); CustomComboBox inline_status = new CustomComboBox(); inline_status.Name = "inline_status"; inline_status.Read_Only = false; inline_status.BorderStyle = BorderStyle.None; inline_status.AddItem(new ComboboxItem("Wait", 0, "Wait")); inline_status.AddItem(new ComboboxItem("Confirmed", 1, "Confirmed")); inline_status.AddItem(new ComboboxItem("Canceled", 2, "Canceled")); this.dgv.Parent.Controls.Add(inline_status); inline_status.comboBox1.SelectedIndex = (this.form_mode == FORM_MODE.EDIT_ITEM ? ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).status : 1); CustomTextBox inline_customer = new CustomTextBox(); inline_customer.Name = "inline_customer"; inline_customer.Read_Only = false; inline_customer.MaxChar = 40; inline_customer.BorderStyle = BorderStyle.None; this.dgv.Parent.Controls.Add(inline_customer); inline_customer.Texts = (this.form_mode == FORM_MODE.EDIT_ITEM ? ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).customer : ""); CustomComboBox inline_medcert = new CustomComboBox(); inline_medcert.Name = "inline_medcert"; inline_medcert.Read_Only = false; inline_medcert.BorderStyle = BorderStyle.None; inline_medcert.AddItem(new ComboboxItem("N/A (ไม่ระบุ)", 9, "X")); inline_medcert.AddItem(new ComboboxItem("ไม่มีเอกสาร", 0, "N")); inline_medcert.AddItem(new ComboboxItem("มีใบรับรองแพทย์", 1, "Y")); this.dgv.Parent.Controls.Add(inline_medcert); inline_medcert.comboBox1.SelectedItem = (this.form_mode == FORM_MODE.EDIT_ITEM ? inline_medcert.comboBox1.Items.Cast<ComboboxItem>().Where(i => i.string_value == ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).med_cert).First<ComboboxItem>() : (ComboboxItem)inline_medcert.comboBox1.Items[0]); NumericUpDown inline_fine = new NumericUpDown(); inline_fine.Name = "inline_fine"; inline_fine.Maximum = 1000; inline_fine.Minimum = 0; inline_fine.AutoSize = false; inline_fine.Font = new Font("tahoma", 9.75f); inline_fine.ThousandsSeparator = true; inline_fine.BorderStyle = BorderStyle.None; inline_fine.TextAlign = HorizontalAlignment.Right; this.dgv.Parent.Controls.Add(inline_fine); inline_fine.Value = (this.form_mode == FORM_MODE.EDIT_ITEM ? ((EventCalendar)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Tag).fine : 0); this.SetInlineFormPosition(); this.dgv.SendToBack(); this.dgv.Enabled = false; inline_users_name.BringToFront(); inline_leave_cause.BringToFront(); inline_from_time.BringToFront(); inline_to_time.BringToFront(); inline_status.BringToFront(); inline_customer.BringToFront(); inline_medcert.BringToFront(); inline_fine.BringToFront(); }
private void AddReasonCondition(ComboboxItem reason) { if (this.list_reason_all.Find(t => t.string_value == reason.string_value) == null) return; this.list_reason_all.Remove(this.list_reason_all.Find(t => t.string_value == reason.string_value)); this.reason_all_source.DataSource = this.list_reason_all; this.reason_all_source.ResetBindings(true); int r = this.dgvReason.Rows.Add(); this.dgvReason.Rows[r].Tag = reason; this.dgvReason.Rows[r].Cells[0].ValueType = typeof(string); this.dgvReason.Rows[r].Cells[0].Value = reason.ToString(); this.dgvReason.Rows[r].Cells[1].Value = "x"; this.dgvReason.Rows[r].Cells[1].ToolTipText = "ลบ"; }
private void AddProblemCondition(ComboboxItem prob) { if (this.list_problem_all.Find(t => t.string_value == prob.string_value) == null) return; this.list_problem_all.Remove(this.list_problem_all.Find(t => t.string_value == prob.string_value)); this.problem_all_source.DataSource = this.list_problem_all; this.problem_all_source.ResetBindings(true); int r = this.dgvProblem.Rows.Add(); this.dgvProblem.Rows[r].Tag = prob; this.dgvProblem.Rows[r].Cells[0].ValueType = typeof(string); this.dgvProblem.Rows[r].Cells[0].Value = prob.ToString(); this.dgvProblem.Rows[r].Cells[1].Value = "x"; this.dgvProblem.Rows[r].Cells[1].ToolTipText = "ลบ"; }
private void RemoveReasonCondition(ComboboxItem reason) { if (this.dgvReason.CurrentCell == null) return; if (this.dgvReason.Rows.Cast<DataGridViewRow>().Where(r => ((ComboboxItem)r.Tag).string_value == reason.string_value).Count<DataGridViewRow>() <= 0) return; this.dgvReason.Rows.Remove(this.dgvReason.Rows.Cast<DataGridViewRow>().Where(r => ((ComboboxItem)r.Tag).string_value == reason.string_value).First<DataGridViewRow>()); this.list_reason_all.Add(reason); this.list_reason_all = this.list_reason_all.OrderBy(t => t.int_value).ToList<ComboboxItem>(); this.reason_all_source.DataSource = this.list_reason_all; this.reason_all_source.ResetBindings(true); }
private void RemoveProblemCondition(ComboboxItem prob) { if (this.dgvProblem.CurrentCell == null) return; if (this.dgvProblem.Rows.Cast<DataGridViewRow>().Where(r => ((ComboboxItem)r.Tag).string_value == prob.string_value).Count<DataGridViewRow>() <= 0) return; this.dgvProblem.Rows.Remove(this.dgvProblem.Rows.Cast<DataGridViewRow>().Where(r => ((ComboboxItem)r.Tag).string_value == prob.string_value).First<DataGridViewRow>()); this.list_problem_all.Add(prob); this.list_problem_all = this.list_problem_all.OrderBy(t => t.int_value).ToList<ComboboxItem>(); this.problem_all_source.DataSource = this.list_problem_all; this.problem_all_source.ResetBindings(true); }
private void CalendarWindow_Load(object sender, EventArgs e) { this.LoadDependenciesData(); #region Load Month name to cbMonth this.cbMonth.Items.Add(new ComboboxItem("มกราคม", 1, "01")); this.cbMonth.Items.Add(new ComboboxItem("กุมภาพันธ์", 2, "02")); this.cbMonth.Items.Add(new ComboboxItem("มีนาคม", 3, "03")); this.cbMonth.Items.Add(new ComboboxItem("เมษายน", 4, "04")); this.cbMonth.Items.Add(new ComboboxItem("พฤษภาคม", 5, "05")); this.cbMonth.Items.Add(new ComboboxItem("มิถุนายน", 6, "06")); this.cbMonth.Items.Add(new ComboboxItem("กรกฎาคม", 7, "07")); this.cbMonth.Items.Add(new ComboboxItem("สิงหาคม", 8, "08")); this.cbMonth.Items.Add(new ComboboxItem("กันยายน", 9, "09")); this.cbMonth.Items.Add(new ComboboxItem("ตุลาคม", 10, "10")); this.cbMonth.Items.Add(new ComboboxItem("พฤศจิกายน", 11, "11")); this.cbMonth.Items.Add(new ComboboxItem("ธันวาคม", 12, "12")); this.cbMonth.SelectedIndex = DateTime.Now.Month - 1; #endregion Load Month name to cbMonth #region Load Year to cbYear for(int i = 2400 ; i < 2700 ; i++ ){ ComboboxItem item = new ComboboxItem(i.ToString(), i - 543, i.ToString()); this.cbYear.Items.Add(item); if (item.int_value == DateTime.Now.Year) { this.cbYear.SelectedItem = item; } } #endregion Load Year to cbYear #region Binding event handler to cbMonth,cbYear this.cbMonth.SelectedIndexChanged += delegate { //this.LoadCalendar(((ComboboxItem)this.cbMonth.SelectedItem).int_value, ((ComboboxItem)this.cbYear.SelectedItem).int_value); this.btnLoadCalendar.PerformClick(); }; this.cbYear.SelectedIndexChanged += delegate { //this.LoadCalendar(((ComboboxItem)this.cbMonth.SelectedItem).int_value, ((ComboboxItem)this.cbYear.SelectedItem).int_value); this.btnLoadCalendar.PerformClick(); }; #endregion Binding event handler to cbMonth,cbYear }