public ActionResult Detail(int id)
        {
            POutGoing outGoing = db.Payments.OfType <POutGoing>().FirstOrDefault(f => f.Id == id);

            //incoming.Customer = db.Customers.Find(incoming.CustomerId);
            return(View(outGoing));
        }
        public ActionResult DetailPaymentPost(CustomerDetailModel model)
        {
            var customerName = db.Customers.Find(model.customer.Id).UserName;

            if (model.PIncoming != null)
            {
                var incoming = new PIncoming()
                {
                    CreateTime       = model.PIncoming.CreateTime,
                    Total            = model.PIncoming.Total,
                    WhichSafe        = db.CashAccounts.Find(model.CashAccountId).AccountName,
                    Description      = model.PIncoming.WhichSafe,
                    CustomerId       = model.customer.Id,
                    CustomerUserName = customerName,
                    WhoUser          = "******",
                    CashAccountId    = model.CashAccountId,
                };
                db.Payments.Add(incoming);
                db.SaveChanges();
            }
            if (model.POutGoing != null)
            {
                var outGoing = new POutGoing()
                {
                    CreateTime       = model.POutGoing.CreateTime,
                    Total            = model.POutGoing.Total,
                    WhichSafe        = db.CashAccounts.Find(model.CashAccountId).AccountName,
                    Description      = model.POutGoing.Description,
                    CustomerId       = model.customer.Id,
                    CustomerUserName = customerName,
                    WhoUser          = "******",
                    CashAccountId    = model.CashAccountId,
                };
                db.Payments.Add(outGoing);
                db.SaveChanges();
            }

            return(RedirectToAction("Detail", new { id = model.customer.Id }));
        }
        public ActionResult Create(PaymentIndexModel model)
        {
            var customerName = db.Customers.Find(model.POutGoing.CustomerId).UserName;

            if (model != null)
            {
                var pOutGoing = new POutGoing()
                {
                    CreateTime       = model.POutGoing.CreateTime,
                    Total            = model.POutGoing.Total,
                    WhichSafe        = db.CashAccounts.Find(model.CashAccountId).AccountName,
                    Description      = model.POutGoing.Description,
                    CustomerId       = model.POutGoing.CustomerId,
                    CustomerUserName = customerName,
                    WhoUser          = "******",
                    CashAccountId    = model.CashAccountId,
                };
                db.Payments.Add(pOutGoing);
                db.SaveChanges();
            }

            return(RedirectToAction("Index", "Payment"));
        }