Beispiel #1
0
        /// <summary>
        /// Voegt een Schip toe aan de DB
        /// </summary>
        /// <param name="schip"></param>
        /// <returns></returns>
        public bool AddSchip(Schip schip)
        {
            bool success = false;

            try
            {
                string        sql = @"INSERT INTO Schip VALUES( :naam, :hoogte, :rijen, :containersperrij, :stroomaansluitingen)";
                OracleCommand cmd = new OracleCommand(sql, conn);
                cmd.Parameters.Add("naam", OracleDbType.Varchar2, schip.Type, ParameterDirection.Input);
                cmd.Parameters.Add("hoogte", OracleDbType.Int32, schip.Hoogte, ParameterDirection.Input);
                cmd.Parameters.Add("rijen", OracleDbType.Int32, schip.Rijen, ParameterDirection.Input);
                cmd.Parameters.Add("containersperrij", OracleDbType.Int32, schip.ContainersPerRij, ParameterDirection.Input);
                cmd.Parameters.Add("stroomaansluitingen", OracleDbType.Int32, schip.StroomAansluitingen, ParameterDirection.Input);
                cmd.CommandType = CommandType.Text;
                Open();
                if (cmd.ExecuteNonQuery() == 0)
                {
                    success = false;
                }
                else
                {
                    success = true;
                }
            }
            catch
            {
                success = false;
            }
            finally
            {
                conn.Close();
            }
            return(success);
        }
        /// <summary>
        /// Constructor voor Inplanning
        /// </summary>
        /// <param name="bestemming">Bestemming voor deze inplanning</param>
        /// <param name="schip">Schip om op in te plannen</param>
        public Inplanning(Bestemming bestemming, Schip schip)
        {
            this.PBestemming = bestemming;
            this.PSchip      = schip;

            DeelIn();
        }
        /// <summary>
        /// Constructor voor Inplanning
        /// </summary>
        /// <param name="bestemming">Bestemming voor deze inplanning</param>
        /// <param name="schip">Schip om op in te plannen</param>
        public Inplanning(Bestemming bestemming, Schip schip)
        {
            this.PBestemming = bestemming;
            this.PSchip = schip;

            DeelIn();
        }
        /// <summary>
        /// Voegt een Schip toe aan de DB
        /// </summary>
        /// <param name="schip"></param>
        /// <returns></returns>
        public bool AddSchip(Schip schip)
        {
            bool success = false;

            try
            {
                string sql = @"INSERT INTO Schip VALUES( :naam, :hoogte, :rijen, :containersperrij, :stroomaansluitingen)";
                OracleCommand cmd = new OracleCommand(sql, conn);
                cmd.Parameters.Add("naam", OracleDbType.Varchar2, schip.Type, ParameterDirection.Input);
                cmd.Parameters.Add("hoogte", OracleDbType.Int32, schip.Hoogte, ParameterDirection.Input);
                cmd.Parameters.Add("rijen", OracleDbType.Int32, schip.Rijen, ParameterDirection.Input);
                cmd.Parameters.Add("containersperrij", OracleDbType.Int32, schip.ContainersPerRij, ParameterDirection.Input);
                cmd.Parameters.Add("stroomaansluitingen", OracleDbType.Int32, schip.StroomAansluitingen, ParameterDirection.Input);
                cmd.CommandType = CommandType.Text;
                Open();
                if (cmd.ExecuteNonQuery() == 0)
                    success = false;
                else
                    success = true;
            }
            catch
            {
                success = false;
            }
            finally
            {
                conn.Close();
            }
            return success;
        }
Beispiel #5
0
        private void btnMaakIndeling_Click(object sender, EventArgs e)
        {
            bool fout = false;
            //Bestemming invoer controleren
            Bestemming bestemming = null;

            foreach (Bestemming b in beheer.Bestemmingen)
            {
                if (b.ToString() == comboBoxBestemming.SelectedValue.ToString())
                {
                    bestemming = b;
                }
            }
            if (bestemming == null)
            {
                MessageBox.Show("Fout bestemming");
                fout = true;
            }

            //Schip invoer controleren
            Schip schip = null;

            foreach (Schip s in beheer.Schepen)
            {
                if (s.ToString() == comboBoxSchip.SelectedValue.ToString())
                {
                    schip = s;
                }
            }
            if (schip == null)
            {
                MessageBox.Show("Fout schip");
                fout = true;
            }
            if (!fout)
            {
                listBoxIndeling.Items.Clear();
                listBoxInfo.Items.Clear();
                planning = new Inplanning(bestemming, schip);
                for (int laag = 0; laag < planning.SchipLading.GetLength(0); laag++)
                {
                    listBoxIndeling.Items.Add("Laag " + laag + ":");
                    for (int rij = 0; rij < planning.SchipLading.GetLength(1); rij++)
                    {
                        string regel = string.Empty;
                        for (int diepte = 0; diepte < planning.SchipLading.GetLength(2); diepte++)
                        {
                            string type = "_";
                            if (planning.SchipLading[laag, rij, diepte] != null)
                            {
                                type = planning.SchipLading[laag, rij, diepte].Type.ToString();
                            }
                            regel += type + " ";
                        }
                        listBoxIndeling.Items.Add(regel);
                    }
                }
                //Trivia invoeren in een listbox
                listBoxInfo.Items.Add("Gewicht links: " + planning.GewichtLinks.ToString());
                listBoxInfo.Items.Add("Gewicht rechts: " + planning.GewichtRechts.ToString());
                listBoxInfo.Items.Add("Gewicht totaal: " + (planning.GewichtLinks + planning.GewichtRechts).ToString());
                listBoxInfo.Items.Add(string.Empty);
                listBoxInfo.Items.Add("Balans links: " + Math.Round(Convert.ToDouble(planning.GewichtLinks) / (Convert.ToDouble(planning.GewichtLinks + planning.GewichtRechts)), 2));
                listBoxInfo.Items.Add("Balans rechts: " + Math.Round(Convert.ToDouble(planning.GewichtRechts) / (Convert.ToDouble(planning.GewichtLinks + planning.GewichtRechts)), 2));
                listBoxInfo.Items.Add("Maximaal gewicht op een container: " + planning.MaxVerticaalGewicht.ToString());

                btnMarkeer.Enabled   = true;
                btnExporteer.Enabled = true;
            }
        }