예제 #1
0
        public ActionResult AddNewPartial(PayableInvoiceDetailModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (SessionHelper.PayableInvoice != null)
                    {
                        if (SessionHelper.PayableInvoice.InvoiceDetail != null && SessionHelper.PayableInvoice.InvoiceDetail.Count > 0)
                        {
                            model.Id = SessionHelper.PayableInvoice.InvoiceDetail.LastOrDefault().Id + 1;
                        }
                        else
                        {
                            model.Id = 1;
                        }
                    }
                    else
                    {
                        model.Id = 1;
                    }

                    PayableInvoiceHelper.Insert(model);
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            return(PartialView("_Detail", PayableInvoiceHelper.GetInvoiceDetail()));
        }
예제 #2
0
        public ActionResult Edit(string id, long periodId)
        {
            PayableInvoiceModel model = PayableInvoiceHelper.GetInvoice(id);

            SessionHelper.Calendar = CalendarHelper.GetCalendar(PayablePeriodHelper.GetPayablePeriod(periodId.ToString()).CalendarId.ToString());

            model.InvoiceDetail = PayableInvoiceHelper.GetInvoiceDetail(id);
            model.SOBId         = SessionHelper.SOBId;
            model.PeriodId      = periodId;
            model.Periods       = PayablePeriodHelper.GetPeriodList(SessionHelper.SOBId);

            VendorModel      vendors      = VendorHelper.GetSingle(model.VendorId.ToString());
            VendorSiteModel  vendorSites  = VendorHelper.GetSingle(model.VendorSiteId);
            InvoiceTypeModel invoiceTypes = InvoiceTypeHelper.GetInvoiceType(model.InvoiceTypeId.ToString());

            ///TODO: Plz do the code audit.
            model.Vendors = new List <SelectListItem>();
            model.Vendors.Add(new SelectListItem
            {
                Value = vendors.Id.ToString(),
                Text  = vendors.Name
            });
            model.VendorSites = new List <SelectListItem>();
            model.VendorSites.Add(new SelectListItem
            {
                Value = vendorSites.Id.ToString(),
                Text  = vendorSites.Name
            });

            model.WHTaxes = new List <SelectListItem>();
            if (model.WHTaxId != null)
            {
                WithholdingModel withHoldingTaxes = WithholdingHelper.GetWithholding(model.WHTaxId.ToString());
                model.WHTaxes.Add(new SelectListItem
                {
                    Value = withHoldingTaxes.Id.ToString(),
                    Text  = withHoldingTaxes.Description
                });
            }

            model.InvoiceTypes = new List <SelectListItem>();
            model.InvoiceTypes.Add(new SelectListItem
            {
                Value = invoiceTypes.Id.ToString(),
                Text  = invoiceTypes.Description
            });

            SessionHelper.PayableInvoice = model;
            return(View(model));
        }
예제 #3
0
 public ActionResult UpdatePartial(PayableInvoiceDetailModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             PayableInvoiceHelper.UpdateInvoiceDetail(model);
         }
         catch (Exception e)
         {
             ViewData["EditError"] = e.Message;
         }
     }
     else
     {
         ViewData["EditError"] = "Please, correct all errors.";
     }
     return(PartialView("_Detail", PayableInvoiceHelper.GetInvoiceDetail()));
 }
예제 #4
0
 public ActionResult DeletePartial(PayableInvoiceDetailModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             PayableInvoiceModel invoice = SessionHelper.PayableInvoice;
             PayableInvoiceHelper.DeleteInvoiceDetail(model);
             SessionHelper.PayableInvoice = invoice;
             IList <PayableInvoiceDetailModel> invoiceDetail = PayableInvoiceHelper.GetInvoiceDetail();
             return(PartialView("_Detail", invoiceDetail));
         }
         catch (Exception e)
         {
             ViewData["EditError"] = e.Message;
         }
     }
     else
     {
         ViewData["EditError"] = "Please, correct all errors.";
     }
     return(PartialView("_Detail"));
     //return PartialView("_Detail", InvoiceHelper.GetInvoiceDetail());
 }
예제 #5
0
 public ActionResult DetailPartial()
 {
     return(PartialView("_Detail", PayableInvoiceHelper.GetInvoiceDetail()));
 }