Esempio n. 1
0
        private void btnAddMachine_Click(object sender, EventArgs e)
        {
            try
            {
                string  DemoNumber         = txtDemoMachine.Text;
                string  ModelName          = cbModelName.Text;
                string  ModelNumber        = txtModelNumber.Text;
                string  Brand              = txtBrand.Text;
                string  CNumber            = txtChassisNumber.Text;
                string  MastType           = txtMastType.Text;
                int     MastBuildingHeight = Convert.ToInt32(txtMastBuildingHeight.Text);
                int     MastLiftHeight     = Convert.ToInt32(txtMastLiftingHeight.Text);
                int     MastFreeLift       = Convert.ToInt32(txtMastFreeLift.Text);
                string  AggregatType       = txtAggregateType.Text;
                string  AggregatNumber     = txtAggregateNumber.Text;
                string  BatteryType        = txtBatteryType.Text;
                string  BatteryNumber      = txtBatteryNumber.Text;
                string  ChargerType        = txtChargerType.Text;
                string  ChargerNumber      = txtChargerNumber.Text;
                string  Controller         = txtController.Text;
                decimal Weight             = Convert.ToDecimal(txtWeight.Text.Replace('.', ','));
                decimal Height             = Convert.ToDecimal(txtHeight.Text.Replace('.', ','));
                decimal Length             = Convert.ToDecimal(txtLength.Text.Replace('.', ','));
                decimal Width              = Convert.ToDecimal(txtWidth.Text.Replace('.', ','));

                List <string>  configurationsList = new List <string>();
                List <TextBox> textBoxList        = new List <TextBox>
                {
                    txtDemoMachine, txtModelNumber,
                    txtBrand, txtChassisNumber, txtMastType, txtMastBuildingHeight,
                    txtMastLiftingHeight, txtMastFreeLift, txtAggregateType,
                    txtAggregateNumber, txtBatteryType, txtBatteryNumber, txtChargerType,
                    txtChargerNumber, txtController, txtWeight, txtHeight, txtLength,
                    txtWidth
                };
                foreach (TextBox t in textBoxList)
                {
                    if (String.IsNullOrEmpty(t.Text))
                    {
                        MessageBox.Show("Please fill all empty boxes");
                    }
                }
                if (String.IsNullOrEmpty(ModelName))
                {
                    MessageBox.Show("Please fill all empty boxes");
                }

                try
                {
                    CC.CreateMachine(DemoNumber, ModelName, ModelNumber, Brand, CNumber, MastType, MastBuildingHeight, MastLiftHeight,
                                     MastFreeLift, AggregatType, AggregatNumber, BatteryType, BatteryNumber, ChargerType, ChargerNumber,
                                     Controller, Weight, Height, Length, Width, configurationsList);

                    MessageBox.Show("The machine has been added");
                    this.Visible = false;
                }
                catch (Exception)
                {
                    MessageBox.Show("Connection error");
                }
            }

            catch { }
        }