private void btnSubmit_Click(object sender, EventArgs e) { account = controller.getAccount(txtDriversLicense.Text); Invoice checkForInvoice = controller.lookupInvoiceForAccount(txtDriversLicense.Text); if (account == null) { MessageBox.Show("Account could not be found"); } else if (checkForInvoice != null) { MessageBox.Show("You have already rented a car that has not been returned yet."); } else { invoice.setAccountID(account.getDriversLicense()); controller.saveInvoice(invoice, false); MessageBox.Show("Enjoy your rental", "My Application", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.Close(); frm.Close(); } }
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())); }
internal void addNewAccount(Account account) { try { DateTime dt = DateTime.Parse(account.getDOB()); string sql = "INSERT INTO Account (DriversLicense, FirstName, LastName, DOB, Address, City, State, Zip) values(@driversLicense, @firstName, @lastName, @dob, @address, @city, @state, @zip)"; conn = new MySql.Data.MySqlClient.MySqlConnection(myConnectionString); MySqlCommand command = new MySqlCommand(sql, conn); command.Parameters.AddWithValue("driversLicense", account.getDriversLicense()); command.Parameters.AddWithValue("firstName", account.getFirstName()); command.Parameters.AddWithValue("lastName", account.getLastName()); command.Parameters.AddWithValue("dob", dt.ToString("yyyy-MM-dd")); command.Parameters.AddWithValue("address", account.getAddress()); command.Parameters.AddWithValue("city", account.getCity()); command.Parameters.AddWithValue("state", account.getState()); command.Parameters.AddWithValue("zip", account.getZip()); conn.Open(); command.ExecuteNonQuery(); MessageBox.Show("Added new account !!", "message", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { conn.Close(); } }