コード例 #1
0
ファイル: PublishController.cs プロジェクト: war-man/vInvoice
        public ActionResult EditRPublish(int id)
        {
            IPublishService pubSrc = IoC.Resolve <IPublishService>();
            Publish         opub   = pubSrc.Getbykey(id);

            if (opub.Status != PublishStatus.InUse)
            {
                PublishModel model           = new PublishModel();
                Company      _currentcompany = IoC.Resolve <ICompanyService>().Getbykey(((EInvoiceContext)FXContext.Current).CurrentCompany.id);

                ITaxAuthorityService taxSrc = IoC.Resolve <ITaxAuthorityService>();
                model.TaxList = new SelectList(from tax in taxSrc.Query select tax, "Code", "Name", opub.TaxAuthorityCode);
                IRegisterTempService regisSrc = IoC.Resolve <IRegisterTempService>();
                model.RegTempList = new SelectList(from re in regisSrc.Query where re.ComId == _currentcompany.id select re, "Id", "Name");

                model.mPublish       = opub;
                model.PubInvoiceList = opub.PublishInvoices.SerializeJSON <PublishInvoice>();
                return(View(model));
            }
            else
            {
                Messages.AddErrorFlashMessage("Thông báo phát hành này không được phép sửa");
                return(RedirectToAction("Index"));
            }
        }
コード例 #2
0
        public ActionResult Create(int tempid)
        {
            Company              currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            IInvTemplateService  tempSrv    = IoC.Resolve <IInvTemplateService>();
            IInvCategoryService  cateSrv    = IoC.Resolve <IInvCategoryService>();
            IRegisterTempService _regSrc    = IoC.Resolve <IRegisterTempService>();

            if (_regSrc.Query.Where(p => p.InvoiceTemp.Id == tempid && p.ComId == currentCom.id).Count() > 0)
            {
                Messages.AddErrorFlashMessage("Mẫu hóa đơn đã được đăng ký, vui lòng chọn mẫu khác.");
                return(RedirectToAction("Choosetemp"));
            }
            RegisterTempModels model = new RegisterTempModels();

            InvTemplate  invTemp = tempSrv.Getbykey(tempid);
            decimal      i       = _regSrc.GetMaxPatternOrder(invTemp.InvCateID, currentCom.id);
            RegisterTemp temp    = new RegisterTemp();

            temp.Name         = invTemp.TemplateName;
            temp.NameInvoice  = invTemp.InvCateName;
            temp.InvCateID    = invTemp.InvCateID;
            temp.InvPattern   = cateSrv.Getbykey(invTemp.InvCateID).InvPattern + "0";
            temp.PatternOrder = i + 1;
            temp.CssData      = invTemp.CssData;
            temp.IsCertify    = invTemp.IsCertify;
            model.RegisTemp   = temp;
            model.CurrentCom  = currentCom;
            model.tempId      = tempid;
            return(View(model));
        }
コード例 #3
0
ファイル: PublishController.cs プロジェクト: war-man/vInvoice
        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"));
        }
コード例 #4
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"));
        }
コード例 #5
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"));
        }
コード例 #6
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"));
        }
コード例 #7
0
        public ActionResult Launch()
        {
            IPublishInvoiceService _PubIn = IoC.Resolve <IPublishInvoiceService>();
            Company     currentCom        = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            LaunchModel model             = new LaunchModel();

            try
            {
                //lstpattern
                List <string> lstpattern = _PubIn.LstByPattern(currentCom.id, 1);
                if (lstpattern.Count == 0)
                {
                    Messages.AddErrorFlashMessage("Cần tạo thông báo phát hành.");
                    return(RedirectToAction("Index", "Publish"));
                }
                model.Listpattern = new SelectList(lstpattern);
                //lstserial
                List <string> oserial = (from s in _PubIn.Query where ((s.ComId == currentCom.id) && (s.Status == 1 || s.Status == 2)) select s.InvSerial).ToList <string>();
                model.Listserial = new SelectList(oserial);
            }
            catch (Exception ex)
            {
                Messages.AddErrorFlashMessage("Có lỗi xảy ra, vui lòng thực hiện lại.");
                log.Error(" Launch -" + ex.Message);
                return(RedirectToAction("Index", "Home"));
            }
            return(View(model));
        }
