public void dahoanthanh() { List <DuAn> lda = DuAnControllers.getListDuAnfromDB(); foreach (DuAn da in lda) { int flag = 0; if (da.CongViecDuAn != null) { string[] lcongviecda = da.CongViecDuAn.Trim().Split(','); List <CongViec> lstcv = new List <CongViec>(); foreach (var item in lcongviecda) { if (CongViecControllers.CheckCongViecHoanThanhfromDB(item) == false) { flag = 1; break; } else { lstcv.Add(CongViecControllers.getCongViecfromDB(item)); } } if (flag == 0) { da.NgayHoanThanh = checkmaxtime(lstcv); } DuAnControllers.updateDA(da); } } }
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 btnThemCongViec_Click(object sender, EventArgs e) { if (this.txtMaCongViecNhanVien.Text.Trim().Length <= 0 || this.txtMaNhanVien.Text.Trim().Length <= 0 || this.dateTimeDuKienHoanThanhCVNV.Value > DateTime.Now || this.dateTimeNgayBatDauCVNV.Value > DateTime.Now || this.dateTimeNgayKetThucCVNV.Value > DateTime.Now) { if (this.txtMaCongViecNhanVien.Text.Trim().Length <= 0) { this.errorProvider1.SetError(this.txtMaCongViecNhanVien, "Ma cong viec khong duoc trong"); return; } else if (this.txtMaNhanVien.Text.Trim().Length <= 0) { this.errorProvider1.SetError(this.txtMaNhanVien, "Ma nhan vien khong duoc de trong"); return; } this.errorProvider1.Clear(); if (this.txtTenCongViecNhanVien.Text.Trim().Length <= 0) { this.errorProvider1.SetError(this.txtTenCongViecNhanVien, "nhap ten cong viec"); return; } else { this.errorProvider1.Clear(); } if (this.txtMoTaCongViecNhanVien.Text.Trim().Length <= 0) { this.errorProvider1.SetError(this.txtMoTaCongViecNhanVien, "nhap mo ta cong viec"); return; } else { this.errorProvider1.Clear(); } if (this.txtLuongCongViec.Text.Trim().Length <= 0) { this.errorProvider1.SetError(this.txtLuongCongViec, "nhap luong cong viec"); return; } else { this.errorProvider1.Clear(); } if (this.dateTimeNgayBatDauCVNV.Value <= DateTime.Now) { this.errorProvider1.SetError(this.dateTimeNgayBatDauCVNV, "nhap ngay bat dau"); return; } else { this.errorProvider1.Clear(); } if (this.dateTimeDuKienHoanThanhCVNV.Value <= DateTime.Now) { this.errorProvider1.SetError(this.dateTimeDuKienHoanThanhCVNV, "nhap ngay du kien hoan thanh"); return; } else { this.errorProvider1.Clear(); } } CongViecNhanVien cv = new CongViecNhanVien(); cv.MaCongViecNhanVien = txtMaCongViecNhanVien.Text.Trim(); cv.TenCongViec = txtTenCongViecNhanVien.Text.Trim(); cv.MaNhanVienPhuTrach = txtMaNhanVien.Text.Trim(); cv.MoTa = txtMoTaCongViecNhanVien.Text.Trim(); cv.LuongCongViec = int.Parse(txtLuongCongViec.Text.Trim()); cv.TaiLieu = txtTaiLieu.Text.Trim(); cv.NgayBatDau = DateTime.Parse(dateTimeNgayBatDauCVNV.Value.ToString()); cv.DuKienHoanThanh = DateTime.Parse(dateTimeDuKienHoanThanhCVNV.Value.ToString()); cv.NgayHoanThanh = DateTime.Parse(dateTimeNgayKetThucCVNV.Value.ToString()); ChiPhi cp = new ChiPhi(); cp.ChiPhiCongViec = cv.LuongCongViec; cp.MaCongViecChiTieu = cv.MaCongViecNhanVien; cp.CongViecChiTieu = cv.TenCongViec; cp.ThucHien = DateTime.Parse(dateTimeNgayKetThucCVNV.Value.ToString()); ChiPhiControllers.AddChiPhi(cp); CongViec congviec = CongViecControllers.getCongViecfromDB(lcv[(cbxListCongViecnv.SelectedIndex)].MaCongViec.Trim()); if (congviec.NoiDungCongViec.Trim() == "" || congviec.NoiDungCongViec == null) { congviec.NoiDungCongViec = txtMaCongViecNhanVien.Text.Trim(); } else { congviec.NoiDungCongViec = congviec.NoiDungCongViec.Trim() + "," + txtMaCongViecNhanVien.Text.Trim(); } CongViecControllers.updateCongViec(congviec); CongViecNhanVienControllers.AddCongViecNhanVien(cv); BindingSource source = new BindingSource(); source.DataSource = CongViecNhanVienControllers.getListCongViecNhanVienfromDB(); this.dataGridViewCongViecDangThucHien.DataSource = source; }
private void btnThemNhom_Click(object sender, EventArgs e) { if (this.txtNhom.Text.Trim().Length <= 0) { this.errorProvider1.SetError(this.txtNhom, "nhap ten ma nhom"); return; } else { this.errorProvider1.Clear(); } if (NhomControllers.getNhomfromDB(this.txtNhom.Text.Trim()) != "") { this.errorProvider1.SetError(this.txtNhom, "Ma nhom da ton tai"); return; } this.errorProvider1.Clear(); if (this.txtTenNhom.Text.Trim().Length <= 0) { this.errorProvider1.SetError(this.txtTenNhom, "nhap ten nhom"); return; } else { this.errorProvider1.Clear(); } if (this.txtNhomTruong.Text.Trim().Length <= 0) { this.errorProvider1.SetError(this.txtNhomTruong, "nhap ma nhan vien nhom truong"); return; } else { this.errorProvider1.Clear(); } if (NhanVienControllers.getNhanVienfromDB(this.txtNhomTruong.Text.Trim()) == null) { this.errorProvider1.SetError(this.txtNhom, "khong tim thay nhom truong"); return; } this.errorProvider1.Clear(); Nhom nh = new Nhom(); nh.MaNhom = txtNhom.Text.Trim(); nh.TenNhom = txtTenNhom.Text.Trim(); nh.NhomTruong = txtNhomTruong.Text.Trim(); NhomControllers.AddNhom(nh); BindingSource source = new BindingSource(); source.DataSource = NhomControllers.getListNhomfromDB(); this.dataGridView1.DataSource = source; CongViec cv = CongViecControllers.getCongViecfromDB(lcv[(cbxListCongViec.SelectedIndex)].MaCongViec.Trim()); if (cv.ListNhomPhuTrach == "" || cv.ListNhomPhuTrach == null) { cv.ListNhomPhuTrach = txtNhom.Text.Trim(); } else { cv.ListNhomPhuTrach = cv.ListNhomPhuTrach.Trim() + "," + txtNhom.Text.Trim(); } CongViecControllers.updateCongViec(cv); }