private void btnSearch_Click(object sender, EventArgs e) { eSinhVien sv = new eSinhVien(); sv = svBLL.GetSinhVienByID(txtID.Text.Trim()); if (sv != null) { txtTen.Text = sv.HoVaTen; txtAddress.Text = sv.DiaChi; txtMail.Text = sv.Mail; txtPhone.Text = sv.SDT; txtLopNC.Text = new LopNienCheBLL().GetLopNienCheByID(sv.ID_LopNienChe).TenLop.Trim(); if (sv.HinhAnh != null) { picHinhAnh.Image = ByteToImg(Convert.ToBase64String(sv.HinhAnh)); } frmDangKyHocPhanPN frm = new frmDangKyHocPhanPN(sv); frm.TopLevel = false; frm.Visible = true; frm.FormBorderStyle = FormBorderStyle.None; frm.Dock = DockStyle.Fill; panel.Controls.Clear(); panel.Controls.Add(frm); } else { MessageBox.Show("Sai mã số sinh viên"); } }
//Kiem tra dang nhap tai khoan sinh vien public eSinhVien CheckLogInSinhVien(string userName, string passWord) { SinhVien sv = db.SinhViens.Where(x => x.ID_SinhVien == userName).FirstOrDefault(); //sai MSSV if (sv == null) { return(null); } else { // sai MK if (sv.MatKhau.Trim() != passWord) { return(null); } else { eSinhVien esv = new eSinhVien(); esv.ID_SinhVien = sv.ID_SinhVien; esv.MatKhau = sv.MatKhau; esv.HoVaTen = sv.HoVaTen; esv.ID_LopNienChe = sv.ID_LopNienChe; esv.SDT = sv.SDT; esv.DiaChi = sv.DiaChi; esv.Mail = sv.Mail; esv.HinhAnh = sv.HinhAnh; return(esv); } } }
public frmDangKyHocPhan(object tk) { InitializeComponent(); this.taiKhoan = tk; if (tk is eSinhVien) { btnSearch.Visible = false; txtID.ReadOnly = true; frmDangKyHocPhanPN frm = new frmDangKyHocPhanPN((eSinhVien)tk); frm.TopLevel = false; frm.Visible = true; frm.FormBorderStyle = FormBorderStyle.None; frm.Dock = DockStyle.Fill; panel.Controls.Clear(); panel.Controls.Add(frm); eSinhVien sv = (eSinhVien)tk; txtID.Text = sv.ID_SinhVien; txtTen.Text = sv.HoVaTen; txtAddress.Text = sv.DiaChi; txtMail.Text = sv.Mail; txtPhone.Text = sv.SDT; txtLopNC.Text = new LopNienCheBLL().GetLopNienCheByID(sv.ID_LopNienChe).TenLop.Trim(); if (sv.HinhAnh != null) { picHinhAnh.Image = ByteToImg(Convert.ToBase64String(sv.HinhAnh)); } } else { btnSearch.Visible = true; txtID.ReadOnly = false; } }
public bool EditSinhVien(string id, eSinhVien eSV) { try { SinhVien x = db.SinhViens.Where(m => m.ID_SinhVien == id).FirstOrDefault(); if (x == null) { return(false); } else { x.HinhAnh = eSV.HinhAnh; x.HinhAnh = eSV.HinhAnh; x.ID_SinhVien = eSV.ID_SinhVien; x.HoVaTen = eSV.HoVaTen; x.SDT = eSV.SDT; x.MatKhau = eSV.MatKhau; x.ID_LopNienChe = eSV.ID_LopNienChe; x.DiaChi = eSV.DiaChi; x.Mail = eSV.Mail; db.SaveChanges(); return(true); } } catch { return(false); } }
public frmDiemSV(eSinhVien e) { InitializeComponent(); this.eSV = e; btnSearch.Visible = false; txtID.ReadOnly = true; Load_dgvHeader(); Search(); pKT = 0; }
public SinhVienViewModels(eSinhVien sv) { this.ID_SinhVien = sv.ID_SinhVien; this.MatKhau = sv.MatKhau; this.HoVaTen = sv.HoVaTen; this.ID_LopNienChe = sv.ID_LopNienChe; this.DiaChi = sv.DiaChi; this.SDT = sv.SDT; this.Mail = sv.Mail; this.HinhAnh = sv.HinhAnh; this.TenLopNienChe = new LopNienCheBLL().GetLopNienCheByID(sv.ID_LopNienChe).TenLop; }
public frmDangKyHocPhanPN(eSinhVien eSV) { InitializeComponent(); this.eSV = eSV; #region cbNienKhoa List <eNienKhoa> lstNienKhoa = new NienKhoaBLL().GetAllNienKhoa(); cbNamHocSearch.DataSource = lstNienKhoa; cbNamHocSearch.DisplayMember = "NienKhoa1"; cbNamHocSearch.ValueMember = "ID_NienKhoa"; cbHocKiSearch.SelectedIndex = 0; #endregion }
private void btnSearchSV_Click(object sender, EventArgs e) { eSinhVien x = new SinhVienBLL().GetSinhVienByID(txtID.Text.Trim()); if (x != null) { this.eSV = x; txtTen.Text = x.HoVaTen.Trim(); } else { MessageBox.Show("Sai mã sinh viên"); } }
public frmLichHoc(eSinhVien sV) { InitializeComponent(); this.eSV = sV; btnSearchSV.Visible = false; txtID.ReadOnly = true; txtID.Text = eSV.ID_SinhVien.Trim(); txtTen.Text = eSV.HoVaTen.Trim(); cbNamHocSearch.DataSource = new NienKhoaBLL().GetAllNienKhoa(); cbNamHocSearch.ValueMember = "ID_NienKhoa"; cbNamHocSearch.DisplayMember = "NienKhoa1"; cbHocKiSearch.SelectedIndex = 0; }
public eSinhVien GetSinhVienByID(string id) { eSinhVien eSV = db.SinhViens.Where(t => t.ID_SinhVien == id).Select(x => new eSinhVien { HinhAnh = x.HinhAnh, ID_SinhVien = x.ID_SinhVien, HoVaTen = x.HoVaTen, SDT = x.SDT, MatKhau = x.MatKhau, ID_LopNienChe = x.ID_LopNienChe, DiaChi = x.DiaChi, Mail = x.Mail }).FirstOrDefault(); return(eSV); }
public void Search() { if (pKT == 1) { eSinhVien sv = new eSinhVien(); sv = svBLL.GetSinhVienByID(txtID.Text.Trim()); if (sv != null) { eSV = sv; this.eSV = sv; txtAddress.Text = eSV.DiaChi; txtLopNC.Text = new LopNienCheBLL().GetLopNienCheByID(eSV.ID_LopNienChe.Trim()).TenLop.Trim(); txtMail.Text = eSV.Mail; txtPhone.Text = eSV.SDT; txtTen.Text = eSV.HoVaTen; if (eSV.HinhAnh != null) { picHinhAnh.Image = ByteToImg(Convert.ToBase64String(eSV.HinhAnh)); } LoadDiem(eSV.ID_SinhVien.Trim()); btnPrint.Visible = true; } else { MessageBox.Show("Sai mã số sinh viên"); btnPrint.Visible = false; } } else { txtAddress.Text = eSV.DiaChi; txtLopNC.Text = new LopNienCheBLL().GetLopNienCheByID(eSV.ID_LopNienChe.Trim()).TenLop.Trim(); txtMail.Text = eSV.Mail; txtPhone.Text = eSV.SDT; txtTen.Text = eSV.HoVaTen; if (eSV.HinhAnh != null) { picHinhAnh.Image = ByteToImg(Convert.ToBase64String(eSV.HinhAnh)); } LoadDiem(eSV.ID_SinhVien.Trim()); btnPrint.Visible = true; } }
public bool DoiMatKhau(eSinhVien tk, string mkMoi) { try { SinhVien x = db.SinhViens.Where(m => m.ID_SinhVien == tk.ID_SinhVien).FirstOrDefault(); if (x == null) { return(false); } else { x.MatKhau = mkMoi; db.SaveChanges(); return(true); } } catch { return(false); } }
public bool AddNewSinhVien(eSinhVien eSV) { try { SinhVien x = new SinhVien(); x.HinhAnh = eSV.HinhAnh; x.ID_SinhVien = eSV.ID_SinhVien; x.HoVaTen = eSV.HoVaTen; x.SDT = eSV.SDT; x.MatKhau = eSV.MatKhau; x.ID_LopNienChe = eSV.ID_LopNienChe; x.DiaChi = eSV.DiaChi; x.Mail = eSV.Mail; db.SinhViens.Add(x); db.SaveChanges(); return(true); } catch { return(false); } }
//Search SV private void button1_Click(object sender, EventArgs e) { eSinhVien sv = new eSinhVien(); sv = svBLL.GetSinhVienByID(tbxID.Text.Trim()); if (sv != null) { tbxAddress.Text = sv.DiaChi; // tbxLopNC.Text = sv.LopNienChe.TenLop; tbxMail.Text = sv.Mail; tbxPhone.Text = sv.SDT; tbxTen.Text = sv.HoVaTen; if (sv.HinhAnh != null) { pictureBox1.Image = ByteToImg(Convert.ToBase64String(sv.HinhAnh)); } ShowDataGridView(diemBLL.GetDiemSV(sv.ID_SinhVien), dataGridView1); } else { MessageBox.Show("Sai mã số sinh viên"); } }
public bool EditSinhVien(string id, eSinhVien eSV) { return(svDAL.EditSinhVien(id, eSV)); }
public bool AddNewSinhVien(eSinhVien eSV) { return(svDAL.AddNewSinhVien(eSV)); }
private void btnLuu_Click(object sender, EventArgs e) { kt = 0; if (string.IsNullOrEmpty(tbxTen.Text)) { err.SetError(tbxTen, "Không được để trống"); } else { if (!Regex.IsMatch(tbxTen.Text, @"^[A-ZÀÁÂÃÈÉÊÌÍÒÓÔÕÙÚĂĐĨŨƠƯĂẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼỀỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴÝỶỸ][a-zàáâãèéếêìíòóôõùúăđĩũơưăạảấầẩẫậắằẳẵặẹẻẽềềểễệỉịọỏốồổỗộớờởỡợụủứừửữựỳỵỷỹ]*(\s[A-ZÀÁÂÃÈÉÊÌÍÒÓÔÕÙÚĂĐĨŨƠƯĂẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼỀỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴÝỶỸ][a-zàáâãèéếêìíòóôõùúăđĩũơưăạảấầẩẫậắằẳẵặẹẻẽềềểễệỉịọỏốồổỗộớờởỡợụủứừửữựỳỵỷỹ]*)*$")) { err.SetError(tbxTen, "Tên không hợp lệ"); } else { err.SetError(tbxTen, ""); kt++; } } if (string.IsNullOrEmpty(tbxPhone.Text)) { err.SetError(tbxPhone, "Không được để trống"); } else { if (!Regex.IsMatch(tbxPhone.Text, @"^[0][1-9][0-9]+$")) { err.SetError(tbxPhone, "Số điện thoại không hợp lệ"); } else { err.SetError(tbxPhone, ""); kt++; } } if (string.IsNullOrEmpty(tbxAddress.Text)) { err.SetError(tbxTen, "Không được để trống"); } else { err.SetError(tbxAddress, ""); kt++; } if (string.IsNullOrEmpty(tbxMail.Text)) { err.SetError(tbxTen, "Không được để trống"); } else { if (!Regex.IsMatch(tbxMail.Text, @"^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$")) { err.SetError(tbxMail, "Email không hợp lệ"); } else { err.SetError(tbxMail, ""); kt++; } } if (kt == 4) { if (taiKhoan is eSinhVien) { eSinhVien x = new eSinhVien(); x.HinhAnh = ImageToByteArray(pictureBox1.Image); x.HoVaTen = tbxTen.Text; x.DiaChi = tbxAddress.Text; x.Mail = tbxMail.Text; x.SDT = tbxPhone.Text; x.ID_LopNienChe = ((eSinhVien)taiKhoan).ID_LopNienChe; x.ID_SinhVien = ((eSinhVien)taiKhoan).ID_SinhVien; x.MatKhau = ((eSinhVien)taiKhoan).MatKhau; if (new SinhVienBLL().EditSinhVien(x.ID_SinhVien, x) == true) { MessageBox.Show("Lưu Thành Công"); taiKhoan = x; Loadform(); kt = 0; } else { MessageBox.Show("Lưu Thất Bại"); } } else if (taiKhoan is eNhanVienPDT) { eNhanVienPDT x = new eNhanVienPDT(); x.HinhAnh = ImageToByteArray(pictureBox1.Image); x.HoVaTen = tbxTen.Text; x.DiaChi = tbxAddress.Text; x.Mail = tbxMail.Text; x.SDT = tbxPhone.Text; x.ID_NhanVienPDT = ((eNhanVienPDT)taiKhoan).ID_NhanVienPDT; x.MatKhau = ((eNhanVienPDT)taiKhoan).MatKhau; if (new NhanVienBLL().EditNhanVien(x) == 1) { MessageBox.Show("Lưu Thành Công"); taiKhoan = x; Loadform(); kt = 0; } else { MessageBox.Show("Lưu Thất Bại"); } } else { eGiangVien x = new eGiangVien(); x.HinhAnh = ImageToByteArray(pictureBox1.Image); x.HoVaTen = tbxTen.Text; x.DiaChi = tbxAddress.Text; x.Mail = tbxMail.Text; x.SDT = tbxPhone.Text; x.ID_GiangVien = ((eGiangVien)taiKhoan).ID_GiangVien; x.TrinhDo = ((eGiangVien)taiKhoan).TrinhDo; x.MatKhau = ((eGiangVien)taiKhoan).MatKhau; if (new GiangVienBLL().EditGiangVien(x.ID_GiangVien, x) == true) { MessageBox.Show("Lưu Thành Công"); taiKhoan = x; Loadform(); kt = 0; } else { MessageBox.Show("Lưu Thất Bại"); } } } }
private void btnLuu_Click(object sender, EventArgs e) { kt = 0; #region Kiểm tra dữ liệu nhập //Tên if (string.IsNullOrEmpty(txtTen.Text)) { err.SetError(txtTen, "Không được để trống"); } else { if (!Regex.IsMatch(txtTen.Text, @"^[A-ZÀÁÂÃÈÉÊÌÍÒÓÔÕÙÚĂĐĨŨƠƯĂẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼỀỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴÝỶỸ][a-zàáâãèéếêìíòóôõùúăđĩũơưăạảấầẩẫậắằẳẵặẹẻẽềềểễệỉịọỏốồổỗộớờởỡợụủứừửữựỳỵỷỹ]*(\s[A-ZÀÁÂÃÈÉÊÌÍÒÓÔÕÙÚĂĐĨŨƠƯĂẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼỀỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴÝỶỸ][a-zàáâãèéếêìíòóôõùúăđĩũơưăạảấầẩẫậắằẳẵặẹẻẽềềểễệỉịọỏốồổỗộớờởỡợụủứừửữựỳỵỷỹ]*)+$")) { err.SetError(txtTen, "Tên không hợp lệ"); } else { err.SetError(txtTen, ""); kt++; } } //Phone if (string.IsNullOrEmpty(txtPhone.Text)) { err.SetError(txtPhone, "Không được để trống"); } else { if (!Regex.IsMatch(txtPhone.Text, @"^[0][1-9][0-9]+$")) { err.SetError(txtPhone, "Số điện thoại không hợp lệ"); } else { err.SetError(txtPhone, ""); kt++; } } //Địa chỉ if (string.IsNullOrEmpty(txtAddress.Text)) { err.SetError(txtAddress, "Không được để trống"); } else { if (!Regex.IsMatch(txtAddress.Text, @"^[A-ZÀÁÂÃÈÉÊÌÍÒÓÔÕÙÚĂĐĨŨƠƯĂẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼỀỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴÝỶỸ1-9][a-zàáâãèéếêìíòóôõùúăđĩũơưăạảấầẩẫậắằẳẵặẹẻẽềềểễệỉịọỏốồổỗộớờởỡợụủứừửữựỳỵỷỹ1-9]*(\s[A-ZÀÁÂÃÈÉÊÌÍÒÓÔÕÙÚĂĐĨŨƠƯĂẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼỀỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴÝỶỸ1-9][a-zàáâãèéếêìíòóôõùúăđĩũơưăạảấầẩẫậắằẳẵặẹẻẽềềểễệỉịọỏốồổỗộớờởỡợụủứừửữựỳỵỷỹ1-9]*)+$")) { err.SetError(txtAddress, "Tên không hợp lệ"); } else { err.SetError(txtAddress, ""); kt++; } } //email if (string.IsNullOrEmpty(txtMail.Text)) { err.SetError(txtMail, "Không được để trống"); } else { if (!Regex.IsMatch(txtMail.Text, "")) { err.SetError(txtMail, "Email không hợp lệ"); } else { err.SetError(txtMail, ""); kt++; } } #endregion if (kt == 4) { eSinhVien sv = new eSinhVien(); sv.HinhAnh = byteImage; sv.ID_SinhVien = txtID.Text.Trim(); sv.HoVaTen = txtTen.Text.Trim(); sv.ID_LopNienChe = cbLop.SelectedValue.ToString().Trim(); sv.SDT = txtPhone.Text.Trim(); sv.Mail = txtMail.Text.Trim(); sv.DiaChi = txtAddress.Text.Trim(); sv.MatKhau = txtMK.Text.Trim(); if (groupBox1.Text == "Thêm Sinh Viên") { if (svBLL.AddNewSinhVien(sv) == false) { MessageBox.Show("Lưu Thất Bại!!!"); } else { MessageBox.Show("Thêm Thành Công"); kt = 0; LoadDatagridView(svBLL.SearchAllSinhVien(txtIDSearch.Text.Trim(), txtTenSearch.Text.Trim()), dgvSinhVien); ShowDataGrid(); pictureBox1.Image = Resources.book; } } else { if (svBLL.EditSinhVien(sv.ID_SinhVien, sv) == false) { MessageBox.Show("Lưu Thất Bại!!!"); } else { MessageBox.Show("Chỉnh Sửa Thành Công"); kt = 0; LoadDatagridView(svBLL.SearchAllSinhVien(txtIDSearch.Text.Trim(), txtTenSearch.Text.Trim()), dgvSinhVien); ShowDataGrid(); } } } }