Ejemplo n.º 1
0
        private void btnLoad_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                db     = new LetranIntegratedSystemEntities();
                EAList = new List <EmployeeAgeList>();

                var emp = db.GetHRiSListbyAge().ToList();

                foreach (var x in emp)
                {
                    EmployeeAgeList eal = new EmployeeAgeList();
                    if (x.Age > 0)
                    {
                        eal.Age = x.Age.Value;
                    }
                    else
                    {
                        eal.Age = 0;
                    }

                    if (x.Birthday != null)
                    {
                        eal.Birthday = x.Birthday.Value;
                    }
                    else
                    {
                        eal.Birthday = DateTime.Now;
                    }
                    eal.Department   = x.AcaDepartmentName;
                    eal.EmployeeName = x.EmployeeName;
                    EAList.Add(eal);
                }
                if (!String.IsNullOrEmpty(cbDepartment.Text))
                {
                    string dept = cbDepartment.SelectedValue.ToString();

                    EAList = EAList.Where(m => m.Department == dept).ToList();
                }
                EAList = EAList.OrderBy(m => m.Department).ToList();
                ListCollectionView ealcollection = new ListCollectionView(EAList);
                ealcollection.GroupDescriptions.Add(new PropertyGroupDescription("Department"));
                dgEmployeeAge.ItemsSource = ealcollection;
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 2
0
        public void GridRefresh()
        {
            try
            {
                var db = new LetranIntegratedSystemEntities();
                EAList = new List <EmployeeAgeList>();

                var emp = db.GetHRiSListbyAge().ToList();

                foreach (var x in emp)
                {
                    EmployeeAgeList eal = new EmployeeAgeList();
                    if (x.Age > 0)
                    {
                        eal.Age = x.Age.Value;
                    }
                    else
                    {
                        eal.Age = 0;
                    }

                    if (x.Birthday != null)
                    {
                        eal.Birthday = x.Birthday.Value;
                    }
                    else
                    {
                        eal.Birthday = DateTime.Now;
                    }


                    eal.Department   = x.AcaDepartmentName;
                    eal.EmployeeName = x.EmployeeName;
                    EAList.Add(eal);
                }
                EAList = EAList.OrderBy(m => m.Department).ToList();
                ListCollectionView ealcollection = new ListCollectionView(EAList);
                ealcollection.GroupDescriptions.Add(new PropertyGroupDescription("Department"));
                dgEmployeeAge.ItemsSource = ealcollection;
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }