Пример #1
0
        /// <summary>
        /// Voegt een Bestemming toe aan de DB
        /// </summary>
        /// <param name="bestemming"></param>
        /// <returns></returns>
        public bool AddBestemming(Bestemming bestemming)
        {
            bool success = false;

            try
            {
                string        sql = @"INSERT INTO Bestemming VALUES( :naam, :land)";
                OracleCommand cmd = new OracleCommand(sql, conn);
                cmd.Parameters.Add("naam", OracleDbType.Varchar2, bestemming.Naam, ParameterDirection.Input);
                cmd.Parameters.Add("land", OracleDbType.Varchar2, bestemming.Land, 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>
        /// Voegt een Bestemming toe aan de DB
        /// </summary>
        /// <param name="bestemming"></param>
        /// <returns></returns>
        public bool AddBestemming(Bestemming bestemming)
        {
            bool success = false;

            try
            {
                string sql = @"INSERT INTO Bestemming VALUES( :naam, :land)";
                OracleCommand cmd = new OracleCommand(sql, conn);
                cmd.Parameters.Add("naam", OracleDbType.Varchar2, bestemming.Naam, ParameterDirection.Input);
                cmd.Parameters.Add("land", OracleDbType.Varchar2, bestemming.Land, ParameterDirection.Input);
                cmd.CommandType = CommandType.Text;
                Open();
                if (cmd.ExecuteNonQuery() == 0)
                    success = false;
                else
                    success = true;
            }
            catch
            {
                success = false;
            }
            finally
            {
                conn.Close();
            }
            return success;
        }
Пример #3
0
        /// <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();
        }
Пример #4
0
        /// <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();
        }
Пример #5
0
 public Container(int id, string bedrijf, Bestemming bestemming, int gewicht, ContainerType type, bool ingeplanned)
 {
     this.ID = id;
     this.Containertruckingbedrijf = bedrijf;
     this.CBestemming = bestemming;
     this.Gewicht     = gewicht;
     this.Type        = type;
     this.Ingeplanned = ingeplanned;
 }
Пример #6
0
 public Container(int id, string bedrijf, Bestemming bestemming, int gewicht, ContainerType type, bool ingeplanned)
 {
     this.ID = id;
     this.Containertruckingbedrijf = bedrijf;
     this.CBestemming = bestemming;
     this.Gewicht = gewicht;
     this.Type = type;
     this.Ingeplanned = ingeplanned;
 }
Пример #7
0
        private void btn_Con_Voegtoe_Click(object sender, EventArgs e)
        {
            bool fout = false;
            //Type container invoer controleren
            ContainerType type;

            if (!Enum.TryParse <ContainerType>(cb_Con_Type.SelectedValue.ToString(), out type))
            {
                MessageBox.Show("Fout type");
                fout = true;
            }
            //Bedrijf invoer controleren
            Containertruckingbedrijf bedrijf = null;

            foreach (Containertruckingbedrijf b in beheer.Bedrijven)
            {
                if (b.ToString() == cb_Con_Bedrijf.SelectedValue.ToString())
                {
                    bedrijf = b;
                }
            }
            if (bedrijf == null)
            {
                MessageBox.Show("Fout bedrijf");
                fout = true;
            }
            //Bestemming invoer controleren
            Bestemming bestemming = null;

            foreach (Bestemming b in beheer.Bestemmingen)
            {
                if (b.ToString() == cb_Con_Bestemming.SelectedValue.ToString())
                {
                    bestemming = b;
                }
            }
            if (bestemming == null)
            {
                MessageBox.Show("Fout bestemming");
                fout = true;
            }
            //Gewicht invoer controleren
            int gewicht = 0;

            if (!int.TryParse(tb_Con_Gewicht.Text, out gewicht))
            {
                MessageBox.Show("Gewicht moet een getal zijn!");
                fout = true;
            }

            if (!fout)
            {
                if (!database.AddContainer(new Container(0, bedrijf.Naam, bestemming, gewicht, type, false)))
                {
                    MessageBox.Show("Fout bij toevoegen");
                }
                else
                {
                    MessageBox.Show("Container toegevoegd.", "Gelukt!", MessageBoxButtons.OK);
                }
            }
            beheer.Refresh();
        }
Пример #8
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;
            }
        }