public AwardCertificationForm() { InitializeComponent(); customerResults = new ResultSet(cyclingDAL.GetDataReader("[CustomerTable]")); // Set the suggestions of the SuggestingTextBox to the Customer Names and add a Suggestion clicked listener to call SuggestionChosen CustomerNameSuggestingTextBox.SetSuggestions(customerResults.GetColumnData(1)); CustomerNameSuggestingTextBox.SuggestionClickedEvent += new SuggestingTextBox.SuggestionClickedEventArgs(SuggestionChosen); CustomerNameSuggestingTextBox.textBox.TextChanged += new EventHandler(CustomerNameSuggestingTextBox_TextChanged); // Read and store the displayedResultSet data displayedResults = UpdateResultSet("CertificationBookingsTable JOIN ChildTable ON CertificationBookingsTable.ChildID = ChildTable.ChildID JOIN CustomerTable ON ChildTable.CustomerID = CustomerTable.CustomerID ", "1=1", "[CustomerTable].CustomerID, CustomerName, [ChildTable].ChildID, ChildName, CertificationBookingID, Level, Price"); if (displayedResults.GetSize() > 0) { ShowRecord(0); // Shows the first record of this ResultSet. } }
bool settingSuggestedText = false; // Used to prevent the built in WinForms event call of TextChanged changing the Displayed Results #endregion Fields #region Constructors public CancelBookingForm() { InitializeComponent(); bookingResults = UpdateResultSet("[dbo].[BookingTable]"); // Extract data from different tables and save them as ResultSets customerResults = UpdateResultSet("[dbo].[CustomerTable]"); campingResults = UpdateResultSet("[dbo].[CampingBookingsTable]"); pitchResults = UpdateResultSet("[dbo].[PitchBookingsTable]"); displayedResultSet = UpdateResultSet("BookingTable JOIN CustomerTable ON BookingTable.CustomerID = CustomerTable.CustomerID", "1=1", "BookingID, BookingTable.CustomerID, CustomerName, StartDate, NightsStayed, PricePerNight, TotalPrice"); // Display all of the booking results as we are not yet filtering them CustomerNameSuggestingTextBox.SetSuggestions(customerResults.GetColumnData(1)); // Set the customer names as the suggestions for the SuggestingTextBox CustomerNameSuggestingTextBox.SuggestionClickedEvent += new SuggestingTextBox.SuggestionClickedEventArgs(CustomerNameSuggestingTextBox_SuggestionChosen); // When a suggestion is chosen run the CustomerNameSuggestingTextBox_SuggestionChosen method CustomerNameSuggestingTextBox.textBox.TextChanged += new EventHandler(CustomerNameSuggestingTextBox_TextChanged); if (customerResults.GetSize() > 0) { ShowRecord(0); // Shows the first record of this ResultSet. Does not depend on a bookingID } }
public ReturnEquipmentForm() { InitializeComponent(); equipmentLoansResults = UpdateResultSet("[dbo].[EquipmentLoansTable]"); // Read and store the data from the EquipmentLoansTable // Read and store the displayedResultSet data displayedResultSet = UpdateResultSet("[dbo].[EquipmentLoansTable] JOIN [dbo].[CustomerTable] ON EquipmentLoansTable.CustomerID = CustomerTable.CustomerID JOIN [dbo].[EquipmentTable] ON EquipmentLoansTable.EquipmentID = EquipmentTable.EquipmentID", "1=1", "EquipmentLoanID, EquipmentLoansTable.EquipmentID, EquipmentName, CustomerTable.CustomerID, CustomerName, StartDate, Duration, Quantity, RentalPrice, StockLevel"); originalDisplayedResults = displayedResultSet; // Set the suggestions of the SuggestingTextBox to the Customer Names and add a Suggestion clicked listener to call CustomerNameSuggestingTextBox_SuggestionChosen CustomerNameSuggestingTextBox.SetSuggestions(displayedResultSet.GetColumnData(4)); CustomerNameSuggestingTextBox.SuggestionClickedEvent += new SuggestingTextBox.SuggestionClickedEventArgs(CustomerNameSuggestingTextBox_SuggestionChosen); CustomerNameSuggestingTextBox.textBox.TextChanged += new EventHandler(CustomerNameSuggestingTextBox_TextChanged); if (equipmentLoansResults.GetSize() > 0) { ShowRecord(0); // Shows the first record of this ResultSet. } }
// When a customer name suggestion is chosen private void CustomerSuggestionChosen(string suggestion) { string command = "CustomerName = '" + suggestion + "'"; ResultSet resultSet = new ResultSet(busDal.GetDataReader("[dbo].[CustomerTable]", command, "CustomerID")); // Get the data related to the chosen customer name busDal.CloseConnection(); // Update the CustomerIDComboBox to show only the CustomerID's relating to the chosen customer name CustomerIDComboBox.Items.Clear(); for (int i = 0; i < resultSet.GetSize(); i++) { CustomerIDComboBox.Items.Add(resultSet.GetData<int>(0, i) + ""); } if (CustomerIDComboBox.Items.Count > 0) { CustomerIDComboBox.Text = CustomerIDComboBox.Items[0] + ""; } }
// Used to Change the results that are displayed to the contents of a ResultSet private void UpdateDisplayedResults(ResultSet rs) { displayedResults = rs; Console.WriteLine(rs.GetSize()); PreviousChildButton.Enabled = false; if (rs.GetSize() == 1) // If there is only one result don't allow the user to move to the next result { NextChildButton.Enabled = false; } else { NextChildButton.Enabled = true; } ShowRecord(0); // Show the first available record }
// When a suggested Customer Name is chosen private void SuggestionChosen(string suggestion) { // Obtain the data that relates to the chosen customer name string command = "CustomerName = '" + suggestion + "'"; ResultSet resultSet = new ResultSet(cyclingDAL.GetDataReader("[dbo].[CustomerTable]", command, "CustomerID")); // Make the CustomerIDComboBox show only the customerID's relating to the chosen Customer Name CustomerIDComboBox.Items.Clear(); for (int i = 0; i < resultSet.GetSize(); i++) { CustomerIDComboBox.Items.Add(resultSet.GetData<int>(0, i) + ""); } if (CustomerIDComboBox.Items.Count > 0) { CustomerIDComboBox.Text = CustomerIDComboBox.Items[0] + ""; } CustomerIDComboBox_SelectedIndexChanged(CustomerNameSuggestingTextBox, new EventArgs()); }
// When a customer name suggestion is chosen private void CustomerSuggestionChosen(string suggestion) { string command = "CustomerName = '" + suggestion + "'"; ResultSet resultSet = new ResultSet(cyclingDAL.GetDataReader("[dbo].[CustomerTable]", command, "CustomerID")); // Update the CustomerIDComboBox with the ID's of the customers relating to the suggested customer name CustomerIDComboBox.Items.Clear(); for (int i = 0; i < resultSet.GetSize(); i++) { CustomerIDComboBox.Items.Add(resultSet.GetData<int>(0, i) + ""); } if (CustomerIDComboBox.Items.Count > 0) { CustomerIDComboBox.Text = CustomerIDComboBox.Items[0] + ""; } }
// When a customer name suggestion is chosen private void CustomerSuggestionChosen(string suggestion) { // Read the CustomerIDs relating to this name string command = "CustomerName = '" + suggestion + "'"; ResultSet resultSet = new ResultSet(cyclingDAL.GetDataReader("[dbo].[CustomerTable]", command, "CustomerID")); // Set the contents of the CustomerIDComboBox to display the read CustomerIDs CustomerIDComboBox.Items.Clear(); for (int i = 0; i < resultSet.GetSize(); i++) { CustomerIDComboBox.Items.Add(resultSet.GetData<int>(0, i) + ""); } if (CustomerIDComboBox.Items.Count > 0) { CustomerIDComboBox.Text = CustomerIDComboBox.Items[0] + ""; } }
// When a customer name suggestion was chosen private void NameSuggestionChosen(string suggestion) { string command = "CustomerName = '"+ suggestion + "'"; ResultSet resultSet = new ResultSet(dal.GetDataReader("[dbo].[CustomerTable]", command, "CustomerID")); // Obtaing details about CustomerIDs //dal.CloseConnection(); // Set the CustomerIDComboBox to display CustomerIDs that apply to this customer name CustomerIDComboBox.Items.Clear(); for(int i = 0; i < resultSet.GetSize(); i++){ CustomerIDComboBox.Items.Add(resultSet.GetData<int>(0, i) + ""); } if (CustomerIDComboBox.Items.Count > 0) { CustomerIDComboBox.Text = CustomerIDComboBox.Items[0] + ""; } }
// Used to Change the results that are displayed to the contents of a ResultSet private void UpdateDisplayedResults(ResultSet rs) { displayedResultSet = rs; CustomerNameSuggestingTextBox.SetSuggestions(rs.GetColumnData(2)); PreviousBookingButton.Enabled = false; if (rs.GetSize() == 1) // If there is only one result don't allow the user to move to the next result { NextBookingButton.Enabled = false; } else { NextBookingButton.Enabled = true; } ShowRecord(0); // Show the first available record }
// Returns the number of children registered for a specific lesson public int GetNumberAttendingLesson(DateTime date, string timeSlot) { // Run a query to find the number of children attending the lesson at the specified date and time slot string query = string.Format("[Date] = '{0}' AND TimeSlot = '{1}'", string.Format("{0:MM-dd-yy}", date), timeSlot); ResultSet lessonResults = new ResultSet(GetDataReader("[CyclingLessonTable]", query, "NumberChildren")); CloseConnection(); if (lessonResults.GetSize() == 0) { return 0; } return lessonResults.GetData<int>(0, 0); }
// Returns the number of bicycles that have not yet been hired for a specific lesson public int GetBicyclesLeft(DateTime date, string timeSlot) { // Run a query to find the number of bicylces left for the lesson at the specified date and time slot string query = string.Format("[Date] = '{0}' AND TimeSlot = '{1}'", string.Format("{0:MM-dd-yy}", date), timeSlot); ResultSet tourResults = new ResultSet(GetDataReader("[CyclingTourTable]", query, "NumberBicycles")); CloseConnection(); if (tourResults.GetSize() == 0) { return 15; } else { return (15 - tourResults.GetData<int>(0, 0)); } }
// Method to determine the number of people that have signed up for a tour on a specific time slot on a specific date public int GetNumberSignedUp(DateTime date, string timeSlot) { OpenConnection(); // Run a query to find the number of cyclists registered for the specified time slot and specified date string query = string.Format("[CyclingTourTable].Date = '{0}' AND [CyclingTourTable].TimeSlot = '{1}'", string.Format("{0:MM-dd-yy}", date), timeSlot); ResultSet tourResults = new ResultSet(GetDataReader("[CyclingTourTable]", query, "NumberCyclists")); CloseConnection(); if (tourResults.GetSize() == 0) { return 0; } return tourResults.GetData<int>(0, 0); }