public CustomersV() { InitializeComponent(); CustomerService customerSrv = new CustomerService(); List<CustomerBO> customers = customerSrv.getAllFromTable(); listCustomers.ItemsSource = customers; }
// constructor for current logged in admin public ReportV(String adminName) { InitializeComponent(); // determine last available date for period date pickers endDate.DisplayDateEnd = DateTime.Today.AddDays(-1); startDate.DisplayDateEnd = DateTime.Today.AddDays(-1); if (startDate.SelectedDate == null) { startDate.DisplayDate = DateTime.Today.AddDays(-1); } if (endDate.SelectedDate == null) { endDate.DisplayDate = DateTime.Today.AddDays(-1); } RoomService roomSrv = new RoomService(); CustomerService customerSrv = new CustomerService(); AdministratorService adminSrv = new AdministratorService(); //populate list of Customers with Customer Names from database. List<CustomerBO> customers = customerSrv.getAllFromTable(); List<String> customerNames = new List<String>(); foreach (CustomerBO customer in customers) { String customerName = customer.CompanyName; customerNames.Add(customerName); } listCustomers.ItemsSource = customerNames; //populate comboBox of Rooms with room names from database List<RoomBO> rooms = roomSrv.getAllFromTable(); List<String> roomNames = new List<String>(); foreach (RoomBO room in rooms) { String roomName = room.Name; roomNames.Add(roomName); } cboxRooms.ItemsSource = roomNames; }
/// <remarks> /// reloads the view. useful for NavigationService.GoBack(); /// </remarks> /// <param name="sender"></param> /// <param name="e"></param> private void updateView(object sender, RoutedEventArgs e) { CustomerService customerSrv = new CustomerService(); List<CustomerBO> customers = customerSrv.getAllFromTable(); listCustomers.ItemsSource = customers; listContacts.ItemsSource = null; Frame pageFrame = null; DependencyObject currParent = VisualTreeHelper.GetParent(this); while (currParent != null && pageFrame == null) { pageFrame = currParent as Frame; currParent = VisualTreeHelper.GetParent(currParent); } // if current frame has any assigned tags, remove. if (pageFrame.Tag != null) { pageFrame.Tag = null; } }
private static void emptyTableCustomer() { CustomerService customerSrv = new CustomerService(); customerSrv.emptyTable(); List<CustomerBO> customers = customerSrv.getAllFromTable(); Assert.AreEqual(0, customers.Count(), string.Format("'Customer' Table should be empty.")); }
private static void fullFillCustomerTable() { CustomerService customerSrv = new CustomerService(); customerSrv.addNew("ABC OÜ", "Anne"); customerSrv.addNew("XYZ AS", "Daria"); List<CustomerBO> customers = customerSrv.getAllFromTable(); Assert.AreNotEqual(0, customers.Count(), string.Format("There should be values in 'Customer' Table.")); }
private static void fullFillContactTable() { ContactTypeService contactTypeSrv = new ContactTypeService(); List<ContactTypeBO> contactTypes = contactTypeSrv.getAllFromTable(); Assert.AreNotEqual(0, contactTypes.Count(), string.Format("There should be values in 'ContactType' Table.")); int existingContactTypeID = contactTypes.ElementAt(0).ContactTypeID; CustomerService customerSrv = new CustomerService(); List<CustomerBO> customers = customerSrv.getAllFromTable(); Assert.AreNotEqual(0, customers.Count(), string.Format("There should be values in 'Customer' Table.")); int existingCustomerID = customers.ElementAt(0).CustomerID; //TODO: Verify that contact cannot be created before Customer (CustomerID foreign key) //TODO: Verify that contact cannot be created before ContactType (ContactTypeID foreign key) ContactService contactSrv = new ContactService(); contactSrv.addNew(existingCustomerID, existingContactTypeID, "val_skype", DateTime.Now);//TODO: take first from list contactSrv.addNew(existingCustomerID, existingContactTypeID, "val_mail", DateTime.Now); contactSrv.addNew(existingCustomerID, existingContactTypeID, "val_phone", DateTime.Now); List<ContactBO> contacts = contactSrv.getAllFromTable(); Assert.AreNotEqual(0, contacts.Count(), string.Format("There should be values in 'Contact' Table.")); }
private static void fullFillTableBooking() { RoomService roomSrv = new RoomService(); List<RoomBO> rooms = roomSrv.getAllFromTable(); Assert.AreNotEqual(0, rooms.Count(), string.Format("There should be values in 'Rooms' Table.")); int existingRoomID = rooms.ElementAt(0).RoomID; CustomerService customerSrv = new CustomerService(); List<CustomerBO> customers = customerSrv.getAllFromTable(); Assert.AreNotEqual(0, customers.Count(), string.Format("There should be values in 'Customer' Table.")); int existingCustomerID = customers.ElementAt(0).CustomerID; AdministratorService adminSrv = new AdministratorService(); List<AdministratorBO> admins = adminSrv.getAllFromTable(); Assert.AreNotEqual(0, admins.Count(), string.Format("There should be values in 'Administrator' Table.")); int existingAdminID = admins.ElementAt(0).AdminID; //Verify that booking cannot be created before Customer (CustomerID foreign key) //Verify that booking cannot be created before Room (RoomID foreign key) //Verify that booking cannot be created before Administrator (AdminID foreign key) BookingService bookingSrv = new BookingService(); bookingSrv.addNew(DateTime.Now.AddDays(1), existingRoomID, existingCustomerID, 25, DateTime.Now, existingAdminID, "no smoking");// take first from list bookingSrv.addNew(DateTime.Now.AddDays(1), existingRoomID, existingCustomerID, 40, DateTime.Now, existingAdminID, "no pets allowed"); bookingSrv.addNew(DateTime.Now.AddDays(10), existingRoomID, existingCustomerID, 77, DateTime.Now, existingAdminID, "reconfirm by phone"); bookingSrv.addNew(DateTime.Now.AddDays(17), existingRoomID, existingCustomerID, 55, DateTime.Now, existingAdminID, "reconfirm by phone tomorrow"); bookingSrv.addNew(DateTime.Now.AddDays(-5), existingRoomID, existingCustomerID, 10, DateTime.Now.AddDays(-8), existingAdminID, "catering "); bookingSrv.addNew(DateTime.Now.AddDays(-2), existingRoomID, existingCustomerID, 100, DateTime.Now.AddDays(-5), existingAdminID, "no catering"); List<BookingBO> bookings = bookingSrv.getAllFromTable(); Assert.AreNotEqual(0, bookings.Count(), string.Format("There should be values in 'Booking' Table.")); }