コード例 #8
0
ファイル: PaymentController.cs プロジェクト: war-man/vInvoice
 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"));
     }
 }
コード例 #9
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"));
        }
コード例 #10
0
ファイル: AccountController.cs プロジェクト: war-man/vInvoice
        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"));
        }
コード例 #11
0
        public ActionResult Edit(int id)
        {
            Company currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            IRegisterTempService   registerTempSrv = IoC.Resolve <IRegisterTempService>();
            IPublishInvoiceService publishInvSrv   = IoC.Resolve <IPublishInvoiceService>();

            if (publishInvSrv.GetPubOfReg(id, currentCom.id).Count > 0)
            {
                Messages.AddErrorFlashMessage("Không được sửa mẫu hóa đơn đang sử dụng.");
                return(RedirectToAction("Index"));
            }
            string             logoKey      = string.Format("{0}_{1}", currentCom.id, "logo");
            string             backgroudKey = string.Format("{0}_{1}", currentCom.id, "backgroud");
            RegisterTemp       registerTemp = registerTempSrv.Getbykey(id);
            RegisterTempModels model        = new RegisterTempModels();

            model.tempId     = registerTemp.InvoiceTemp.Id;
            model.CurrentCom = currentCom;
            model.logoFile   = model.imgFile = registerTemp.Name;
            model.RegisTemp  = registerTemp;
            if (!string.IsNullOrWhiteSpace(registerTemp.CssLogo))
            {
                setCacheContext(logoKey, registerTemp.CssLogo);
            }
            if (!string.IsNullOrWhiteSpace(registerTemp.CssBackgr))
            {
                setCacheContext(backgroudKey, registerTemp.CssBackgr);
            }
            return(View(model));
        }
コード例 #12
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));
     }
 }
コード例 #13
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"));
 }
コード例 #14
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"));
        }
コード例 #15
0
        public ActionResult Quickreport(ReportsDetailModel model)
        {
            Company currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            IPublishInvoiceService PubInvSrv = IoC.Resolve <IPublishInvoiceService>();
            //if (model == null) model = new ReportsDetailModel();
            IList <string> lstPattern = PubInvSrv.LstByPattern(currentCom.id, 2);

            if (lstPattern.Count == 0)
            {
                Messages.AddErrorFlashMessage("Thông báo phát hành chưa được chấp nhận hoặc chưa có hóa đơn.");
                return(Redirect("/"));
            }
            if (lstPattern.Count > 0)
            {
                if (String.IsNullOrEmpty(model.Pattern))
                {
                    model.Pattern = lstPattern[0];
                }
            }
            List <string> lstSerial = (from p in PubInvSrv.Query where p.ComId == currentCom.id && p.InvPattern == model.Pattern && (p.Status > 1) select p.InvSerial).Distinct().ToList <string>();

            model.lstPattern = new SelectList(lstPattern);
            model.lstSerial  = new SelectList(lstSerial);
            return(View(model));
        }
コード例 #16
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"));
 }
コード例 #17
0
 public ActionResult ReportLaunch(ReportsLaunchModel model)
 {
     try
     {
         Company currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany;
         IPublishInvoiceService PubInvSrv  = IoC.Resolve <IPublishInvoiceService>();
         IList <string>         lstPattern = PubInvSrv.LstByPattern(currentCom.id, 2);
         if (lstPattern.Count == 0)
         {
             Messages.AddErrorFlashMessage("Thông báo phát hành chưa được chấp nhận hoặc chưa có hóa đơn.");
             return(Redirect("/"));
         }
         if (lstPattern.Count > 0)
         {
             if (string.IsNullOrEmpty(model.Pattern))
             {
                 model.Pattern = lstPattern[0];
                 IInvoiceService IInvSrv = InvServiceFactory.GetService(model.Pattern, currentCom.id);
             }
         }
         List <string> lstSerial = (from p in PubInvSrv.Query where (p.ComId == currentCom.id) && (p.InvPattern == model.Pattern) && (p.Status > 1) select p.InvSerial).Distinct().ToList <string>();
         model.lstPattern = new SelectList(lstPattern);
         model.lstSerial  = new SelectList(lstSerial);
         return(View(model));
     }
     catch (Exception ex)
     {
         Messages.AddErrorFlashMessage(ex.Message);
         return(RedirectToAction("Index", "Home"));
     }
 }
