public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblAeroplane_HMS03_Team7 tblAeroplane_HMS03_Team7 = db.tblAeroplane_HMS03_Team7.Find(id);

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

            var user = db.tblAeroplane_HMS03_Team7.Where(x => x.PlaneRegistrationID == tblAeroplane_HMS03_Team7.PlaneRegistrationID).FirstOrDefault();

            if (user != null)
            {
                if (tblAeroplane_HMS03_Team7.ScheduleStatus == "scheduled" || tblAeroplane_HMS03_Team7.ScheduleStatus == "Scheduled")
                {
                    MessageBox.Show("Flight already scheduled!");
                    return(RedirectToAction("Index"));
                }
            }
            return(View(tblAeroplane_HMS03_Team7));
        }
Example #2
0
        public ActionResult Edit([Bind(Include = "ScheduleID,PlaneRegistrationID,Source,Destination,Departure,Arrival,Fare_Premium_Adult,Fare_Economy_Adult,Fare_Firstclass_Adult,Fare_Premium_Child,Fare_Firstclass_Child,Fare_Economy_Child,Availability_Premium,Availability_Firstclass,Availability_Economy,TravelDistance,StatusofFlight,BonusMiles,BonusMilesPoints")] tblSchedule_HMS03_Team7 tblSchedule_HMS03_Team7)
        {
            //if (tblSchedule_HMS03_Team7.Departure.Date.Equals(DateTime.Today.Date) && (tblSchedule_HMS03_Team7.Departure.TimeOfDay.Subtract(DateTime.Now.TimeOfDay)).TotalHours < 4)
            //{
            //    MessageBox.Show("you can't update flight!!sorry boss!!");
            //    return RedirectToAction("Index");
            //}
            if (ModelState.IsValid)
            {
                Session["s1"] = tblSchedule_HMS03_Team7.PlaneRegistrationID;
                tblSchedule_HMS03_Team7.StatusofFlight = "Scheduled";
                tblAeroplane_HMS03_Team7 airplane = db.tblAeroplane_HMS03_Team7.Find(tblSchedule_HMS03_Team7.PlaneRegistrationID);


                tblSchedule_HMS03_Team7.Availability_Economy    = airplane.Capacity_Economy;
                tblSchedule_HMS03_Team7.Availability_Premium    = airplane.Capacity_Premium;
                tblSchedule_HMS03_Team7.Availability_Firstclass = airplane.Capacity_FirstClass;
                db.Entry(tblSchedule_HMS03_Team7).State         = EntityState.Modified;
                db.SaveChanges();
                MessageBox.Show("Flight Schedule edited successfully" + Session["s1"].ToString());
                return(RedirectToAction("VeiwScheduleToScheduler"));
            }
            ViewBag.PlaneRegistrationID = new SelectList(db.tblAeroplane_HMS03_Team7, "PlaneRegistrationID", "AirplaneSeries", tblSchedule_HMS03_Team7.PlaneRegistrationID);
            return(View(tblSchedule_HMS03_Team7));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            tblAeroplane_HMS03_Team7 tblAeroplane_HMS03_Team7 = db.tblAeroplane_HMS03_Team7.Find(id);

            db.tblAeroplane_HMS03_Team7.Remove(tblAeroplane_HMS03_Team7);
            db.SaveChanges();
            MessageBox.Show("Flight deleted successfully!" + tblAeroplane_HMS03_Team7.AirplaneSeries);
            return(RedirectToAction("Index"));
        }
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblAeroplane_HMS03_Team7 tblAeroplane_HMS03_Team7 = db.tblAeroplane_HMS03_Team7.Find(id);

            //tblAeroplane_HMS03_Team7.ScheduleStatus = (string)Session["status"];
            if (tblAeroplane_HMS03_Team7 == null)
            {
                return(HttpNotFound());
            }
            //if(tblAeroplane_HMS03_Team7.PlaneRegistrationID=)
            return(View(tblAeroplane_HMS03_Team7));
        }
        public ActionResult Create([Bind(Include = "PlaneRegistrationID,DateOfCommencement,DateOdMAnufacturing,AirplaneSeries,Airline,Capacity_Premium,Capacity_FirstClass,Capacity_Economy,TakeOffWeight,MaximumDistance,LocationOfPlane,SchedulerID,RecentUpdate,ScheduleStatus")] tblAeroplane_HMS03_Team7 tblAeroplane_HMS03_Team7)
        {
            if (ModelState.IsValid)
            {
                if (tblAeroplane_HMS03_Team7.DateOdMAnufacturing > DateTime.Now && tblAeroplane_HMS03_Team7.DateOfCommencement > DateTime.Now)
                {
                    MessageBox.Show("manufacturing and commencement cannot be in future");
                    return(RedirectToAction("Create"));
                }
                else if (tblAeroplane_HMS03_Team7.DateOdMAnufacturing > DateTime.Now)
                {
                    MessageBox.Show("date of manufacturing cannot be in future");
                    return(RedirectToAction("Create"));
                }
                else if (tblAeroplane_HMS03_Team7.DateOfCommencement > DateTime.Now)
                {
                    MessageBox.Show("date of commencement cannot be in future");
                    return(RedirectToAction("Create"));
                }
                if (db.tblAeroplane_HMS03_Team7.Any(x => x.AirplaneSeries == tblAeroplane_HMS03_Team7.AirplaneSeries))
                {
                    //ModelState.AddModelError("CustomError", "name already exists");
                    MessageBox.Show("name already exists:" + tblAeroplane_HMS03_Team7.AirplaneSeries);
                    return(RedirectToAction("Create"));
                }

                if (tblAeroplane_HMS03_Team7.DateOfCommencement < tblAeroplane_HMS03_Team7.DateOdMAnufacturing)
                {
                    MessageBox.Show("can't be same or Date of Commencement should be greater than date of manufacturing");
                    return(RedirectToAction("Create"));
                }

                tblAeroplane_HMS03_Team7.SchedulerID    = int.Parse(Session["FMID"].ToString());
                tblAeroplane_HMS03_Team7.ScheduleStatus = "Not Scheduled";
                tblAeroplane_HMS03_Team7.RecentUpdate   = DateTime.Now;
                db.tblAeroplane_HMS03_Team7.Add(tblAeroplane_HMS03_Team7);
                db.SaveChanges();


                MessageBox.Show("Created successfully with ID:" + tblAeroplane_HMS03_Team7.PlaneRegistrationID);
                return(RedirectToAction("Index"));
            }

            ViewBag.SchedulerID = new SelectList(db.tblEmployee_HMS03_Team7, "EmployeeID", "Employee_Name", tblAeroplane_HMS03_Team7.SchedulerID);
            return(View(tblAeroplane_HMS03_Team7));
        }
        public ActionResult Search([Bind(Include = "PlaneRegistrationID,DateOfCommencement,DateOdMAnufacturing,AirplaneSeries,Airline,Capacity_Premium,Capacity_FirstClass,Capacity_Economy,TakeOffWeight,MaximumDistance,LocationOfPlane,SchedulerID,RecentUpdate,ScheduleStatus")] tblAeroplane_HMS03_Team7 flight)
        {
            Session["planeid"]    = flight.PlaneRegistrationID;
            Session["flightname"] = flight.AirplaneSeries;
            Session["airlines"]   = flight.Airline;
            var result = db.tblAeroplane_HMS03_Team7.Where(x => x.PlaneRegistrationID == flight.PlaneRegistrationID && x.AirplaneSeries == flight.AirplaneSeries && x.Airline == flight.Airline).FirstOrDefault();

            if (result != null)
            {
                return(RedirectToAction("Searchflights"));
            }
            else
            {
                MessageBox.Show("there are no flights existed for entered details");
                return(RedirectToAction("Search"));
            }
        }
 public ActionResult Edit([Bind(Include = "PlaneRegistrationID,DateOfCommencement,DateOdMAnufacturing,AirplaneSeries,Airline,Capacity_Premium,Capacity_FirstClass,Capacity_Economy,TakeOffWeight,MaximumDistance,LocationOfPlane,SchedulerID,RecentUpdate,ScheduleStatus")] tblAeroplane_HMS03_Team7 tblAeroplane_HMS03_Team7)
 {
     if (ModelState.IsValid)
     {
         if (tblAeroplane_HMS03_Team7.DateOdMAnufacturing > DateTime.Now && tblAeroplane_HMS03_Team7.DateOfCommencement > DateTime.Now)
         {
             MessageBox.Show("Manufacturing and commencement cannot be in future");
             return(RedirectToAction("Edit"));
         }
         if (tblAeroplane_HMS03_Team7.DateOfCommencement < tblAeroplane_HMS03_Team7.DateOdMAnufacturing)
         {
             MessageBox.Show("Can't be same or Date of Commencement should be greater than date of manufacturing");
             return(RedirectToAction("Edit"));
         }
         db.Entry(tblAeroplane_HMS03_Team7).State = EntityState.Modified;
         db.SaveChanges();
         MessageBox.Show("Updated successfully");
         return(RedirectToAction("Index"));
     }
     ViewBag.SchedulerID = new SelectList(db.tblEmployee_HMS03_Team7, "EmployeeID", "Employee_Name", tblAeroplane_HMS03_Team7.SchedulerID);
     return(View(tblAeroplane_HMS03_Team7));
 }
