Example #1
0
        public ActionResult Index(PaymentModel model, int?page, int?Pagesize)
        {
            IPublishInvoiceService _PubIn = IoC.Resolve <IPublishInvoiceService>();
            Company        currentCom     = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            IList <string> lstPubinv      = _PubIn.LstByPattern(currentCom.id, 2);

            if (lstPubinv.Count == 0) // chưa đăng ký mẫu hóa đơn
            {
                Messages.AddErrorFlashMessage(Resources.Message.MNullInvInLst);
                return(RedirectToAction("Index", "Publish"));
            }
            if (model == null)
            {
                model = new PaymentModel();
            }
            if (String.IsNullOrEmpty(model.Pattern))
            {
                model.Pattern = lstPubinv[0];   // mặc định lấy pattern đầu tiên
            }
            model.PatternList = new SelectList(lstPubinv);
            List <string> se = _PubIn.LstBySerial(currentCom.id, model.Pattern, 1);

            model.SerialList = new SelectList(se);
            int              defautPagesize   = Pagesize.HasValue ? Convert.ToInt32(Pagesize) : 10;
            int              currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            int              totalRecords     = 0;
            IInvoiceService  IInvSrv          = InvServiceFactory.GetService(model.Pattern, currentCom.id);
            IList <IInvoice> lstInv;

            if (model.InvNo.HasValue && model.InvNo > 0) // lấy hóa đơn theo số, sêri
            {
                IInvoice Invoice = IInvSrv.GetByNo(currentCom.id, model.Pattern, model.Serial, model.InvNo.Value);
                lstInv = new List <IInvoice>();
                if (Invoice != null)
                {
                    lstInv.Add(Invoice);
                }
                totalRecords = 1;
            }
            else // tìm theo tham số khác
            {
                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);
                }
                if (model.PaymentStatus >= 0)
                {
                    lstInv = IInvSrv.SearchPayment(currentCom.id, model.Pattern, model.Serial, model.nameCus, model.code, DateFrom, DateTo, currentPageIndex, defautPagesize, out totalRecords, (Payment)model.PaymentStatus);
                }
                else
                {
                    lstInv = IInvSrv.SearchPayment(currentCom.id, model.Pattern, model.Serial, model.nameCus, model.code, DateFrom, DateTo, currentPageIndex, defautPagesize, out totalRecords);
                }
            }
            model.PageListINV = new PagedList <IInvoice>(lstInv, currentPageIndex, defautPagesize, totalRecords);
            return(View(model));
        }
        public ActionResult CancelInvNotReIndex(EInvoiceIndexModel model, int?page, int?Pagesize)
        {
            IPublishInvoiceService _PubIn = IoC.Resolve <IPublishInvoiceService>();
            Company        currentCom     = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            IList <string> lstpattern     = _PubIn.LstByPattern(currentCom.id, 1);

            if (lstpattern.Count == 0)
            {
                Messages.AddErrorFlashMessage(Resources.Message.MInv_SMesNoPubAccess);
                return(RedirectToAction("Index", "Home"));
            }
            if (model == null)
            {
                model = new EInvoiceIndexModel();
            }
            //lay pattern
            if (string.IsNullOrEmpty(model.Pattern))
            {
                model.Pattern = lstpattern[0];
            }
            model.lstpattern = lstpattern;
            //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 = LstSerial;
            if (string.IsNullOrEmpty(model.Serial))
            {
                model.Serial = LstSerial[0];
            }
            int defautPagesize   = Pagesize.HasValue ? Convert.ToInt32(Pagesize) : 10;
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            int totalRecords     = 0;

            IInvoiceService  IInvSrv = InvServiceFactory.GetService(model.Pattern, currentCom.id);
            IList <IInvoice> lst;

            if (!model.InvNo.HasValue)
            {
                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);
                }
                if (DateFrom != null && DateTo != null && DateFrom > DateTo)
                {
                    Messages.AddErrorMessage("Nhập đúng dữ liệu tìm kiếm theo ngày!");
                    DateFrom = DateTo = null;
                }
                InvoiceStatus[] status = new InvoiceStatus[] { InvoiceStatus.SignedInv, InvoiceStatus.AdjustedInv, InvoiceStatus.ReplacedInv, InvoiceStatus.InUseInv };
                lst = IInvSrv.SearchByStatus(currentCom.id, model.Pattern, model.Serial, DateFrom, DateTo, model.nameCus, model.code, model.CodeTax, (InvoiceType)model.typeInvoice, currentPageIndex, defautPagesize, out totalRecords, status);
            }
            else
            {
                lst = new List <IInvoice>();
                IInvoice inv = IInvSrv.GetByNo(currentCom.id, model.Pattern, model.Serial, model.InvNo.Value);
                if (inv != null)
                {
                    lst.Add(inv);
                }
                totalRecords = lst.Count();
            }
            model.PageListINV = new PagedList <IInvoice>(lst, currentPageIndex, defautPagesize, totalRecords);
            return(View(model));
        }
