Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (RVUtil.isEmpty(textBox2.Text))
                {
                    MessageBox.Show(RVMessage.NoCatIndentified);
                }
                else
                {
                    RentVehicleControl mcControl           = new RentVehicleControl();
                    DataTable          rentalAvailableList = mcControl.retrieveVehicleInfo(textBox2.Text.ToString());
                    dataGridView1.DataSource = rentalAvailableList;
                    dateTimePicker1.Enabled  = true;
                    textBox1.ReadOnly        = false;
                    button2.Enabled          = true;
                }
            }
            catch (Exception excep)
            {
                Console.WriteLine("Exception !!!");
                Console.WriteLine(excep.Message);
                Console.WriteLine(excep.StackTrace);
                MessageBox.Show(RVMessage.GenError);

                // cancel form load event and close the form
                this.BeginInvoke(new MethodInvoker(this.Close));
            }
        }
Example #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                if (RVUtil.isEmpty(textBox1.Text))
                {
                    MessageBox.Show(RVMessage.EmptyCustomerID);
                    return;
                }
                else
                {
                    RentVehicleControl rvControl = new RentVehicleControl();

                    int             selectedrowindex = dataGridView1.SelectedCells[0].RowIndex;
                    DataGridViewRow selectedRow      = dataGridView1.Rows[selectedrowindex];

                    Vehicle c = new Vehicle();
                    c.plateNo = Convert.ToString(selectedRow.Cells[0].Value);

                    rvControl.updateVehicleInfo(c);

                    Rental r = new Rental();
                    r.customerID   = textBox1.Text.ToString();
                    r.plateNum     = Convert.ToString(selectedRow.Cells[0].Value);
                    r.dateOfRental = dateTimePicker1.Value.ToShortDateString();

                    rvControl.createRental(r);


                    MessageBox.Show(RVMessage.RentVehicleSuccessful);

                    this.Hide();
                    var RentVehicle = new RentVehicle();
                    RentVehicle.Closed += (s, args) => this.Close();
                    RentVehicle.Show();
                }
            }
            catch (RVException dftExcep)
            {
                Console.WriteLine("Exception !!!");
                Console.WriteLine(dftExcep.Message);
                Console.WriteLine(dftExcep.StackTrace);
                MessageBox.Show(dftExcep.Message);
            }
            catch (Exception excep)
            {
                Console.WriteLine("Exception !!!");
                Console.WriteLine(excep.Message);
                Console.WriteLine(excep.StackTrace);
                MessageBox.Show(RVMessage.GenError);
            }
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (RVUtil.isEmpty(textBox1.Text))
                {
                    MessageBox.Show(RVMessage.EmptyPlateNo);
                    textBox2.Text = String.Empty;
                    textBox3.Text = String.Empty;
                    textBox4.Text = String.Empty;
                    textBox5.Text = String.Empty;
                    textBox6.Text = String.Empty;
                }
                else
                {
                    EnquiryVehicleStatusControl evControl = new EnquiryVehicleStatusControl();
                    Vehicle c = evControl.RetrievePlateNo(textBox1.Text.ToString());

                    textBox1.Text = String.Empty;
                    textBox2.Text = c.model;
                    textBox3.Text = c.colour;
                    textBox4.Text = c.engineNo;
                    textBox5.Text = c.status;
                    textBox6.Text = c.plateNo;
                }
            }
            catch (RVException rvExcep)
            {
                Console.WriteLine("Exception !!!");
                Console.WriteLine(rvExcep.Message);
                Console.WriteLine(rvExcep.StackTrace);
                MessageBox.Show(rvExcep.Message);
            }
            catch (Exception excep)
            {
                Console.WriteLine("Exception !!!");
                Console.WriteLine(excep.Message);
                Console.WriteLine(excep.StackTrace);
                MessageBox.Show(RVMessage.GenError);
            }
        }