public ReturnRentalReceipt(Controller controller, Invoice invoice, Form frm)
        {
            this.controller = controller;
            this.invoice = invoice;
            this.frm = frm;
            account = controller.getAccount(invoice.getAccountID());
            car = controller.getCar(invoice.getCarID());

            InitializeComponent();
            lblLastName.Text = account.getLastName();
            lblFirstName.Text = account.getFirstName();
            lblAccountNumber.Text = account.getDriversLicense();
            lblAddress.Text = account.getAddress();
            lblCity.Text = account.getCity();
            lblState.Text = account.getState();
            lblZip.Text = account.getZip();
            lblDays.Text = invoice.getDuration();
            lblPreCost.Text = String.Format("{0:C}",Double.Parse(invoice.getPreCharge()));
            lblMake.Text = car.getMake();
            lblModel.Text = car.getModel();
            lblModelCost.Text = String.Format("{0:C}", controller.rentalModelCost(car.getRentalModel()));
        }
Example #2
0
        internal Car getCar(string aCarId)
        {
            Car car = null;
            try
            {
                string sql = "SELECT Car.* FROM Car WHERE (Car.Id = @aCarId)";
                conn = new MySql.Data.MySqlClient.MySqlConnection(myConnectionString);
                MySqlCommand command = new MySqlCommand(sql, conn);
                command.Parameters.AddWithValue("aCarId", aCarId);

                conn.Open();

                MySqlDataReader reader = command.ExecuteReader();
                try
                {
                    while (reader.Read())
                    {
                        car = new Car(reader[0].ToString(), reader[1].ToString(), reader[2].ToString(), reader[3].ToString(), reader[4].ToString(), reader[5].ToString());
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    // Always call Close when done reading.
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                conn.Close();
            }
            return car;
        }