コード例 #18
0
ファイル: AdJustController.cs プロジェクト: war-man/vInvoice
        /// <summary>
        /// Doi trang thai hoa don
        /// status=2 den status=4
        /// </summary>
        /// <param name="pat"></param>
        /// <param name="seri"></param>
        /// <param name="invNo"></param>
        /// <returns></returns>
        public ActionResult adInv(string pat, string seri, string invNo)
        {
            Company         currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            IInvoiceService IInvSrv    = InvServiceFactory.GetService(pat, currentCom.id);

            try
            {
                //sua lai
                decimal No;
                decimal.TryParse(invNo, out No); if (No == 0)
                {
                    No = -1;
                }
                IInvoice inv = IInvSrv.GetByNo(currentCom.id, pat, seri, Convert.ToDecimal(No));
                if (inv.Status == InvoiceStatus.SignedInv)
                {
                    return(Json(new
                    {
                        inv.Pattern,
                        inv.Serial
                    }));
                }
                else
                {
                    return(Json(""));
                }
            }
            catch (Exception ex)
            {
                log.Error(" adInv -:" + ex.Message);
                Messages.AddErrorFlashMessage(Resources.Message.AdjReInv_MInvalidInv);
                return(RedirectToAction("SearchInvAdjust"));
            }
        }
コード例 #19
0
ファイル: AdJustController.cs プロジェクト: war-man/vInvoice
 /// <summary>
 /// Tải văn bản hủy hóa đơn đính kèm
 /// </summary>
 /// <param name="id">ID của hóa đơn bị thay thế</param>
 /// <returns></returns>
 public ActionResult DownloadRecordsCancel(int id)
 {
     try
     {
         AdjustInv obj = _adjustInvSrv.Getbykey(id);
         if (obj != null)
         {
             if (!string.IsNullOrEmpty(obj.Attachefile))
             {
                 string extension   = Path.GetExtension(obj.Attachefile);
                 string contentType = "application/pdf";
                 if (extension.Equals("docx") || extension.Equals("doc"))
                 {
                     contentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
                 }
                 if (System.IO.File.Exists(GetFullPathRecordsCancel(obj.Attachefile)))
                 {
                     return(File(GetFullPathRecordsCancel(obj.Attachefile), contentType, Path.GetFileName(obj.Attachefile)));
                 }
             }
             Messages.AddErrorFlashMessage("Không tồn tại văn bản hủy đính kèm hóa đơn !");
             return(RedirectToAction("Index", "Home"));
         }
         Messages.AddErrorFlashMessage("Không tồn tại văn bản hủy đính kèm hóa đơn !");
     }
     catch (Exception ex)
     {
         log.Error(" DownloadRecordsCancel -:" + ex.ToString());
         return(RedirectToAction("Index", "Home"));
     }
     return(RedirectToAction("Index", "Home"));
 }
コード例 #20
0
        public ActionResult Edit(string Pattern, int id)
        {
            ICompanyService        comSrv     = IoC.Resolve <ICompanyService>();
            Company                currentCom = comSrv.Getbykey(((EInvoiceContext)FXContext.Current).CurrentCompany.id);
            IPublishInvoiceService _PubIn     = IoC.Resolve <IPublishInvoiceService>();
            IRegisterTempService   _ReTemSvc  = IoC.Resolve <IRegisterTempService>();
            string ViewName = InvServiceFactory.GetView(Pattern, currentCom.id) + "Edit";
            //khoi tao service
            IInvoiceService IInvSrv = InvServiceFactory.GetService(Pattern, currentCom.id);
            //lay ve mot ban ghi hoa don
            IInvoice model = IInvSrv.Getbykey <IInvoice>(id);

            if (model.Status != InvoiceStatus.NewInv)
            {
                Messages.AddErrorFlashMessage("Không thể sửa hóa đơn này.");
                return(RedirectToAction("Index", new { Pattern = Pattern, Serial = model.Serial }));
            }
            //lay va doi danh sach cac san pham thanh doi tuong json
            //nếu Unit=null thì mặc định hiển thị ""
            foreach (var item in model.Products)
            {
                if (item.Unit == null)
                {
                    item.Unit = "";
                }
            }
            //lay ra danh sach cac serial
            List <string> ser = _PubIn.GetSerialByPatter(model.Pattern, currentCom.id);

            ViewData["ser"] = ser;
            //lay thong tin ve don vi ban hang
            ViewData["company"] = currentCom;
            model.Note          = "";
            return(View(ViewName, model));
        }
