Beispiel #1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ERPEF entity = new ERPEF();

            comboBoxStates.ItemsSource   = entity.States.ToList();
            comboBoxStates.SelectedIndex = 0;
        }
Beispiel #2
0
 private void gridViewData_RowDetailsVisibilityChanged(object sender, DataGridRowDetailsEventArgs e)
 {
     try
     {
         if (e.Row.DetailsVisibility == System.Windows.Visibility.Visible)
         {
             var      item       = e.Row.Item;
             Type     type       = item.GetType();
             int      employeeId = (int)type.GetProperty("EmployeeId").GetValue(item, null);
             DataGrid dataGrid   = e.DetailsElement as DataGrid;
             using (ERPEF context = new ERPEF())
             {
                 IQueryable <FamilyRelation> relations = context.FamilyRelations
                                                         .Where(n => n.EmployeeId == employeeId);
                 if (relations.Count() > 0)
                 {
                     dataGrid.ItemsSource = relations.ToList();
                 }
                 else
                 {
                     dataGrid.Visibility = Visibility.Hidden;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #3
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;
                    }
                    

                    CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(employees.ToList());
                    PropertyGroupDescription group  = new PropertyGroupDescription("StateCode");
                    view.GroupDescriptions.Add(group);
                    gridViewData.ItemsSource = view;

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            
        }