//constructor creating page with pre-filled data from selected customer details public CustomerUpdateV(CustomerBO selectedCustomer, bool newCustomer) { InitializeComponent(); //determine, whether user want to add new customer, or update existing customer this._addingNewCustomer = newCustomer; this._selectedCustomer = selectedCustomer; //top part of the window is the same asd CustomerAddV, so the information is transferred txtCompanyName.Text = selectedCustomer.CompanyName; txtCompanyContactName.Text = selectedCustomer.ContactPerson; // filling ContactTypes combobox with respective values ContactTypeService contactTypeSrv = new ContactTypeService(); List<ContactTypeBO> contactTypes = contactTypeSrv.getAllFromTable(); cboxContacts.ItemsSource = contactTypes; // filling Contact list with respective values updateListContacts(); }
/// <remarks> /// on Customer selection prepare CustomerBO object by chosen customer name. /// </remarks> private void CustomerSelectionChanged(object sender, SelectionChangedEventArgs e) { String selectedCompanyName = (String)listCustomers.SelectedItem; CustomerService customerSrv = new CustomerService(); _selectedCustomer = (CustomerBO)customerSrv. getCustomerByName(selectedCompanyName); }
/// <remarks> /// fills Customer name TextBox with selected Customer Company Name from DB /// </remarks> private void listCustomers_selectionChanged(object sender, SelectionChangedEventArgs e) { if (listCustomers.SelectedItem != null) { _selectedCustomer = (CustomerBO)listCustomers.SelectedItem; txtCustomer.Text = (String)_selectedCustomer.CompanyName; } }
/// <remarks> /// Saves validates and saves the data in fields as new BookingBO and returns to previous page. /// </remarks> /// <param name="sender"></param> /// <param name="e"></param> private void btnBook_Click(object sender, RoutedEventArgs e) { lblWarningBook.Text = ""; //check if date is selected, if not, display warning if (txtDate.SelectedDate == null) lblWarningBook.Text = "Palun vali kuupäev"; else { //check, if date isn't in the past if (DateTime.Compare((DateTime)txtDate.SelectedDate,DateTime.Today)<0) { lblWarningBook.Text = "Valitud kuupäev on minevikus"; } //if date is selected, convert to DateTime and assing _selectedDate = (DateTime)txtDate.SelectedDate; //check if Room is selected, of not, display warning if (cboxRoom.SelectedItem == null) lblWarningBook.Text = "Palun vali ruum"; else { //if Room is selected, assign _selectedRoom = (RoomBO)cboxRoom.SelectedItem; //check if customer is selected, if not, display warning if ((CustomerBO)listCustomers.SelectedItem == null) { lblWarningBook.Text = "Palun vali klient"; } else { //if customer is selected, assign. Clear warning lable _selectedCustomer = (CustomerBO)listCustomers.SelectedItem; if (int.TryParse(txtParticipants.Text, out _participants) == false) { lblWarningBook.Text = "Palun sisesta osalejate arv"; return; } _participants = int.Parse(txtParticipants.Text); // if number is negative or 0, display warning if (_participants <= 0) { lblWarningBook.Text = "Palun sisesta osalejate arv"; return; } if (lblWarning.Text.Equals("") && lblWarning2.Text.Equals("") && lblWarningBook.Text.Equals("")) { //if all conditions filfilled and values assigned, assign optional values if ((_participants > 0) && (_selectedRoom != null) && (_selectedDate != null) && (_selectedCustomer != null)) { _additionalInfo = txtAdditionalInfo.Text; // if user created new booking, add new booking to DB if (_selectedBooking == null) { _bookingSrv.addNew(_selectedDate, _selectedRoom.RoomID, _selectedCustomer.CustomerID, _participants, DateTime.Now, _admin.AdminID, _additionalInfo); } // if user updates existing booking, update booking by Id else { _bookingSrv.UpdateById(_selectedBooking.BookingID, _selectedDate, _selectedRoom.RoomID, _selectedCustomer.CustomerID, _participants, _additionalInfo); } //return to previous page // Find the frame. Frame pageFrame = null; DependencyObject currParent = VisualTreeHelper.GetParent(this); while (currParent != null && pageFrame == null) { pageFrame = currParent as Frame; currParent = VisualTreeHelper.GetParent(currParent); } // gets us back to View we came from pageFrame.NavigationService.GoBack(); } } } } } }
public CustomerReportBO(DateTime start, DateTime end, CustomerBO customer) : base(start, end) { this._customer = customer; }