コード例 #21
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"));
 }
コード例 #22
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 }));
        }
コード例 #23
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"));
        }
コード例 #24
0
ファイル: HomeController.cs プロジェクト: war-man/vInvoice
        public ActionResult Index()
        {
            string errorMessage = null;

            if (!DataHelper.IsValidated(out errorMessage))
            {
                Messages.AddErrorFlashMessage(errorMessage);
            }
            return(View());
        }
コード例 #25
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);
            }
        }
コード例 #26
0
ファイル: AccountController.cs プロジェクト: war-man/vInvoice
        public ActionResult ServiceRoleEdit(int id)
        {
            IRBACMembershipProvider _MemberShipProvider = IoC.Resolve <IRBACMembershipProvider>();
            user model = _MemberShipProvider.GetUser(id, false);

            if (HttpContext.User.Identity.Name == model.username)
            {
                Messages.AddErrorFlashMessage(Resources.Message.User_UMesCantEdit);
                return(RedirectToAction("ServiceRoleIndex"));
            }
            ViewData["RetypePassword"] = model.password;
            return(View(model));
        }
コード例 #27
0
ファイル: AdJustController.cs プロジェクト: war-man/vInvoice
        public ActionResult AdjustInvIndex(AdjustInvoiceModel model, int?page)
        {
            IPublishInvoiceService PubIn = IoC.Resolve <IPublishInvoiceService>();
            Company       currentCom     = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            List <string> lstpattern     = PubIn.LstByPattern(currentCom.id, 2);

            if (lstpattern.Count == 0)
            {
                Messages.AddErrorFlashMessage(Resources.Message.MInv_SMesNoPubAccess);
                return(Redirect("/"));
            }
            model.lstPattern = new SelectList(lstpattern);
            if (string.IsNullOrEmpty(model.pattern) && lstpattern.Count > 0)
            {
                model.pattern = lstpattern[0];
            }
            //lay serial
            List <string> LstSerial = (from p in PubIn.Query where p.Status != 0 && p.InvPattern == model.pattern && p.ComId == currentCom.id select p.InvSerial).Distinct().ToList <string>();

            model.lstSerial = new SelectList(LstSerial);
            if (string.IsNullOrEmpty(model.Serial))
            {
                model.Serial = LstSerial[0];
            }
            // call service
            model.ComId = currentCom.id;
            //phân trang
            int      defautPagesize   = 10;
            int      currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            int      totalcount;
            decimal  InvNo    = model.InvNo.HasValue ? model.InvNo.Value : 0;
            DateTime?DateFrom = null;
            DateTime?DateTo   = null;

            if (!string.IsNullOrWhiteSpace(model.FromDate))
            {
                DateFrom = DateTime.ParseExact(model.FromDate, "dd/MM/yyyy", null);
            }
            if (!string.IsNullOrWhiteSpace(model.ToDate))
            {
                DateTo = DateTime.ParseExact(model.ToDate, "dd/MM/yyyy", null);
            }
            //IList<AdjustInv> lst = _adjustInvSrv.GetAdjustInv(model.ComId, model.pattern, model.Serial, DateFrom, DateTo, InvNo, ProcessingStatus.AdjustedInv, model.nameCus, model.code, model.CodeTax);
            IList <AjustSearchModel> lst = _adjustInvSrv.SearchAdjust(model.ComId, model.pattern, model.Serial, DateFrom, DateTo, InvNo, ProcessingStatus.AdjustedInv, model.nameCus, model.code, model.CodeTax, currentPageIndex, defautPagesize, out totalcount);

            model.PageListAdjustSearch = new PagedList <AjustSearchModel>(lst, currentPageIndex, defautPagesize, totalcount);
            ViewData["Title1"]         = "Hóa đơn bị điều chỉnh";
            ViewData["Title2"]         = "Hóa đơn điều chỉnh";
            ViewData["TypeView"]       = 2;
            return(View(model));
        }
