//Đă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(); } }
//Xem Thông Tin Cá Nhân private void btnInformation_Click(object sender, EventArgs e) { frmThong_Tin thong_Tin = new frmThong_Tin(); thong_Tin.hs_new = hs; thong_Tin.ShowDialog(); hs = BUS_Tai_Khoan.layThongTinTaiKhoan(hs.Tai_Khoan) as Hoc_Sinhh; }
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 UpdateStudent(Hoc_Sinhh Student, string Student_User_Account) { if (Student.Tai_Khoan == Student_User_Account) { DAO_Admin.UpdateStudent(Student); MessageBox.Show("Update Success"); } else { MessageBox.Show("You Can't Change The Name Account Of User!"); } }
//Lưu Thông Tin private void btnSave_Click(object sender, EventArgs e) { Disable(); Hoc_Sinhh hs_new = new Hoc_Sinhh(); hs_new.Tai_Khoan = txtSudent_code.Text; hs_new.Ho_Ten = txtStudent_Name.Text; hs_new.CMND_TCC = txtCMND.Text; hs_new.Email = txtStudent_email.Text; hs_new.SDT = txtStudent_phone_number.Text; hs_new.Ngay_Sinh = dpStudent_birth_date.Value; hs_new.Lop = txtStudent_class.Text; BUS_Hoc_Sinh.Sua_Thong_Tin(hs_new); }
public static void Sua_Thong_Tin(Hoc_Sinhh hs_new) { using (var QLTTN = new QLTTNDataContext()) { var Querry = from _hs_ in QLTTN.NGUOIDUNGs where _hs_.TaiKhoan == hs_new.Tai_Khoan select _hs_; Querry.First().HoTen = hs_new.Ho_Ten; Querry.First().CMND_TCC = hs_new.CMND_TCC; Querry.First().Email = hs_new.Email; Querry.First().NgaySinh = hs_new.Ngay_Sinh; Querry.First().SoDienThoai = hs_new.SDT; Querry.First().MaLop = BUS_Hoc_Sinh.ID_Lop(hs_new.Lop); QLTTN.SubmitChanges(); } }
private void btnUpdate_student_Click(object sender, EventArgs e) { Hoc_Sinhh Student = new Hoc_Sinhh() { Ho_Ten = txtFull_name_student.Text, Tai_Khoan = txtUser_name_student.Text, Mat_Khau = txtUser_name_student.Text, CMND_TCC = txtCMND_TCC_student.Text, Lop = listClasses[Class_CBB.SelectedIndex].ClassID, Khoi = null, Email = txtMail_student.Text, SDT = txtSDT_student.Text, Ngay_Sinh = DateTime.Parse(dtStudent_Picker.Value.ToString()) }; BUS_Admin.UpdateStudent(Student, Student_User_Account); }
public static void UpdateStudent(Hoc_Sinhh Student) { using (var dataContext = new QLTTNDataContext()) { var data = dataContext.NGUOIDUNGs.Where(nd => nd.TaiKhoan.Equals(Student.Tai_Khoan)).Select(nd => nd).Single(); data.TaiKhoan = Student.Tai_Khoan; data.MatKhau = Student.Mat_Khau; data.MaKhoi = Student.Khoi; data.MaLop = Student.Lop; data.HoTen = Student.Ho_Ten; data.CMND_TCC = Student.CMND_TCC; data.NgaySinh = Student.Ngay_Sinh; data.SoDienThoai = Student.SDT; data.Email = Student.Email; dataContext.SubmitChanges(); } }
public static void InsertStudentWithLinq(Hoc_Sinhh Student) { using (QLTTNDataContext dataContext = new QLTTNDataContext()) { NGUOIDUNG newUser = new NGUOIDUNG() { TaiKhoan = Student.Tai_Khoan, MatKhau = Student.Mat_Khau, MaKhoi = Student.Khoi, MaLop = Student.Lop, HoTen = Student.Ho_Ten, CMND_TCC = Student.CMND_TCC, NgaySinh = Student.Ngay_Sinh, SoDienThoai = Student.SDT, Email = Student.Email, MaPhanQuyen = "HS" }; dataContext.NGUOIDUNGs.InsertOnSubmit(newUser); dataContext.SubmitChanges(); } }
private void btnAdd_student_Click(object sender, EventArgs e) { if (ValidateChildren(ValidationConstraints.Enabled)) { Hoc_Sinhh Student = new Hoc_Sinhh() { Ho_Ten = txtFull_name_student.Text, Tai_Khoan = txtUser_name_student.Text, Mat_Khau = txtUser_name_student.Text, CMND_TCC = txtCMND_TCC_student.Text, Lop = listClasses[Class_CBB.SelectedIndex].ClassID, Khoi = null, Email = txtMail_student.Text, SDT = txtSDT_student.Text, Ngay_Sinh = DateTime.Parse(dtStudent_Picker.Value.ToString()) }; BUS_Admin.InsertStudent(Student); MessageBox.Show("Add Student Success!"); } MessageBox.Show("Add Student Failed!"); return; }
private void frmHoc_Sinh_Load(object sender, EventArgs e) { controlStudent.TabPages.Clear(); hs = BUS_Tai_Khoan.layThongTinTaiKhoan(hs.Tai_Khoan) as Hoc_Sinhh; }
public static void Sua_Thong_Tin(Hoc_Sinhh hs_new) { DAO_Hoc_Sinh.Sua_Thong_Tin(hs_new); }
public static void InsertStudent(Hoc_Sinhh Student) { DAO_Admin.InsertStudentWithLinq(Student); }