public void cvhoanthanh() { List <CongViec> lcv = CongViecControllers.getListCongViecfromDB(); foreach (CongViec cv in lcv) { int flag = 0; string[] lcongviennv = cv.NoiDungCongViec.Trim().Split(','); List <CongViecNhanVien> lstcvnv = new List <CongViecNhanVien>(); foreach (var item in lcongviennv) { if (CongViecNhanVienControllers.CheckCongViecNhanVienHoanThanhfromDB(item) == false) { flag = 1; break; } else { lstcvnv.Add(CongViecNhanVienControllers.getCongViecNhanVienfromDB(item)); } } if (flag == 0) { cv.NgayHoanThanh = checkmaxtime(lstcvnv); } CongViecControllers.updateCongViec(cv); } }
public void display() { this.clMaCongViecNhanVien.DataPropertyName = nameof(CongViecNhanVien.MaCongViecNhanVien); this.clMaNhanVienPhuTrach.DataPropertyName = nameof(CongViecNhanVien.MaNhanVienPhuTrach); this.clTenCongViec.DataPropertyName = nameof(CongViecNhanVien.TenCongViec); this.clMoTa.DataPropertyName = nameof(CongViecNhanVien.MoTa); this.clTaiLieu.DataPropertyName = nameof(CongViecNhanVien.TaiLieu); this.clLuongCongViec.DataPropertyName = nameof(CongViecNhanVien.LuongCongViec); this.clDuKienHoanThanh.DataPropertyName = nameof(CongViec.DuKienHoanThanh); this.clNgayBatDau.DataPropertyName = nameof(CongViec.NgayBatDau); this.clTienDo.DataPropertyName = nameof(CongViec.TienDo); this.clNgayHoanThanh.DataPropertyName = nameof(CongViec.NgayHoanThanh); cbxListCongViecnv.DataSource = CongViecControllers.getListCongViecfromDB(); cbxListCongViecnv.DisplayMember = "TenCongViec"; List <CongViecNhanVien> lstCongViecNhanVien = CongViecNhanVienControllers.getListCongViecNhanVienfromDB(); BindingSource src = new BindingSource(); src.DataSource = lstCongViecNhanVien; dataGridViewCongViecDangThucHien.DataSource = src; if (qh == 0) { btnThemCongViec.Visible = false; //btnSuaCongViec.Visible = false; } else if (qh == 1) { } dataGridViewCongViecDangThucHien.Columns[10].Visible = false; //dataGridViewCongViec.Columns[10].Visible = false; }
public void tinhTienDoDA() { List <DuAn> lstDuAn = DuAnControllers.getListDuAnfromDB(); foreach (DuAn da in lstDuAn) { if (da.CongViecDuAn != null) { string macongviec = da.CongViecDuAn; macongviec = macongviec.Trim(); string[] listtencongviec = macongviec.Split(','); List <CongViec> lcv = CongViecControllers.getListCongViecfromDB(listtencongviec); int td = 0; int k = lcv.Count; foreach (CongViec cv in lcv) { if (cv.TienDo == 100) { td += 1; } } float ht = 100; float h = (float)td / k; da.TienDo = (int)(h * ht); DuAnControllers.updateDA(da); } } }
public void tinhChiPhiDA() { List <DuAn> lstDuAn = DuAnControllers.getListDuAnfromDB(); foreach (DuAn da in lstDuAn) { if (da.CongViecDuAn != null) { string macongviec = da.CongViecDuAn.Trim(); macongviec = macongviec.Trim(); string[] listtencongviec = macongviec.Split(','); List <CongViec> lcv = CongViecControllers.getListCongViecfromDB(listtencongviec); int cp = 0; foreach (CongViec cv in lcv) { if (cv.ChiPhi != null) { cp += cv.ChiPhi.Value; } } da.ChiPhiDuAn = cp; DuAnControllers.updateDA(da); } } }
public void display() { this.clMaNhom.DataPropertyName = nameof(Nhom.MaNhom); this.clTenNhom.DataPropertyName = nameof(Nhom.TenNhom); this.clNhomTruong.DataPropertyName = nameof(Nhom.NhomTruong); cbxListCongViec.DataSource = CongViecControllers.getListCongViecfromDB(); cbxListCongViec.DisplayMember = "TenCongViec"; List <Nhom> lstNhom = NhomControllers.getListNhomfromDB(); BindingSource src = new BindingSource(); src.DataSource = lstNhom; dataGridView1.DataSource = src; if (qh == 0) { btnThemNhom.Visible = false; btnSuaNhom.Visible = false; btnXoaNhom.Visible = false; } else if (qh == 1) { } dataGridView1.Columns[3].Visible = false; dataGridView1.Columns[4].Visible = false; dataGridView1.Columns[5].Visible = false; dataGridView1.Columns[6].Visible = false; }
private void dataGridViewCongViecDangThucHien_CellClick(object sender, DataGridViewCellEventArgs e) { try { txtMaNhanVien.Text = dataGridViewCongViecDangThucHien.CurrentRow.Cells[1].Value.ToString(); txtMaCongViecNhanVien.Text = dataGridViewCongViecDangThucHien.CurrentRow.Cells[0].Value.ToString(); txtTenCongViecNhanVien.Text = dataGridViewCongViecDangThucHien.CurrentRow.Cells[2].Value.ToString(); txtMoTaCongViecNhanVien.Text = dataGridViewCongViecDangThucHien.CurrentRow.Cells[3].Value.ToString(); txtTaiLieu.Text = dataGridViewCongViecDangThucHien.CurrentRow.Cells[4].Value.ToString(); txtLuongCongViec.Text = dataGridViewCongViecDangThucHien.CurrentRow.Cells[5].Value.ToString(); dateTimeDuKienHoanThanhCVNV.Value = DateTime.Parse(dataGridViewCongViecDangThucHien.CurrentRow.Cells[6].Value.ToString()); dateTimeNgayBatDauCVNV.Value = DateTime.Parse(dataGridViewCongViecDangThucHien.CurrentRow.Cells[7].Value.ToString()); txtTienDoCongViecNhanVien.Text = dataGridViewCongViecDangThucHien.CurrentRow.Cells[8].Value.ToString(); dateTimeNgayKetThucCVNV.Value = DateTime.Parse(dataGridViewCongViecDangThucHien.CurrentRow.Cells[9].Value.ToString()); List <CongViec> lcv = CongViecControllers.getListCongViecfromDB(); List <CongViecNhanVien> lcvnv = CongViecNhanVienControllers.getListCongViecNhanVienfromDB(); int index = -1; for (int i = 0; i < lcv.Count; i++) { if (lcv[i].NoiDungCongViec != null) { string[] check = lcv[i].NoiDungCongViec.Split(','); foreach (var item2 in check) { if (item2.Trim() == lcvnv[dataGridViewCongViecDangThucHien.CurrentRow.Index].MaCongViecNhanVien.Trim()) { index = i; } } if (index != -1) { break; } } } if (index == -1) { return; } cbxListCongViecnv.SelectedIndex = index; } catch { return; } }
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 btnXoaCongViec_Click(object sender, EventArgs e) { if (this.dataGridViewCongViec.CurrentCell.Value == null) { return; } DuAn da = lda[cbxListDuAn.SelectedIndex]; string[] lcongviec = da.CongViecDuAn.Split(','); List <string> lstringcv = lcongviec.ToList(); foreach (var item in lstringcv) { if (dataGridViewCongViec.CurrentRow.Cells[0].Value.ToString().Trim() == item.Trim()) { lstringcv.Remove(item); break; } } if (lstringcv.Count != 0) { da.CongViecDuAn = lstringcv[0].Trim(); for (int i = 1; i < lstringcv.Count; i++) { da.CongViecDuAn = da.CongViecDuAn + "," + lstringcv[i].Trim(); } DuAnControllers.updateDA(da); } else { da.CongViecDuAn = ""; DuAnControllers.updateDA(da); } CongViec cv = CongViecControllers.getCongViecfromDB(this.dataGridViewCongViec.CurrentRow.Cells[0].Value.ToString().Trim()); if (cv.NoiDungCongViec.ToString().Trim() != "") { List <string> listcongviecnv = cv.NoiDungCongViec.Split(',').ToList(); // listcongviecnv[listcongviecnv.Count - 1].Trim(); foreach (var item in listcongviecnv) { CongViecNhanVienControllers.DeleteCVNV(item); } } if (cv.ListNhomPhuTrach != null) { List <string> listnhom = cv.ListNhomPhuTrach.Split(',').ToList(); listnhom[listnhom.Count - 1].Trim(); foreach (var item in listnhom) { List <NhanVien> listnv = NhanVienControllers.getListNhanVienfromDB(); foreach (var item2 in listnv) { if (item2.Nhom.Trim() == item.Trim()) { NhanVienControllers.DeleteNhanVien(item2); } } NhomControllers.DeleteNhom(item); } } CongViecControllers.DeleteCongViec(this.dataGridViewCongViec.CurrentRow.Cells[0].Value.ToString().Trim()); BindingSource src = new BindingSource(); src.DataSource = CongViecControllers.getListCongViecfromDB(); this.dataGridViewCongViec.DataSource = src; }
private void btnSuaCongViec_Click(object sender, EventArgs e) { if (this.txtTenCongViec.Text.Trim().Length <= 0 || this.txtMaCongViec.Text.Trim().Length <= 0 || this.dateTimeDuKienHoanThanh.Value > DateTime.Now || this.dateTimeBatDauCongViec.Value > DateTime.Now || this.dateTimeDuKienHoanThanh.Value > DateTime.Now) { if (this.txtMaCongViec.Text.Trim().Length <= 0) { this.errorProvider1.SetError(this.txtMaCongViec, "Ma cong viec khong duoc trong"); return; } else if (CongViecControllers.getMaCongViecfromDB(this.txtMaCongViec.Text.Trim()) != "") { this.errorProvider1.SetError(this.txtMaCongViec, "Ma cong viec da ton tai"); return; } else { this.errorProvider1.Clear(); } if (this.txtTenCongViec.Text.Trim().Length <= 0) { this.errorProvider1.SetError(this.txtTenCongViec, "nhap ten cong viec"); return; } else { this.errorProvider1.Clear(); } if (this.dateTimeBatDauCongViec.Value <= DateTime.Now) { this.errorProvider1.SetError(this.dateTimeBatDauCongViec, "nhap ngay bat dau"); return; } else { this.errorProvider1.Clear(); } if (this.dateTimeDuKienHoanThanh.Value <= DateTime.Now) { this.errorProvider1.SetError(this.dateTimeDuKienHoanThanh, "nhap ngay du kien hoan thanh"); return; } else { this.errorProvider1.Clear(); } } var lcv = CongViecControllers.getListCongViecfromDB(); CongViec cv = new CongViec(); cv.MaCongViec = txtMaCongViec.Text.Trim(); cv.TenCongViec = txtTenCongViec.Text.Trim(); cv.NoiDungCongViec = rtxtNoiDungCongViec.Text.Trim(); //cv.ListNhomPhuTrach = cbbNhom.SelectedItem.ToString(); cv.NgayBatDau = DateTime.Parse(dateTimeBatDauCongViec.Value.ToString()); cv.DuKienHoanThanh = DateTime.Parse(dateTimeDuKienHoanThanh.Value.ToString()); cv.NgayHoanThanh = lcv[dataGridViewCongViec.CurrentRow.Index].NgayHoanThanh; cv.TienDo = lcv[dataGridViewCongViec.CurrentRow.Index].TienDo; cv.ChiPhi = lcv[dataGridViewCongViec.CurrentRow.Index].ChiPhi; CongViecControllers.updateCongViec(cv); BindingSource source = new BindingSource(); source.DataSource = CongViecControllers.getListCongViecfromDB(); this.dataGridViewCongViec.DataSource = source; }
private void btnThemCongViec_Click(object sender, EventArgs e) { if (this.txtTenCongViec.Text.Trim().Length <= 0 || this.txtMaCongViec.Text.Trim().Length <= 0 || this.dateTimeDuKienHoanThanh.Value > DateTime.Now || this.dateTimeBatDauCongViec.Value > DateTime.Now || this.dateTimeDuKienHoanThanh.Value > DateTime.Now) { if (this.txtMaCongViec.Text.Trim().Length <= 0) { this.errorProvider1.SetError(this.txtMaCongViec, "Ma cong viec khong duoc trong"); return; } else if (CongViecControllers.getMaCongViecfromDB(this.txtMaCongViec.Text.Trim()) != "") { this.errorProvider1.SetError(this.txtMaCongViec, "Ma cong viec da ton tai"); return; } else { this.errorProvider1.Clear(); } if (this.txtTenCongViec.Text.Trim().Length <= 0) { this.errorProvider1.SetError(this.txtTenCongViec, "nhap ten cong viec"); return; } else { this.errorProvider1.Clear(); } if (this.dateTimeBatDauCongViec.Value <= DateTime.Now) { this.errorProvider1.SetError(this.dateTimeBatDauCongViec, "nhap ngay bat dau"); return; } else { this.errorProvider1.Clear(); } if (this.dateTimeDuKienHoanThanh.Value <= DateTime.Now) { this.errorProvider1.SetError(this.dateTimeDuKienHoanThanh, "nhap ngay du kien hoan thanh"); return; } else { this.errorProvider1.Clear(); } } CongViec cv = new CongViec(); cv.MaCongViec = txtMaCongViec.Text.Trim(); cv.TenCongViec = txtTenCongViec.Text.Trim(); cv.NoiDungCongViec = rtxtNoiDungCongViec.Text.Trim(); //cv.ListNhomPhuTrach = cbbNhom.SelectedItem.ToString(); cv.NgayBatDau = DateTime.Parse(dateTimeBatDauCongViec.Value.ToString()); cv.DuKienHoanThanh = DateTime.Parse(dateTimeDuKienHoanThanh.Value.ToString()); cv.NgayHoanThanh = DateTime.Parse("01/01/2000 12:00:00 AM"); cv.TienDo = 0; cv.ChiPhi = 0; DuAn da = DuAnControllers.getDuAnfromDB(lda[(cbxListDuAn.SelectedIndex)].MaDuAn.Trim()); if (da.CongViecDuAn == null) { da.CongViecDuAn = txtMaCongViec.Text.Trim(); } else { da.CongViecDuAn = da.CongViecDuAn.Trim() + "," + txtMaCongViec.Text.Trim(); } DuAnControllers.updateDA(da); CongViecControllers.AddCongViec(cv); BindingSource source = new BindingSource(); source.DataSource = CongViecControllers.getListCongViecfromDB(); this.dataGridViewCongViec.DataSource = source; }
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; } }
private void dataGridViewDuAn_CellClick(object sender, DataGridViewCellEventArgs e) { chlbCongViec.Items.Clear(); tinhChiPhiDA(); tinhTienDoDA(); dahoanthanh(); cbxNhom.DataSource = null; if (true) { if (this.dataGridViewDuAn.Columns[e.ColumnIndex].DataPropertyName != nameof(DuAn.MaDuAn)) { if (this.dataGridViewDuAn.CurrentRow.Cells[0].Value == null) { MessageBox.Show("Chua nhap Ma Du An"); return; } } if (dataGridViewDuAn.CurrentRow.Cells[3].Value == null) { txtChiPhiDuAn.Text = "0"; } else { txtChiPhiDuAn.Text = dataGridViewDuAn.CurrentRow.Cells[3].Value.ToString(); } txtMaDuAn.Text = dataGridViewDuAn.CurrentRow.Cells[0].Value.ToString(); txtTenDuAn.Text = dataGridViewDuAn.CurrentRow.Cells[1].Value.ToString(); dateTimeBatDauDuAn.Value = DateTime.Parse(dataGridViewDuAn.CurrentRow.Cells[7].Value.ToString()); dateNgayDuKienHoanThanh.Value = DateTime.Parse(dataGridViewDuAn.CurrentRow.Cells[6].Value.ToString()); if (dataGridViewDuAn.CurrentRow.Cells[9].Value == null) { dateTimeNgayHoanThanh.Value = DateTime.Parse("01/01/2000 12:00:00 AM"); } else { dateTimeNgayHoanThanh.Value = DateTime.Parse(dataGridViewDuAn.CurrentRow.Cells[9].Value.ToString()); } if (dataGridViewDuAn.CurrentRow.Cells[2].Value != null) { rtxtMucTieu.Text = dataGridViewDuAn.CurrentRow.Cells[2].Value.ToString(); } if (dataGridViewDuAn.CurrentRow.Cells[8].Value == null || int.Parse(dataGridViewDuAn.CurrentRow.Cells[8].Value.ToString()) == -2147483648) { pgbTienDoDuAn.Value = 0; } else { pgbTienDoDuAn.Value = int.Parse(dataGridViewDuAn.CurrentRow.Cells[8].Value.ToString()); } //cho ma cong viec vao => list cong viec setitemchecked List <DuAn> da = DuAnControllers.getListDuAnfromDB(); if (da[dataGridViewDuAn.CurrentRow.Index].CongViecDuAn == null) { return; } string macongviec = da[dataGridViewDuAn.CurrentRow.Index].CongViecDuAn; macongviec = macongviec.Trim(); string[] listtencongviec = macongviec.Trim().Split(','); List <CongViec> lcv = CongViecControllers.getListCongViecfromDB(listtencongviec); foreach (var item in listtencongviec) { chlbCongViec.Items.Add(item.Trim()); } foreach (var item in lcv) { if (item.TienDo == 100) { for (int i = 0; i < chlbCongViec.Items.Count; i++) { if (chlbCongViec.Items[i].ToString() == item.MaCongViec.ToString().Trim()) { chlbCongViec.SetItemChecked(i, true); } } } } List <string> listnhom = new List <string>(); foreach (var item in listtencongviec) { if (NhomControllers.getListNhomfromDB(item) != null) { string[] lstnhom = NhomControllers.getListNhomfromDB(item).Split(','); foreach (var nhom in lstnhom) { listnhom.Add(nhom); } } } cbxNhom.DataSource = listnhom; } else { return; } }