예제 #1
0
        public ActionResult ChangeProfile(gov_person item)
        {
            if (Request.Cookies["Cookie_Student_" + item.id.ToString()] == null)
            {
                return Redirect("/cuu-sinh-vien/cuu-sinh-vien-tieu-bieu/" + item.id.ToString() + "/xac-nhan-mat-ma");
            }
            gov_person personInfo = _cnttDB.gov_person.Find(item.id);
            personInfo.full_name = item.full_name;
            personInfo.specialized_id = item.specialized_id;
            personInfo.course_id = item.course_id;
            personInfo.lop = item.lop;
            personInfo.phone = item.phone;
            personInfo.email = item.email;
            personInfo.address = item.address;
            personInfo.department = item.department;
            personInfo.description = item.description;
            personInfo.show_address = item.show_address;
            personInfo.show_department = item.show_department;
            personInfo.show_email = item.show_email;
            personInfo.show_shared = item.show_shared;
            personInfo.show_tel = item.show_tel;
            personInfo.update_datetime = DateTime.Now;
            personInfo.active_flg = false;
            if (Request.Files.Count > 0)
            {
                var fileName = string.Empty;
                var file = Request.Files[0];
                var bytes = new byte[file.ContentLength];
                if (bytes.Length > 0)
                {
                    String dirAvatarOld = personInfo.avatar;
                    file.InputStream.Read(bytes, 0, file.ContentLength);
                    fileName = (file.FileName.IndexOf('\\') != -1 ? file.FileName.Substring(file.FileName.LastIndexOf('\\') + 1) : file.FileName);

                    var fileFolder = fileSaveFolder;
                    var fileDir = Server.MapPath("/") + fileFolder;
                    if (!System.IO.Directory.Exists(fileDir))
                        System.IO.Directory.CreateDirectory(fileDir);
                    var filePath = fileFolder + "\\" + fileName.Substring(0, fileName.LastIndexOf(".")) + "_" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + fileName.Substring(fileName.LastIndexOf("."));
                    System.IO.File.WriteAllBytes(Server.MapPath("/") + filePath, bytes);
                    personInfo.avatar = filePath.Replace("\\", "/");
                    if (System.IO.File.Exists(Server.MapPath(dirAvatarOld)) && !dirAvatarOld.Equals(Constant.AVATAR_DEFAULT))
                    {
                        System.IO.File.Delete(Server.MapPath(dirAvatarOld));
                    }
                }
            }
            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.ManagerStudent))
                    {
                        try
                        {
                            gov_message_system messageInfo = new gov_message_system();
                            messageInfo.entry_datetime = DateTime.Now;
                            messageInfo.type_message = Constant.MESSAGE_TYPE_STUDENT;
                            messageInfo.status = false;
                            messageInfo.content_message = "<strong>" + personInfo.full_name + "</strong>" + Constant.MESSAGE_EDIT_STUDENT;
                            messageInfo.username = user.username;
                            messageInfo.link = "/admin/student/index";
                            _cnttDB.gov_message_system.Add(messageInfo);
                            _cnttDB.SaveChanges();
                        }
                        catch (Exception ex)
                        {
                            ViewData["err"] = "Đã có lỗi xảy ra. Đăng ký thông tin thất bại!";
                        }
                    }
                }
                ViewData["message"] = "Thay đổi thông tin cựu sinh viên thành công! Thông tin cựu sinh viên của bạn sẽ được kiểm duyệt lại trước khi cho hiển thị lên website!";
                var c = new HttpCookie("Cookie_Student_" + item.id.ToString());
                c.Expires = DateTime.Now.AddDays(-1);
                Response.Cookies.Add(c);
            }
            return View("Success");
        }
