private void FrmThiSinh_Load(object sender, EventArgs e) { try { bindingSource1.DataSource = HocVienService.GetAll(); //pContainer.Enabled = False DTO.HocVien obj = bindingSource1.Current as DTO.HocVien; if (obj == null) { if (!string.IsNullOrEmpty(obj.AnhThiSinh)) { pic.Image = Image.FromFile(obj.AnhThiSinh); } } else { pic.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; pic.Image = Image.FromFile(obj.AnhThiSinh); } } catch (Exception ex) { MetroFramework.MetroMessageBox.Show(this, ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnDelete_Click(object sender, EventArgs e) { objState = EntityState.Deleted; if (MetroFramework.MetroMessageBox.Show(this, "Bạn có chắc muốn xóa không?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { DTO.HocVien obj = bindingSource1.Current as DTO.HocVien; if (obj != null) { bool result = HocVienService.Delete(obj.MaHV); if (result) { bindingSource1.RemoveCurrent(); //pContainer.Enabled = False pic.Image = null; objState = EntityState.Unchanged; } } } catch (Exception ex) { MetroFramework.MetroMessageBox.Show(this, ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public int insert(string id, string pass, string mahv, string hoten, int gioitinh, string diachi, string sdt, string email, DateTime ngaydk, int tinhtrang, DateTime ngaysinh) { if (CheckService.checkID(id, pass) == 1) { if (CheckService.checkRole(id, 1) == 1 || CheckService.checkRole(id, 0) == 1) //kiểm tra id này có quyền insert không... { if (TruongRong(hoten, gioitinh, diachi, sdt, email, ngaydk, tinhtrang, ngaysinh) == true) { if (gioitinh != 1 && gioitinh != 0) { return(0); } if (sdt.Length > 13) { return(0); } // Console.WriteLine(TruongRong(hoten, gioitinh, diachi, sdt, email, ngaydk, tinhtrang, ngaysinh)); HocVienService hvsv = new HocVienService(); int k = hvsv.insert(mahv, hoten, gioitinh, diachi, sdt, email, ngaydk, tinhtrang, ngaysinh); // Console.WriteLine(k); return(k); } } } return(0); }
public DataTable join(string id, string pass) { if (CheckService.checkID(id, pass) == 1)//kiểm tra id,pass này có đúng không. { HocVienService hvsv = new HocVienService(); return(hvsv.join()); } return(null); }
public DataTable get(string id, string pass, string mahv) { if (CheckService.checkID(id, pass) == 1) { HocVienService hvsv = new HocVienService(); return(hvsv.get(mahv)); } return(null); }
public int delete(string id, string pass, string mahv) //id và pass của nhân viên không phải id và pass của giảng viên { if (CheckService.checkID(id, pass) == 1) { if (CheckService.checkRole(id, 1) == 1 || CheckService.checkRole(id, 0) == 1)//kiểm tra id này có quyền delete giảng viên không... { HocVienService hvsv = new HocVienService(); return(hvsv.delete(mahv)); } } return(0); }
public int update(string id, string pass, string mahv, string hoten, int gioitinh, string diachi, string sdt, string email, DateTime ngaydk, int tinhtrang, DateTime ngaysinh) { if (CheckService.checkID(id, pass) == 1) { if (CheckService.checkRole(id, 1) == 1 || CheckService.checkRole(id, 0) == 1) { if (TruongRong(hoten, gioitinh, diachi, sdt, email, ngaydk, tinhtrang, ngaysinh) == true) { HocVienService hvsv = new HocVienService(); return(hvsv.update(mahv, hoten, gioitinh, diachi, sdt, email, ngaydk, tinhtrang, ngaysinh)); } } } return(0); }
private void btnSave_Click(object sender, EventArgs e) { try { bindingSource1.EndEdit(); HocVien obj = bindingSource1.Current as HocVien; if (obj != null) { obj = HocVienService.Save(obj, objState); metroGrid1.Refresh(); objState = EntityState.Unchanged; MetroFramework.MetroMessageBox.Show(this, "Đã Cập Nhật Thành Công", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MetroFramework.MetroMessageBox.Show(this, ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public HocVienController(HocVienService hocVienService) { _hocVienService = hocVienService; }