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; }
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; } }
private void Display() { this.clChucVu.DataPropertyName = nameof(NhanVien.ChucVu); this.clDiaChi.DataPropertyName = nameof(NhanVien.DiaChi); this.clHoTen.DataPropertyName = nameof(NhanVien.HoTen); this.clLuong.DataPropertyName = nameof(NhanVien.Luong); this.clMaNhanVien.DataPropertyName = nameof(NhanVien.MaNhanVien); this.clMatKhau.DataPropertyName = nameof(NhanVien.MatKhau); this.clNgaySinh.DataPropertyName = nameof(NhanVien.NgaySinh); this.clSoDienThoai.DataPropertyName = nameof(NhanVien.SoDienThoai); this.clNhom.DataPropertyName = nameof(NhanVien.Nhom); List <NhanVien> lstnhanvien = NhanVienControllers.getListNhanVienfromDB(); for (int i = 0; i <= lstnhanvien.Count - 1; i++) { CongViecNhanVienControllers.updateLuong(lstnhanvien[i]); } BindingSource src = new BindingSource(); src.DataSource = lstnhanvien; dataNhanVien.DataSource = src; if (qh == 0) { btnThemNhanVien.Visible = false; btnSuaNhanVien.Visible = false; btnXoaNhanVien.Visible = false; } else if (qh == 1) { } dataNhanVien.Columns[11].Visible = false; dataNhanVien.Columns[10].Visible = false; dataNhanVien.Columns[9].Visible = false; dataNhanVien.Columns[8].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.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()); cv.TienDo = bool.Parse(txtTienDoCongViecNhanVien.Text); ChiPhi cp = new ChiPhi(); cp.ChiPhiCongViec = cv.LuongCongViec; cp.MaCongViecChiTieu = cv.MaCongViecNhanVien; cp.CongViecChiTieu = cv.TenCongViec; cp.ThucHien = DateTime.Parse(dateTimeNgayKetThucCVNV.Value.ToString()); ChiPhiControllers.updateChiPhi(cp); CongViecNhanVienControllers.updateCongViecNhanVien(cv); BindingSource source = new BindingSource(); source.DataSource = CongViecNhanVienControllers.getListCongViecNhanVienfromDB(); this.dataGridViewCongViecDangThucHien.DataSource = source; }