예제 #1
0
 public ActionResult SaveEdit(gov_notebook item) {
     if (Session.getCurrentUser() == null)
         return Redirect("/admin/account/logon");
     if (!SercurityServices.HasPermission((int)TypeModule.MODULE_CUUSINHVIEN, Session.getCurrentUser().username, TypeAudit.ManagerNotebook))
     {
         return Redirect("/admin/error/error403");
     }
     gov_notebook notebookInfo = _cnttDB.gov_notebook.Find(item.id);
     notebookInfo.email = item.email;
     notebookInfo.lop = item.lop;
     notebookInfo.specialized_id = item.specialized_id;
     notebookInfo.course_id = item.course_id;
     notebookInfo.note = item.note;
     notebookInfo.remember = item.remember;
     notebookInfo.teacher = item.teacher;
     notebookInfo.title = item.title;
     notebookInfo.dream = item.dream;
     notebookInfo.update_datetime = DateTime.Now;
     try
     {
         int rs = _cnttDB.SaveChanges();
         if (rs > 0)
         {
             insertHistory(AccessType.chinhSuaLuuBut, Constant.CHINHSUA(Constant.ITEM_LUUBUTRATRUONG, Constant.ID, item.id.ToString()));
             TempData["message"] = Constant.EDIT_SUCCESSFULL;
         }
         else
         {
             TempData["err"] = Constant.EDIT_ERR;
         }
     }
     catch (Exception ex)
     {
         TempData["err"] = Constant.EDIT_ERR;
     }
     return Redirect("Index");
 }
 public ActionResult SaveRegist(gov_notebook item)
 {
     item.entry_datetime = DateTime.Now;
     item.update_datetime = DateTime.Now;
     _cnttDB.gov_notebook.Add(item);
     try {
         int rs = _cnttDB.SaveChanges();
         if (rs > 0)
         {
             var lstUser = _cnttDB.gov_user.Where(u => u.active_flg == true).ToList();
             foreach (var user in lstUser)
             {
                 if (SercurityServices.HasPermission((int)TypeModule.MODULE_CUUSINHVIEN, user.username, TypeAudit.ManagerNotebook))
                 {
                     try
                     {
                         gov_message_system messageInfo = new gov_message_system();
                         messageInfo.entry_datetime = DateTime.Now;
                         messageInfo.type_message = Constant.MESSAGE_TYPE_NOTEBOOK;
                         messageInfo.status = false;
                         messageInfo.content_message = "<strong>" + item.email + "</strong>" + Constant.MESSAGE_COMMENT_NOTEBOOK;
                         messageInfo.username = user.username;
                         messageInfo.link = "/admin/notebook/index";
                         _cnttDB.gov_message_system.Add(messageInfo);
                         _cnttDB.SaveChanges();
                     }
                     catch (Exception ex)
                     {
                         ViewData["error"] = "Đã có lỗi xảy ra. Đăng ký thông tin thất bại!";
                     }
                 }
             }
             ViewData["message"] = "Đăng ký lưu bút ra trường thành công. Lưu bút của bạn sẽ được kiểm duyệt trước khi cho hiển thị lên website!";
         }
         else
         {
             ViewData["error"] = "Đăng ký thất bại. Vui lòng thử lại";
         }
     } catch(Exception ex){
         ViewData["error"] = "Đăng ký thất bại. Vui lòng thử lại";
     }
     ViewData["lstCourse"] = _cnttDB.gov_course.OrderByDescending(c => c.course_name).ToList();
     ViewData["lstSpecialized"] = _cnttDB.gov_specialized.OrderBy(c => c.specialized_name).ToList();
     return View("Regist");
 }
예제 #3
0
 public ActionResult delete(int id)
 {
     if (Session.getCurrentUser() == null)
         return Redirect("/admin/account/logon");
     if (!SercurityServices.HasPermission((int)TypeModule.MODULE_CUUSINHVIEN, Session.getCurrentUser().username, TypeAudit.ManagerNotebook))
     {
         return Redirect("/admin/error/error403");
     }
     gov_notebook item = new gov_notebook();
     item = _cnttDB.gov_notebook.Find(id);
     if (item != null)
     {
         try
         {
             _cnttDB.gov_notebook.Remove(item);
             int rs = _cnttDB.SaveChanges();
             if (rs > 0)
             {
                 insertHistory(AccessType.xoaLuuBut, Constant.XOA(Constant.ITEM_LUUBUTRATRUONG, Constant.ID, id.ToString()));
                 TempData["message"] = Constant.DELETE_SUCCESSFULL;
             }
             else
             {
                 TempData["err"] = Constant.DELETE_ERR;
             }
         }
         catch (Exception ex)
         {
             return Redirect("/admin/error/error404");
         }
     }
     else
     {
         return Redirect("/admin/error/error405");
     }
     return Redirect("Index");
 }