private bool CheckLuaChon() { HOCSINH tg = getHOCSINHByID(); if (tg.ID == 0) { MessageBox.Show("Chưa có học sinh nào được chọn", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } return(true); }
// GET: Admin/HOCSINHs/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } HOCSINH hOCSINH = db.HOCSINHs.Find(id); if (hOCSINH == null) { return(HttpNotFound()); } return(View(hOCSINH)); }
private void btnLuu_Click(object sender, EventArgs e) { try { HOCSINH model = new HOCSINH() { hoten = txtHoTen.Text, ngaysinh = Convert.ToDateTime(dateNS.Text), diachi = txtDiaChi.Text, sdt = txtDienThoai.Text, }; int ID_ = -1; if (txtMaHS.Text != "") { ID_ = int.Parse(txtMaHS.Text.ToString()); } model.mahs = ID_; if (txtMaHS.Text == "") { var result = new HOCSINHF().Insert(model); if (result) { MessageBox.Show("Done"); } else { MessageBox.Show("Lỗi"); } } else { var result = new HOCSINHF().Update(model); if (result) { MessageBox.Show("Done"); } else { MessageBox.Show("Lỗi"); } } Init_(); ClearBinding(); Bindingtxt(); } catch (Exception exp) { MessageBox.Show(exp.Message); } }
private void btnLuu_Click(object sender, EventArgs e) { HOCSINH hs = new HOCSINH() { hoTen = txttenhocsinh.Text, gioiTinh = (rbnam.Checked == true) ? "Nam" : "Nữ", ngaySinh = dtpNgaySinhHS.Value, noiSinh = txtnoisinh.Text, hoTenCha = txthotencha.Text, ngheNghiepCha = txtnghenghiepcha.Text, hoTenMe = txthotenme.Text, ngheNghiepMe = txtnghenghiepme.Text, }; if (lblChucNang.Text.Equals(_THEM_MOI)) { int re_hs = bus_HocSinh.insert(hs); if (re_hs < 1) { MessageBox.Show("Có lỗi trong quá trình Thêm HỌC SINH !!!", "Lỗi", MessageBoxButtons.OK); return; } else { MessageBox.Show("Lưu thành công HỌC SINH !!!", "Thành công", MessageBoxButtons.OK); _Empty_All_Text(); lblChucNang.Text = _KHONG_; _Load_BindingDataSource(); } } else { int idhs = Int32.Parse(txtmahocsinh.Text); hs.maHocSinh = idhs; int re = bus_HocSinh.update(hs); if (re < 1) { MessageBox.Show("Có lỗi trong quá trình Cập nhật HỌC SINH !!!", "Lỗi", MessageBoxButtons.OK); return; } else { MessageBox.Show("Lưu thành công HỌC SINH !!!", "Thành công", MessageBoxButtons.OK); _Empty_All_Text(); lblChucNang.Text = _KHONG_; _Load_BindingDataSource(); } } }
public ActionResult SuaBTN(int id) { ModelQuyenNguoiDung quyenNguoiDung = Session["QuyenNguoiDung"] as ModelQuyenNguoiDung; if (quyenNguoiDung != null && (quyenNguoiDung.Quyen.Ten == "QuanLyThongTinHocSinh" || quyenNguoiDung.Quyen.Ten == "Admin")) { Session["file"] = null; BANGTOTNGHIEP btn = db.BANGTOTNGHIEPs.Find(id); HOCSINH hs = db.HOCSINHs.SingleOrDefault(n => n.id_BTN == btn.id); ViewBag.id_hs = hs.id; Session["chuyenTab"] = 4; return(View(btn)); } return(RedirectToAction("Index", "Home")); }
// Thêm học sinh public static void Insert(string maHS, string hoTen, string gioiTinh, DateTime ngaySinh, string diaChi, string email) { using (SQL_QLHSDataContext db = new SQL_QLHSDataContext()) { HOCSINH hs = new HOCSINH(); hs.MAHS = maHS; hs.HOTEN = hoTen; hs.GIOITINH = gioiTinh; hs.NGAYSINH = ngaySinh; hs.DIACHI = diaChi; hs.EMAIL = email; db.HOCSINHs.InsertOnSubmit(hs); db.SubmitChanges(); } }
static HOCSINH TinhToan_TimHocSinhYeuNhat(HOCSINH[] dsHocSinh) { HOCSINH hsYeuNhat = dsHocSinh[0]; double diemTBThapNhat = dsHocSinh[0].diemTB; foreach (HOCSINH hs in dsHocSinh) { if (hs.diemTB < diemTBThapNhat) { diemTBThapNhat = hs.diemTB; hsYeuNhat = hs; } } return(hsYeuNhat); }
// GET: HOCSINHs/Create public ActionResult Create() { ViewBag.DANTOC_DT_MA = new SelectList(db.DANTOCs, "DT_MA", "DT_TEN"); ViewBag.KHENTHUONG_KT_MA = new SelectList(db.KHENTHUONGs, "KT_MA", "KT_THANHTICH"); ViewBag.KHOI_KHOI_MA = new SelectList(db.KHOIs, "KHOI_MA", "KHOI_TEN"); ViewBag.KYLUAT_KL_MA = new SelectList(db.KYLUATs, "KL_MA", "KL_HINHTHUC"); ViewBag.LOP_LOP_MA = new SelectList(db.LOPs, "LOP_MA", "LOP_TEN"); ViewBag.QUANHUYEN_QH_MA = new SelectList(db.QUANHUYENs, "QH_MA", "QH_TEN"); ViewBag.TINHTHANH_TT_MA = new SelectList(db.TINHTHANHs, "TT_MA", "TT_TEN"); ViewBag.XAPHUONG_XP_MA = new SelectList(db.XAPHUONGs, "XP_MA", "XP_TEN"); HOCSINH obj = new HOCSINH(); obj.HS_MA = CreateID.CreateID_ByteText(); return(View(obj)); }
static HOCSINH TinhToan_TimHocSinhGioiNhat(HOCSINH[] dsHocSinh) { HOCSINH hsGioiNhat = dsHocSinh[0]; double diemTBCaoNhat = dsHocSinh[0].diemTB; foreach (HOCSINH hs in dsHocSinh) { if (hs.diemTB > diemTBCaoNhat) { diemTBCaoNhat = hs.diemTB; hsGioiNhat = hs; } } return(hsGioiNhat); }
private void btnThem_Click(object sender, EventArgs e) { if (btnThem.Text == "Thêm") { btnSua.Enabled = false; btnThem.Text = "Lưu"; btnXoa.Text = "Hủy"; ClearControl(); UnlockControl(); return; } if (btnThem.Text == "Lưu") { if (Check()) { btnThem.Text = "Thêm"; btnXoa.Text = "Xóa"; LockControl(); HOCSINH moi = getHOCSINHByForm(); db.HOCSINHs.Add(moi); try { LOPHOC lop = db.LOPHOCs.Where(p => p.ID == moi.LOPHOCID).FirstOrDefault(); lop.SISO++; db.SaveChanges(); MessageBox.Show("Thêm thông tin học sinh thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("Thêm thông tin học sinh thất bại\n" + ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } LoadDgvHOCSINH(); } return; } }
public ActionResult ThemHocsinh(HOCSINH hocsinh) { if (ModelState.IsValid) { if (hocsinh.TenHS != null) { db.HOCSINHs.Add(hocsinh); db.SaveChanges(); Session["hocsinh"] = hocsinh.TenHS; Session["id_hs"] = hocsinh.id; return(RedirectToAction("Index")); } return(View(hocsinh)); } return(View(hocsinh)); }
public ActionResult SuaCMT(string soCMT, int loaiCMT) { ModelQuyenNguoiDung quyenNguoiDung = Session["QuyenNguoiDung"] as ModelQuyenNguoiDung; if (quyenNguoiDung != null && (quyenNguoiDung.Quyen.Ten == "QuanLyThongTinHocSinh" || quyenNguoiDung.Quyen.Ten == "Admin")) { Session["file"] = null; CMT cmt = db.CMTs.Find(soCMT); ViewBag.LoaiCMT = loaiCMT; HOCSINH hs = db.HOCSINHs.SingleOrDefault(n => n.SoCMT == soCMT); ViewBag.id_hs = hs.id; Session["chuyenTab"] = 2; return(View(cmt)); } return(RedirectToAction("Index", "Home")); }
public ActionResult ThemmoiR(int?id_hs) { ModelQuyenNguoiDung quyenNguoiDung = Session["QuyenNguoiDung"] as ModelQuyenNguoiDung; if (quyenNguoiDung != null && (quyenNguoiDung.Quyen.Ten == "QuanLyThongTinHocSinh" || quyenNguoiDung.Quyen.Ten == "Admin")) { HOCSINH hocsinh = db.HOCSINHs.Find(id_hs); if (quyenNguoiDung.Nhanvien.id == hocsinh.NguoiTao) { Session["file"] = null; Session["id_HS"] = id_hs; return(View()); } } return(RedirectToAction("Index", "Home")); }
private HOCSINH getHOCSINHByID() { try { int id = (int)dgvHOCSINH.GetFocusedRowCellValue("ID"); HOCSINH ans = db.HOCSINHs.Where(p => p.ID == id).FirstOrDefault(); if (ans == null) { return(new HOCSINH()); } return(ans); } catch { return(new HOCSINH()); } }
// Lấy danh sách học sinh đã được phân lớp public static List <HOCSINH> LayDSHocSinhDaPhanLop() { List <HOCSINH> lst = new List <HOCSINH>(); using (SQL_QLHSDataContext db = new SQL_QLHSDataContext()) { var ds = db.sp_LayDSHSDaPhanLop(); foreach (var x in ds) { HOCSINH hs = new HOCSINH(); hs.MAHS = x.MAHS; hs.HOTEN = x.HOTEN; lst.Add(hs); } } return(lst); }
public ActionResult SuaHB(int id) { ModelQuyenNguoiDung quyenNguoiDung = Session["QuyenNguoiDung"] as ModelQuyenNguoiDung; if (quyenNguoiDung != null && (quyenNguoiDung.Quyen.Ten == "QuanLyThongTinHocSinh" || quyenNguoiDung.Quyen.Ten == "Admin")) { HOCBA hb = db.HOCBAs.Find(id); HOCSINH hs = db.HOCSINHs.SingleOrDefault(n => n.id_HB == id); if (quyenNguoiDung.Nhanvien.id == hs.NguoiTao) { ViewBag.id_hs = hs.id; Session["chuyenTab"] = 5; return(View(hb)); } } return(RedirectToAction("Index", "Home")); }
private void btnAdd_Click(object sender, EventArgs e) { HOCSINH hocsinh = new HOCSINH { MaHocSinh = Int32.Parse(txtIDStudent.Text), TenHocSinh = txtFullName.Text, NgaySinh = Convert.ToDateTime(dtNgaySinh.Text), GioiTinh = txtSex.Text, MaLop = Int32.Parse(txtIDClass.Text) }; QLHSDataContext context = new QLHSDataContext(); context.HOCSINHs.InsertOnSubmit(hocsinh); context.SubmitChanges(); context.Dispose(); this.Close(); }
public JsonResult ChinhSuaLoiHoTen(List <string> listKey) { LoiModel chitietLoi = new LoiModel(); int idLoi = Int32.Parse(listKey[0]); string TenHS = listKey[1]; string TenCMT = listKey[2]; string TenGKS = listKey[3]; string TenBTN = listKey[4]; string TenHB = listKey[5]; TABLE_LOI tableLoi = db.TABLE_LOI.Find(idLoi); string typeLoi = tableLoi.TypeLOI; if (TenHS != null) { HOCSINH hocsinh = db.HOCSINHs.Find(tableLoi.id_HS); hocsinh.TenHS = TenHS; db.Entry(hocsinh).State = System.Data.Entity.EntityState.Modified; } if (TenCMT != null) { CMT cmt = db.CMTs.Find(tableLoi.So_CMT); cmt.HoTen = TenCMT; db.Entry(cmt).State = System.Data.Entity.EntityState.Modified; } if (TenGKS != null) { GIAYKHAISINH gks = db.GIAYKHAISINHs.Find(tableLoi.id_GKS); gks.HoTen = TenGKS; db.Entry(gks).State = System.Data.Entity.EntityState.Modified; } if (TenBTN != null) { BANGTOTNGHIEP btn = db.BANGTOTNGHIEPs.Find(tableLoi.id_BTN); btn.HoTen = TenBTN; db.Entry(btn).State = System.Data.Entity.EntityState.Modified; } if (TenHB != null) { HOCBA hocba = db.HOCBAs.Find(tableLoi.id_HB); hocba.HoTen = TenHB; db.Entry(hocba).State = System.Data.Entity.EntityState.Modified; } db.SaveChanges(); return(Json(true, JsonRequestBehavior.AllowGet)); }
public JsonResult XulyHocba(HOCBA hocba) { if (ModelState.IsValid) { db.HOCBAs.Add(hocba); db.SaveChanges(); //Tự động add thêm thông tin hocba vào bảng HOCSINH int id_hs = (int)Session["id_hs"]; HOCSINH hs = db.HOCSINHs.SingleOrDefault(n => n.id == id_hs); HOCBA NewH = db.HOCBAs.ToList().Last(); hs.id_HB = NewH.id; //Lưu lại dữ liệu bảng Học Sinh db.Entry(hs).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(Json(hocba, JsonRequestBehavior.AllowGet)); } return(Json(hocba, JsonRequestBehavior.AllowGet)); }
public ActionResult SuaGKS(int id) { ModelQuyenNguoiDung quyenNguoiDung = Session["QuyenNguoiDung"] as ModelQuyenNguoiDung; if (quyenNguoiDung != null && (quyenNguoiDung.Quyen.Ten == "QuanLyThongTinHocSinh" || quyenNguoiDung.Quyen.Ten == "Admin")) { GIAYKHAISINH gks = db.GIAYKHAISINHs.Find(id); HOCSINH hs = db.HOCSINHs.SingleOrDefault(n => n.id_GKS == id); if (quyenNguoiDung.Nhanvien.id == hs.NguoiTao) { Session["file"] = null; ViewBag.id_hs = hs.id; Session["chuyenTab"] = 3; return(View(gks)); } } return(RedirectToAction("Index", "Home")); }
public ActionResult SuaHocsinh(int id) { ModelQuyenNguoiDung quyenNguoiDung = Session["QuyenNguoiDung"] as ModelQuyenNguoiDung; if (quyenNguoiDung != null && (quyenNguoiDung.Quyen.Ten == "QuanLyThongTinHocSinh" || quyenNguoiDung.Quyen.Ten == "Admin")) { HOCSINH hocsinh = db.HOCSINHs.Find(id); if (quyenNguoiDung.Nhanvien.id == hocsinh.NguoiTao) { return(View(hocsinh)); } else { return(RedirectToAction("Index", "HocSinh")); } } return(RedirectToAction("Index", "Home")); }
private HOCSINH getHOCSINHByForm() { HOCSINH ans = new HOCSINH(); try { ans.MASV = txtMaGV.Text; ans.TEN = txtHoTen.Text; ans.GIOITINH = cbxGioiTinh.SelectedIndex; ans.NGAYSINH = dateNgaySinh.DateTime; ans.QUEQUAN = txtQueQuan.Text; ans.SDT = txtSDT.Text; ans.LOPHOCID = (int)cbxLop.EditValue; } catch { } return(ans); }
public ActionResult Edit([Bind(Include = "MaHS,HoTenHS,GioiTinh,NgaySinh,DiaChi,SDT,NienKhoa,DanToc,TonGiao,MaLop,MaDUT")] HOCSINH diem) { var lop = db.LOPs.ToList(); SelectList listLop = new SelectList(lop, "MaLop", "TenLop"); ViewBag.CatagoryLop = listLop; var DUT = db.DIENUUTIENs.ToList(); SelectList listDut = new SelectList(DUT, "MaDUT", "TenDUT"); ViewBag.CatagoryDut = listDut; if (ModelState.IsValid) { db.Entry(diem).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(diem)); }
public ActionResult SuaHB(HOCBA hb) { ModelQuyenNguoiDung quyenNguoiDung = Session["QuyenNguoiDung"] as ModelQuyenNguoiDung; if (quyenNguoiDung != null && (quyenNguoiDung.Quyen.Ten == "QuanLyThongTinHocSinh" || quyenNguoiDung.Quyen.Ten == "Admin")) { if (ModelState.IsValid) { HOCSINH hs = db.HOCSINHs.SingleOrDefault(n => n.id_HB == hb.id); db.Entry(hb).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); Session["chuyenTab"] = 5; return(RedirectToAction("DetailChung/" + hs.id, "HocSinh")); } return(View(hb)); } return(RedirectToAction("Index", "Home")); }
public ActionResult Edit([Bind(Include = "HS_MA,HS_HOTEN,HS_GIOITINH,HS_NGAYSINH,HS_TONGIAO,TINHTHANH_TT_MA,XAPHUONG_XP_MA,KYLUAT_KL_MA,KHENTHUONG_KT_MA,QUANHUYEN_QH_MA,DANTOC_DT_MA,LOP_LOP_MA,KHOI_KHOI_MA")] HOCSINH hOCSINH) { if (ModelState.IsValid) { db.Entry(hOCSINH).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DANTOC_DT_MA = new SelectList(db.DANTOCs, "DT_MA", "DT_TEN", hOCSINH.DANTOC_DT_MA); ViewBag.KHENTHUONG_KT_MA = new SelectList(db.KHENTHUONGs, "KT_MA", "KT_THANHTICH", hOCSINH.KHENTHUONG_KT_MA); ViewBag.KHOI_KHOI_MA = new SelectList(db.KHOIs, "KHOI_MA", "KHOI_TEN", hOCSINH.KHOI_KHOI_MA); ViewBag.KYLUAT_KL_MA = new SelectList(db.KYLUATs, "KL_MA", "KL_HINHTHUC", hOCSINH.KYLUAT_KL_MA); ViewBag.LOP_LOP_MA = new SelectList(db.LOPs, "LOP_MA", "LOP_TEN", hOCSINH.LOP_LOP_MA); ViewBag.QUANHUYEN_QH_MA = new SelectList(db.QUANHUYENs, "QH_MA", "QH_TEN", hOCSINH.QUANHUYEN_QH_MA); ViewBag.TINHTHANH_TT_MA = new SelectList(db.TINHTHANHs, "TT_MA", "TT_TEN", hOCSINH.TINHTHANH_TT_MA); ViewBag.XAPHUONG_XP_MA = new SelectList(db.XAPHUONGs, "XP_MA", "XP_TEN", hOCSINH.XAPHUONG_XP_MA); return(View(hOCSINH)); }
public ActionResult ThemBangtotnghiep(BANGTOTNGHIEP bangTN) { if (ModelState.IsValid) { db.BANGTOTNGHIEPs.Add(bangTN); db.SaveChanges(); //Tự động add thêm thông tin bangtotnghiep vào bảng HOCSINH int id_hs = (int)Session["id_hs"]; HOCSINH hs = db.HOCSINHs.SingleOrDefault(n => n.id == id_hs); //dua ra giay khai sinh vua them vào (nam ơ vi tri cuoi cung) BANGTOTNGHIEP newB = db.BANGTOTNGHIEPs.ToList().Last(); hs.id_BTN = newB.id; //Lưu lại dữ liệu bảng Học Sinh db.Entry(hs).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(bangTN)); }
public ActionResult DetailBTN() { ModelQuyenNguoiDung quyenNguoiDung = Session["QuyenNguoiDung"] as ModelQuyenNguoiDung; if (quyenNguoiDung != null && (quyenNguoiDung.Quyen.Ten == "QuanLyThongTinHocSinh" || quyenNguoiDung.Quyen.Ten == "Admin")) { int id_hs = (int)Session["id_hsDetail"]; HOCSINH hocsinh = db.HOCSINHs.Find(id_hs); if (hocsinh.id_BTN > 0) { ViewBag.ThongbaoBTN = "OK"; BANGTOTNGHIEP btn = db.BANGTOTNGHIEPs.SingleOrDefault(n => n.id == hocsinh.id_BTN); return(View(btn)); } ViewBag.ThongbaoBTN = "NO"; return(View()); } return(RedirectToAction("Index", "Home")); }
public ActionResult DetailGCT() { ModelQuyenNguoiDung quyenNguoiDung = Session["QuyenNguoiDung"] as ModelQuyenNguoiDung; if (quyenNguoiDung != null && (quyenNguoiDung.Quyen.Ten == "QuanLyThongTinHocSinh" || quyenNguoiDung.Quyen.Ten == "Admin")) { int id_hs = (int)Session["id_hsDetail"]; HOCSINH hocsinh = db.HOCSINHs.Find(id_hs); List <GIAYCHUNGTHUC> listGiay = db.GIAYCHUNGTHUCs.Where(n => n.id_HSHS == hocsinh.id).ToList(); if (listGiay.Count > 0) { ViewBag.ThongbaoBTN = "OK"; return(View(listGiay)); } ViewBag.ThongbaoBTN = "NO"; return(View()); } return(RedirectToAction("Index", "Home")); }
//Cập nhật public bool Update(HOCSINH model) { HOCSINH dbEntry = context.HOCSINHs.Find(model.mahs); if (dbEntry == null) { return(false); } dbEntry.mahs = model.mahs; dbEntry.hoten = model.hoten; dbEntry.malop = model.malop; dbEntry.ngaysinh = model.ngaysinh; dbEntry.diachi = model.diachi; dbEntry.sdt = model.sdt; dbEntry.hotencha = model.hotencha; dbEntry.hotenme = model.hotenme; context.SaveChanges(); return(true); }
public ActionResult SuaNGH(string soCMT, int loaiCMT) { ModelQuyenNguoiDung quyenNguoiDung = Session["QuyenNguoiDung"] as ModelQuyenNguoiDung; if (quyenNguoiDung != null && (quyenNguoiDung.Quyen.Ten == "QuanLyThongTinHocSinh" || quyenNguoiDung.Quyen.Ten == "Admin")) { Session["file"] = null; NGUOIGIAMHO nggiamho = db.NGUOIGIAMHOes.Find(soCMT); ViewBag.LoaiCMT = loaiCMT; HOCSINH hs = db.HOCSINHs.SingleOrDefault(n => n.id_NgGiamHo == soCMT); if (hs != null && quyenNguoiDung.Nhanvien.id == hs.NguoiTao) { ViewBag.id_hs = hs.id; Session["chuyenTab"] = 6; return(View(nggiamho)); } } return(RedirectToAction("Index", "Home")); }