public void display() { this.clMaCongViec.DataPropertyName = nameof(CongViec.MaCongViec); this.clTenCongViec.DataPropertyName = nameof(CongViec.TenCongViec); this.clNoiDungCongViec.DataPropertyName = nameof(CongViec.NoiDungCongViec); this.clNhomPhuTrach.DataPropertyName = nameof(CongViec.ListNhomPhuTrach); this.clChiPhi.DataPropertyName = nameof(CongViec.ChiPhi); this.clDuKienHoanThanh.DataPropertyName = nameof(CongViec.DuKienHoanThanh); this.clNgayBatDau.DataPropertyName = nameof(CongViec.NgayBatDau); this.clTienDo.DataPropertyName = nameof(CongViec.TienDo); this.clNgayHoanThanh.DataPropertyName = nameof(CongViec.NgayHoanThanh); cbxListDuAn.DataSource = DuAnControllers.getListDuAnfromDB(); cbxListDuAn.DisplayMember = "TenDuAn"; List <CongViec> lstCongViec = CongViecControllers.getListCongViecfromDB(); for (int i = 0; i <= lstCongViec.Count - 1; i++) { CongViecControllers.updateChiPhi(lstCongViec[i]); CongViecControllers.updateTienDo(lstCongViec[i]); } BindingSource src = new BindingSource(); src.DataSource = lstCongViec; dataGridViewCongViec.DataSource = src; if (qh == 0) { btnThemCongViec.Visible = false; btnSuaCongViec.Visible = false; } else if (qh == 1) { } dataGridViewCongViec.Columns[9].Visible = false; dataGridViewCongViec.Columns[10].Visible = false; }
private void dataGridViewCongViec_CellClick(object sender, DataGridViewCellEventArgs e) { List <CongViec> lstCongViec = CongViecControllers.getListCongViecfromDB(); for (int i = 0; i <= lstCongViec.Count - 1; i++) { CongViecControllers.updateChiPhi(lstCongViec[i]); CongViecControllers.updateTienDo(lstCongViec[i]); } try { txtMaCongViec.Text = dataGridViewCongViec.CurrentRow.Cells[0].Value.ToString(); txtTenCongViec.Text = dataGridViewCongViec.CurrentRow.Cells[1].Value.ToString(); rtxtNoiDungCongViec.Text = dataGridViewCongViec.CurrentRow.Cells[2].Value.ToString(); if (dataGridViewCongViec.CurrentRow.Cells[3].Value == null) { cbbNhom.DataSource = null; cbbNhom.Text = ""; } else { cbbNhom.Text = dataGridViewCongViec.CurrentRow.Cells[3].Value.ToString(); } txtChiPhi.Text = dataGridViewCongViec.CurrentRow.Cells[4].Value.ToString(); dateTimeDuKienHoanThanh.Value = DateTime.Parse(dataGridViewCongViec.CurrentRow.Cells[5].Value.ToString()); dateTimeBatDauCongViec.Value = DateTime.Parse(dataGridViewCongViec.CurrentRow.Cells[6].Value.ToString()); //cbbTienDo.Text = if (dataGridViewCongViec.CurrentRow.Cells[7].Value != null) { progressBar1.Value = int.Parse(dataGridViewCongViec.CurrentRow.Cells[7].Value.ToString()); } else { progressBar1.Value = 0; } /////////////// dateTimeThoiGianHoanThanh.Value = DateTime.Parse(dataGridViewCongViec.CurrentRow.Cells[8].Value.ToString()); var lcv = CongViecControllers.getListCongViecfromDB(); lda = DuAnControllers.getListDuAnfromDB(); int index = -1; for (int i = 0; i < lda.Count; i++) { if (lda[i].CongViecDuAn != null) { string[] check = lda[i].CongViecDuAn.Split(','); foreach (var item2 in check) { if (item2.Trim() == lcv[dataGridViewCongViec.CurrentRow.Index].MaCongViec.Trim()) { index = i; } } if (index != -1) { break; } } } if (index == -1) { return; } cbxListDuAn.SelectedIndex = index; } catch { return; } }