private void saveChanges_Click(object sender, EventArgs e) { if (!changesSaved) { try { if (CheckInput()) { RouteID routeID = (RouteID)routesIDList.SelectedItem; string company = carCompanyIn.Text.Trim(); int fuelCapacity = Convert.ToInt32(fuelCapacityIn.Text); int fuelConsumption = Convert.ToInt32(fuelConsumptionIn.Text); if (Car == null) { CarID carID = new CarID(Convert.ToInt32(carIDIn.Text)); Car = new RouteTaxi(carID, company, routeID, fuelCapacity, fuelConsumption); } else { Car.Company = company; Car.RouteID = routeID; } IsHandled = true; changesSaved = true; saveChanges.Enabled = false; } } catch (Exception exception) { MessageBox.Show(exception.Message); } } }
private void editCar_Click(object sender, EventArgs e) { if (carsList.SelectedIndex > -1) { int index = carsList.SelectedIndex; List <CarID> carsIDList = new List <CarID>(); foreach (Transport car in Cars) { carsIDList.Add(car.ID); } if ((Cars[index] as RouteTaxi) != null) { EditRouteTaxi editRouteTaxi = new EditRouteTaxi(carsIDList, "Edit car", (RouteTaxi)Cars[index]); editRouteTaxi.ShowDialog(); if (editRouteTaxi.IsHandled) { Cars[index] = new RouteTaxi(editRouteTaxi.Car); carsList.SelectedIndex = Cars.Count - 1; carsList_SelectedIndexChanged(this, new EventArgs()); changesSaved = false; EnableSave(true); } } } }
public ActionResult DeleteConfirmed(int id) { RouteTaxi routeTaxi = db.RouteTaxis.Find(id); db.RouteTaxis.Remove(routeTaxi); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,Seats,RouteId,Model,Mileage,PurchaseDate,WriteOffDate,Cat")] RouteTaxi routeTaxi) { if (ModelState.IsValid) { db.Entry(routeTaxi).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.RouteId = new SelectList(db.Routes, "Id", "Name", routeTaxi.RouteId); return(View(routeTaxi)); }
public EditRouteTaxi(List <CarID> carsIDList, string caption, RouteTaxi car = null) { InitializeComponent(); CarsIDList = carsIDList; Text = caption; Car = car; IsHandled = false; SetTypes(); FillData(); }
// GET: RouteTaxis/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RouteTaxi routeTaxi = db.RouteTaxis.Find(id); if (routeTaxi == null) { return(HttpNotFound()); } return(View(routeTaxi)); }
// GET: RouteTaxis/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RouteTaxi routeTaxi = db.RouteTaxis.Find(id); if (routeTaxi == null) { return(HttpNotFound()); } ViewBag.RouteId = new SelectList(db.Routes, "Id", "Name", routeTaxi.RouteId); return(View(routeTaxi)); }