Exemplo n.º 1
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            try
            {
                foreach (string X in lbAddedToBooking.Items)
                {
                    ControllerClass.DemoMachines.Add(X);
                }
                string Name1   = txtName1.Text;
                string Name2   = txtName2.Text;
                string Att     = txtATT.Text;
                string Address = txtAdresss.Text;
                string Country = coboCountry.Text;
                int    ZIP     = Convert.ToInt32(txtZipCode.Text);
                string City    = txtCity.Text;
                int    Phone   = Convert.ToInt32(txtPhone.Text);
                int    Selected;

                if (rbtnYes.Checked == true)
                {
                    Selected = 0;
                }

                else
                {
                    Selected = 1;
                }
                string         salesRep    = coboSalesRep.Text;
                string         Date1       = dtpDeliveryDate.Value.ToShortDateString();
                string         Date2       = dtpRetrievalDate.Value.ToShortDateString();
                string         Transporter = txtCarrier.Text;
                string         Message1    = txtMessageToWorkshop.Text;
                string         Message2    = txtDeliveryNote.Text;
                string         Konfig      = txtKonfig.Text;
                List <TextBox> textBoxList = new List <TextBox>
                {
                    txtName1, txtName2, txtATT, txtAdresss, txtZipCode, txtCity,
                    txtPhone, txtCarrier, txtMessageToWorkshop, txtDeliveryNote
                };

                foreach (TextBox t in textBoxList)
                {
                    if (String.IsNullOrEmpty(t.Text))
                    {
                        MessageBox.Show("Please fill out empty boxes");
                        return;
                    }
                }
                if (String.IsNullOrEmpty(Date1))
                {
                    MessageBox.Show("Please fill out empty boxes");
                    return;
                }
                else if (String.IsNullOrEmpty(Date2))
                {
                    MessageBox.Show("Please fill out empty boxes");
                    return;
                }
                else if (lbAddedToBooking.Items.Count <= 0)
                {
                    MessageBox.Show("Please fill out empty boxes");
                    return;
                }
                else if (String.IsNullOrEmpty(coboCountry.Text))
                {
                    MessageBox.Show("Please fill out empty boxes");
                    return;
                }
                else if (String.IsNullOrEmpty(coboSalesRep.Text))
                {
                    MessageBox.Show("Please fill out empty boxes");
                    return;
                }
                else
                {
                    CTRC.AddCustomer(Name1, Name2, Att, Address, ZIP, City, Country, Phone);
                    CTRC.CreateBooking(salesRep, Date1, Date2, Transporter, Message1, Message2, Selected);
                    CTRC.CreateBookingLine(Konfig);
                    this.Visible = false;
                }
            }
            catch
            {
                MessageBox.Show("Please only use alphabetical Aa - Åå");
            }
        }