Int32 DisplayCustomersByEmail(string EmailFilter) { ///this function accepts one parameter - the Email to filter the list on ///it populates the list box with data //new instance of the clsCustomerCollection clsCustomerCollection AllCustomers = new clsCustomerCollection(); //var to store the count of the record Int32 Count; //var to store email string Email; //var to store the index Int32 Index = 0; //clear the list of any existing items //lstCustomers.Items.Clear(); //call the filter by post code method AllCustomers.ReportByEmail(EmailFilter); //get the count of records found Count = AllCustomers.Count; //loop through each record found using the index to point to each record in data table while (Index < Count) { Email = Convert.ToString(AllCustomers.CustomersList[Index].Email); //set up a new object of class list item lstCustomers.DataSource = AllCustomers.CustomersList; //set the text to be displayed lstCustomers.DisplayMember = "Email"; //increment the index Index++; } //return the number of records found return(Count); }
public void ReportByEmailTestDataFound() { //create an instance of the data clsCustomerCollection data = new clsCustomerCollection(); //var to store outcome Boolean OK = true; //apply an email that doesn't exist data.ReportByEmail("x@z"); //check that the correct number of records are found if (data.Count == 2) { //check that the first record is cusId 10091 if (data.CustomerList[0].cusId != 10091) { OK = false; } //check that the first record is ID cusId 10092 if (data.CustomerList[1].cusId != 10092) { OK = false; } } else { OK = false; } //test to see that there are no records Assert.IsTrue(OK); }
public void ReportByEmailMethodOK() { clsCustomerCollection AllCustomers = new clsCustomerCollection(); clsCustomerCollection FilteredCustomers = new clsCustomerCollection(); FilteredCustomers.ReportByEmail(""); Assert.AreEqual(AllCustomers.Count, FilteredCustomers.Count); }
public void ReportyByEmailMethodOK() { clsCustomerCollection FilteredEmails = new clsCustomerCollection(); FilteredEmails.ReportByEmail("xxxxxxxx"); Assert.AreEqual(0, FilteredEmails.Count); }
public void ReportByEmailNoneFound() { clsCustomerCollection FilteredCustomers = new clsCustomerCollection(); FilteredCustomers.ReportByEmail("xxxx"); Assert.AreEqual(0, FilteredCustomers.Count); }
public void ReportByEmailNotFound() { //create an instance of the filtered adata clsCustomerCollection FilteredCustomers = new clsCustomerCollection(); //apply a post code that doesnt exist FilteredCustomers.ReportByEmail("*****@*****.**"); //test to see that there are no records Assert.AreEqual(0, FilteredCustomers.Count); }
public void ReportByEmailNoneFound() { //instance of the filterd data clsCustomerCollection FilteredCustomers = new clsCustomerCollection(); //apply apost code that dosent exist FilteredCustomers.ReportByEmail("xxxxxxxx"); //test to see that the two values are the same Assert.AreEqual(0, FilteredCustomers.Count); }
protected void btnApply_Click(object sender, EventArgs e) { clsCustomerCollection Customers = new clsCustomerCollection(); Customers.ReportByEmail(txtFilter.Text); lstCustomers.DataSource = Customers.CustomerList; lstCustomers.DataValueField = "CustomerId"; lstCustomers.DataTextField = "Email"; lstCustomers.DataBind(); }
public void ReportByPostCodeNoneFound() { //create an instance of the class containing unfilitered results clsCustomerCollection data = new clsCustomerCollection(); //use an email that doesn't exist data.ReportByEmail("[email protected]"); //compare values Assert.AreEqual(0, data.Count); }
protected void Button1_Click3(object sender, EventArgs e) { clsCustomerCollection Customers = new clsCustomerCollection(); Customers.ReportByEmail(emailInput.Text); lstCustomerList.DataSource = Customers.CustomerList; lstCustomerList.DataValueField = "customer_id"; lstCustomerList.DataTextField = "email"; lstCustomerList.DataBind(); }
public void ReportByEmailMethodOK() { //createa an instance of the calss contaion unfiltered results clsCustomerCollection AllCustomers = new clsCustomerCollection(); //create an instance of the fultered data clsCustomerCollection FilteredCustomers = new clsCustomerCollection(); //apply a blank string FilteredCustomers.ReportByEmail(""); //test to see that the two values are the same Assert.AreEqual(AllCustomers.Count, FilteredCustomers.Count); }
protected void Clear_Click(object sender, EventArgs e) { clsCustomerCollection Customers = new clsCustomerCollection(); Customers.ReportByEmail(""); emailInput.Text = ""; lstCustomerList.DataValueField = "customer_id"; lstCustomerList.DataTextField = "email"; lstCustomerList.DataBind(); }
public void ReportByPostCodeMethodOK() { //create an instance of the class containing unfilitered results clsCustomerCollection data = new clsCustomerCollection(); //create and instance of the filtered data clsCustomerCollection filteredData = new clsCustomerCollection(); //apply a blank string (should return all records): filteredData.ReportByEmail(""); //compare values Assert.AreEqual(data.Count, filteredData.Count); }
public void ReportByEmailMethodOK() { //create an instance of the class contianing unfiltered results clsCustomerCollection AllCustomers = new clsCustomerCollection(); //create an instance of the filtered data clsCustomerCollection FilteredCustomers = new clsCustomerCollection(); //apply a blank tring (should return all records) FilteredCustomers.ReportByEmail(""); //test to see that the two values are the same Assert.AreEqual(AllCustomers.Count, FilteredCustomers.Count); }
protected void btnClear_Click(object sender, EventArgs e) { clsCustomerCollection cIDs = new clsCustomerCollection(); cIDs.ReportByEmail(""); txtFilter.Text = ""; lstCustomerList.DataSource = cIDs.CustomerList; lstCustomerList.DataValueField = "CustomerID"; lstCustomerList.DataTextField = "Email"; lstCustomerList.DataBind(); }
//btn apply filter click protected void btnApplyFilter_Click(object sender, EventArgs e) { //create an instance of the address collection clsCustomerCollection collection = new clsCustomerCollection(); //filter the collection by the input collection.ReportByEmail(txtFilter.Text); //set CustomerListBox data source to new filtered list CustomerListBox.DataSource = collection.CustomerList; //set the name of the primary key CustomerListBox.DataValueField = "cusId"; //State the name of the field to display CustomerListBox.DataTextField = "cusEmail"; //bind the data to the list CustomerListBox.DataBind(); }
//btn clear filter click protected void btnClearFilter_Click(object sender, EventArgs e) { //create an instance of the customer collection clsCustomerCollection data = new clsCustomerCollection(); //filter data.ReportByEmail(""); //clear any existing filter to tidy up the interface txtFilter.Text = ""; //set the data source CustomerListBox.DataSource = data.CustomerList; //set the name of the primary key CustomerListBox.DataValueField = "cusId"; //set the name of the field to display CustomerListBox.DataTextField = "cusName"; //bind the data to the list CustomerListBox.DataBind(); }
//function use to populate the list box Int32 DisplayCustomers(string CustomerEmailFilter) { //create a new instance of the clsAddress clsCustomerCollection MyCustomerList = new clsCustomerCollection(); //var to store the count of records Int32 RecordCount; //var to store the house no string CustomerFirstName; //var to store the street name string CustomerLastName; //var to store the post code string CustomerEmail; //var to store the primary key value string CustomerID; //var to store the index Int32 Index = 0; //clear the list of any existing items lstCustomers.Items.Clear(); //call the filter by post code method MyCustomerList.ReportByEmail(CustomerEmailFilter); //get the count of records found RecordCount = MyCustomerList.Count; //loop through each record found using the index to point to each record in the data table while (Index < RecordCount) { //get the house no from the query results CustomerFirstName = Convert.ToString(MyCustomerList.CustomerList[Index].CustomerFirstName); //get the street from the query results CustomerLastName = Convert.ToString(MyCustomerList.CustomerList[Index].CustomerLastName); //get the post code from the query results CustomerEmail = Convert.ToString(MyCustomerList.CustomerList[Index].CustomerEmail); //get the address no from the query results CustomerID = Convert.ToString(MyCustomerList.CustomerList[Index].CustomerID); //set up a new object of class list item ListItem NewItem = new ListItem(CustomerFirstName + " " + CustomerLastName + " - " + CustomerEmail, CustomerID); //add the new item to the list lstCustomers.Items.Add(NewItem); //increment the index Index++; } //return the number of records found return(RecordCount); }