コード例 #1
0
        //Add container to the database
        private void btAddContainer_Click(object sender, EventArgs e)
        {
            Container container = new Container();
            ContainerType containerType = new ContainerType();
            string error = string.Empty;
            lbError.Text = string.Empty;

            //Check if all fields have input
            if(costumer.id == 0)
            {
                error += "Geen bedrijf geselecteerd \n";
            }

            //Check if a type or destination is selected
            containerType = containerTypes[cbType.SelectedIndex];
            destination = destinations[cbDestination.SelectedIndex];

            if(containerType.id == 0)
            {
                error += "Geen type geselecteerd \n";
            }

            if (destination.id == 0)
            {
                error += "Geen bestemming geselecteerd \n";
            }

            //check if weight is a number
            try
            {
                additionalWeight = Convert.ToInt16(NUPWeight.Value);
            }
            catch(Exception ex)
            {
                error += "Geen correct gewicht nummer \n";
            }

            //check if weight is not 0
            if (additionalWeight < 1)
            {
                error += "Gewicht mag niet nul zijn \n";
            }

            //DEBUG
            //if (error != string.Empty)

            //If there are no errors add the container to the database
            if (error == string.Empty)
            {
                //In case of database failure check result
                bool succes = container.Add(costumer, containerType, destination, additionalWeight);

                //if succes empty form
                if (succes)
                {
                    lbError.Text = string.Empty;
                    NUPWeight.Value = 0;
                    cbType.SelectedIndex = -1;
                    cbDestination.SelectedIndex = -1;
                }
                else
                {
                    //Show errors
                    error += "Er is iets fout gegaan bij het wegschijven";
                    lbError.Text = error;
                }

            }
            else
            {
                //Show errors
                lbError.Text = error;
            }
        }
コード例 #2
0
        //Fill textbox with the found vontainer spots
        private void FillTextBox()
        {
            string text = "\n\n";
            for(int z = 1; z <= freighter.maxHeight; z++)
            {
                text += "Laag " + z + ":\n";

                for (int x = 1; x <= freighter.containerRows; x++)
                {
                    for (int y = 1; y <= freighter.containersEachRow; y++)
                    {
                        ContainerType containertype = new ContainerType();
                        containertype = CheckIfPositionTypeIsFilled(x,y,z);

                        if(containertype != null)
                        {
                            if (containertype.chilled == 0 && containertype.valuable == 0)
                                text += "C ";
                            else
                                text += (containertype.valuable == 1 ? "V " : "E ");
                        }
                        else
                            text += "_ ";
                    }

                    text += "\n";
                }

                text += "\n";

            }

            rtbMapping.Text = text;
        }