public List <clsChucVu_DTO> LayDanhSachChucVu() { List <clsChucVu_DTO> dsChucVu = new List <clsChucVu_DTO>(); SqlConnection con = ThaoTacDuLieu_DAO.TaoKetNoi(); string cauTruyVan = string.Format("SELECT * FROM ChucVu WHERE trang_thai = {0}", 1); SqlCommand cmd = ThaoTacDuLieu_DAO.TruyVan(cauTruyVan, con); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { clsChucVu_DTO chucVu = new clsChucVu_DTO(); if (!reader.IsDBNull(0)) { chucVu.MaChucVu = (string)reader["ma_chuc_vu"]; } if (!reader.IsDBNull(1)) { chucVu.TenChucVu = (string)reader["ten_chuc_vu"]; } if (!reader.IsDBNull(2)) { chucVu.TrangThai = (bool)reader["trang_thai"]; } dsChucVu.Add(chucVu); } return(dsChucVu); }
private void HienThiDSChucVu() { ChucVu_BUS bus = new ChucVu_BUS(); List <clsChucVu_DTO> lstChucVu = bus.LayDanhSachChucVu(); clsChucVu_DTO dtoChucVu = new clsChucVu_DTO(); dtoChucVu.TenChucVu = "Chức vụ"; dtoChucVu.MaChucVu = ""; lstChucVu.Insert(0, dtoChucVu); cboChucVu.DisplayMember = "TenChucVu"; cboChucVu.ValueMember = "MaChucVu"; cboChucVu.DataSource = lstChucVu; }
private void HienThiDSChucVu(ComboBox cbo) { ChucVu_BUS bus = new ChucVu_BUS(); List <clsChucVu_DTO> lstChucVu = bus.LayDanhSachChucVu(); clsChucVu_DTO dtoChucVu = new clsChucVu_DTO(); if (cbo.Name == cboChucVu_TK.Name) { dtoChucVu.TenChucVu = "- -Tất cả- -"; dtoChucVu.MaChucVu = ""; lstChucVu.Insert(0, dtoChucVu); } cbo.DataSource = lstChucVu; cbo.DisplayMember = "TenChucVu"; cbo.ValueMember = "MaChucVu"; cbo.SelectedIndex = 0; }
public List <clsChucVu_DTO> LayDanhSachChucVu() { SqlConnection conn = ThaoTacDuLieu.TaoVaMoKetNoi(); string sql = "SELECT * FROM CHUCVU"; SqlCommand cmd = ThaoTacDuLieu.TaoDoiTuongTruyVan(sql, conn); SqlDataReader dr = cmd.ExecuteReader(); List <clsChucVu_DTO> lsChucVu = new List <clsChucVu_DTO>(); while (dr.Read()) { clsChucVu_DTO ChucVu = new clsChucVu_DTO(); if (!dr.IsDBNull(0)) { ChucVu.MACV = dr.GetString(0); } if (!dr.IsDBNull(1)) { ChucVu.TENCV = dr.GetString(1); } lsChucVu.Add(ChucVu); } ThaoTacDuLieu.DongKetNoi(conn); return(lsChucVu); }
private void dgvDSNV_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (dgvDSNV.Columns[e.ColumnIndex].Name == "colAnhNhanVien") { try { e.Value = new Bitmap(e.Value.ToString()); } catch { } } if (dgvDSNV.Columns[e.ColumnIndex].Name == "colNgayVaoLam") { if (DateTime.Parse(e.Value.ToString()).ToShortDateString() != "01/01/0001") { e.Value = DateTime.Parse(e.Value.ToString()).ToShortDateString(); } } if (dgvDSNV.Columns[e.ColumnIndex].Name == "colNgayThoiViec") { if (e.Value != null) { e.Value = DateTime.Parse(e.Value.ToString()).ToShortDateString(); } } if (dgvDSNV.Columns[e.ColumnIndex].Name == "colGioiTinh") { if (Convert.ToBoolean(e.Value) == true) { e.Value = "Nam"; } else { e.Value = "Nữ"; } } if (dgvDSNV.Columns[e.ColumnIndex].Name == "colChucVu") { ChucVu_BUS bus = new ChucVu_BUS(); List <clsChucVu_DTO> lstChucVu = bus.LayDanhSachChucVu(); clsChucVu_DTO dtoChucVu = lstChucVu.First(u => u.MaChucVu == e.Value.ToString()); e.Value = dtoChucVu.TenChucVu; } if (dgvDSNV.Columns[e.ColumnIndex].Name == "colTrangThai") { TrangThaiNV_BUS bus = new TrangThaiNV_BUS(); List <clsTrangThaiNV_DTO> lstTrangThaiNV = bus.LayDanhSachTrangThaiNhanVien(); clsTrangThaiNV_DTO dtoTrangThaiNV = lstTrangThaiNV.First(u => u.MaTrangThaiNV == Convert.ToInt32(e.Value.ToString())); e.Value = dtoTrangThaiNV.TenTrangThaiNV; } foreach (DataGridViewRow r in dgvDSNV.Rows) { if (Convert.ToInt32(r.Cells["colTrangThai"].Value) == 2) // Đã nghỉ việc { r.DefaultCellStyle.ForeColor = Color.Gray; } else if (Convert.ToInt32(r.Cells["colTrangThai"].Value) == 3) // Đang chờ vào làm { r.DefaultCellStyle.ForeColor = Color.Blue; } else { r.DefaultCellStyle.ForeColor = Color.Black; } } }