void Submit_Click(object sender, EventArgs e) { try { BusinessObjectLayer.Ship ship = new Ship() { Connections = int.Parse(this.Connections.Text.Trim()), Height = int.Parse(this.Height.Text.Trim()), Length = int.Parse(this.Length.Text.Trim()), Width = int.Parse(this.Width.Text.Trim()), Name = this.Name.Text.Trim() }; DataAccessLayer.Ship dalShip = new DataAccessLayer.Ship(); if (dalShip.GetAllBy(new List<SearchParameter>() {new SearchParameter("Name", ship.Name)}).Count > 0) { throw new Exception("Er is al een schip type met deze naam."); } dalShip.Insert(ship); this.SetFlash("Schip type succesvol toegevoegd."); } catch (Exception ex) { this.SetFlash("Er is iets misgegaan. Probeer het nogmaals a.u.b. (Fout: " + ex.Message + ")", FlashType.Danger); this.Response.Redirect(this.Request.RawUrl); } this.Response.RedirectPermanent("?page=DropDownShip"); }
/// <summary> /// The submit_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void Submit_Click(object sender, EventArgs e) { int portId; int shipId; int.TryParse(this.DropDownPort.SelectedValue, out portId); int.TryParse(this.DropDownShip.SelectedValue, out shipId); this.Ship = new DataAccessLayer.Ship().GetBy(new SearchParameter("Id", shipId)); this.Port = new DataAccessLayer.Port().GetBy(new SearchParameter("Id", portId)); this.Run(); }
/// <summary> /// The export_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void Export_Click(object sender, EventArgs e) { int portId; int shipId; int.TryParse(this.DropDownPort.SelectedValue, out portId); int.TryParse(this.DropDownShip.SelectedValue, out shipId); this.Ship = new DataAccessLayer.Ship().GetBy(new SearchParameter("Id", shipId)); this.Port = new DataAccessLayer.Port().GetBy(new SearchParameter("Id", portId)); this.Run(); string filename = string.Empty; try { var dalSimulation = new Simulation(); var dalSimulationContainer = new SimulationContainer(); var simulation = new BusinessObjectLayer.Simulation { PortId = this.Port.Id, ShipId = this.Ship.Id, Created = DateTime.Now }; dalSimulation.Insert(simulation); foreach (Location location in this.Locations) { if (location.Container != null) { var container = new BusinessObjectLayer.SimulationContainer { SimulationId = simulation.Id, ContainerId = location.Container.Id, PositionX = location.X, PositionY = location.Y, PositionZ = location.Z }; dalSimulationContainer.Insert(container); } } simulation = dalSimulation.GetBy(new SearchParameter("Id", simulation.Id)); filename = simulation.ExportSimulation(this.Request.PhysicalApplicationPath + "/Files/Simulations/"); } catch (Exception ex) { this.SetFlash( "Het exporteren van de indeling is mislukt. Probeer het nogmaals a.u.b.. (Fout: " + ex.Message + ")", FlashType.Danger); this.Response.Redirect(this.Request.RawUrl); } this.Response.Redirect("/Files/Simulations/" + filename); }