private void btnSubmit_Click(object sender, EventArgs e) { if (txtFName.Text == "" || txtLName.Text == "" || txtDOB.Text == "" || txtDriversLicenseNumber.Text == "" || txtAddress.Text == "" || txtCity.Text == "" || txtZip.Text == "") { MessageBox.Show("Invalid input"); } else{ Account account = new Account(txtDriversLicenseNumber.Text, txtFName.Text, txtLName.Text, txtDOB.Text, txtAddress.Text, txtCity.Text, cmboState.SelectedItem.ToString(), txtZip.Text); controller.addNewAccount(account); this.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())); }
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 teset() { ac = new Account(); ac.i = 21; }
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(); } }
internal Account getAccount(string aDriversLicense) { Account account = null; try { string sql = "SELECT Account.* FROM Account WHERE (Account.DriversLicense = @driversLicense)"; conn = new MySql.Data.MySqlClient.MySqlConnection(myConnectionString); MySqlCommand command = new MySqlCommand(sql, conn); command.Parameters.AddWithValue("driversLicense", aDriversLicense); conn.Open(); MySqlDataReader reader = command.ExecuteReader(); try { while (reader.Read()) { account = new Account(reader[0].ToString(), reader[1].ToString(), reader[2].ToString(), reader[3].ToString(), reader[4].ToString(), reader[5].ToString(), reader[6].ToString(), reader[7].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 account; }
internal void addNewAccount(Account account) { database.addNewAccount(account); }