public void saveInvoice(Invoice invoice) { try{ DateTime dt = DateTime.Parse(invoice.getDate()); string sql = "INSERT INTO Invoice (CarId, AccountId, Duration, PreCharge, Date) values(@carId, @accountId, @duration, @preCharge, @date)"; conn = new MySql.Data.MySqlClient.MySqlConnection(myConnectionString); MySqlCommand command = new MySqlCommand(sql,conn); command.Parameters.AddWithValue("carId", invoice.getCarID()); command.Parameters.AddWithValue("accountId", invoice.getAccountID()); command.Parameters.AddWithValue("duration", invoice.getDuration()); command.Parameters.AddWithValue("preCharge", invoice.getPreCharge()); command.Parameters.AddWithValue("date", dt.ToString("yyyy-MM-dd")); conn.Open(); command.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { conn.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())); }