Ejemplo n.º 1
0
        public bool kiemtra(LO_TRINH model)
        {
            var             lt  = new LO_TRINH_DAO();
            List <LO_TRINH> ltr = lt.list();

            foreach (LO_TRINH a in ltr)
            {
                if (a.MS_TUYEN == model.MS_TUYEN && a.NGAYDI == model.NGAYDI && a.GIO == model.GIO && a.BSXE == model.BSXE)
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
        public ActionResult Create(LO_TRINH model)
        {
            var dao1 = new XE_KHACH_DAO();

            model.GHE_TRONG = dao1.Tim(model.BSXE).SOCHO;
            if (ModelState.IsValid)
            {
                if (Session["Ten_NV"] != null)
                {
                    ViewBag.Ten_NV = Session["Ten_NV"].ToString();
                }
                if (Session["CHUCVU_NV"] != null)
                {
                    ViewBag.CHUCVU_NV = Session["CHUCVU_NV"].ToString();
                }
                if (Session["Email_NV"] != null)
                {
                    ViewBag.Email_NV = Session["Email_NV"].ToString();
                }
                if (ViewBag.CHUCVU_NV == "GIAMDOC")
                {
                    var dao = new LO_TRINH_DAO();
                    if (dao.kiemtra(model))
                    {
                        ModelState.AddModelError("", "Lộ trình đã tồn tại");
                    }
                    else
                    {
                        int ma = dao.AddLoTrinh(model);
                        if (ma != 0)
                        {
                            ModelState.AddModelError("", "Thêm thành công lộ trình");
                            // return RedirectToAction("Index", "ADTuyenDuong");
                        }
                        else
                        {
                            ModelState.AddModelError("", "Thêm thất bại lộ trình");
                        }
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Bạn không có quyền admin");
                }
            }
            setViewBag();
            return(View(model));
        }
Ejemplo n.º 3
0
 public ActionResult Edit(LO_TRINH model)
 {
     if (ModelState.IsValid)
     {
         if (Session["Ten_NV"] != null)
         {
             ViewBag.Ten_NV = Session["Ten_NV"].ToString();
         }
         if (Session["CHUCVU_NV"] != null)
         {
             ViewBag.CHUCVU_NV = Session["CHUCVU_NV"].ToString();
         }
         if (Session["Email_NV"] != null)
         {
             ViewBag.Email_NV = Session["Email_NV"].ToString();
         }
         if (ViewBag.CHUCVU_NV == "GIAMDOC")
         {
             var dao = new LO_TRINH_DAO();
             if (dao.kiemtra(model))
             {
                 ModelState.AddModelError("", "Lộ trình đã tồn tại");
             }
             else
             {
                 bool kq = dao.UpdateLoTrinh(model);
                 if (kq)
                 {
                     ModelState.AddModelError("", "cập nhật thành công lộ trình");
                     //return RedirectToAction("Index", "ADTuyenDuong");
                 }
                 else
                 {
                     ModelState.AddModelError("", "cập nhật thất bại lộ trình");
                 }
             }
         }
         else
         {
             ModelState.AddModelError("", "Bạn không có quyền admin");
         }
     }
     setViewBag();
     return(View(model));
 }
Ejemplo n.º 4
0
 public bool UpdateLoTrinh(LO_TRINH model)
 {
     try
     {
         var td = context.LO_TRINH.Find(model.MA_LT);
         td.MS_TUYEN  = model.MS_TUYEN;
         td.BSXE      = model.BSXE;
         td.NGAYDI    = model.NGAYDI;
         td.GIO       = model.GIO;
         td.GHE_TRONG = model.GHE_TRONG;
         context.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Ejemplo n.º 5
0
        public ActionResult Edit(int MaLT)
        {
            if (Session["Ten_NV"] != null)
            {
                ViewBag.Ten_NV = Session["Ten_NV"].ToString();
            }
            if (Session["CHUCVU_NV"] != null)
            {
                ViewBag.CHUCVU_NV = Session["CHUCVU_NV"].ToString();
            }
            if (Session["Email_NV"] != null)
            {
                ViewBag.Email_NV = Session["Email_NV"].ToString();
            }
            var      td   = new LO_TRINH_DAO();
            LO_TRINH mode = td.TimMaLT(MaLT);

            setViewBag();
            return(View(mode));
        }
Ejemplo n.º 6
0
 public int AddLoTrinh(LO_TRINH model)
 {
     context.LO_TRINH.Add(model);
     context.SaveChanges();
     return(model.MA_LT);
 }