コード例 #28
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 }));
            }
        }
コード例 #29
0
ファイル: AccountController.cs プロジェクト: war-man/vInvoice
        public ActionResult Edit(int id)
        {
            IRBACMembershipProvider _MemberShipProvider = IoC.Resolve <IRBACMembershipProvider>();
            IRBACRoleProvider       _RoleProvider       = IoC.Resolve <IRBACRoleProvider>();
            Company currentComp = ((EInvoiceContext)FXContext.Current).CurrentCompany;


            user oUser = _MemberShipProvider.GetUser(id, false);

            if (HttpContext.User.Identity.Name == oUser.username)
            {
                Messages.AddErrorFlashMessage(Resources.Message.User_UMesCantEdit);
                return(RedirectToAction("index"));
            }

            IStaffService _staSrv = IoC.Resolve <IStaffService>();

            ViewData["fullname"] = _staSrv.SearchByAccountName(oUser.username, currentComp.id).FullName;

            AccountModel model = new AccountModel();

            model.UserTmp = oUser;
            try
            {
                model.UserRoles = _RoleProvider.GetRolesForUser(oUser.userid);
                if (model.UserRoles.Contains("ServiceRole"))
                {
                    Messages.AddErrorFlashMessage(Resources.Message.User_UMesCantEdit);
                    return(RedirectToAction("index"));
                }
                List <String> lst = new List <string>(_RoleProvider.GetAllRoles());
                if (lst.IndexOf("ServiceRole") >= 0)
                {
                    lst.RemoveAt(lst.IndexOf("ServiceRole"));
                }
                if (lst.IndexOf("Root") >= 0)
                {
                    lst.RemoveAt(lst.IndexOf("Root"));
                }
                model.RetypePassword = oUser.password;
                model.AllRoles       = lst.ToArray();
            }
            catch (Exception ex)
            {
                log.Error("edit: " + id, ex);
                throw ex;
            }
            return(View(model));
        }
コード例 #30
0
ファイル: AccountController.cs プロジェクト: war-man/vInvoice
        public ActionResult SaveServiceRole(int userid, string RetypePassword)
        {
            if (userid <= 0)
            {
                throw new HttpRequestValidationException();
            }
            IRBACMembershipProvider _MemberShipProvider = IoC.Resolve <IRBACMembershipProvider>();
            IRBACRoleProvider       _RoleProvider       = IoC.Resolve <IRBACRoleProvider>();
            Company currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            user    model      = _MemberShipProvider.GetUser(userid, false);

            if (HttpContext.User.Identity.Name == model.username)
            {
                Messages.AddErrorFlashMessage(Resources.Message.User_UMesCantEdit);
                return(RedirectToAction("ServiceRoleIndex"));
            }
            string oldpassHash = model.password;
            string username    = model.username;
            string email       = model.email;

            try
            {
                TryUpdateModel(model);
                model.username = username;
                if (model.password != RetypePassword)
                {
                    ViewData["RetypePassword"] = model.password;
                    Messages.AddErrorFlashMessage(Resources.Message.User_MesConfirmPass);
                    return(View("ServiceRoleEdit", model));
                }
                if (RetypePassword != oldpassHash)
                {
                    model.password = GeneratorPassword.EncodePassword(RetypePassword, model.PasswordFormat, model.PasswordSalt);//FormsAuthentication.HashPasswordForStoringInConfigFile(RetypePassword, "MD5");
                }
                model.FailedPasswordAttemptCount = 0;
                _MemberShipProvider.UpdateUser(model);
                _RoleProvider.UpdateUsersToRoles(model.username, new string[] { "ServiceRole" });
                Messages.AddFlashMessage(Resources.Message.User_UMesSuccess);
                log.Info("ServiceRoleUpdate by: " + HttpContext.User.Identity.Name + "Info-- tai khoan " + model.username);
                return(RedirectToAction("ServiceRoleIndex"));
            }
            catch (Exception ex)
            {
                ViewData["RetypePassword"] = model.password;
                log.Error("ServiceRoleUpdate-" + ex.Message);
                Messages.AddFlashException(ex);
                return(View("ServiceRoleEdit", model));
            }
        }