Example #3
0
        public ActionResult Index(CusSignIndexModel model, int?page, int?Pagesize)
        {
            Company currentCom                = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            IPublishInvoiceService _PubIn     = IoC.Resolve <IPublishInvoiceService>();
            IList <string>         lstPattern = _PubIn.LstByPattern(currentCom.id, 2);

            model.lstpattern = new SelectList(lstPattern);
            if (lstPattern.Count == 0)
            {
                Messages.AddErrorFlashMessage(Resources.Message.MInv_SMesNoPubAccess);
                return(RedirectToAction("/"));
            }
            if (model == null)
            {
                model = new CusSignIndexModel();
            }
            //khoi tao khi pattern rong
            if (string.IsNullOrEmpty(model.Pattern))
            {
                model.Pattern = lstPattern[0];
            }
            IList <IInvoice> lstInv;
            //tham so phan trang
            int defautPagesize   = Pagesize.HasValue ? Convert.ToInt32(Pagesize) : 10;
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            int totalRecords     = 0;
            //su dung khoi tao service
            IInvoiceService IInvSrv = InvServiceFactory.GetService(model.Pattern, currentCom.id);
            decimal         No;

            decimal.TryParse(model.InvNo, out No); if (No == 0)
            {
                No = -1;
            }
            //tim kiem theo mot hoa don theo so hoa don
            if (!string.IsNullOrWhiteSpace(model.InvNo))
            {
                IInvoice Invoice = IInvSrv.GetByNo(currentCom.id, model.Pattern, model.Serial, No);
                lstInv = new List <IInvoice>();
                if (Invoice != null)
                {
                    lstInv.Add(Invoice);
                }
                lstInv       = lstInv.Where(x => x.CusSignStatus != cusSignStatus.NocusSignStatus && x.CusSignStatus != cusSignStatus.ViewNocusSignStatus).ToList();
                totalRecords = lstInv.Count;
            }
            //tim kiem danh sach hoa don voi cac tham so con lai
            else
            {
                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);
                }
                if (model.SignStatus == 0)
                {
                    lstInv = IInvSrv.SearchByCusSign(currentCom.id, model.Pattern, model.Serial, DateFrom, DateTo, null, currentPageIndex, defautPagesize, out totalRecords, cusSignStatus.NoSignStatus, cusSignStatus.ViewNoSignStatus);
                }
                else if (model.SignStatus == 1)
                {
                    lstInv = IInvSrv.SearchByCusSign(currentCom.id, model.Pattern, model.Serial, DateFrom, DateTo, null, currentPageIndex, defautPagesize, out totalRecords, cusSignStatus.SignStatus);
                }
                else
                {
                    lstInv = IInvSrv.SearchByCusSign(currentCom.id, model.Pattern, model.Serial, DateFrom, DateTo, null, currentPageIndex, defautPagesize, out totalRecords, cusSignStatus.NoSignStatus, cusSignStatus.SignStatus, cusSignStatus.ViewNoSignStatus);
                }
            }

            log.Info("Infomation Search = pattern = " + model.Pattern + "| status = " + model.SignStatus + "| FromDate = " + model.FromDate + "| ToDate =" + model.ToDate);
            List <string> olstserial = _PubIn.LstBySerial(currentCom.id, model.Pattern, 1);

            model.lstserial       = new SelectList(olstserial);
            model.PageListCusSign = new PagedList <IInvoice>(lstInv, currentPageIndex, defautPagesize, totalRecords);
            model.defautPagesize  = defautPagesize;
            return(View(model));
        }
