Joshua Paddock

Joshua Paddock

  • NA
  • 4
  • 1.5k

making a Group boxes call data from entity

Jul 9 2015 12:41 PM
I am having trouble getting three different group boxes with check boxes to bring back the data into a data grid. i need it to get all the items checked and bring back the data in the window.
 
What i have so far work one at a time but it will not give me all three only the last checked. i have done this for the three group boxes Carriers, Priority and Cooler
 
private void CheckBox(object sender, RoutedEventArgs e)
{
 var child = new GroupBox();
 List<string> currentlyCheckedCheckBox = new List<string>();
 List<string> currentlyUnCheckedCheckBox = new List<string>();
 foreach (var child in cbCarriers.Children)
 {
 if (child.GetType() == typeof(CheckBox))
 {
 Checking for IsChecked
 CheckBox currentCheckBox = (CheckBox)child;
 if ((bool)currentCheckBox.IsChecked)
 {
 currentlyCheckedCheckBox.Add(currentCheckBox.Content.ToString());
 }
 else
 {
 currentlyUnCheckedCheckBox.Add(currentCheckBox.Content.ToString());
 }
if ((bool)currentCheckBox.IsChecked == false)
{
 return myMain.dtOrders;
}
 }
 }
 if (currentlyCheckedCheckBox.Count == 0)
 {
 currentlyCheckedCheckBox = currentlyUnCheckedCheckBox;
 }
 List<Order> checkedOrders = new List<Order>();
foreach (var item in db.Orders)
 {
 foreach (var checkboxName in currentlyCheckedCheckBox)
 {
 if (item.ShipVia.Trim() == checkboxName)
 {
 checkedOrders.Add(item);
 }
 }
 }
 grdOrders.ItemsSource = checkedOrders;
}
 

Answers (2)