private void frmSuaGV_Load(object sender, EventArgs e) { ckbNgaySinh.Checked = false; dtpNgaySinhMoi.Enabled = false; // int indexPhong = 0; int maPhong = NhanVienControl.layMaPhong(id); List <PhongBan> listPB = new List <PhongBan>(); listPB.Add(new PhongBan { MaPB = 0, TenPB = "---None---", TruongPhong = 0, ViTri = "" }); DataTable dtPB = NhanVienControl.layDanhSachPB(); for (int i = 0; i < dtPB.Rows.Count; ++i) { if (true) { PhongBan temp = new PhongBan { MaPB = Convert.ToInt32(dtPB.Rows[i][0].ToString()), TenPB = dtPB.Rows[i][1].ToString(), TruongPhong = dtPB.Rows[i][2].ToString().Length != 0 ? Convert.ToInt32(dtPB.Rows[i][2].ToString()) : 0, ViTri = dtPB.Rows[i][3].ToString() }; listPB.Add(temp); if (maPhong == temp.MaPB) { indexPhong = i; } } } cbPhongBanMoi.DataSource = listPB; cbPhongBanMoi.DisplayMember = "TenPB"; cbPhongBanMoi.SelectedIndex = maPhong + 0; int indexNQL = -1; int maNQL = NhanVienControl.layNQL(id); List <NhanVien> listNV = new List <NhanVien>(); DataTable dtNV = NhanVienControl.layDanhSachNQL(); for (int i = 0; i < dtNV.Rows.Count; ++i) { if (id == Convert.ToInt32(dtNV.Rows[i][0].ToString())) { dtNV.Rows.RemoveAt(i); } } listNV.Add(new NhanVien { MaNV = 0, TenNV = "---None---", NgaySinh = DateTime.Now, GioiTinh = "Nữ", Phong = 0, NQL = 0, Luong = 0 }); for (int i = 0; i < dtNV.Rows.Count; ++i) { if (true) { NhanVien temp = new NhanVien { MaNV = Convert.ToInt32(dtNV.Rows[i][0].ToString()), TenNV = dtNV.Rows[i][1].ToString(), NgaySinh = DateTime.Parse(dtNV.Rows[i][2].ToString()), GioiTinh = dtNV.Rows[i][3].ToString(), Phong = dtNV.Rows[i][4].ToString().Length != 0 ? Convert.ToInt32(dtNV.Rows[i][4].ToString()) : 0, NQL = dtNV.Rows[i][5].ToString().Length != 0 ? Convert.ToInt32(dtNV.Rows[i][5].ToString()) : 0, Luong = double.Parse(dtNV.Rows[i][6].ToString()) }; listNV.Add(temp); if (maNQL == Convert.ToInt32(dtNV.Rows[i][0].ToString())) { indexNQL = i; } } } cbQuanLyMoi.DataSource = listNV; cbQuanLyMoi.DisplayMember = "TenNV"; cbQuanLyMoi.SelectedIndex = indexNQL + 1; // }