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");
 }
Пример #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 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");
        }
Пример #4
0
 public Boolean comment(String fullName, String email, String commentContent, int newsId, int idParent)
 {
     /*CommentServices commentServices = new CommentServices();
     CommentModels commentModels = new CommentModels();
     commentModels.ParentId = idParent;
     commentModels.NewsId = newsId;
     commentModels.FullName = fullName;
     commentModels.Email = email;
     commentModels.CommentsContent = commentContent;
     commentModels.TotalLike = 0;
     commentModels.ActiveFlg = true;
     commentModels.EntryDatetime = DateTime.Now;
     int rs = commentServices.insert(commentModels);*/
     gov_comments commentInfo = new gov_comments();
     commentInfo.parent_id = idParent;
     commentInfo.news_id = newsId;
     commentInfo.full_name= fullName;
     commentInfo.email = email;
     commentInfo.comments_content = commentContent;
     commentInfo.total_like = 0;
     commentInfo.active_flg = false;
     commentInfo.entry_datetime = DateTime.Now;
     commentInfo = _cnttDB.gov_comments.Add(commentInfo);
     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_TINTUC, user.username, TypeAudit.ManagerComment))
             {
                 try
                 {
                     gov_message_system messageInfo = new gov_message_system();
                     messageInfo.entry_datetime = DateTime.Now;
                     messageInfo.type_message = Constant.MESSAGE_TYPE_COMMENT;
                     messageInfo.status = false;
                     messageInfo.content_message = "<strong>" + fullName + "</strong>" + Constant.MESSAGE_COMMENT_CONTENT;
                     messageInfo.username = user.username;
                     messageInfo.link = "/admin/comment/index";
                     _cnttDB.gov_message_system.Add(messageInfo);
                     _cnttDB.SaveChanges();
                 }
                 catch (Exception ex)
                 {
                     return false;
                 }
             }
         }
         return true;
     }
     return false;
 }