private void FillDgvTrainer(TrainingCalendar selected_item = null) { this.dgvTrainer.Rows.Clear(); this.dgvTrainer.Columns.Clear(); this.dgvTrainer.Tag = HelperClass.DGV_TAG.READ; this.dgvTrainer.Columns.Add(new DataGridViewTextBoxColumn() { HeaderText = "ลำดับ", Width = 40 }); this.dgvTrainer.Columns.Add(new DataGridViewTextBoxColumn() { HeaderText = "คอร์สอบรม", Width = 100 }); this.dgvTrainer.Columns.Add(new DataGridViewTextBoxColumn() { HeaderText = "รหัส : ชื่อ", Width = 120 }); this.dgvTrainer.Columns.Add(new DataGridViewTextBoxColumn() { HeaderText = "สถานะ", Width = 100 }); this.dgvTrainer.Columns.Add(new DataGridViewTextBoxColumn() { HeaderText = "ช่วงเวลา", Width = 80 }); this.dgvTrainer.Columns.Add(new DataGridViewTextBoxColumn() { HeaderText = "หมายเหตุ", AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill }); int cnt = 0; foreach (TrainingCalendar t in this.list_training_calendar.Where(t => t.date == this.current_event_date.ToMysqlDate()).ToList<TrainingCalendar>()) { int r = this.dgvTrainer.Rows.Add(); this.dgvTrainer.Rows[r].Tag = t; this.dgvTrainer.Rows[r].Cells[0].ValueType = typeof(int); this.dgvTrainer.Rows[r].Cells[0].Value = ++cnt; this.dgvTrainer.Rows[r].Cells[0].Style.Alignment = DataGridViewContentAlignment.MiddleRight; this.dgvTrainer.Rows[r].Cells[0].Style.ForeColor = Color.Gray; this.dgvTrainer.Rows[r].Cells[0].Style.SelectionForeColor = Color.Gray; this.dgvTrainer.Rows[r].Cells[1].ValueType = typeof(string); this.dgvTrainer.Rows[r].Cells[1].Value = GetCourseTypeString(t.course_type); this.dgvTrainer.Rows[r].Cells[2].ValueType = typeof(string); this.dgvTrainer.Rows[r].Cells[2].Value = t.trainer + " : " + (this.list_trainer_all.Find(u => u.username == t.trainer) != null ? this.list_trainer_all.Find(u => u.username == t.trainer).name : ""); this.dgvTrainer.Rows[r].Cells[3].ValueType = typeof(string); this.dgvTrainer.Rows[r].Cells[3].Value = GetTrainerStatusString(t.status); this.dgvTrainer.Rows[r].Cells[4].ValueType = typeof(string); this.dgvTrainer.Rows[r].Cells[4].Value = GetTrainingTermString(t.term); this.dgvTrainer.Rows[r].Cells[5].ValueType = typeof(string); this.dgvTrainer.Rows[r].Cells[5].Value = t.remark; } this.dgvTrainer.FillLine(this.list_training_calendar.Where(t => t.date == this.current_event_date.ToMysqlDate()).ToList<TrainingCalendar>().Count); }
private TrainingCalendar GetInlineObject() { TrainingCalendar tc = new TrainingCalendar(); tc.id = (this.form_mode == FORM_MODE.EDIT_F8 ? ((TrainingCalendar)this.dgvTrainer.Rows[this.dgvTrainer.CurrentCell.RowIndex].Tag).id : -1); tc.date = this.current_event_date.ToMysqlDate(); tc.course_type = (this.inline_course_type != null ? ((ComboboxItem)this.inline_course_type.comboBox1.SelectedItem).int_value : 0); tc.trainer = (this.inline_trainer != null ? ((ComboboxItem)this.inline_trainer.comboBox1.SelectedItem).string_value : ""); tc.status = (this.inline_status != null ? ((ComboboxItem)this.inline_status.comboBox1.SelectedItem).int_value : 0); tc.term = (this.inline_term != null ? ((ComboboxItem)this.inline_term.comboBox1.SelectedItem).int_value : 0); tc.remark = (this.inline_remark != null ? ((CustomTextBox)this.inline_remark).Texts.cleanString() : ""); //tc.rec_by = this.date_event.G.loged_in_user_name; tc.rec_by = this.date_event2.main_form.G.loged_in_user_name; return tc; }