//Đăng Nhập private void btnLogin_Click(object sender, EventArgs e) { if (BUS_Tai_Khoan.Kiem_tra_Tai_Khoan(txtUserName.Text, txtPassWord.Text)) { this.Hide(); if (BUS_Tai_Khoan.Quyen(txtUserName.Text).Contains("HS")) { Hoc_Sinhh hoc_Sinh = BUS_Tai_Khoan.layThongTinTaiKhoan(txtUserName.Text) as Hoc_Sinhh; frmHoc_Sinh.hs = hoc_Sinh; frmHoc_Sinh hs = new frmHoc_Sinh(); hs.ShowDialog(); } else if (BUS_Tai_Khoan.Quyen(txtUserName.Text).Contains("AD")) { Tai_khoan tk = BUS_Tai_Khoan.layThongTinTaiKhoan(txtUserName.Text) as Tai_khoan; frmAdmin.tk = tk; frmAdmin admin = new frmAdmin(); admin.ShowDialog(); } else if (BUS_Tai_Khoan.Quyen(txtUserName.Text).Contains("GV")) { Giao_Vienn tk = BUS_Tai_Khoan.layThongTinTaiKhoan(txtUserName.Text) as Giao_Vienn; frmGiao_Vien.giaoVien = tk; frmGiao_Vien admin = new frmGiao_Vien(); admin.ShowDialog(); } txtPassWord.Clear(); txtUserName.Clear(); } }
public static Tai_khoan layThongTinTaiKhoan(string taiKhoan) { using (var qlttn = new QLTTNDataContext()) { var thongTin = qlttn.NGUOIDUNGs.Where(nd => nd.TaiKhoan.Equals(taiKhoan)) .Select(nd => new { nd }).Single(); if (thongTin.nd.MaPhanQuyen.Equals("AD ")) { Adminn ad = new Adminn(); ad.Ho_Ten = thongTin.nd.HoTen; ad.Ngay_Sinh = thongTin.nd.NgaySinh.Value; ad.Tai_Khoan = thongTin.nd.TaiKhoan; ad.CMND_TCC = thongTin.nd.CMND_TCC; return(ad); } else if (thongTin.nd.MaPhanQuyen.Equals("GV ")) { var thongTinn = qlttn.NGUOIDUNGs .Join(qlttn.KHOIs, nd => nd.MaKhoi, k => k.MaKhoi, (nd, k) => new { nd, k.TenKhoi }) .Where(nd => nd.nd.TaiKhoan.Equals(taiKhoan)) .Select(nd => new { nd }).Single(); Giao_Vienn gv = new Giao_Vienn(); gv.Tai_Khoan = thongTinn.nd.nd.TaiKhoan; gv.Ho_Ten = thongTinn.nd.nd.HoTen; gv.CMND_TCC = thongTinn.nd.nd.CMND_TCC; gv.Ngay_Sinh = thongTinn.nd.nd.NgaySinh.Value; gv.SDT = thongTinn.nd.nd.SoDienThoai; gv.Email = thongTinn.nd.nd.Email; gv.Khoi = thongTinn.nd.TenKhoi; return(gv); } else { var thongTinn = qlttn.NGUOIDUNGs .Join(qlttn.LOPHOCs, nd => nd.MaLop, lh => lh.MaLop, (nd, lh) => new { nd, lh }) .Join(qlttn.KHOIs, nd => nd.lh.MaKhoi, k => k.MaKhoi, (nd, k) => new { nd, k.TenKhoi }) .Where(nd => nd.nd.nd.TaiKhoan.Equals(taiKhoan)) .Select(nd => new { nd }).Single(); Hoc_Sinhh hs = new Hoc_Sinhh(); hs.Tai_Khoan = thongTinn.nd.nd.nd.TaiKhoan; hs.Ho_Ten = thongTinn.nd.nd.nd.HoTen; hs.CMND_TCC = thongTinn.nd.nd.nd.CMND_TCC; hs.Ngay_Sinh = thongTinn.nd.nd.nd.NgaySinh.Value; hs.SDT = thongTinn.nd.nd.nd.SoDienThoai; hs.Email = thongTinn.nd.nd.nd.Email; hs.Khoi = thongTinn.nd.TenKhoi; hs.Lop = thongTinn.nd.nd.lh.TenLop; return(hs); } } }
public static void UpdateTeacher(Giao_Vienn Teacher, string Teacher_User_Account) { if (Teacher.Tai_Khoan == Teacher_User_Account) { DAO_Admin.UpdateTeacher(Teacher); MessageBox.Show("Update Success"); } MessageBox.Show("You Can't Change The Name Account Of User!"); }
private void btnUpdate_teacher_Click(object sender, EventArgs e) { Giao_Vienn Teacher = new Giao_Vienn() { Ho_Ten = txtFull_name_teacher.Text, Tai_Khoan = txtUserName_teacher.Text, Mat_Khau = txtUserName_teacher.Text, CMND_TCC = txtCMND_TCC_teacher.Text, Lop = null, Khoi = listGrades[Grade_CBB.SelectedIndex].GradeID, Email = txtMail_teacher.Text, SDT = txtSDT_teacher.Text, Ngay_Sinh = DateTime.Parse(dtTeacher_Picker.Value.ToString()) }; BUS_Admin.UpdateTeacher(Teacher, Teacher_User_Account); }
public static void UpdateTeacher(Giao_Vienn Teacher) { using (var dataContext = new QLTTNDataContext()) { var data = dataContext.NGUOIDUNGs.Where(nd => nd.TaiKhoan.Equals(Teacher.Tai_Khoan)).Select(nd => nd).Single(); data.TaiKhoan = Teacher.Tai_Khoan; data.MatKhau = Teacher.Mat_Khau; data.MaKhoi = Teacher.Khoi; data.MaLop = Teacher.Lop; data.HoTen = Teacher.Ho_Ten; data.CMND_TCC = Teacher.CMND_TCC; data.NgaySinh = Teacher.Ngay_Sinh; data.SoDienThoai = Teacher.SDT; data.Email = Teacher.Email; dataContext.SubmitChanges(); } }
public static void InsertTeacherWithLinq(Giao_Vienn Teacher) { using (QLTTNDataContext dataContext = new QLTTNDataContext()) { NGUOIDUNG newUser = new NGUOIDUNG() { TaiKhoan = Teacher.Tai_Khoan, MatKhau = Teacher.Mat_Khau, MaKhoi = Teacher.Khoi, MaLop = Teacher.Lop, HoTen = Teacher.Ho_Ten, CMND_TCC = Teacher.CMND_TCC, NgaySinh = Teacher.Ngay_Sinh, SoDienThoai = Teacher.SDT, Email = Teacher.Email, MaPhanQuyen = "GV" }; dataContext.NGUOIDUNGs.InsertOnSubmit(newUser); dataContext.SubmitChanges(); } }
private void btnAdd_teacher_Click(object sender, EventArgs e) { if (ValidateChildren(ValidationConstraints.Enabled)) { Giao_Vienn Teacher = new Giao_Vienn() { Ho_Ten = txtFull_name_teacher.Text, Tai_Khoan = txtUserName_teacher.Text, Mat_Khau = txtUserName_teacher.Text, CMND_TCC = txtCMND_TCC_teacher.Text, Khoi = listGrades[Grade_CBB.SelectedIndex].GradeID, Lop = null, Email = txtMail_teacher.Text, SDT = txtSDT_teacher.Text, Ngay_Sinh = DateTime.Parse(dtTeacher_Picker.Value.ToString()) }; BUS_Admin.InsertTeacher(Teacher); MessageBox.Show("Add Teacher Success!"); } MessageBox.Show("Add Teacher Failed!"); return; }
static public bool capNhatNguoiDungVaoDB(Giao_Vienn nd) { using (QLTTNDataContext qlttn = new QLTTNDataContext()) { try { var nguoiDung = qlttn.NGUOIDUNGs.Where(ndd => ndd.TaiKhoan.Equals(nd.Tai_Khoan)); foreach (var ndd in nguoiDung) { ndd.HoTen = nd.Ho_Ten; ndd.CMND_TCC = nd.CMND_TCC; ndd.NgaySinh = nd.Ngay_Sinh; ndd.SoDienThoai = nd.SDT; ndd.Email = nd.Email; } qlttn.SubmitChanges(); return(true); } catch { return(false); } } }
static public bool capNhatNguoiDungVaoDB(Giao_Vienn nd) { return(DAO_Giao_Vien.capNhatNguoiDungVaoDB(nd)); }
public static void InsertTeacher(Giao_Vienn Teacher) { DAO_Admin.InsertTeacherWithLinq(Teacher); }