Ejemplo n.º 1
0
        public ActionResult EditDet([Bind(Include = "VPRentID,Month,Arrears,Current,RecoveryAmt,RecoveryDate,BalanceArrears,BalanceCurrent,ReceiptNo")] VPRentDetail vPRentDetail)
        {
            if (ModelState.IsValid)
            {
                db.Entry(vPRentDetail).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(vPRentDetail));
        }
Ejemplo n.º 2
0
        public ActionResult CreateDet([Bind(Include = "VPRentID,Month,Arrears,Current,RecoveryAmt,RecoveryDate,BalanceArrears,BalanceCurrent")] VPRentDetail vPRentDetail)
        {
            if (ModelState.IsValid)
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        var payerName = db.VPRents.Find(vPRentDetail.VPRentID).RentPayerName;
                        var item      = new Form4 {
                            Amount = vPRentDetail.RecoveryAmt, LedgerID = 7, PayDate = DateTime.Today, RecvdFrom = "Property Rent: " + payerName, SubLedgerID = 30
                        };                                                                                                                                                              //Shop rent
                        db.Form4.Add(item);

                        db.VPRentDetails.Add(vPRentDetail);
                        db.SaveChanges();
                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        throw ex;
                    }
                    return(RedirectToAction("Index"));
                }
            }

            //if not valid model
            VPRent vPRent = db.VPRents.Find(vPRentDetail.VPRentID);

            if (vPRent == null)
            {
                return(HttpNotFound());
            }
            ViewBag.vpRent = vPRent;

            ViewBag.rd       = db.VPRentDetails.Where(r => r.VPRentID == vPRentDetail.VPRentID).OrderBy(r => r.Month);
            ViewBag.MonthBox = MyExtensions.MonthList();
            return(View("Details", vPRentDetail));
        }