private void btnLuu_Click(object sender, EventArgs e) { if (Them) { if (this.txtMaSV.Text == "") { epvSinhVien.SetError(this.txtMaSV, "!"); MessageBox.Show("Bạn chưa nhập Mã SV", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); epvSinhVien.Clear(); this.txtMaSV.Focus(); } else if (dbSinhVien.KiemTraSinhVienTonTai(this.txtMaSV.Text, ref err)) { epvSinhVien.SetError(this.txtMaSV, "!"); MessageBox.Show("Mã SV đã tồn tại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); epvSinhVien.Clear(); this.txtMaSV.Focus(); } else if (dbSinhVien.KiemTraMaLop(this.cboMaLop.Text, ref err) == false) { MessageBox.Show("Mã Lớp không chính xác!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (dbSinhVien.ThemSinhVien(this.txtMaSV.Text, this.txtHoTen.Text, this.mskNgaySinh.Text, this.cboGioiTinh.Text, this.txtDiaChi.Text , this.cboMaLop.Text, ref err)) { LoadData(); MessageBox.Show("Đã thêm xong!"); } else { MessageBox.Show("Không thêm được. Lỗi rồi!!! " + err); } } } else { if (dbSinhVien.KiemTraMaLop(this.cboMaLop.Text, ref err) == false) { MessageBox.Show("Mã Lớp không chính xác!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (dbSinhVien.CapNhatSinhVien(this.txtMaSV.Text, this.txtHoTen.Text, this.mskNgaySinh.Text, this.cboGioiTinh.Text, this.txtDiaChi.Text , this.cboMaLop.Text, ref err)) { LoadData(); MessageBox.Show("Đã sửa xong!"); } else { MessageBox.Show("Không sửa được. Lỗi rồi!!! " + err); } } } }