コード例 #1
0
 public ActionResult UpdatePartial(PaymentInvoiceLinesModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             PaymentHelper.UpdatePaymentLine(model);
         }
         catch (Exception e)
         {
             ViewData["EditError"] = e.Message;
         }
     }
     else
         ViewData["EditError"] = "Please, correct all errors.";
     return PartialView("createPartial", PaymentHelper.GetPaymentLines());
 }
コード例 #2
0
 public ActionResult DeletePartial(PaymentInvoiceLinesModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             PaymentViewModel header = SessionHelper.Payment;
             PaymentHelper.DeletePaymentLine(model);
             SessionHelper.Payment = header;
             IList<PaymentInvoiceLinesModel> paymentLines = PaymentHelper.GetPaymentLines();
             return PartialView("createPartial", paymentLines);
         }
         catch (Exception e)
         {
             ViewData["EditError"] = e.Message;
         }
     }
     else
         ViewData["EditError"] = "Please, correct all errors.";
     return PartialView("createPartial");
 }
コード例 #3
0
        public ActionResult AddNewPartial(PaymentInvoiceLinesModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    bool validated = false;

                    if (SessionHelper.Payment != null)
                    {
                        if (SessionHelper.Payment.BankAccountId == 0)
                        {
                            ViewData["EditError"] = "Please select Bank Account";
                            return PartialView("createPartial", PaymentHelper.GetPaymentLines());
                        }

                        if (SessionHelper.Payment.VendorSiteId == 0)
                        {
                            ViewData["EditError"] = "Please select Vendor Site";
                            return PartialView("createPartial", PaymentHelper.GetPaymentLines());
                        }

                        model.Id = SessionHelper.Payment.PaymentInvoiceLines.Last().Id + 1;
                        validated = true;
                    }
                    else
                        model.Id = 1;

                    if (validated)
                        PaymentHelper.Insert(model);
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
                ViewData["EditError"] = "Please, correct all errors.";
            return PartialView("createPartial", PaymentHelper.GetPaymentLines());
        }
コード例 #4
0
        private static PaymentInvoiceLines getEntityByModel(PaymentInvoiceLinesModel model)
        {
            if (model == null) return null;

            PaymentInvoiceLines entity = new PaymentInvoiceLines
            {
                Amount = model.Amount,
                PaymentId = model.PaymentId,
                InvoiceId = model.InvoiceId,
                Id = model.Id
            };
            if (model.Id == 0)
            {
                entity.CreateBy = AuthenticationHelper.UserId;
                entity.CreateDate = DateTime.Now;
            }
            else
            {
                entity.CreateBy = model.CreateBy;
                entity.CreateDate = model.CreateDate;
            }
            entity.UpdateBy = AuthenticationHelper.UserId;
            entity.UpdateDate = DateTime.Now;
            return entity;
        }
コード例 #5
0
 public static void Insert(PaymentInvoiceLinesModel model)
 {
     PaymentViewModel header = SessionHelper.Payment;
     header.PaymentInvoiceLines.Add(model);
 }
コード例 #6
0
 public static void DeletePaymentLine(PaymentInvoiceLinesModel model)
 {
     PaymentViewModel header = SessionHelper.Payment;
     PaymentInvoiceLinesModel paymentLine = header.PaymentInvoiceLines.FirstOrDefault(x => x.Id == model.Id);
     header.PaymentInvoiceLines.Remove(paymentLine);
 }
コード例 #7
0
 public static void UpdatePaymentLine(PaymentInvoiceLinesModel model)
 {
     PaymentViewModel header = SessionHelper.Payment;
     header.PaymentInvoiceLines.FirstOrDefault(x => x.Id == model.Id).Amount = model.Amount;
     header.PaymentInvoiceLines.FirstOrDefault(x => x.Id == model.Id).InvoiceId = model.InvoiceId;
 }