예제 #1
0
        public ActionResult Edit(int id,Payment payment, FormCollection collection)
        {
            Payment _entity = svc.GetById(id);
            if (ModelState.IsValid)
            {
                _entity.PaymentMethod = collection["PaymentMethod"];
                _entity.ReferenceNumber = collection["ReferenceNumber"];
                _entity.Remarks = collection["Remarks"];

                _entity.Amount = decimal.Parse(collection["Amount"]);
                _entity.CustomerId = int.Parse(collection["CustomerId"]);
                try
                {
                    svc.Update(_entity);
                }
                catch (Exception e)
                {
                    
                }
                

                return RedirectToAction("Details", new { id = _entity.Id });
            }
            return View(_entity);
        }
예제 #2
0
        public ActionResult Create()
        {
            ViewBag.idmas_GST = new SelectList(gstSvc.GetAll(), "Id", "Code");

            Payment _payment = new Payment();
            return View(_payment);
        }
예제 #3
0
        public ActionResult Create(Payment payment, FormCollection collection)
        {
            if (ModelState.IsValid)
            {
                int invoiceId_payment = int.Parse(collection["invoiceId_payment"]);
                int customerId_payment = int.Parse(collection["customerId_payment"]);
                payment.CustomerId = invoiceId_payment;
                svc.Save(payment);
                IList<PaymentDetail> list = null;
                        //svc.GetAll().Where(p=>p.PaymentDetail==payment.InvoiceId)
                        //.ToList() ;

                return Json(new
                {
                    success = true,
                    html = this.RenderViewToString("~/Views/Payment/_ListItem.cshtml", list)
                });
            }
            return Json(new
            {
                success = false,
                errors = ModelState.Errors(),
                html = ModelState.Errors()
            });
        }
예제 #4
0
        public int ImportPaymentHeader(Stream csvFile)
        {
            StreamReader textReader = new StreamReader(csvFile);
            CsvReader CSV = new CsvReader(textReader);
            CSV.Configuration.IsHeaderCaseSensitive = false;
            CSV.Configuration.TrimFields = true;
            CSV.Configuration.WillThrowOnMissingField = false;

            List<Payment> list = new List<Payment>();
            int count = 0;
            try
            {
                while (CSV.Read())
                {
                    string paymentNo = CSV.GetField<string>("payment#").Trim();
                    string customerName = CSV.GetField<string>("customer");
                    string date = CSV.GetField<string>("date");
                    string PaymentMethod = CSV.GetField<string>("PaymentMethod");
                    string ChequeNo = CSV.GetField<string>("ChequeNo");
                    string Amount = CSV.GetField<string>("Amount");

                    if (!string.IsNullOrEmpty(customerName) && !string.IsNullOrEmpty(paymentNo) && !string.IsNullOrEmpty(date))
                    {
                        DateTime orderDate = DateTime.Parse(date);
                        decimal _Amount = Decimal.Parse(Amount);
                        Customer customer = custSvr.GetByName(customerName);
                        if (customer != null)
                        {
                            //Payment entity = paymentSvc.GetById(paymentNo);
                            //if (entity != null)
                            //{
                            //}
                            //else
                            //{

                                Payment newInvoice = new Payment
                                { 
                                    PaymentMethod = PaymentMethod,
                                    ReferenceNumber = ChequeNo,
                                    Date = orderDate,
                                    CustomerId = customer.Id,
                                    Remarks = paymentNo,
                                    Amount = _Amount
                                };
                                list.Add(newInvoice);
                            //}
                        }
                    }

                }

                paymentSvc.Save(list);
                count = list.Count();
            }
            catch (Exception e)
            {
                throw new Exception("Save Invoice Error", e);
            }
            return count;
        }