public List <clsTrangThaiBanPhanCong_DTO> LayDSTrangThaiBPC() { SqlConnection con = ThaoTacDuLieu_DAO.TaoKetNoi(); string query = "SELECT * FROM TrangThaiBanPhanCong"; SqlCommand cmd = ThaoTacDuLieu_DAO.TruyVan(query, con); SqlDataReader reader = cmd.ExecuteReader(); List <clsTrangThaiBanPhanCong_DTO> listTTBPC = new List <clsTrangThaiBanPhanCong_DTO>(); while (reader.Read()) { clsTrangThaiBanPhanCong_DTO TTBPC = new clsTrangThaiBanPhanCong_DTO(); if (!reader.IsDBNull(0)) { TTBPC.MaTrangThaiBanPhanCong = (int)reader[0]; } if (!reader.IsDBNull(1)) { TTBPC.TenTrangThaiBanPhanCong = (string)reader[1]; } listTTBPC.Add(TTBPC); } ThaoTacDuLieu_DAO.DongKetNoi(con); return(listTTBPC); }
private void dgvDSNVCaChieu_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (dgvDSNVCaChieu.Rows.Count > 0) { if (dgvDSNVCaChieu.Columns[e.ColumnIndex].Name == "colHoTenChieu") { NhanVien_BUS busNV = new NhanVien_BUS(); List <clsNhanVien_DTO> lstNV = busNV.LayNhanVienTheoTenHoacMaa("", ""); clsNhanVien_DTO dtoNV = lstNV.Find(u => u.MaNhanVien == e.Value.ToString()); e.Value = dtoNV.HoTen; } if (dgvDSNVCaChieu.Columns[e.ColumnIndex].Name == "colTrangThaiChieu") { dtoTTBPC = listTTBPC.Find(u => u.MaTrangThaiBanPhanCong == (int)e.Value); e.Value = dtoTTBPC.TenTrangThaiBanPhanCong; } foreach (DataGridViewRow row in dgvDSNVCaChieu.Rows) { if (row.Cells["colTrangThaiChieu"].Value.ToString() == "5") { row.DefaultCellStyle.ForeColor = Color.Blue; } else { row.DefaultCellStyle.ForeColor = Color.Black; } } } }
private void dgvLichLamViec_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (dgvLichLamViec.Rows.Count > 0) { if (dgvLichLamViec.Columns[e.ColumnIndex].Name == "colHoTen") { dtoNV = lstNV.First(u => u.MaNhanVien == e.Value.ToString()); e.Value = dtoNV.HoTen; } if (dgvLichLamViec.Columns[e.ColumnIndex].Name == "colCa") { dtoCa = lstCa.First(u => u.MaCaLamViec == e.Value.ToString()); e.Value = dtoCa.TenCaLamViec; } if (dgvLichLamViec.Columns[e.ColumnIndex].Name == "colTrangThai") { dtoTTBanPhanCong = lstTTBanPhanCong.First(u => u.MaTrangThaiBanPhanCong == (int)e.Value); e.Value = dtoTTBanPhanCong.TenTrangThaiBanPhanCong; } } }