Exemplo n.º 1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ERPEF entity = new ERPEF();

            comboBoxStates.ItemsSource   = entity.States.ToList();
            comboBoxStates.SelectedIndex = 0;
        }
Exemplo n.º 2
0
        private void buttonDisplay_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (ERPEF entity = new ERPEF())
                {
                    IQueryable <Employee> employees = null;
                    string keyword = textBoxKeyword.Text;
                    string state   = Convert.ToString(comboBoxStates.SelectedValue).Trim();
                    if (keyword != "" || state != "")
                    {
                        employees = entity.Employees.
                                    Where(n => (keyword != "" &&
                                                (n.FirstName.Contains(keyword) ||
                                                 n.LastName.Contains(keyword))) ||
                                          keyword == "").
                                    Where(n => state == "" ||
                                          (state != "" &&
                                           n.StateCode.Equals(state)));
                    }
                    else
                    {
                        employees = entity.Employees;
                    }
                    //listViewData.ItemsSource = employees.ToList();

                    CollectionView           view             = (CollectionView)CollectionViewSource.GetDefaultView(employees.ToList());
                    PropertyGroupDescription groupDescription = new PropertyGroupDescription("StateCode");
                    view.GroupDescriptions.Add(groupDescription);
                    listViewData.ItemsSource = view;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }