public void CreateTransactionDetailsUI(RentalTransactions transaction, int rentalRate) { ReturnDetailsUI f = new ReturnDetailsUI(); f.displayTransactionDetails(transaction, rentalRate); f.ShowDialog(); }
public RentalTransactions retrieveTransactionRecord(string txtCarPlateNo, out int rentalRate) { SqlParameter pCarPlateNumber = new SqlParameter("@carPlateNumber", SqlDbType.NVarChar, 50); pCarPlateNumber.Value = txtCarPlateNo; cmSelectTransactionDetails.Parameters.Clear(); cmSelectTransactionDetails.Parameters.Add(pCarPlateNumber); RentalTransactions t = new RentalTransactions(); SqlDataReader rd = cmSelectTransactionDetails.ExecuteReader(); if (rd.Read()) { t.TransID = int.Parse(rd["TransID"].ToString()); t.RentalStartDate = DateTime.Parse(rd["RentalStartDate"].ToString()); t.CustomerID = int.Parse(rd["CustomerID"].ToString()); rentalRate = int.Parse(rd["RentalRate"].ToString()); } else { throw new VehException(VehMessage.VehicleRecordNotFound); } rd.Close(); return(t); }
public void displayTransactionDetails(RentalTransactions transaction, int rentalRate) { txtCustomerID.Text = transaction.CustomerID.ToString(); txtRentalStartDate.Text = transaction.RentalStartDate.ToString(); txtReturnDate.Text = DateTime.Now.Date.ToString(); txtPayment.Text = (DateTime.Now.Date - transaction.RentalStartDate).ToString(); }
public void ReturnTransaction(string carPlateNumber) { VehicleDAO dao = VehicleDAO.getInstance(); try { int rentalRate; dao.openConnection(); RentalTransactions t = dao.retrieveTransactionRecord(carPlateNumber, out rentalRate); CreateTransactionDetailsUI(t, rentalRate); } catch (Exception) { throw; } finally { dao.CloseConnection(); } }