public ActionResult Detail(int id)
        {
            IInvCancelService _icsSer = IoC.Resolve <IInvCancelService>();
            InvCancel         ic      = _icsSer.Getbykey(id);

            return(View(ic));
        }
        public ActionResult Index(InvCancelModel model, int?page)
        {
            int               total            = 0;
            int               currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            Company           _currentCom      = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            IInvCancelService _InvCancelSrv    = IoC.Resolve <IInvCancelService>();
            DateTime          DateFrom         = String.IsNullOrEmpty(model.dateFrom) ? DateTime.MinValue : DateTime.ParseExact(model.dateFrom, "dd/MM/yyyy", null);
            DateTime          DateTo           = String.IsNullOrEmpty(model.dateTo) ? DateTime.MaxValue : DateTime.ParseExact(model.dateTo, "dd/MM/yyyy", null);
            IList <InvCancel> lst = _InvCancelSrv.SearchInvCancel(model.creater, DateFrom, DateTo, currentPageIndex, pagesize, out total, _currentCom.id);

            model.PageListIC = new PagedList <InvCancel>(lst, currentPageIndex, pagesize, total);
            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));
        }