예제 #2
0
        public ActionResult Regist(gov_person personInfo, String captcha)
        {
            if (Request.Files.Count > 0)
            {
                var fileName = string.Empty;
                var file = Request.Files[0];
                var bytes = new byte[file.ContentLength];
                if (bytes.Length > 0)
                {
                    file.InputStream.Read(bytes, 0, file.ContentLength);
                    fileName = (file.FileName.IndexOf('\\') != -1 ? file.FileName.Substring(file.FileName.LastIndexOf('\\') + 1) : file.FileName);

                    var fileFolder = fileSaveFolder;
                    var fileDir = Server.MapPath("/") + fileFolder;
                    if (!System.IO.Directory.Exists(fileDir))
                        System.IO.Directory.CreateDirectory(fileDir);
                    var filePath = fileFolder + "\\" + fileName.Substring(0, fileName.LastIndexOf(".")) + "_" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + fileName.Substring(fileName.LastIndexOf("."));
                    System.IO.File.WriteAllBytes(Server.MapPath("/") + filePath, bytes);
                    personInfo.avatar = filePath.Replace("\\", "/");
                }
            }

            personInfo.code = captcha;
            personInfo.entry_datetime = DateTime.Now;
            personInfo.update_datetime = DateTime.Now;
            personInfo.active_flg = false;
            personInfo = _cnttDB.gov_person.Add(personInfo);
            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.ManagerStudent))
                    {
                        try
                        {
                            gov_message_system messageInfo = new gov_message_system();
                            messageInfo.entry_datetime = DateTime.Now;
                            messageInfo.type_message = Constant.MESSAGE_TYPE_STUDENT;
                            messageInfo.status = false;
                            messageInfo.content_message = "<strong>" + personInfo.full_name + "</strong>" + Constant.MESSAGE_COMMENT_STUDENT;
                            messageInfo.username = user.username;
                            messageInfo.link = "/admin/student/index";
                            _cnttDB.gov_message_system.Add(messageInfo);
                            _cnttDB.SaveChanges();
                        }
                        catch (Exception ex)
                        {
                            ViewData["message"] = "Đã có lỗi xảy ra. Đăng ký thông tin thất bại!";
                        }
                    }
                }
                ViewData["message"] = "Đăng ký thông tin thành công. Thông tin cựu sinh viên của bạn sẽ được kiểm duyệt trước khi cho hiển thị lên website!";
            }
            ViewData["lstCourse"] = _cnttDB.gov_course.OrderByDescending(c => c.course_name).ToList();
            ViewData["lstSpecialized"] = _cnttDB.gov_specialized.OrderBy(c => c.specialized_name).ToList();
            return View();
        }
예제 #3
0
 public ActionResult SaveEdit(gov_person item)
 {
     if (Session.getCurrentUser() == null)
         return Redirect("/admin/account/logon");
     if (!SercurityServices.HasPermission((int)TypeModule.MODULE_CUUSINHVIEN, Session.getCurrentUser().username, TypeAudit.ManagerStudent))
     {
         return Redirect("/admin/error/error403");
     }
     gov_person personInfo = _cnttDB.gov_person.Find(item.id);
     personInfo.full_name = item.full_name;
     personInfo.specialized_id = item.specialized_id;
     personInfo.course_id = item.course_id;
     personInfo.lop = item.lop;
     personInfo.phone = item.phone;
     personInfo.email = item.email;
     personInfo.address = item.address;
     personInfo.avatar = item.avatar;
     personInfo.department = item.department;
     personInfo.description = item.description;
     personInfo.show_address = item.show_address;
     personInfo.show_department = item.show_department;
     personInfo.show_email = item.show_email;
     personInfo.show_shared = item.show_shared;
     personInfo.show_tel = item.show_tel;
     personInfo.code = item.code;
     personInfo.update_datetime = DateTime.Now;
     try
     {
         int rs = _cnttDB.SaveChanges();
         if (rs > 0)
         {
             insertHistory(AccessType.chinhSuaCuuSinhVien, Constant.CHINHSUA(Constant.ITEM_CUUSINHVIEN, 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");
 }
예제 #4
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.ManagerStudent))
     {
         return Redirect("/admin/error/error403");
     }
     gov_person item = new gov_person();
     item = _cnttDB.gov_person.Find(id);
     if (item != null)
     {
         try {
             _cnttDB.gov_person.Remove(item);
             int rs = _cnttDB.SaveChanges();
             if (rs > 0)
             {
                 insertHistory(AccessType.xoaCuuSinhVien, Constant.XOA(Constant.ITEM_CUUSINHVIEN, 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");
 }
예제 #5
0
 public ActionResult saveRegist(gov_person item) {
     if (Session.getCurrentUser() == null)
         return Redirect("/admin/account/logon");
     if (!SercurityServices.HasPermission((int)TypeModule.MODULE_CUUSINHVIEN, Session.getCurrentUser().username, TypeAudit.ManagerStudent))
     {
         return Redirect("/admin/error/error403");
     }
     item.active_flg = true;
     item.update_datetime = DateTime.Now;
     _cnttDB.gov_person.Add(item);
     int rs = _cnttDB.SaveChanges();
     if (rs > 0)
     {
         insertHistory(AccessType.themMoiCuuSinhVien, Constant.THEM(Constant.ITEM_CUUSINHVIEN, Constant.ID, item.id.ToString()));
     }
     return Redirect("Index");
 }