Ejemplo n.º 1
0
        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"));
            }
        }
Ejemplo n.º 2
0
        public ActionResult DetailRPublish(int id)
        {
            if (id <= 0)
            {
                throw new HttpRequestValidationException();
            }
            IPublishService        pubSrc    = IoC.Resolve <IPublishService>();
            Publish                model     = pubSrc.Getbykey(id);
            IPublishInvoiceService pubinvSrc = IoC.Resolve <IPublishInvoiceService>();
            var qr = (from pi in pubinvSrc.Query where pi.PublishID == model.id select pi);
            IList <PublishInvoice> lstpubinv = qr.ToList();

            ViewData["lstpubinv"] = lstpubinv;
            return(View(model));
        }
Ejemplo n.º 3
0
        public ActionResult SelectedPublish(int id)
        {
            if (id <= 0)
            {
                throw new HttpRequestValidationException();
            }
            Company         _currentcompany = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            IPublishService pubSrc          = IoC.Resolve <IPublishService>();
            string          ERRMessage      = "";
            Publish         pub             = pubSrc.Getbykey(id);

            if (pub.Status == PublishStatus.Newpub)
            {
                if (pubSrc.SendforApprove(pub, out ERRMessage) == true)
                {
                    log.Info("SelectedPublish Publish by: " + HttpContext.User.Identity.Name + " Info-- ID: " + id.ToString());
                    Messages.AddFlashMessage("Gửi thành công");
                }
                else
                {
                    log.Error("SelectedPublish Publish:" + ERRMessage);
                    Messages.AddErrorFlashMessage(ERRMessage);
                }
                return(RedirectToAction("DetailRPublish/" + id + ""));
            }
            if (pub.Status == PublishStatus.Waiting)
            {
                if (pubSrc.Approve(pub, out ERRMessage) == true)
                {
                    log.Info("SelectedPublish Publish by: " + HttpContext.User.Identity.Name + " Info-- ID: " + id.ToString());
                    Messages.AddFlashMessage("Phát hành thành công!");
                }
                else
                {
                    log.Error("SelectedPublish Publish:" + ERRMessage);
                    Messages.AddErrorFlashMessage(ERRMessage);
                }
                return(RedirectToAction("DetailRPublish/" + id + ""));
            }
            Messages.AddErrorFlashMessage("Không thực hiện thành công");
            return(RedirectToAction("DetailRPublish/" + id + ""));
        }
Ejemplo n.º 4
0
        public ActionResult UpdatePublish(int id, string PubInvoiceList)
        {
            if (id <= 0)
            {
                throw new HttpRequestValidationException();
            }
            IPublishService      pubSrc = IoC.Resolve <IPublishService>();
            ITaxAuthorityService taxSrv = IoC.Resolve <ITaxAuthorityService>();
            Publish opub = pubSrc.Getbykey(id);

            try
            {
                TryUpdateModel <Publish>(opub);
                opub.TaxAuthorityName = (from tax in taxSrv.Query where tax.Code == opub.TaxAuthorityCode select tax.Name).FirstOrDefault();
                JavaScriptSerializer   jss = new JavaScriptSerializer();
                IList <PublishInvoice> lst = jss.Deserialize <IList <PublishInvoice> >(PubInvoiceList);
                foreach (var it in lst)
                {
                    IPublishInvoiceService pubinvSrv = IoC.Resolve <IPublishInvoiceService>();
                    ICompanyService        _comSrv   = IoC.Resolve <ICompanyService>();
                    Company _currentcompany          = _comSrv.Getbykey(((EInvoiceContext)FXContext.Current).CurrentCompany.id);
                    string  invSer = string.Format("{0}/{1}E", it.InvSerialPrefix, it.InvSerialSuffix);
                    var     old    = pubinvSrv.Query.Where(p => p.RegisterID == it.RegisterID && p.InvSerial == invSer && p.StartDate > it.StartDate && p.FromNo < it.FromNo && p.ComId == _currentcompany.id).FirstOrDefault();
                    if (old != null)
                    {
                        Messages.AddErrorMessage(string.Format("Thông báo có ký hiệu {0}, phải có ngày bắt đầu từ ngày: {1}", old.InvSerial, old.StartDate.ToString("dd/MM/yyyy")));
                        PublishModel model = new PublishModel();
                        model.mPublish = opub;
                        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.PubInvoiceList = opub.PublishInvoices.SerializeJSON <PublishInvoice>();
                        return(View("EditRPublish", model));
                    }
                    else
                    {
                        old = pubinvSrv.Query.Where(p => p.RegisterID == it.RegisterID && p.InvSerial == invSer && p.StartDate <it.StartDate && p.FromNo> it.FromNo && p.ComId == _currentcompany.id).FirstOrDefault();
                        if (old != null)
                        {
                            Messages.AddErrorMessage(string.Format("Thông báo có ký hiệu {0}, phải có ngày bắt đầu nhỏ hơn ngày: {1}", old.InvSerial, old.StartDate.ToString("dd/MM/yyyy")));
                            PublishModel model = new PublishModel();
                            model.mPublish = opub;
                            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.PubInvoiceList = opub.PublishInvoices.SerializeJSON <PublishInvoice>();
                            return(View("EditRPublish", model));
                        }
                    }
                }
                string mess = "";
                if (pubSrc.Update(opub, lst, out mess) == true)
                {
                    StringBuilder InvInfo = new StringBuilder();
                    for (int i = 0; i < lst.Count; i++)
                    {
                        InvInfo.AppendFormat("{0};{1};{2};{3};{4}_", lst[i].RegisterID, lst[i].InvSerial, lst[i].Quantity, lst[i].FromNo, lst[i].ToNo);
                    }
                    log.Info("Edit Publish by: " + HttpContext.User.Identity.Name + "|InvInfo:" + InvInfo.ToString());
                    Messages.AddFlashMessage("Sửa thành công");
                    return(RedirectToAction("Index"));
                }
                else
                {
                    log.Error("Update Publish:" + mess);
                    ICompanyService _comSrv         = IoC.Resolve <ICompanyService>();
                    Company         _currentcompany = _comSrv.Getbykey(((EInvoiceContext)FXContext.Current).CurrentCompany.id);
                    PublishModel    model           = new PublishModel();
                    model.mPublish = opub;
                    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.PubInvoiceList = opub.PublishInvoices.SerializeJSON <PublishInvoice>();
                    Messages.AddErrorMessage(mess);
                    return(View("EditRPublish", model));
                }
            }
            catch (Exception ex)
            {
                log.Error("EditRPublish -" + ex);
                Messages.AddErrorMessage("Có lỗi xảy ra, vui lòng thực hiện lại!");
                PublishModel model = new PublishModel();
                model.mPublish = opub;
                ICompanyService      _comSrv         = IoC.Resolve <ICompanyService>();
                Company              _currentcompany = _comSrv.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.PubInvoiceList = opub.PublishInvoices.SerializeJSON <PublishInvoice>();
                return(View("EditRPublish", model));
            }
        }