Example #4
0
        public ActionResult Index(EInvoiceIndexModel model, int?page, int?Pagesize)
        {
            IPublishInvoiceService _PubIn = IoC.Resolve <IPublishInvoiceService>();
            Company currentCom            = ((EInvoiceContext)FXContext.Current).CurrentCompany;

            try
            {
                IList <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"));
                }
                if (model == null)
                {
                    model = new EInvoiceIndexModel();
                }
                model.Pattern    = string.IsNullOrEmpty(model.Pattern) ? lstpattern[0] : model.Pattern;
                model.lstpattern = lstpattern;
                List <string> LstSerial = _PubIn.ListSerialByPattern(currentCom.id, model.Pattern, new int[] { 1, 2, 3 }).Distinct().ToList <string>();
                model.lstserial = LstSerial;
                int defautPagesize   = Pagesize.HasValue ? Convert.ToInt32(Pagesize) : 10;
                int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
                int totalRecords     = 0;

                IInvoiceService  IInvSrv = InvServiceFactory.GetService(model.Pattern, currentCom.id);
                IList <IInvoice> lst;
                if (!model.InvNo.HasValue || model.InvNo == null)
                {
                    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);
                    }
                    if (DateFrom != null && DateTo != null && DateFrom > DateTo)
                    {
                        Messages.AddErrorMessage("Nhập đúng dữ liệu tìm kiếm theo ngày!");
                        DateFrom = DateTo = null;
                    }
                    lst = IInvSrv.SearchByCustomer(currentCom.id, model.Pattern, model.Serial, DateFrom, DateTo, (InvoiceStatus)model.Status, model.nameCus, model.code, model.CodeTax, (InvoiceType)model.typeInvoice, currentPageIndex, defautPagesize, out totalRecords);
                }
                else
                {
                    lst          = IInvSrv.GetListByNo(currentCom.id, model.Pattern, model.Serial, model.InvNo.Value);
                    totalRecords = lst.Count();
                }
                model.PageListINV = new PagedList <IInvoice>(lst, currentPageIndex, defautPagesize, totalRecords);
                int signPlugin = 0;
                if (currentCom.Config.Keys.Contains("SignPlugin"))
                {
                    int.TryParse(currentCom.Config["SignPlugin"], out signPlugin);
                }
                model.SignPlugin = signPlugin;
                return(View(model));
            }
            catch (UnAuthorizedException e)
            {
                log.Error(e);
                Messages.AddErrorMessage("Có lỗi xảy ra, vui lòng thực hiện lại!");
                return(RedirectToAction("Index", "Home"));
            }
            catch (ArgumentException ex)
            {
                log.Error(ex);
                return(Redirect("/Home/PotentiallyError"));
            }
            catch (HttpRequestValidationException ex)
            {
                log.Error(ex);
                return(RedirectToAction("PotentiallyError", "Home"));
            }
        }
        public ActionResult Upload(int?TypeTran)
        {
            int typetran = TypeTran.HasValue ? TypeTran.Value : 0;
            IPublishInvoiceService _PubIn = IoC.Resolve <IPublishInvoiceService>();
            Company     currentCom        = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            UploadModel model             = new UploadModel();

            model.Month = DateTime.Now.Month;
            model.Year  = DateTime.Now.Year;
            if (DateTime.Now.Month < 12)
            {
                model.Years = new List <int>()
                {
                    DateTime.Now.Year - 1, DateTime.Now.Year
                }
            }
            ;
            else
            {
                model.Years = new List <int>()
                {
                    DateTime.Now.Year
                }
            };
            int m = DateTime.Now.Month;

            model.Months = new List <int>();
            while (m > 0)
            {
                model.Months.Add(m);
                m--;
            }
            model.TypeTrans = typetran;
            model.TypeLabel = TransactionName.NameByType(typetran);
            try
            {
                //lstpattern
                List <string> lstpattern = _PubIn.LstByPattern(currentCom.id, 1);
                if (lstpattern.Count == 0)
                {
                    Messages.AddErrorFlashMessage(Resources.Message.MInv_SMesNoPubAccess);
                    return(RedirectToAction("Index", new { TypeTran = model.TypeTrans }));
                }
                Dictionary <string, string> dicPattern = new Dictionary <string, string>();
                foreach (string str in lstpattern)
                {
                    dicPattern.Add(str, GetResxNameByValue(str));
                }

                model.Listpattern = new SelectList(dicPattern, "key", "value");
                //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
            {
                Messages.AddErrorFlashMessage(Resources.Message.Key_MesReqConfig);
                return(RedirectToAction("Index", new { TypeTran = model.TypeTrans }));
            }
            return(View(model));
        }