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));
        }
        public ActionResult ChooseTemp()
        {
            RegisterTempChoiseModels model      = new RegisterTempChoiseModels();
            IInvCategoryService      invCateSrv = IoC.Resolve <IInvCategoryService>();
            IRegisterTempService     _regSrc    = IoC.Resolve <IRegisterTempService>();

            model.InvCategories = invCateSrv.Query.OrderBy(p => p.id).ToList();
            IInvTemplateService _invTempSrc = IoC.Resolve <IInvTemplateService>();

            model.CurrentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            return(View(model));
        }
        public ActionResult Create(InvCancel invCancel, string LstCancelDetail)
        {
            ICompanyService comSrv      = IoC.Resolve <ICompanyService>();
            Company         _currentCom = comSrv.Getbykey(((EInvoiceContext)FXContext.Current).CurrentCompany.id);

            invCancel.ComID      = _currentCom.id;
            invCancel.ComName    = _currentCom.Name;
            invCancel.ComTaxCode = _currentCom.TaxCode;
            invCancel.ComAddress = _currentCom.Address;
            if (string.IsNullOrWhiteSpace(LstCancelDetail))
            {
                CreateInvCancelModel md = new CreateInvCancelModel();
                md.CancelTemp = invCancel;
                IInvCategoryService _icateSer = IoC.Resolve <IInvCategoryService>();
                IList <InvCategory> lst       = _icateSer.GetAll();
                md.lstInvCategory = new SelectList(lst, "id", "Name");
                Messages.AddErrorMessage("Chưa chọn dải hóa đơn.");
                return(View(md));
            }
            invCancel.InvCancels = (IList <InvCancelDetails>)LstCancelDetail.DeserializeJSON <InvCancelDetails>(typeof(IList <InvCancelDetails>));
            IInvCancelService _invCancelSrv = IoC.Resolve <IInvCancelService>();
            string            errMes;

            if (_invCancelSrv.CancelInv(invCancel, out errMes))
            {
                StringBuilder strInfo = new StringBuilder();
                try
                {
                    for (int i = 0; i < invCancel.InvCancels.Count; i++)
                    {
                        strInfo.Append("----- pattern: " + invCancel.InvCancels[i].InvPattern + "    Serial: " + invCancel.InvCancels[i].InvSerial + "   From: " + invCancel.InvCancels[i].FromNo + "   To: " + invCancel.InvCancels[i].ToNo + "-------");
                    }
                }
                catch (Exception ex)
                {
                    log.Error(" Create -" + ex.Message);
                }
                log.Info("Cancel Range Invoice  by: " + HttpContext.User.Identity.Name + " Info-- Ngay Huy: " + invCancel.CancelDate + " Thong tin dai so: " + strInfo.ToString());
                Messages.AddFlashMessage(Resources.Message.ReCancel_MesSuccess);
                return(RedirectToAction("Index"));
            }
            CreateInvCancelModel model    = new CreateInvCancelModel();
            IInvCategoryService  icateSer = IoC.Resolve <IInvCategoryService>();
            IList <InvCategory>  list     = icateSer.GetAll();

            model.CancelTemp     = invCancel;
            model.lstInvCategory = new SelectList(list, "id", "Name");
            Messages.AddErrorMessage(Resources.Message.ReCancel_MesCanceled);
            return(View(model));
        }
        public ActionResult Create()
        {
            InvCancel            invc   = new InvCancel();
            CreateInvCancelModel model  = new CreateInvCancelModel();
            ICompanyService      comSrv = IoC.Resolve <ICompanyService>();
            Company _currentCom         = comSrv.Getbykey(((EInvoiceContext)FXContext.Current).CurrentCompany.id);

            invc.ComID      = _currentCom.id;
            invc.ComName    = _currentCom.Name;
            invc.ComTaxCode = _currentCom.TaxCode;
            invc.ComAddress = _currentCom.Address;
            IInvCategoryService _icateSer = IoC.Resolve <IInvCategoryService>();
            IList <InvCategory> lst       = _icateSer.GetAll();

            model.lstInvCategory = new SelectList(lst, "id", "Name");
            model.CancelTemp     = invc;
            return(View(model));
        }