Example #8
0
        public ActionResult Create([Bind(Include = "ScheduleID,PlaneRegistrationID,Source,Destination,Departure,Arrival,Fare_Premium_Adult,Fare_Economy_Adult,Fare_Firstclass_Adult,Fare_Premium_Child,Fare_Firstclass_Child,Fare_Economy_Child,Availability_Premium,Availability_Firstclass,Availability_Economy,TravelDistance,StatusofFlight,BonusMiles,BonusMilesPoints")] tblSchedule_HMS03_Team7 tblSchedule_HMS03_Team7)
        {
            if (ModelState.IsValid)
            {
                tblSchedule_HMS03_Team7.StatusofFlight = "Scheduled";
                if (tblSchedule_HMS03_Team7.Source.Equals(tblSchedule_HMS03_Team7.Destination))
                {
                    MessageBox.Show("Source and destination can't be same");
                    // return RedirectToAction("Create");
                }
                if (tblSchedule_HMS03_Team7.Arrival < tblSchedule_HMS03_Team7.Departure)
                {
                    MessageBox.Show("Arrival should be after departure!");
                    return(RedirectToAction("VeiwScheduleToScheduler"));
                }
                if (tblSchedule_HMS03_Team7.Departure < DateTime.Now)
                {
                    MessageBox.Show("Departure should be in future!");
                    return(RedirectToAction("VeiwScheduleToScheduler"));
                }
                if (tblSchedule_HMS03_Team7.Departure.Subtract(DateTime.Now).TotalDays < 1)
                {
                    MessageBox.Show("Departure should be after 24 hours!");
                    return(RedirectToAction("VeiwScheduleToScheduler"));
                }
                var busy = db.tblSchedule_HMS03_Team7.Where(x => x.PlaneRegistrationID == tblSchedule_HMS03_Team7.PlaneRegistrationID && ((x.Departure <= tblSchedule_HMS03_Team7.Arrival && x.Arrival >= tblSchedule_HMS03_Team7.Arrival) || (x.Departure <= tblSchedule_HMS03_Team7.Departure && x.Arrival >= tblSchedule_HMS03_Team7.Departure))).FirstOrDefault();
                if (busy != null)
                {
                    MessageBox.Show("Flight already Scheduled!");
                    return(RedirectToAction("VeiwScheduleToScheduler"));
                }
                var duplicate = db.tblSchedule_HMS03_Team7.Where(x => x.Departure == tblSchedule_HMS03_Team7.Departure && x.Arrival == tblSchedule_HMS03_Team7.Arrival && x.Source == tblSchedule_HMS03_Team7.Source && x.Destination == tblSchedule_HMS03_Team7.Destination).FirstOrDefault();
                if (duplicate != null)
                {
                    MessageBox.Show("Duplicate Schedule!");
                    return(RedirectToAction("VeiwScheduleToScheduler"));
                }
                List <tblAeroplane_HMS03_Team7> alist = db.tblAeroplane_HMS03_Team7.ToList();
                foreach (var i in alist)
                {
                    if (i.PlaneRegistrationID == tblSchedule_HMS03_Team7.PlaneRegistrationID)
                    {
                        tblSchedule_HMS03_Team7 tr = new tblSchedule_HMS03_Team7();
                        i.ScheduleStatus = tblSchedule_HMS03_Team7.StatusofFlight;
                        db.SaveChanges();
                    }
                }

                //To increment the schedule count for the scheduled airplane
                tblAeroplane_HMS03_Team7 airplane = db.tblAeroplane_HMS03_Team7.Find(tblSchedule_HMS03_Team7.PlaneRegistrationID);
                /*airplane.SchedulerID = int.Parse(Session["FSID"].ToString());*/ //Change it to int.Parse(Session["EmployeeID"].ToString());
                                                                                  //airplane.ScheduleStatus = "Scheduled";

                tblSchedule_HMS03_Team7.Availability_Economy    = airplane.Capacity_Economy;
                tblSchedule_HMS03_Team7.Availability_Premium    = airplane.Capacity_Premium;
                tblSchedule_HMS03_Team7.Availability_Firstclass = airplane.Capacity_FirstClass;

                db.tblSchedule_HMS03_Team7.Add(tblSchedule_HMS03_Team7);
                db.SaveChanges();
                return(RedirectToAction("VeiwScheduleToScheduler"));
            }

            ViewBag.PlaneRegistrationID = new SelectList(db.tblAeroplane_HMS03_Team7, "PlaneRegistrationID", "AirplaneSeries", tblSchedule_HMS03_Team7.PlaneRegistrationID);
            return(View(tblSchedule_HMS03_Team7));
        }