예제 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            this.Hide();
            var RentVehicle = new RentVehicle();

            RentVehicle.Closed += (s, args) => this.Close();
            RentVehicle.Show();
        }
예제 #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);
            }
        }