public void display() { this.cMaCVChiTieu.DataPropertyName = nameof(ChiPhi.MaCongViecChiTieu); this.cCongViecChiTieu.DataPropertyName = nameof(ChiPhi.CongViecChiTieu); this.cNgayThucHien.DataPropertyName = nameof(ChiPhi.ThucHien); this.cChiPhi.DataPropertyName = nameof(ChiPhi.ChiPhiCongViec); List <ChiPhi> lstChiPhi = ChiPhiControllers.getListChiPhifromDB(); BindingSource src = new BindingSource(); src.DataSource = lstChiPhi; dataGridView1.DataSource = src; //dataGridView1.Columns[3].Visible = false; }
private void btnThemChiPhi_Click(object sender, EventArgs e) { if (this.txtMaCongViec.Text.Trim().Length <= 0) { this.errorProvider1.SetError(this.txtMaCongViec, "nhap ten ma cong viec"); return; } else { this.errorProvider1.Clear(); } if (this.txtCongViec.Text.Trim().Length <= 0) { this.errorProvider1.SetError(this.txtCongViec, "nhap ten cong viec"); return; } else { this.errorProvider1.Clear(); } if (this.txtChiPhi.Text.Trim().Length <= 0) { this.errorProvider1.SetError(this.txtChiPhi, "nhap chi phi"); return; } else { this.errorProvider1.Clear(); } ChiPhi cp = new ChiPhi(); cp.MaCongViecChiTieu = txtMaCongViec.Text.Trim(); cp.CongViecChiTieu = txtCongViec.Text.Trim(); cp.ChiPhiCongViec = int.Parse(txtChiPhi.Text.Trim()); cp.ThucHien = dateTimeNgayThucHien.Value; ChiPhiControllers.AddChiPhi(cp); BindingSource source = new BindingSource(); source.DataSource = ChiPhiControllers.getListChiPhifromDB(); this.dataGridView1.DataSource = source; }
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; }