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));
        }
 public LoiModel(CMT cmt, GIAYKHAISINH giaykhaisinh, BANGTOTNGHIEP bangtotnghiep, HOCBA hocba)
 {
     this.cmt           = cmt;
     this.giaykhaisinh  = giaykhaisinh;
     this.bangtotnghiep = bangtotnghiep;
     this.hocba         = hocba;
 }
 public bool sats(GIAYKHAISINH hb)
 {
     if (ModelState.IsValid)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
        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);
                ViewBag.id_hs        = hs.id;
                Session["chuyenTab"] = 3;
                return(View(gks));
            }
            return(RedirectToAction("Index", "Home"));
        }
        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));
            }
        }
        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 ActionResult SuaGKS(GIAYKHAISINH gks)
        {
            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_GKS == gks.id);
                    db.Entry(gks).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    Session["chuyenTab"] = 3;
                    return(RedirectToAction("DetailChung/" + hs.id, "HocSinh"));
                }
                return(View(gks));
            }
            return(RedirectToAction("Index", "Home"));
        }
        public ActionResult DetailGKS()
        {
            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_GKS > 0)
                {
                    ViewBag.ThongbaoGKS = "OK";
                    GIAYKHAISINH gks = db.GIAYKHAISINHs.Find(hocsinh.id_GKS);
                    return(View(gks));
                }
                ViewBag.ThongbaoGKS = "NO";
                return(View());
            }
            return(RedirectToAction("Index", "Home"));
        }
        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);
        }
Exemple #10
0
 public JsonResult UpLoadFileGKS()
 {
     if (System.Web.HttpContext.Current.Request.Files.AllKeys.Any())
     {
         var file = Request.Files["HelpSectionFile"];
         //lưu tên file
         var fileName = Path.GetFileName(file.FileName);
         //lưu đường dẫn
         var path = Path.Combine(Server.MapPath("~/Content/filePDF"), fileName);
         // file is uploaded
         var type = file.ContentType;
         if (System.IO.File.Exists(path))
         {
             ViewBag.Thongbao = "File đã tồn tại";
         }
         else
         {
             if (type == "application/docx" || type == "application/pdf")
             {
                 file.SaveAs(path);
             }
         }
         Session["file"] = fileName;
         if (Session["id_hsDetail"] != null)
         {
             int     id_hs   = (int)Session["id_hsDetail"];
             HOCSINH hocsinh = db.HOCSINHs.Find(id_hs);
             if (hocsinh.id_GKS != null)
             {
                 GIAYKHAISINH gks = db.GIAYKHAISINHs.Find(hocsinh.id_GKS);
                 gks.fileGKS          = fileName;
                 db.Entry(gks).State  = System.Data.Entity.EntityState.Modified;
                 Session["chuyenTab"] = 3;
                 db.SaveChanges();
                 return(Json(hocsinh.id, JsonRequestBehavior.AllowGet));
             }
         }
         return(Json(fileName, JsonRequestBehavior.AllowGet));
     }
     Session["file"] = null;
     return(Json("Khong", JsonRequestBehavior.AllowGet));
 }
Exemple #11
0
 public JsonResult Themmoi(GIAYKHAISINH gks)
 {
     if (ModelState.IsValid)
     {
         if (Session["file"] != null)
         {
             gks.fileGKS = (string)Session["file"];
         }
         db.GIAYKHAISINHs.Add(gks);
         db.SaveChanges();
         //Cập nhật lại bảng học sinh
         int     id_HS   = (int)Session["id_HS"];
         HOCSINH hocsinh = db.HOCSINHs.Find(id_HS);
         hocsinh.id_GKS          = gks.id;
         db.Entry(hocsinh).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(Json("Thêm mới thành công", JsonRequestBehavior.AllowGet));
     }
     return(Json("Thêm mới thất bại", JsonRequestBehavior.AllowGet));
 }
        public ActionResult ThemGiaykhaisinh(GIAYKHAISINH gks)
        {
            if (ModelState.IsValid)
            {
                db.GIAYKHAISINHs.Add(gks);
                db.SaveChanges();
                //Tự động add thêm thông tin GKS 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)
                GIAYKHAISINH newG = db.GIAYKHAISINHs.ToList().Last();
                hs.id_GKS = newG.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(gks));
        }
        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));
        }
 public LoiModel(CMT cmt, GIAYKHAISINH giaykhaisinh)
 {
     this.cmt          = cmt;
     this.giaykhaisinh = giaykhaisinh;
 }
        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"));
        }