private void InvoiceMenu_View(object sender, System.Windows.RoutedEventArgs e) { DataRowView dataRowView = (DataRowView)((MenuItem)e.Source).DataContext; int invoiceID = Int32.Parse(dataRowView[0].ToString()); RentalManager manager = new RentalManager(new UnitOfWork(new RentalContext())); DomainLayer.Domain.Invoice invoice = manager.GetInvoice(invoiceID); }
private void LoadTodaysReservations() { todaysReservationsTable.Rows.Clear(); RentalManager manager = new RentalManager(new UnitOfWork(new RentalContext())); foreach (Reservation reservation in manager.GetReservations(DateTime.Today, DateTime.Today.AddDays(1))) { DomainLayer.Domain.Invoice invoice = manager.GetInvoice(reservation.InvoiceID); Client client = manager.GetClient(reservation.ClientID); string clientStr = client.FirstName + " " + client.LastName; if (!string.IsNullOrWhiteSpace(client.CompanyName)) { clientStr = "(" + client.CompanyName + ") " + clientStr; } AddTodaysReservationsRow(reservation.ID, clientStr, reservation.ReservationDate, reservation.ReservedUntil, char.ToUpper(reservation.Arrangement.ToString().ToLower()[0]) + reservation.Arrangement.ToString().ToLower().Substring(1), reservation.StartLocation, reservation.EndLocation, string.Format("€{0:0.00}", invoice.TotalInc), (invoice.PaymentDue == 0) ? "Paid" : "Unpaid"); } }
private void InvoiceMenu_MarkPaid(object sender, System.Windows.RoutedEventArgs e) { DataRowView dataRowView = (DataRowView)((MenuItem)e.Source).DataContext; int invoiceID = Int32.Parse(dataRowView[0].ToString()); RentalManager manager = new RentalManager(new UnitOfWork(new RentalContext())); DomainLayer.Domain.Invoice invoice = manager.GetInvoice(invoiceID); if (invoice.PaymentDue > 0) { invoice.PaymentDue = 0; manager.UpdateInvoice(invoice); LoadUnpaidInvoices(); MainWindow.DisplayThrowbackDialog("Invoice Updated", "The invoice has been updated to paid."); } else { MainWindow.DisplayThrowbackDialog("Invoice Already Paid", "The invoice you tried to mark as paid is already paid."); } }
private void InitializeDataGrid_Data() { reservationTable.Rows.Clear(); RentalManager manager = new RentalManager(new UnitOfWork(new RentalContext())); foreach (Reservation reservation in manager.GetAllReservations()) { DomainLayer.Domain.Invoice invoice = manager.GetInvoice(reservation.InvoiceID); Client client = manager.GetClient(reservation.ClientID); List <Car> reservationCars = manager.GetReservationCars(reservation.ID); StringBuilder sb = new StringBuilder(); foreach (Car car in reservationCars) { sb.Append("#" + car.ID + " " + car.Brand + " " + car.Type + ","); } String cars = reservationCars.ToString(); AddTableRow(reservation.ID, client.FirstName + " " + client.LastName, sb.ToString().Substring(0, sb.ToString().Length - 1), reservation.ReservationDate, reservation.ReservedUntil, (reservation.ReservationEnded > DateTime.MinValue) ? reservation.ReservationEnded.ToString() : "", char.ToUpper(reservation.Arrangement.ToString().ToLower()[0]) + reservation.Arrangement.ToString().ToLower().Substring(1), reservation.StartLocation, reservation.EndLocation, reservation.OrderDate, invoice.ID, "€" + invoice.TotalInc, (invoice.PaymentDue == 0) ? "Paid" : "Unpaid"); } }