Exemplo n.º 1
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;
            }
        }
Exemplo n.º 2
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;
            }
        }