/// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        /// <exception cref="Exception">
        /// </exception>
        protected void Page_Load(object sender, EventArgs e)
        {
            int simulationId;
            int.TryParse(this.Request.QueryString["simulation"], out simulationId);

            try
            {
                Simulation simulation = new DataAccessLayer.Simulation().GetBy(new SearchParameter("Id", simulationId));
                if (simulation == null)
                {
                    throw new Exception("Indeling niet gevonden.");
                }

                if (simulation.Containers.Count(x => !x.Container.Active) > 0)
                {
                    throw new Exception("Indeling is niet up-to-date.");
                }

                var dalVessel = new DataAccessLayer.Vessel();
                var dalVesselContainer = new VesselContainer();
                var dalContainer = new DataAccessLayer.Container();

                var vessel = new Vessel { PortId = simulation.PortId, ShipId = simulation.ShipId, Created = DateTime.Now };
                dalVessel.Insert(vessel);

                foreach (SimulationContainer simulationContainer in simulation.Containers)
                {
                    var container = simulationContainer.Container;
                    container.Active = false;
                    dalContainer.Update(container);

                    var vesselContainer = new BusinessObjectLayer.VesselContainer
                                              {
                                                  VesselId = vessel.Id,
                                                  ContainerId = simulationContainer.ContainerId,
                                                  PositionX = simulationContainer.PositionX,
                                                  PositionY = simulationContainer.PositionY,
                                                  PositionZ = simulationContainer.PositionZ
                                              };
                    dalVesselContainer.Insert(vesselContainer);
                }

                this.SetFlash("Indeling succesvol omgezet.");
            }
            catch (Exception ex)
            {
                this.SetFlash("Omzetten van indeling niet gelukt. (Fout: " + ex.Message + ")", FlashType.Danger);
                this.Response.Redirect("/");
            }

            this.Response.Redirect("?page=Vessel");
        }
        /// <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);
        }