Ejemplo n.º 1
0
        private void ViewSoldVehiclesButton_Click(object sender, EventArgs e)
        {
            Hide();
            ViewSoldVehiclesF vsv = new ViewSoldVehiclesF();

            vsv.Show();
        }
        private void button4_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(FirstNameTextbox.Text) || string.IsNullOrEmpty(AmountTextBox.Text) || string.IsNullOrEmpty(LastNameTextBox.Text) || string.IsNullOrEmpty(MobileNoTextBox.Text) || string.IsNullOrEmpty(EmailTextbox.Text) || string.IsNullOrEmpty(AddressTextBox.Text) || string.IsNullOrEmpty(InsuranceCoTextBox.Text) || string.IsNullOrEmpty(InsIDTextbox.Text) || string.IsNullOrEmpty(VehicleIdTextBox.Text))
            {
                MessageBox.Show("Insufficient Information \n Please Fill-up all information", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            else
            {
                try
                {
                    int temp = Convert.ToInt32(AmountTextBox.Text);


                    try
                    {
                        var customerRegister = new customer
                        {
                            fName            = FirstNameTextbox.Text.Trim(),
                            lName            = LastNameTextBox.Text.Trim(),
                            mobile           = MobileNoTextBox.Text.Trim(),
                            email            = EmailTextbox.Text.Trim(),
                            address          = AddressTextBox.Text.Trim(),
                            insuranceCompany = InsuranceCoTextBox.Text.Trim(),
                            insuranceId      = InsIDTextbox.Text.Trim(),
                            invoiceDate      = InvoiceDatePicker.Value.Date,
                            warrentyS        = WstartDatePicker.Value.Date,
                            warrentyE        = WendDatePicker.Value.Date,
                            vehicleId        = Int32.Parse(VehicleIdTextBox.Text),
                            paymentType      = PaymentTypeComboBox.SelectedItem.ToString()
                        };
                        _repousr2.Create(customerRegister);
                        int id_of_car = AddViewDeleteF.carid;
                        int sellPrice = Int32.Parse(AmountTextBox.Text.Trim());
                        _repousr3.Update(id_of_car, sellPrice);

                        MessageBox.Show("Provided Informations Successfully Inserted!!");
                        this.Visible = false;
                        ViewSoldVehiclesF vsv = new ViewSoldVehiclesF();
                        vsv.Visible = true;
                    }

                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
                catch (Exception h)
                {
                    MessageBox.Show("Please provide number Input for Amount");
                }
            }
        }