예제 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            PropertyBooking propertyBooking = db.PropertyBookings.Find(id);

            db.PropertyBookings.Remove(propertyBooking);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #2
0
        // GET: PropertyBookings/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PropertyBooking propertyBooking = db.PropertyBookings.Find(id);

            if (propertyBooking == null)
            {
                return(HttpNotFound());
            }
            return(View(propertyBooking));
        }
예제 #3
0
        // GET: PropertyBookings/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PropertyBooking propertyBooking = db.PropertyBookings.Find(id);

            if (propertyBooking == null)
            {
                return(HttpNotFound());
            }
            ViewBag.PropertyID = new SelectList(db.Properties, "PropertyID", "PropertyName", propertyBooking.PropertyID);
            return(View(propertyBooking));
        }
예제 #4
0
        public ActionResult Create([Bind(Include = "PropertyBookingID,PropertyID,Inward_No,TDate,NameOfApplicant,PhoneNo,HDate,AdvReceiptNo,AdvAmount,SecurityDepositAmt,ApplForSDRefund,FullPayReceiptNo,FullPayAmount,LuxTaxReceiptNo,RefundSDVoucherNo,PaymentOfLuxTax,Remarks")] PropertyBooking propertyBooking)
        {
            if (ModelState.IsValid)
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        var AdvRcpt = new Form4 {
                            CitizenID = null, Amount = propertyBooking.AdvAmount, PayDate = DateTime.Now, LedgerID = 7, SubLedgerID = 3, RecvdFrom = propertyBooking.NameOfApplicant, HouseNo = null
                        };
                        db.Form4.Add(AdvRcpt);
                        db.SaveChanges();
                        propertyBooking.AdvReceiptNo      = AdvRcpt.RecieptNo;
                        propertyBooking.ApplForSDRefund   = null;
                        propertyBooking.FullPayReceiptNo  = null;
                        propertyBooking.FullPayAmount     = null;
                        propertyBooking.LuxTaxReceiptNo   = null;
                        propertyBooking.RefundSDVoucherNo = null;
                        propertyBooking.PaymentOfLuxTax   = null;
                        propertyBooking.TDate             = DateTime.Now;
                        db.PropertyBookings.Add(propertyBooking);
                        db.SaveChanges();
                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        throw ex;
                    }

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

            ViewBag.PropertyID = new SelectList(db.Properties, "PropertyID", "PropertyName", propertyBooking.PropertyID);
            return(View(propertyBooking));
        }
예제 #5
0
        public ActionResult Edit([Bind(Include = "PropertyBookingID,PropertyID,Inward_No,TDate,NameOfApplicant,PhoneNo,HDate,AdvReceiptNo,AdvAmount,SecurityDepositAmt,ApplForSDRefund,FullPayReceiptNo,FullPayAmount,LuxTaxReceiptNo,RefundSDVoucherNo,PaymentOfLuxTax,Remarks")] PropertyBooking propertyBooking)
        {
            if (ModelState.IsValid)
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        db.Entry(propertyBooking).State = EntityState.Modified;
                        if (propertyBooking.FullPayAmount != null)
                        {
                            if (!propertyBooking.FullPayReceiptNo.HasValue)//Create a receipt only if it is the initial edit
                            {
                                var fullPayRcpt = new Form4 {
                                    CitizenID = null, Amount = propertyBooking.FullPayAmount, PayDate = DateTime.Now, LedgerID = 7, SubLedgerID = 3, RecvdFrom = propertyBooking.NameOfApplicant, HouseNo = null
                                };
                                db.Form4.Add(fullPayRcpt);
                                db.SaveChanges();
                                propertyBooking.FullPayReceiptNo = fullPayRcpt.RecieptNo;
                            }
                        }
                        if (propertyBooking.PaymentOfLuxTax != null)
                        {
                            if (!propertyBooking.LuxTaxReceiptNo.HasValue)
                            {
                                var LuxTax = new Form4 {
                                    CitizenID = null, Amount = propertyBooking.PaymentOfLuxTax, PayDate = DateTime.Now, LedgerID = 7, SubLedgerID = 3, RecvdFrom = propertyBooking.NameOfApplicant, HouseNo = null
                                };
                                db.Form4.Add(LuxTax);
                                db.SaveChanges();
                                propertyBooking.LuxTaxReceiptNo = LuxTax.RecieptNo;
                            }
                        }
                        if (propertyBooking.ApplForSDRefund != null)
                        {
                            if (!propertyBooking.RefundSDVoucherNo.HasValue)
                            {
                                string UserID = User.Identity.GetUserName();
                                var    pn     = db.Configs.Select(x => x.VP).FirstOrDefault();


                                var RefundSD = new Voucher {
                                    PassedBy = UserID, of = pn, Amount = propertyBooking.SecurityDepositAmt, ActualAmount = propertyBooking.SecurityDepositAmt, For = "Security Deposit refund of property booking", PayDate = propertyBooking.TDate, CBfolio = null, ResNo = null, HeldOn = propertyBooking.HDate, Meeting = "N/A", LedgerID = 7, SubLedgerID = 3
                                };
                                db.Vouchers.Add(RefundSD);
                                db.SaveChanges();
                                propertyBooking.RefundSDVoucherNo = RefundSD.VoucherID;
                            }
                        }
                        db.SaveChanges();
                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        throw ex;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewBag.PropertyID = new SelectList(db.Properties, "PropertyID", "PropertyName", propertyBooking.PropertyID);
            return(View(propertyBooking));
        }