Exemplo n.º 1
0
 public ActionResult Create(Document model, HttpPostedFileBase dataFile)
 {
     try
     {
         if (dataFile != null && dataFile.ContentLength > 0)
         {
             byte[] bf = new byte[dataFile.ContentLength];
             dataFile.InputStream.Read(bf, 0, dataFile.ContentLength);
             model.Data       = bf;
             model.CreateBy   = HttpContext.User.Identity.Name;
             model.CreateDate = DateTime.Now;
             documentSrv.CreateNew(model);
             documentSrv.CommitChanges();
             Messages.AddFlashMessage("Tạo mới văn bản pháp quy thành công");
             logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Document - Create :" + model.Id, "Create Document Success", LogType.Success, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
             return(RedirectToAction("Index"));
         }
         Messages.AddErrorFlashMessage("Chưa chọn file văn bản.");
         return(View(model));
     }
     catch (Exception e)
     {
         logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Document - Create", "Create Document Error : " + e, LogType.Error, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
         Messages.AddErrorMessage("Có lỗi trong quá trình xử lý, vui lòng thực hiện lại.");
         return(View(model));
     }
 }
Exemplo n.º 2
0
        public ActionResult Delete(int roleid)
        {
            if (roleid <= 0)
            {
                throw new HttpRequestValidationException();
            }
            IroleService _RoleSrc = IoC.Resolve <IroleService>();
            role         model    = _RoleSrc.Getbykey(roleid);

            if (model == null)
            {
                Messages.AddErrorFlashMessage("Role không tồn tại, không thể xóa.");
                return(RedirectToAction("Index"));
            }
            if (model.name == "Root")
            {
                Messages.AddErrorFlashMessage("Không thể xóa role này.");
                return(RedirectToAction("Index"));
            }
            try
            {
                _RoleSrc.Delete(model);
                _RoleSrc.CommitChanges();
                Messages.AddFlashMessage("Xóa role thành công.");
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Role - Delete : " + roleid, "Edit Role Success : " + " NameRole " + model.name, LogType.Success, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
            }
            catch (Exception ex)
            {
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Role - Delete : " + roleid, "Edit Role Error : " + ex, LogType.Success, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);

                Messages.AddErrorFlashMessage("Có lỗi xảy ra, vui lòng thực hiện lại.");
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        public ActionResult Delete(int id)
        {
            if (id <= 0)
            {
                throw new HttpRequestValidationException();
            }
            string        ErrorMessage = "";
            IStaffService _staSrv      = IoC.Resolve <IStaffService>();
            Staff         model        = _staSrv.Getbykey(id);

            if (model.AccountName == HttpContext.User.Identity.Name)
            {
                Messages.AddErrorFlashMessage("Tài khoản của nhân viên này đang đăng nhập lên không thể xóa!");
                return(RedirectToAction("Index"));
            }
            if (_staSrv.DeleteStaff(id, out ErrorMessage) == true)
            {
                log.Info("Delete staff by: " + HttpContext.User.Identity.Name + " Info-- ID: " + id.ToString());
                Messages.AddFlashMessage(Resources.Message.Staff_DMesSuccess);
            }
            else
            {
                Messages.AddErrorFlashMessage(Resources.Message.Staff_DMesUnsuccess);
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 4
0
        public ActionResult Create(Staff model)
        {
            if (string.IsNullOrWhiteSpace(model.FullName) || string.IsNullOrWhiteSpace(model.AccountName))
            {
                Messages.AddErrorMessage("Cần nhập các thông tin bắt buộc!");
                return(View(model));
            }
            IStaffService _staSrv = IoC.Resolve <IStaffService>();

            if (_staSrv.Query.Where(p => p.AccountName.ToUpper() == model.AccountName.Trim().ToUpper()).Count() > 0)
            {
                Messages.AddErrorMessage("Tồn tại tài khoản trên hệ thống.");
                return(View("Create", model));
            }
            Company _currentCom  = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            string  ErrorMessage = "";

            if (_staSrv.CreateStaff(model, _currentCom.id, out ErrorMessage) == true)
            {
                log.Info("Create staff by: " + HttpContext.User.Identity.Name + " Info-- TenNhanVien: " + model.FullName + " TaiKhoanNhanVien: " + model.AccountName + " Email: " + model.Email);
                Messages.AddFlashMessage(Resources.Message.Staff_IMesSuccess);
                return(RedirectToAction("Index"));
            }
            else
            {
                Messages.AddErrorMessage("Lỗi: " + ErrorMessage);
                return(View(model));
            }
        }
Exemplo n.º 5
0
 public ActionResult SelectSendAgain(string[] cbid)
 {
     try
     {
         if (cbid == null)
         {
             Messages.AddErrorFlashMessage("Bạn chưa chọn mail để gửi lại");
             return(RedirectToAction("Index"));
         }
         int i = 0;
         foreach (string itemId in cbid)
         {
             SendMail model = _SendmailSvc.Getbykey(Guid.Parse(itemId));
             if (ChangeStatusMail(model, "0") == true)
             {
                 i++;
             }
         }
         if (i > 0)
         {
             Messages.AddFlashMessage("Hệ thống đang gửi lại: " + i + " mail!");
             return(RedirectToAction("Index", new { status = 3 }));
         }
         else
         {
             Messages.AddErrorFlashMessage("Mail đang chờ để gửi, không cần gửi lại.");
         }
     }
     catch (Exception ex)
     {
         log.Error(" SelectSendAgain -" + ex.Message);
         Messages.AddErrorFlashMessage("Có lỗi xảy ra, vui lòng thực hiện lại!");
     }
     return(RedirectToAction("Index"));
 }
Exemplo n.º 6
0
 public ActionResult SendAgain(Guid id)
 {
     if (id == Guid.Empty)
     {
         throw new HttpRequestValidationException();
     }
     try
     {
         SendMail model = _SendmailSvc.Getbykey(id);
         TryUpdateModel(model);
         if (ChangeStatusMail(model, "1") == true)
         {
             Messages.AddFlashMessage("Hệ thống đang gửi lại mail!");
             return(RedirectToAction("Index", new { EmailTo = model.Email }));
         }
         _SendmailSvc.Update(model);
         _SendmailSvc.CommitChanges();
         log.Info("SendAgain Email by: " + HttpContext.User.Identity.Name);
     }
     catch (Exception ex)
     {
         log.Error(" Index -" + ex);
         Messages.AddErrorFlashMessage("Có lỗi xảy ra, vui lòng thực hiện lại!");
     }
     return(RedirectToAction("Index"));
 }
Exemplo n.º 7
0
        public ActionResult Create(Category cate)
        {
            try
            {
                ICategoryService cateSrv = IoC.Resolve <ICategoryService>();

                int c = cateSrv.Query.Where(p => p.NameVNI == cate.NameVNI || p.NameENG == cate.NameENG || p.UrlName == cate.UrlName).Count();
                if (c > 0)
                {
                    Messages.AddErrorMessage("Tiêu đề hoặc đường dẫn cho chuyên mục đã tồn tại.");
                    CategoryModels model = new CategoryModels();
                    model.ArtCategory    = cate;
                    model.ParentCategory = cateSrv.Query.Where(p => p.ParentID == 0).OrderBy(p => p.NameVNI).ThenBy(p => p.NameENG).ToList();
                    return(View(model));
                }
                cate.CreatedBy = HttpContext.User.Identity.Name;
                cateSrv.CreateNew(cate);
                cateSrv.CommitChanges();
                Messages.AddFlashMessage("Thêm mới thành công.");
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Category - Create :" + cate.Id, "Create Category Success", LogType.Success, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Category - Create :" + cate.Id, "Create Category Error :" + ex, LogType.Error, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
                Messages.AddErrorMessage("Có lỗi xảy ra, vui lòng thực hiện lại.");
                ICategoryService artCateSrv = IoC.Resolve <ICategoryService>();
                CategoryModels   model      = new CategoryModels();
                model.ArtCategory    = cate;
                model.ParentCategory = artCateSrv.Query.Where(p => p.ParentID == 0).OrderBy(p => p.NameVNI).ThenBy(p => p.NameENG).ToList();
                return(View(model));
            }
        }
Exemplo n.º 8
0
 public ActionResult Delete(int id)
 {
     try
     {
         ICategoryService cateSrv = IoC.Resolve <ICategoryService>();
         IArticlesService artSrv  = IoC.Resolve <IArticlesService>();
         int c = artSrv.Query.Where(p => p.CategoryID == id).Count();
         if (c > 0)
         {
             Messages.AddErrorFlashMessage("Không được xóa chuyên mục đang sử dụng.");
             logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Category - Xóa :" + id, "Không được xóa chuyên mục đang sử dụng", LogType.Error, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
             return(RedirectToAction("Index"));
         }
         Category cate = cateSrv.Getbykey(id);
         cateSrv.Delete(cate);
         cateSrv.CommitChanges();
         Messages.AddFlashMessage("Xóa thành công.");
         logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Category - Delete :" + id, "Edit Category Success", LogType.Success, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
     }
     catch (Exception ex)
     {
         logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Category - Delete :" + id, "Delete Category Error: " + ex, LogType.Error, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
         Messages.AddErrorFlashMessage("Chưa xóa được, vui lòng thực hiện lại.");
     }
     return(RedirectToAction("Index"));
 }
Exemplo n.º 9
0
        public ActionResult Delete(int id)
        {
            IRBACMembershipProvider _MemberShipProvider = IoC.Resolve <IRBACMembershipProvider>();
            IRBACRoleProvider       _RoleProvider       = IoC.Resolve <IRBACRoleProvider>();

            try
            {
                user     model = _MemberShipProvider.GetUser(id, false);
                string[] roles = _RoleProvider.GetRolesForUser(model.userid);
                if (model.username.ToUpper() == HttpContext.User.Identity.Name.ToUpper() || roles.Contains("ServiceRole"))
                {
                    Messages.AddErrorFlashMessage("Không được xóa tài khoản đang sử dụng.");
                    return(RedirectToAction("index"));
                }
                if (!_MemberShipProvider.DeleteUser(model.userid, true))
                {
                    Messages.AddErrorFlashMessage("Chưa xóa được tài khoản.");
                }
                else
                {
                    Messages.AddFlashMessage("Xóa tài khoản thành công!");
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                Messages.AddErrorFlashMessage("Có lỗi xảy ra, vui lòng thực hiện lại.");
            }
            return(RedirectToAction("index"));
        }
Exemplo n.º 10
0
        public ActionResult Update(int id)
        {
            if (id <= 0)
            {
                throw new HttpRequestValidationException();
            }
            IStaffService _staSrv = IoC.Resolve <IStaffService>();
            var           model   = _staSrv.Getbykey(id);

            try
            {
                TryUpdateModel <Staff>(model);
                _staSrv.Save(model);
                _staSrv.CommitChanges();
                log.Info("Edit staff by: " + HttpContext.User.Identity.Name + " Info-- TenNhanVien: " + model.FullName + " TaiKhoanNhanVien: " + model.AccountName + " Email: " + model.Email);
                Messages.AddFlashMessage(Resources.Message.Staff_UMesSuccess);
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                log.Error("Edit-" + ex);
                Messages.AddErrorMessage(Resources.Message.Staff_UMesUnsuccess);
                return(View("Edit", model));
            }
        }
Exemplo n.º 11
0
        public ActionResult Edit(int id, HttpPostedFileBase dataFile)
        {
            var model = documentSrv.Getbykey(id);

            try
            {
                TryUpdateModel <Document>(model);
                if (dataFile != null && dataFile.ContentLength > 0)
                {
                    byte[] bf = new byte[dataFile.ContentLength];
                    dataFile.InputStream.Read(bf, 0, dataFile.ContentLength);
                    model.Data = bf;
                }
                model.CreateBy   = HttpContext.User.Identity.Name;
                model.CreateDate = DateTime.Now;
                documentSrv.Save(model);
                documentSrv.CommitChanges();
                Messages.AddFlashMessage("Sửa văn bản pháp quy thành công");
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Document - Edit :" + id, "Edit Document Success", LogType.Success, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Document - Edit :" + id, "Edit Document Error : " + e, LogType.Error, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
                Messages.AddErrorMessage("Có lỗi trong quá trình xử lý, vui lòng thực hiện lại.");
                return(View(model));
            }
        }
Exemplo n.º 12
0
        public ActionResult Delete(int id)
        {
            try
            {
                IVideosService videoSrv = IoC.Resolve <IVideosService>();
                Videos         video    = videoSrv.Getbykey(id);
                string[]       vpath    = video.VideoPath.Split('/');
                var            filePath = ConfigurationSettings.AppSettings.Get("PhysicalSiteDataDirectory") + "/video/" + vpath[vpath.Length - 1];

                if (System.IO.File.Exists(filePath))
                {
                    System.IO.File.Delete(filePath);
                }
                videoSrv.Delete(video);
                videoSrv.CommitChanges();
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Video - Delete : " + id, "Delete Video Success", LogType.Success, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
                Messages.AddFlashMessage("Xóa thành công.");
            }
            catch (Exception ex)
            {
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "Video - Delete : " + id, "Delete Video Error : " + ex, LogType.Error, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
                Messages.AddErrorMessage("Chưa xóa được, vui lòng thực hiện lại.");
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 13
0
        public ActionResult Delete(int id)
        {
            try
            {
                IVideoTypeService typeSrv  = IoC.Resolve <IVideoTypeService>();
                IVideosService    videoSrv = IoC.Resolve <IVideosService>();
                int c = videoSrv.Query.Where(p => p.VideoTypeID == id).Count();
                if (c > 0)
                {
                    Messages.AddErrorFlashMessage("Không được xóa chuyên mục đang sử dụng.");
                    return(RedirectToAction("Index"));
                }
                VideoType type = typeSrv.Getbykey(id);
                typeSrv.Delete(type);
                typeSrv.CommitChanges();
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "VideoType - Delete : " + id, "Delete VideoType Success", LogType.Success, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);

                Messages.AddFlashMessage("Xóa thành công.");
            }
            catch (Exception ex)
            {
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "VideoType - Delete : " + id, "Delete VideoType Error " + ex, LogType.Error, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);

                Messages.AddErrorMessage("Chưa xóa được, vui lòng thực hiện lại.");
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 14
0
        public ActionResult Delete(string Pattern, int id)
        {
            if (id <= 0)
            {
                throw new HttpRequestValidationException();
            }
            log.Debug("Access - Delete");
            Company         currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            IInvoiceService IInvSrv    = InvServiceFactory.GetService(Pattern, currentCom.id);
            IInvoice        model      = IInvSrv.Getbykey <IInvoice>(id);

            try
            {
                string ErrorMessage = "";
                if (IInvSrv.DeleteInvoice(model, out ErrorMessage) == true)
                {
                    log.Info("Delete EInvoice by: " + HttpContext.User.Identity.Name + " Info-- ID: " + model.id + "Pattern: " + model.Pattern + " Serial: " + model.Serial + " SoHoaDon: " + model.No.ToString() + " TenKhachHang: " + model.CusName + " MaKhachHang: " + model.CusCode + " SoTien: " + model.Amount);
                    Messages.AddFlashMessage("Xóa hóa đơn thành công.");
                    log.Info("Delete successfull id =" + id);
                }
                else
                {
                    Messages.AddErrorFlashMessage(ErrorMessage);
                }
            }
            catch (Exception ex)
            {
                log.Error(" Delete-" + ex.Message);
            }
            return(RedirectToAction("Index", new { Pattern = Pattern, Serial = model.Serial }));
        }
Exemplo n.º 15
0
        public ActionResult Edit(string Name, int id)
        {
            if (id <= 0)
            {
                throw new HttpRequestValidationException();
            }
            IMenusService menuSrv = IoC.Resolve <IMenusService>();
            Menu          model   = menuSrv.Getbykey(id);

            try
            {
                TryUpdateModel <Menu>(model);
                model.Name = Name;
                menuSrv.Save(model);
                menuSrv.CommitChanges();
                Messages.AddFlashMessage("Cập nhật thành công!");
                log.Info("Update menu by:" + HttpContext.User.Identity.Name + ", Date:" + DateTime.Now);
                MenuModels.ResetMenu();
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                log.Error("Update menu error", ex);
                ViewBag.ParentMenus = menuSrv.GetParent(model.ComID);
                Messages.AddErrorMessage("Có lỗi trong quá trình xử lý, vui lòng thực hiện lại!");
                return(View(model));
            }
        }
Exemplo n.º 16
0
        public ActionResult Create([Bind(Exclude = "Id")] FileResource fileResource, HttpPostedFileBase fileData, int[] roleIds, string categoryids)
        {
            BindCategoriesAndRoles(fileResource, categoryids, roleIds);

            if (fileData != null && fileData.ContentLength > 0)
            {
                fileResource.Section          = CurrentSection;
                fileResource.FileName         = fileData.FileName;
                fileResource.PhysicalFilePath = Path.Combine(this._module.FileDir, fileResource.FileName);
                fileResource.Length           = fileData.ContentLength;
                fileResource.MimeType         = fileData.ContentType;

                if (ValidateModel(fileResource, new[] { "Title", "Summary", "FileName", "PublishedAt", "PublishedUntil" }))
                {
                    try
                    {
                        this._fileResourceService.SaveFileResource(fileResource, fileData.InputStream);
                        Messages.AddFlashMessage("FileSavedMessage");
                        return(RedirectToAction("Index", "ManageFiles", GetNodeAndSectionParams()));
                    }
                    catch (Exception ex)
                    {
                        Messages.AddException(ex);
                    }
                }
            }
            else
            {
                Messages.AddErrorMessage("NoFileUploadedMessage");
            }
            ViewData["Roles"] = this._userService.GetAllRolesBySite(CuyahogaContext.CurrentSite);
            return(View("New", GetModuleAdminViewModel(fileResource)));
        }
Exemplo n.º 17
0
 public ActionResult Upload(HttpPostedFileBase FilePath)
 {
     try
     {
         IPaymentTransactionService tranSrv = IoC.Resolve <IPaymentTransactionService>();
         Company currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany;
         if (FilePath != null && FilePath.ContentLength > 0)
         {
             byte[] bf = new byte[FilePath.ContentLength];
             FilePath.InputStream.Read(bf, 0, FilePath.ContentLength);
             if (!FilePath.FileName.ToLower().Contains(".xls"))
             {
                 Messages.AddErrorFlashMessage("File upload phải là file .xls hoặc .XLS!");
                 return(RedirectToAction("Upload"));
             }
             Guid guid = Guid.NewGuid();
             //thanh toan theo lo
             PaymentTransaction mTran = paymentViaBlock(bf);
             tranSrv.CreateNew(mTran);
             tranSrv.CommitChanges();
             Messages.AddFlashMessage("Upload file và gạch nợ xong, mã giao dịch: " + mTran.id);
             return(RedirectToAction("PaymentTransactionIndex"));
         }
         Messages.AddErrorFlashMessage("Chọn file cần upload!");
         return(RedirectToAction("Upload"));
     }
     catch (Exception ex)
     {
         Messages.AddErrorMessage("Có lỗi xảy ra, vui lòng kiểm tra log để biết thêm chi tiết.");
         return(View("Upload"));
     }
 }
Exemplo n.º 18
0
        public ActionResult CopyPage(int nodeId, int newParentNodeId)
        {
            Node newNode = this._nodeService.CopyNode(nodeId, newParentNodeId);

            Messages.AddFlashMessage("PageCopiedMessage");
            return(RedirectToAction("Index", new { id = newNode.Id }));
        }
Exemplo n.º 19
0
        public ActionResult Delete(int id)
        {
            if (id <= 0)
            {
                throw new HttpRequestValidationException();
            }
            IRBACMembershipProvider _MemberShipProvider = IoC.Resolve <IRBACMembershipProvider>();
            user model = _MemberShipProvider.GetUser(id, false);

            if (HttpContext.User.Identity.Name.ToUpper() == model.username.ToUpper())
            {
                Messages.AddErrorFlashMessage("Không thể xóa tài khoản đang sử dụng!");
                return(RedirectToAction("index"));
            }
            if (!_MemberShipProvider.DeleteUser(id, true))
            {
                Messages.AddErrorFlashMessage("Chưa xóa được tài khoản.");
            }
            else
            {
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "User - Delete : " + string.Format("Delete: {0} by {1}", model.username, HttpContext.User.Identity.Name), "Delete User Success ", LogType.Success, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);


                Messages.AddFlashMessage("Xóa tài khoản thành công!");
            }
            return(RedirectToAction("index"));
        }
Exemplo n.º 20
0
        public ActionResult Uninstall(string moduleName)
        {
            ModuleType moduleType = this._moduleTypeService.GetModuleByName(moduleName);
            // First check if there are no sections attached
            IList <Section> sectionsByModuleType = this._sectionService.GetSectionsByModuleType(moduleType);

            if (sectionsByModuleType.Count > 0)
            {
                StringBuilder messageBuilder = new StringBuilder();
                messageBuilder.Append(GetText("UninstallModuleForbiddenBecauseOfRelatedSectionsMessage"));
                messageBuilder.Append(":<br />");
                foreach (var section in sectionsByModuleType)
                {
                    messageBuilder.AppendFormat("{0} ({1})<br />", section.Title, section.Id);
                }
                Messages.AddFlashMessage(messageBuilder.ToString());
            }
            else
            {
                try
                {
                    DatabaseInstaller dbInstaller = GetDbInstallerForModuleType(moduleType);
                    dbInstaller.Uninstall();
                    Messages.AddFlashMessageWithParams("ModuleUninstalledMessage", moduleName);
                }
                catch (Exception ex)
                {
                    Messages.AddFlashException(ex);
                }
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 21
0
        public ActionResult Delete(int roleid)
        {
            if (roleid <= 0)
            {
                throw new HttpRequestValidationException();
            }
            IroleService _RoleSrc = IoC.Resolve <IroleService>();
            role         model    = _RoleSrc.Getbykey(roleid);

            if (model == null)
            {
                Messages.AddErrorFlashMessage("Role không tồn tại, không thể xóa.");
                return(RedirectToAction("Index"));
            }
            if (model.name == "Admin" || model.name == "ServiceRole")
            {
                Messages.AddErrorFlashMessage("Không thể xóa role này.");
                return(RedirectToAction("Index"));
            }
            try
            {
                _RoleSrc.Delete(model);
                _RoleSrc.CommitChanges();
                Messages.AddFlashMessage("Xóa role thành công.");
                log.Info("Delete Role by:" + HttpContext.User.Identity.Name + " Info--id " + model.roleid + " NameRole " + model.name);
            }
            catch (Exception ex)
            {
                log.Error("Delete Role-" + ex);
                Messages.AddErrorFlashMessage("Có lỗi xảy ra, vui lòng thực hiện lại.");
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 22
0
        public ActionResult DeleteDecision(int id)
        {
            if (id <= 0)
            {
                throw new HttpRequestValidationException();
            }
            IDecisionService decSrc = IoC.Resolve <IDecisionService>();
            Decision         model  = decSrc.Getbykey(id);

            try
            {
                if (model.Status == 0)
                {
                    decSrc.Delete(model);
                    decSrc.CommitChanges();
                    Messages.AddFlashMessage(Resources.Message.Dec_DMesSuccess);
                    log.Info("Delete Decision by: " + HttpContext.User.Identity.Name);
                }
                else
                {
                    Messages.AddFlashMessage(Resources.Message.Dec_DMesCantDel);
                }
            }
            catch (Exception ex)
            {
                Messages.AddErrorFlashMessage(Resources.Message.Dec_DMesUnsuccess);
                log.Error("DeleteDecision -" + ex);
            }
            return(RedirectToAction("ListDecision"));
        }
Exemplo n.º 23
0
        public ActionResult Delete(int id)
        {
            Company currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            IRegisterTempService   registerTempSrv = IoC.Resolve <IRegisterTempService>();
            IPublishInvoiceService publishInvSrv   = IoC.Resolve <IPublishInvoiceService>();

            try
            {
                if (publishInvSrv.GetPubOfReg(id, currentCom.id).Count > 0)
                {
                    Messages.AddErrorFlashMessage("Không được xóa mẫu hóa đơn đang sử dụng.");
                    return(RedirectToAction("Index"));
                }
                RegisterTemp model = registerTempSrv.Getbykey(id);
                registerTempSrv.Delete(model);
                registerTempSrv.CommitChanges();
                Messages.AddFlashMessage("Xóa mẫu hóa đơn thành công.");
            }
            catch (Exception ex)
            {
                log.Error(ex);
                Messages.AddErrorFlashMessage("Có lỗi xảy ra, vui lòng thực hiện lại.");
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 24
0
        public ActionResult Update(int id, HttpPostedFileBase fileData, int[] roleIds, string categoryids)
        {
            FileResource fileResource = this._contentItemService.GetById(id);

            BindCategoriesAndRoles(fileResource, categoryids, roleIds);

            if (TryUpdateModel(fileResource, new[] { "Title", "Summary", "PublishedAt", "PublishedUntil" }) &&
                ValidateModel(fileResource, new[] { "Title", "Summary", "PublishedAt", "PublishedUntil" }))
            {
                try
                {
                    if (fileData != null && fileData.ContentLength > 0)
                    {
                        fileResource.FileName         = fileData.FileName;
                        fileResource.PhysicalFilePath = Path.Combine(this._module.FileDir, fileResource.FileName);
                        fileResource.Length           = fileData.ContentLength;
                        fileResource.MimeType         = fileData.ContentType;
                        this._fileResourceService.SaveFileResource(fileResource, fileData.InputStream);
                    }
                    else
                    {
                        this._fileResourceService.UpdateFileResource(fileResource);
                    }
                    Messages.AddFlashMessage("FileSavedMessage");
                    return(RedirectToAction("Index", "ManageFiles", GetNodeAndSectionParams()));
                }
                catch (Exception ex)
                {
                    Messages.AddException(ex);
                }
            }

            ViewData["Roles"] = this._userService.GetAllRolesBySite(CuyahogaContext.CurrentSite);
            return(View("Edit", GetModuleAdminViewModel(fileResource)));
        }
Exemplo n.º 25
0
        public ActionResult Create(VideoType type)
        {
            try
            {
                IVideoTypeService typeSrv = IoC.Resolve <IVideoTypeService>();
                var c = typeSrv.Query.Where(p => p.NameVNI == type.NameVNI || p.NameENG == type.NameENG).Count();
                if (c > 0)
                {
                    Messages.AddErrorMessage("Tiêu đề tin tức đã tồn tại");
                    VideoTypeModels model = new VideoTypeModels();
                    model.ArtVideoType = type;
                    return(View(model));
                }
                type.UrlName   = FX.Utils.Common.TextHelper.ToUrlFriendly(type.NameVNI);
                type.CreatedBy = HttpContext.User.Identity.Name;
                typeSrv.CreateNew(type);
                typeSrv.CommitChanges();
                Messages.AddFlashMessage("Thêm mới thành công.");
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "VideoType - Create", "Create VideoType Success", LogType.Success, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "VideoType - Create", "Create VideoType Error : " + ex, LogType.Error, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);
                Messages.AddErrorMessage("Có lỗi xảy ra, vui lòng thực hiện lại.");
                VideoTypeModels model = new VideoTypeModels();
                model.ArtVideoType = type;
                return(View(model));
            }
        }
Exemplo n.º 26
0
        public ActionResult Update(int userid, string RetypePassword, string[] AssignRoles)
        {
            if (userid <= 0)
            {
                throw new HttpRequestValidationException();
            }
            IRBACRoleProvider       _RoleProvider       = IoC.Resolve <IRBACRoleProvider>();
            IRBACMembershipProvider _MemberShipProvider = IoC.Resolve <IRBACMembershipProvider>();
            AccountModels           model = new AccountModels();
            user   _model      = _MemberShipProvider.GetUser(userid, false);
            string oldpassHash = _model.password;

            //giu lai username khong cho sua
            string username = _model.username;

            try
            {
                TryUpdateModel(_model);
                if (_model.username != username)
                {
                    throw new HttpRequestValidationException();
                }
                AssignRoles = AssignRoles ?? new string[] { };
                if (_model.password != RetypePassword)
                {
                    List <String> lst = new List <string>(_RoleProvider.GetAllRoles());
                    model.RetypePassword = _model.password = oldpassHash;
                    model.AllRoles       = lst.ToArray();
                    model.UserRoles      = _RoleProvider.GetRolesForUser(_model.username);
                    model.tmpUser        = _model;
                    Messages.AddErrorMessage("Nhập đúng mật khẩu của bạn.");
                    return(View("Edit", model));
                }
                if (RetypePassword != oldpassHash)
                {
                    _model.password = FormsAuthentication.HashPasswordForStoringInConfigFile(RetypePassword, "MD5");
                }
                _model.FailedPasswordAttemptCount = 0;
                _MemberShipProvider.UpdateUser(_model);
                _RoleProvider.UpdateUsersToRoles(_model.username, AssignRoles);
                Messages.AddFlashMessage("Cập nhật thông tin thành công.");

                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "User - Update : " + string.Format("Update: {0} by {1}", _model.username, HttpContext.User.Identity.Name), "Update User Success ", LogType.Success, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);

                return(RedirectToAction("index"));
            }
            catch (Exception ex)
            {
                logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "User - Update ", "Update User Error " + ex, LogType.Error, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser);

                List <String> lst = new List <string>(_RoleProvider.GetAllRoles());
                model.RetypePassword = _model.password = oldpassHash;
                model.AllRoles       = lst.ToArray();
                model.UserRoles      = _RoleProvider.GetRolesForUser(_model.username);
                model.tmpUser        = _model;
                Messages.AddErrorMessage("Có lỗi xảy ra, vui lòng thực hiện lại!");
                return(View("Edit", model));
            }
        }
Exemplo n.º 27
0
        public ActionResult Approve(int id)
        {
            IArticlesService artSrv = IoC.Resolve <IArticlesService>();
            Articles         model  = artSrv.Getbykey(id);

            model.Active = true;
            Messages.AddFlashMessage("Tin đã được chỉnh sửa thành công.");
            return(View(model));
        }
Exemplo n.º 28
0
        public bool LaunchCollectInvoice(string FromDate, string ToDate, string pattern, string serial)
        {
            DateTime?DateFrom = null;
            DateTime?DateTo   = null;

            if (!string.IsNullOrWhiteSpace(FromDate))
            {
                DateFrom = DateTime.ParseExact(FromDate, "dd/MM/yyyy", null);
            }
            if (!string.IsNullOrWhiteSpace(ToDate))
            {
                DateTo = DateTime.ParseExact(ToDate, "dd/MM/yyyy", null);
            }
            try
            {
                Company         currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany;
                IInvoiceService IInvSrv    = InvServiceFactory.GetService(pattern, currentCom.id);
                // chỉ tìm NewInv
                int totalRecords             = 0;
                IList <IInvoice> listInvoice = IInvSrv.SearchInvoice(currentCom.id, pattern, serial, DateFrom, DateTo, 0, 0, out totalRecords, InvoiceStatus.NewInv);
                if (listInvoice.Count > 0)
                {
                    //edit phat hanh hoa don 03/07/2014
                    int[]  ids           = listInvoice.Select(c => c.id).ToArray();
                    string resultMessage = "";
                    LaunchInvoices.Instance.Launch(ids, pattern, serial, out resultMessage);
                    log.Info("Publish EInvoice by: " + HttpContext.User.Identity.Name + " Info-- Pattern: " + pattern + " Serial: " + serial + " SoLuongPhatHanh: " + listInvoice.Count.ToString());
                    if (resultMessage.Contains("OK"))
                    {
                        Messages.AddFlashMessage(resultMessage);
                    }
                    else if (resultMessage.Contains("ERR:14"))
                    {
                        Messages.AddErrorFlashMessage("Có lô hóa đơn khác đang được phát hành, xin vui lòng thực hiện lại.");
                    }
                    else
                    {
                        Messages.AddErrorFlashMessage(resultMessage);
                    }
                    log.Info("Launch Result: " + resultMessage);
                }
                else
                {
                    Messages.AddErrorFlashMessage("Không có hóa đơn mới tạo.");
                    return(false);
                }
                return(true);
            }
            catch (Exception ex)
            {
                Messages.AddErrorFlashMessage("Có lỗi xảy ra, vui lòng thực hiện lại.");
                log.Error(" LaunchCollectInvoice -:" + ex);
                return(false);
            }
        }
Exemplo n.º 29
0
        public ActionResult EditDecision(DecisionModels model)
        {
            if (model.id <= 0)
            {
                throw new HttpRequestValidationException();
            }
            IDecisionService decSrc = IoC.Resolve <IDecisionService>();

            try
            {
                Decision oDec = model.UpdateDecision(new Decision());

                //lấy thông tin về mẫu hóa đơn
                IList <Pupor> lstp       = (IList <Pupor>)model.DecDatasource.DeserializeJSON <Pupor>(typeof(IList <Pupor>));
                string        json       = "<Root>";
                string        lstPattern = "";
                foreach (Pupor p in lstp)
                {
                    json       += "<Purpose>" + p.Mucdich + "</Purpose>";
                    lstPattern += p.InvPattern + ',';
                }
                json               += "</Root>";
                lstPattern          = lstPattern.Remove(lstPattern.Length - 1, 1);
                oDec.ListInvPattern = lstPattern;
                oDec.Purpose        = json;
                //end

                //oDec.EffectiveDate = DateTime.ParseExact(Request["EffectiveDate"], "dd/MM/yyyy", null);
                decSrc.Save(oDec);
                decSrc.CommitChanges();
                Messages.AddFlashMessage(Resources.Message.Dec_UMesSuccess);
                log.Info("EditDecision by: " + HttpContext.User.Identity.Name);
                return(RedirectToAction("ListDecision"));
            }
            catch (HttpRequestValidationException ex)
            {
                return(Redirect("/Home/PotentiallyError"));
            }
            catch (ArgumentException ex)
            {
                return(Redirect("/Home/PotentiallyError"));
            }
            catch (Exception ex)
            {
                ICompanyService      _comSrv         = IoC.Resolve <ICompanyService>();
                Company              _currentcompany = _comSrv.Getbykey(((EInvoiceContext)FXContext.Current).CurrentCompany.id);
                IRegisterTempService regisSrc        = IoC.Resolve <IRegisterTempService>();
                model.RegTempList = new SelectList(from re in regisSrc.Query where re.ComId == _currentcompany.id select re, "InvPattern", "InvPattern");
                Messages.AddErrorMessage(Resources.Message.Dec_UMesUnsuccess);
                log.Error(" EditDecision -" + ex.Message);
                return(View(model));
            }
        }
Exemplo n.º 30
0
        public ActionResult CancelInvApprove(string[] cbeinv, string hdPattern, string Serial)
        {
            Company         currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            IInvoiceService IInvSrv    = InvServiceFactory.GetService(hdPattern, currentCom.id);

            try
            {
                int[] invIds = (from s in cbeinv select Convert.ToInt32(s)).ToArray();
                if (invIds.Length < 0)
                {
                    Messages.AddErrorMessage("Bạn chưa chọn hóa đơn để hủy.");
                    return(RedirectToAction("CancelInvNotReIndex", new { Pattern = hdPattern, Serial = Serial }));
                }
                ILogSystemService businessLog = IoC.Resolve <ILogSystemService>();
                IList <IInvoice>  invLst      = IInvSrv.GetByID(currentCom.id, invIds);
                int succCount = 0;
                IInvSrv.BeginTran();
                var context = (EInvoiceContext)FXContext.Current;
                foreach (var item in invIds)
                {
                    IInvoice Oinvoice = IInvSrv.GetByID(currentCom.id, hdPattern, item);
                    if (Oinvoice.Status == InvoiceStatus.CanceledInv || Oinvoice.Status == InvoiceStatus.ReplacedInv || Oinvoice.Status == InvoiceStatus.AdjustedInv)
                    {
                        continue;
                    }
                    succCount++;
                    Oinvoice.Status = InvoiceStatus.CanceledInv;
                    Oinvoice.Note  += "  || Thực hiện hủy Hóa đơn (Không thay thế):   Người hủy:" + context.CurrentUser.username + "   Ngày hủy:" + DateTime.Now.ToString();
                    IInvSrv.Update(Oinvoice);
                    log.Info("INVCANCEL_" + context.CurrentUser.username + "_" + hdPattern + "_" + Oinvoice.Serial + "_" + Oinvoice.No + "_" + DateTime.Now);
                    businessLog.WriteLogCancel(currentCom.id, context.CurrentUser.username, Oinvoice.Pattern, Oinvoice.Serial, Oinvoice.No.ToString("0000000"), Oinvoice.ArisingDate, Oinvoice.Amount, Oinvoice.CusName, Oinvoice.CusAddress, Oinvoice.CusCode, Oinvoice.CusTaxCode, BusinessLogType.Cancel);
                }
                if (succCount == 0)
                {
                    Messages.AddErrorFlashMessage("Kiểm tra lại hóa đơn hủy, có thể đã được thanh toán hoặc sửa đổi.");
                }
                else
                {
                    IInvSrv.CommitTran();
                    Messages.AddFlashMessage("Tổng số hóa đơn hủy là:" + succCount);
                }
                return(RedirectToAction("CancelInvNotReIndex", new { Pattern = hdPattern, Serial = Serial }));
            }
            catch (Exception ex)
            {
                Messages.AddErrorFlashMessage("Có lỗi trong quá trình xử lý, vui lòng thực hiện lại!");
                log.Error(" CancelInvApprove -" + ex.Message);
                IInvSrv.RolbackTran();
                return(RedirectToAction("CancelInvNotReIndex", new { Pattern = hdPattern, Serial = Serial }));
            }
        }