Exemple #1
0
        // GET: CarReservations/Create
        public ActionResult FormRenter(int?id)
        {
            DateTime today = DateTime.Now;

            today = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(today, TimeZoneInfo.Local.Id, "Singapore Standard Time");

            CarReservation reservation = new CarReservation();

            reservation.DtTrx       = today;
            reservation.DtStart     = today.AddDays(2).ToString();
            reservation.DtEnd       = today.AddDays(3).ToString();
            reservation.JobRefNo    = 0;
            reservation.SelfDrive   = 0;  //with driver = 0, self drive = 1;
            reservation.EstHrPerDay = 10;
            reservation.EstKmTravel = 100;

            //get previous id
            CarReservation lastId = db.CarReservations.ToList().OrderByDescending(c => c.Id).LastOrDefault();

            CarRatePackage selfDrive = db.CarRatePackages.Find(1);

            //get last reservation id
            ViewBag.RsvId = lastId != null ?  lastId.Id + 1 : 1;

            ViewBag.CarUnitId        = new SelectList(db.CarUnits, "Id", "Description", id);
            ViewBag.id               = id;
            ViewBag.carRatesPackages = db.CarRateUnitPackages.ToList();
            ViewBag.CarUnitList      = db.CarUnits.ToList();
            ViewBag.CarRates         = db.CarRates.ToList();
            ViewBag.isAuthorize      = HttpContext.User.Identity.Name == ""  ? 0 : 1;

            //except self drive package
            ViewBag.Packages = db.CarRatePackages.ToList();
            return(View(reservation));
        }
Exemple #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            CarRatePackage carRatePackage = db.CarRatePackages.Find(id);

            db.CarRatePackages.Remove(carRatePackage);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,Description,Remarks,DailyMeals,DailyRoom,DaysMin")] CarRatePackage carRatePackage)
 {
     if (ModelState.IsValid)
     {
         db.Entry(carRatePackage).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(carRatePackage));
 }
Exemple #4
0
 public ActionResult Edit([Bind(Include = "Id,Description,Remarks,DailyMeals,DailyRoom,DaysMin,Status")] CarRatePackage carRatePackage)
 {
     if (ModelState.IsValid)
     {
         db.Entry(carRatePackage).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Status = new SelectList(StatusList, "value", "text", carRatePackage.Status);
     return(View(carRatePackage));
 }
        public ActionResult Create([Bind(Include = "Id,Description,Remarks,DailyMeals,DailyRoom,DaysMin")] CarRatePackage carRatePackage)
        {
            if (ModelState.IsValid)
            {
                db.CarRatePackages.Add(carRatePackage);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(carRatePackage));
        }
Exemple #6
0
        // GET: CarRatePackages/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CarRatePackage carRatePackage = db.CarRatePackages.Find(id);

            if (carRatePackage == null)
            {
                return(HttpNotFound());
            }
            return(View(carRatePackage));
        }
Exemple #7
0
        // GET: CarRatePackages/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CarRatePackage carRatePackage = db.CarRatePackages.Find(id);

            if (carRatePackage == null)
            {
                return(HttpNotFound());
            }

            ViewBag.Status = new SelectList(StatusList, "value", "text", carRatePackage.Status);
            return(View(carRatePackage));
        }
        // GET: CarReservations/Create
        public ActionResult FormRenter(int?id, int days, int rentType, int meals, int fuel, int pkg)
        {
            DateTime today = DateTime.Now;

            today = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(today, TimeZoneInfo.Local.Id, "Singapore Standard Time");

            int          Authorize      = HttpContext.User.Identity.Name == "" ? 0 : 1;
            PackageTable PackageSummary = carRsv.getPackageSummary((int)id, days, rentType, meals, fuel, pkg, Authorize);

            CarReservation reservation = new CarReservation();

            reservation.DtTrx        = today;
            reservation.DtStart      = today.AddDays(2).ToString();
            reservation.DtEnd        = today.AddDays(4).ToString();
            reservation.JobRefNo     = 0;
            reservation.SelfDrive    = 0; //with driver = 0, self drive = 1;
            reservation.EstHrPerDay  = 10;
            reservation.EstKmTravel  = 100;
            reservation.Destinations = db.CarRatePackages.Find(pkg).Description;
            reservation.UseFor       = db.CarRatePackages.Find(pkg).Description;
            reservation.BaseRate     = PackageSummary.Rate.ToString();

            //get previous id
            CarReservation lastId = db.CarReservations.ToList().OrderByDescending(c => c.Id).LastOrDefault();

            CarRatePackage selfDrive = db.CarRatePackages.Find(1);

            ViewBag.CarUnitId = new SelectList(db.CarUnits, "Id", "Description", id);
            //get last reservation id
            ViewBag.RsvId = lastId != null ?  lastId.Id + 1 : 1;
            ViewBag.id    = id;
            ViewBag.fuel  = fuel;
            ViewBag.meals = meals;
            ViewBag.pkgId = pkg;

            ViewBag.DtStart = today.AddDays(2);
            ViewBag.DtEnd   = today.AddDays(3);

            //except self drive package
            ViewBag.PackagesDesc = db.CarRatePackages.Find(pkg).Description;

            return(View(reservation));
        }