コード例 #1
0
        public JsonResult ChinhSuaLoiDanToc(List <string> listKey)
        {
            LoiModel  chitietLoi = new LoiModel();
            int       idLoi      = Int32.Parse(listKey[0]);
            string    DanTocGKS  = listKey[1];
            string    DanTocBTN  = listKey[2];
            string    DanTocHB   = listKey[3];
            TABLE_LOI tableLoi   = db.TABLE_LOI.Find(idLoi);
            string    typeLoi    = tableLoi.TypeLOI;

            if (DanTocGKS != null)
            {
                GIAYKHAISINH gks = db.GIAYKHAISINHs.Find(tableLoi.id_GKS);
                gks.DanToc          = DanTocGKS;
                db.Entry(gks).State = System.Data.Entity.EntityState.Modified;
            }
            if (DanTocBTN != null)
            {
                BANGTOTNGHIEP btn = db.BANGTOTNGHIEPs.Find(tableLoi.id_BTN);
                btn.DanToc          = DanTocBTN;
                db.Entry(btn).State = System.Data.Entity.EntityState.Modified;
            }
            if (DanTocHB != null)
            {
                HOCBA hocba = db.HOCBAs.Find(tableLoi.id_HB);
                hocba.DanToc          = DanTocHB;
                db.Entry(hocba).State = System.Data.Entity.EntityState.Modified;
            }
            db.SaveChanges();
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public ActionResult ChinhSuaLoiDanToc(int id)
        {
            ModelQuyenNguoiDung quyenNguoiDung = Session["QuyenNguoiDung"] as ModelQuyenNguoiDung;

            if (quyenNguoiDung != null && (quyenNguoiDung.Quyen.Ten == "QuanLyThongTinHocSinh" || quyenNguoiDung.Quyen.Ten == "Admin"))
            {
                LoiModel  chitietLoi = new LoiModel();
                TABLE_LOI tableLoi   = db.TABLE_LOI.Find(id);
                string    typeLoi    = tableLoi.TypeLOI;
                ViewBag.typeLoi = typeLoi;
                ViewBag.idLoi   = id;
                Xuly xuly = new Xuly();
                ViewBag.HocSinhLoi = xuly.ReturnHoten(id);
                int id_GKS = tableLoi.id_GKS ?? 0;
                int id_BTN = tableLoi.id_BTN ?? 0;
                int id_HB  = tableLoi.id_HB ?? 0;
                if (check(id_GKS))
                {
                    chitietLoi.Giaykhaisinh = db.GIAYKHAISINHs.Find(id_GKS);
                }
                if (check(id_BTN))
                {
                    chitietLoi.Bangtotnghiep = db.BANGTOTNGHIEPs.Find(id_BTN);
                }
                if (check(id_HB))
                {
                    chitietLoi.Hocba = db.HOCBAs.Find(id_HB);
                }
            }
            return(RedirectToAction("Index", "Home"));
        }
コード例 #3
0
        public ActionResult ChinhSuaLoiQueQuan(int id)
        {
            ModelQuyenNguoiDung quyenNguoiDung = Session["QuyenNguoiDung"] as ModelQuyenNguoiDung;

            if (quyenNguoiDung != null && (quyenNguoiDung.Quyen.Ten == "QuanLyThongTinHocSinh" || quyenNguoiDung.Quyen.Ten == "Admin"))
            {
                LoiModel  chitietLoi = new LoiModel();
                TABLE_LOI tableLoi   = db.TABLE_LOI.Find(id);
                string    typeLoi    = tableLoi.TypeLOI;
                ViewBag.idLoi   = id;
                ViewBag.typeLoi = typeLoi;
                Xuly xuly = new Xuly();
                ViewBag.HocSinhLoi = xuly.ReturnHoten(id);
                int    id_GKS = tableLoi.id_GKS ?? 0;
                string so_CMT = tableLoi.So_CMT ?? null;
                if (check(id_GKS))
                {
                    chitietLoi.Giaykhaisinh = db.GIAYKHAISINHs.Find(id_GKS);
                }
                if (so_CMT != null)
                {
                    chitietLoi.Cmt = db.CMTs.Find(so_CMT);
                }
            }
            return(RedirectToAction("Index", "Home"));
        }
コード例 #4
0
        public bool checkNguoiTao(TABLE_LOI tableLoi, int id_nguoitao)
        {
            if (tableLoi.id_HS != 0 && tableLoi.id_HS != null)
            {
                HOCSINH hs = db.HOCSINHs.Find(tableLoi.id_HS);
                if (hs.NguoiTao == id_nguoitao)
                {
                    return(true);
                }
            }
            string socmt = tableLoi.So_CMT;

            if (socmt != null)
            {
                HOCSINH hs = db.HOCSINHs.SingleOrDefault(n => n.SoCMT == socmt);
                if (hs.NguoiTao == id_nguoitao)
                {
                    return(true);
                }
            }
            int id_gks = tableLoi.id_GKS == null ? 0 : (int)tableLoi.id_GKS;

            if (id_gks != 0)
            {
                HOCSINH hs = db.HOCSINHs.SingleOrDefault(n => n.id_GKS == id_gks);
                if (hs.NguoiTao == id_nguoitao)
                {
                    return(true);
                }
            }
            int id_btn = tableLoi.id_BTN == null ? 0 : (int)tableLoi.id_BTN;

            if (id_btn != 0)
            {
                HOCSINH hs = db.HOCSINHs.SingleOrDefault(n => n.id_BTN == id_btn);
                if (hs.NguoiTao == id_nguoitao)
                {
                    return(true);
                }
            }
            int id_hb = tableLoi.id_HB == null ? 0 : (int)tableLoi.id_HB;

            if (id_hb != 0)
            {
                HOCSINH hs = db.HOCSINHs.SingleOrDefault(n => n.id_HB == id_hb);
                if (hs.NguoiTao == id_nguoitao)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #5
0
        public ActionResult SearchLoi(string keySearchLoi) //tìm kiếm theo tên và loại lỗi
        {
            List <HOCSINH>   list        = db.HOCSINHs.Where(n => n.TenHS.Contains(keySearchLoi)).ToList();
            List <TABLE_LOI> listTbleLoi = db.TABLE_LOI.Where(n => n.TypeLOI.Contains(keySearchLoi)).ToList();

            foreach (var item in list)
            {
                TABLE_LOI tb = db.TABLE_LOI.SingleOrDefault(n => n.id_HS == item.id);
                if (tb != null)
                {
                    listTbleLoi.Add(tb);
                }
            }
            return(View(listTbleLoi));
        }
コード例 #6
0
        public JsonResult ChinhSuaLoiNgaySinh(List <string> listKey)
        {
            try
            {
                LoiModel  chitietLoi = new LoiModel();
                int       idLoi      = Int32.Parse(listKey[0]);
                TABLE_LOI tableLoi   = db.TABLE_LOI.Find(idLoi);
                string    typeLoi    = tableLoi.TypeLOI;
                if (listKey[1] != null)
                {
                    DateTime NgaySinhCMT = DateTime.Parse(listKey[1]);
                    CMT      cmt         = db.CMTs.Find(tableLoi.So_CMT);
                    cmt.NgaySinh        = NgaySinhCMT;
                    db.Entry(cmt).State = EntityState.Modified;
                }

                if (listKey[2] != null)
                {
                    DateTime     NgaySinhGKS = DateTime.Parse(listKey[2]);
                    GIAYKHAISINH gks         = db.GIAYKHAISINHs.Find(tableLoi.id_GKS);
                    gks.NgaySinh        = NgaySinhGKS;
                    db.Entry(gks).State = EntityState.Modified;
                }

                if (listKey[3] != null)
                {
                    DateTime      NgaySinhBTN = DateTime.Parse(listKey[3]);
                    BANGTOTNGHIEP btn         = db.BANGTOTNGHIEPs.Find(tableLoi.id_BTN);
                    btn.NgaySinh        = NgaySinhBTN;
                    db.Entry(btn).State = EntityState.Modified;
                }

                if (listKey[4] != null)
                {
                    DateTime NgaySinhHB = DateTime.Parse(listKey[4]);
                    HOCBA    hocba      = db.HOCBAs.Find(tableLoi.id_HB);
                    hocba.NgaySinh        = NgaySinhHB;
                    db.Entry(hocba).State = EntityState.Modified;
                }
                db.SaveChanges();
                return(Json(true, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json(e, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        public ActionResult ChinhSua(int id)  //id -- mã bên lỗi
        {
            ModelQuyenNguoiDung quyenNguoiDung = Session["QuyenNguoiDung"] as ModelQuyenNguoiDung;

            if (quyenNguoiDung != null && (quyenNguoiDung.Quyen.Ten == "QuanLyThongTinHocSinh" || quyenNguoiDung.Quyen.Ten == "Admin"))
            {
                CapNhatTb();

                LoiModel  chitietLoi = new LoiModel();
                TABLE_LOI tableLoi   = db.TABLE_LOI.Find(id);
                if (checkNguoiTao(tableLoi, quyenNguoiDung.Nhanvien.id) == false)
                {
                    return(RedirectToAction("Index", "Home"));
                }
                string typeLoi = tableLoi.TypeLOI;
                ViewBag.typeLoi = typeLoi;

                if (typeLoi == "HoTen")
                {
                    return(RedirectToAction("ChinhSuaLoiHoTen", new { id = id }));
                }
                if (typeLoi == "NgaySinh")
                {
                    return(RedirectToAction("ChinhSuaLoiNgaySinh", new { id = id }));
                }
                if (typeLoi == "NoiSinh")
                {
                    return(RedirectToAction("ChinhSuaLoiNoiSinh", new { id = id }));
                }
                if (typeLoi == "QueQuan")
                {
                    return(RedirectToAction("ChinhSuaLoiQueQuan", new { id = id }));
                }
                if (typeLoi == "GioiTinh")
                {
                    return(RedirectToAction("ChinhSuaLoiGioiTinh", new { id = id }));
                }
                if (typeLoi == "DanToc")
                {
                    return(RedirectToAction("ChinhSuaLoiDanToc", new { id = id }));
                }
            }
            return(RedirectToAction("Index", "Home"));
        }
コード例 #9
0
        public string ReturnHoten(int id_loi)
        {
            TABLE_LOI tb_loi = db.TABLE_LOI.Find(id_loi);

            if (tb_loi.id_HS > 0)
            {
                HOCSINH hs = db.HOCSINHs.Find(tb_loi.id_HS);
                return(hs.TenHS);
            }
            else
            {
                if (tb_loi.So_CMT != null)
                {
                    CMT cmt = db.CMTs.Find(tb_loi.So_CMT);
                    return(cmt.HoTen);
                }
                else
                {
                    if (tb_loi.id_GKS > 0)
                    {
                        GIAYKHAISINH gks = db.GIAYKHAISINHs.Find(tb_loi.id_GKS);
                        return(gks.HoTen);
                    }
                    else
                    {
                        if (tb_loi.id_BTN > 0)
                        {
                            BANGTOTNGHIEP btn = db.BANGTOTNGHIEPs.Find(tb_loi.id_BTN);
                            return(btn.HoTen);
                        }
                        else
                        {
                            if (tb_loi.id_HB > 0)
                            {
                                HOCBA hb = db.HOCBAs.Find(tb_loi.id_HB);
                                return(hb.HoTen);
                            }
                        }
                    }
                }
            }
            return(null);
        }
コード例 #10
0
        public ActionResult SearchLoi(string keySearchLoi) //tìm kiếm theo tên và loại lỗi
        {
            ModelQuyenNguoiDung quyenNguoiDung = Session["QuyenNguoiDung"] as ModelQuyenNguoiDung;

            if (quyenNguoiDung != null && (quyenNguoiDung.Quyen.Ten == "QuanLyThongTinHocSinh" || quyenNguoiDung.Quyen.Ten == "Admin"))
            {
                List <HOCSINH> list = db.HOCSINHs.Where(n => n.TenHS.Contains(keySearchLoi)).ToList();
                //xet loai loi
                List <TABLE_LOI> listTbleLoi = db.TABLE_LOI.Where(n => n.TypeLOI.Contains(keySearchLoi) && n.NguoiSua == quyenNguoiDung.Nhanvien.id).ToList();
                //xet ten hoc sinh
                foreach (var item in list)
                {
                    TABLE_LOI tb = db.TABLE_LOI.SingleOrDefault(n => n.id_HS == item.id && n.NguoiSua == quyenNguoiDung.Nhanvien.id);
                    if (tb != null)
                    {
                        listTbleLoi.Add(tb);
                    }
                }
                return(View(listTbleLoi));
            }
            return(RedirectToAction("Index", "Home"));
        }
コード例 #11
0
        public JsonResult ChinhSuaLoiQueQuan(List <string> listKey)
        {
            LoiModel  chitietLoi = new LoiModel();
            int       idLoi      = Int32.Parse(listKey[0]);
            string    QueQuanCMT = listKey[1];
            string    QueQuanGKS = listKey[2];
            TABLE_LOI tableLoi   = db.TABLE_LOI.Find(idLoi);
            string    typeLoi    = tableLoi.TypeLOI;

            if (QueQuanCMT != null)
            {
                CMT cmt = db.CMTs.Find(tableLoi.So_CMT);
                cmt.QueQuan         = QueQuanCMT;
                db.Entry(cmt).State = System.Data.Entity.EntityState.Modified;
            }
            if (QueQuanGKS != null)
            {
                GIAYKHAISINH gks = db.GIAYKHAISINHs.Find(tableLoi.id_GKS);
                gks.QueQuan         = QueQuanGKS;
                db.Entry(gks).State = System.Data.Entity.EntityState.Modified;
            }
            db.SaveChanges();
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
コード例 #12
0
        public void Hoten()
        {
            List <HOCSINH>       ListHs  = db.HOCSINHs.ToList();
            List <CMT>           listCMT = db.CMTs.ToList();
            List <HOCBA>         listHB  = db.HOCBAs.ToList();
            List <BANGTOTNGHIEP> listBTN = db.BANGTOTNGHIEPs.ToList();
            List <GIAYKHAISINH>  listGKS = db.GIAYKHAISINHs.ToList();
            var model = from HS in ListHs
                        join cmt in listCMT on HS.SoCMT equals cmt.SoCMT
                        join hb in listHB on HS.id_HB equals hb.id
                        join btn in listBTN on HS.id_BTN equals btn.id
                        join gks in listGKS on HS.id_GKS equals gks.id
                        select new
            {
                id_hs  = HS.id,
                tenHs  = HS.TenHS,
                soCmt  = HS.SoCMT,
                tenCmt = cmt.HoTen,
                id_hb  = HS.id_HB,
                tenHb  = hb.HoTen,
                id_btn = HS.id_BTN,
                tenBtn = btn.HoTen,
                id_gks = HS.id_GKS,
                tenGks = gks.HoTen
            };

            foreach (var i in model.ToList())
            {
                TABLE_LOI tb_loi = new TABLE_LOI();
                if (i.tenHs != i.tenCmt)
                {
                    tb_loi.id_HS  = i.id_hs;
                    tb_loi.id_CMT = i.soCmt;
                }
                if (i.tenHs != i.tenHb)
                {
                    tb_loi.id_HS = i.id_hs;
                    tb_loi.id_HB = i.id_hb;
                }
                if (i.tenHs != i.tenBtn)
                {
                    tb_loi.id_HS  = i.id_hs;
                    tb_loi.id_BTN = i.id_btn;
                }
                if (i.tenGks != i.tenHs)
                {
                    tb_loi.id_HS  = i.id_hs;
                    tb_loi.id_GKS = i.id_gks;
                }
                if (tb_loi.id_HS != null)
                {
                    tb_loi.TyPe      = "HoTen";
                    tb_loi.TrangThai = 1;
                    tb_loi.TimeStart = DateTime.Now;
                    DateTime start = (DateTime)tb_loi.TimeStart;
                    DateTime end   = start.AddDays(5);
                    tb_loi.TimeEnd = end;
                    db.TABLE_LOI.Add(tb_loi);
                    db.SaveChanges();
                }
            }
        }
コード例 #13
0
        public JsonResult ThongBao(int id_loi)
        {
            TABLE_LOI tableLoi = db.TABLE_LOI.Find(id_loi);

            if (tableLoi.id_HS > 0)
            {
                HOCSINH hs = db.HOCSINHs.Find(tableLoi.id_HS);
                if (hs != null && hs.email != null)
                {
                    Senmail senmail = new Senmail();
                    senmail.SendEmail(hs.email, "Hiện tại thông tin bạn đang có sự khác nhau về '" + tableLoi.TypeLOI + "' trên các giấy tờ.\n Vì vậy tôi mong bạn có thể gửi lại thông tin để chúng tôi hoặc bạn có thể đến trực tiếp trung tâm để chỉnh sửa và bạn có thể liên hệ trực tiếp với chúng tôi qua tài khoản gmail này.\n Tôi trân trọng thông báo!!!");
                    tableLoi.Status          = true;
                    db.Entry(tableLoi).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    return(Json("YES", JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                if (tableLoi.So_CMT != null || tableLoi.So_CMT == "")
                {
                    HOCSINH hs = db.HOCSINHs.SingleOrDefault(n => n.SoCMT == tableLoi.So_CMT);
                    if (hs != null && hs.email != null)
                    {
                        Senmail senmail = new Senmail();
                        senmail.SendEmail(hs.email, "Hiện tại thông tin bạn đang có sự khác nhau về '" + tableLoi.TypeLOI + "' trên các giấy tờ.\n Vì vậy tôi mong bạn có thể gửi lại thông tin để chúng tôi hoặc bạn có thể đến trực tiếp trung tâm để chỉnh sửa và bạn có thể liên hệ trực tiếp với chúng tôi qua tài khoản gmail này.\n Tôi trân trọng thông báo!!!");
                        tableLoi.Status          = true;
                        db.Entry(tableLoi).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                        return(Json("YES", JsonRequestBehavior.AllowGet));
                    }
                }
                if (tableLoi.id_GKS > 0)
                {
                    HOCSINH hs = db.HOCSINHs.SingleOrDefault(n => n.id_GKS == tableLoi.id_GKS);
                    if (hs != null && hs.email != null)
                    {
                        Senmail senmail = new Senmail();
                        senmail.SendEmail(hs.email, "Hiện tại thông tin bạn đang có sự khác nhau về '" + tableLoi.TypeLOI + "' trên các giấy tờ.\n Vì vậy tôi mong bạn có thể gửi lại thông tin để chúng tôi hoặc bạn có thể đến trực tiếp trung tâm để chỉnh sửa và bạn có thể liên hệ trực tiếp với chúng tôi qua tài khoản gmail này.\n Tôi trân trọng thông báo!!!");
                        tableLoi.Status          = true;
                        db.Entry(tableLoi).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                        return(Json("YES", JsonRequestBehavior.AllowGet));
                    }
                }
                if (tableLoi.id_BTN > 0)
                {
                    HOCSINH hs = db.HOCSINHs.SingleOrDefault(n => n.id_BTN == tableLoi.id_BTN);
                    if (hs != null && hs.email != null)
                    {
                        Senmail senmail = new Senmail();
                        senmail.SendEmail(hs.email, "Hiện tại thông tin bạn đang có sự khác nhau về '" + tableLoi.TypeLOI + "' trên các giấy tờ.\n Vì vậy tôi mong bạn có thể gửi lại thông tin để chúng tôi hoặc bạn có thể đến trực tiếp trung tâm để chỉnh sửa và bạn có thể liên hệ trực tiếp với chúng tôi qua tài khoản gmail này.\n Tôi trân trọng thông báo!!!");
                        tableLoi.Status          = true;
                        db.Entry(tableLoi).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                        return(Json("YES", JsonRequestBehavior.AllowGet));
                    }
                }
                if (tableLoi.id_HB > 0)
                {
                    HOCSINH hs = db.HOCSINHs.SingleOrDefault(n => n.id_HB == tableLoi.id_HB);
                    if (hs != null && hs.email != null)
                    {
                        Senmail senmail = new Senmail();
                        senmail.SendEmail(hs.email, "Hiện tại thông tin bạn đang có sự khác nhau về '" + tableLoi.TypeLOI + "' trên các giấy tờ.\n Vì vậy tôi mong bạn có thể gửi lại thông tin để chúng tôi hoặc bạn có thể đến trực tiếp trung tâm để chỉnh sửa và bạn có thể liên hệ trực tiếp với chúng tôi qua tài khoản gmail này.\n Tôi trân trọng thông báo!!!");
                        tableLoi.Status          = true;
                        db.Entry(tableLoi).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                        return(Json("YES", JsonRequestBehavior.AllowGet));
                    }
                }
            }
            return(Json("NO", JsonRequestBehavior.AllowGet));
        }
コード例 #14
0
        public ActionResult XoaHocSinh(int id)
        {
            //xóa dữ liệu trong bảng học sinh
            HOCSINH hocsinh = db.HOCSINHs.Find(id);

            db.HOCSINHs.Remove(hocsinh);
            TABLE_LOI tble = db.TABLE_LOI.SingleOrDefault(n => n.id_HS == id);

            if (tble != null)
            {
                db.TABLE_LOI.Remove(tble);
            }
            //xóa các dữ liệu liên quan
            string socmt = hocsinh.SoCMT;

            if (socmt != null)
            {
                CMT       cmt   = db.CMTs.Find(socmt);
                TABLE_LOI tble1 = db.TABLE_LOI.SingleOrDefault(n => n.So_CMT == socmt);
                if (tble1 != null)
                {
                    db.TABLE_LOI.Remove(tble1);
                }
                db.CMTs.Remove(cmt);
            }
            int id_gks = hocsinh.id_GKS == null ? 0 :(int)hocsinh.id_GKS;

            if (id_gks != 0)
            {
                GIAYKHAISINH gks   = db.GIAYKHAISINHs.Find(id_gks);
                TABLE_LOI    tble2 = db.TABLE_LOI.SingleOrDefault(n => n.id_GKS == id_gks);
                if (tble2 != null)
                {
                    db.TABLE_LOI.Remove(tble2);
                }
                db.GIAYKHAISINHs.Remove(gks);
            }
            int id_btn = hocsinh.id_BTN == null ? 0 : (int)hocsinh.id_BTN;

            if (id_btn != 0)
            {
                BANGTOTNGHIEP btn   = db.BANGTOTNGHIEPs.Find(id_btn);
                TABLE_LOI     tble3 = db.TABLE_LOI.SingleOrDefault(n => n.id_BTN == id_btn);
                if (tble3 != null)
                {
                    db.TABLE_LOI.Remove(tble3);
                }
                db.BANGTOTNGHIEPs.Remove(btn);
            }
            int id_hb = hocsinh.id_HB == null ? 0 : (int)hocsinh.id_HB;

            if (id_hb != 0)
            {
                HOCBA     hocba = db.HOCBAs.Find(id_hb);
                TABLE_LOI tble4 = db.TABLE_LOI.SingleOrDefault(n => n.id_HB == id_hb);
                if (tble4 != null)
                {
                    db.TABLE_LOI.Remove(tble4);
                }
                db.HOCBAs.Remove(hocba);
            }
            string socmtNGH = hocsinh.id_NgGiamHo;

            if (socmtNGH != null)
            {
                NGUOIGIAMHO nggiamho = db.NGUOIGIAMHOes.Find(socmtNGH);
                db.NGUOIGIAMHOes.Remove(nggiamho);
            }
            db.SaveChanges();
            return(RedirectToAction("Index", "HocSinh"));
        }