//method to populate the data grid with call records private void PopulateGrid(ICallData callData) { //create a list of the call records _callRecords = callData.GetCalls().ToList(); //remove any invalid records when the page loads _callRecords = RemoveInvalidRecords(_callRecords); //create a new binding source and set the data source to _callRecords BindingSource bs = new BindingSource(); bs.DataSource = _callRecords; //attach the binding source info to the data grid dataGridViewRecords.DataSource = bs; //hide the column with the Rate object dataGridViewRecords.Columns[7].Visible = false; //show the count in the label (number of entries) labelCount.Text = _callRecords.Count.ToString(); Validate(); }
//method to populate the data grid by the from phone number private void PopulateGridByPhoneNumber(ICallData callData) { //get the records _callRecords = callData.GetCalls().ToList(); //remove any invalid records _callRecords = RemoveInvalidRecords(_callRecords); //create a new binding source and set the data source to _callRecords BindingSource bs = new BindingSource(); bs.DataSource = from record in _callRecords select record; //create a binding list using _callRecords BindingList <CallRecord> list = new BindingList <CallRecord>(_callRecords); //filter the list by the fromPhoneNumber combo box var filter = list.Where(rec => rec.CallFromNumber == comboBoxFromPhoneNumber.SelectedItem.ToString()).ToList(); //if the "answered only" box isn't selected, show all the records from the phone number if (!checkBoxAnsweredCalls.Checked) { dataGridViewRecords.DataSource = filter; labelCount.Text = filter.Count.ToString(); //update the count //hide the column with the Rate object dataGridViewRecords.Columns[7].Visible = false; } //otherwise only show records from the phone number that have "Y" for callCompletedStatus else { ShowAnsweredOnly(filter); } //set the list to contain only the filtered records _callRecords = filter; }