Пример #1
0
 private void btnAddMachine_Click(object sender, EventArgs e)
 {
     try
     {
         if (CC.CheckConnection() == true)
         {
             AddMachine TM = new AddMachine();
             TM.Show();
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Connection error");
     }
 }
Пример #2
0
        private void btnRemove_Click(object sender, EventArgs e)
        {
            try
            {
                if (CC.CheckConnection() == false)
                {
                    throw new Exception();
                }


                try
                {
                    DialogResult dRes = MessageBox.Show("Are you sure you want to delete Booking ID " + CC.BookingIntSpawner(libBookingID.SelectedItem.ToString()) + "?", "Attention!", MessageBoxButtons.YesNo);
                    if (dRes == DialogResult.Yes)
                    {
                        string BookingID         = CC.BookingIntSpawner(libBookingID.SelectedItem.ToString());
                        int    bookingIDSelected = Convert.ToInt32(BookingID);
                        CC.RemoveBooking(bookingIDSelected);
                        MessageBox.Show("Booking removed: Booking ID:" + bookingIDSelected);
                        libBookingID.Items.Clear();
                    }
                    else
                    {
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Error: Booking not removed");
                }
            }

            catch (Exception
                   )
            {
                MessageBox.Show("Connection error");
            }
        }
Пример #3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (txtModelname.Text != "")
            {
                try
                {
                    CC.CheckConnection();
                    CC.AddModelName(txtModelname.Text);
                    this.Close();
                }
                catch (Exception)
                {
                    MessageBox.Show("Connection error");
                }
            }

            else
            {
                MessageBox.Show("Write the model name you want to add and then press the 'Add' button");
            }
        }
Пример #4
0
        private void btnManageUsers_Click(object sender, EventArgs e)
        {
            try
            {
                if (CC.CheckConnection() == true)
                {
                    ManageUsers MU = new ManageUsers();
                    MU.Show();
                    this.Visible = false;
                }

                else
                {
                    MessageBox.Show("Connection error");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Connection error");
            }
        }
Пример #5
0
        private void btnSaveMachine_Click(object sender, EventArgs e)
        {
            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 <TextBox> textBoxList1 = 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 textBoxList1)
            {
                if (String.IsNullOrEmpty(t.Text))
                {
                    MessageBox.Show("Please fill all empty boxes");
                    return;
                }
            }
            if (String.IsNullOrEmpty(ModelName))
            {
                MessageBox.Show("Please fill all empty boxes");
                return;
            }

            try
            {
                CC.CheckConnection();
                CC.UpdateInformation(DemoNumber, ModelName, ModelNumber, Brand, CNumber, MastType, MastBuildingHeight, MastLiftHeight,
                                     MastFreeLift, AggregatType, AggregatNumber, BatteryType, BatteryNumber, ChargerType, ChargerNumber,
                                     Controller, Weight, Height, Length, Width, oldDemoNumber);
                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 tb in textBoxList)
                {
                    tb.ReadOnly = true;
                }
                cbModelName.Enabled    = false;
                btnSaveMachine.Visible = false;
                btnEditMachine.Visible = true;
            }
            catch (Exception)
            {
                MessageBox.Show("Connection error");
            }
        }