Exemple #1
0
        private void btnLoad_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Mouse.OverrideCursor = Cursors.Wait;
                db     = new LetranIntegratedSystemEntities();
                EDList = new List <EmployeeDepartmentList>();
                var dept = cbDepartment.SelectedValue.ToString();

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

                foreach (var x in emp)
                {
                    EmployeeDepartmentList edl = new EmployeeDepartmentList();
                    edl.Department          = x.AcaDepartmentName;
                    edl.EmployeeDesignation = x.EmployeeStatusName;
                    edl.EmployeeLevel       = x.EmployeeLevel;
                    edl.EmployeeName        = x.EmployeeName;
                    edl.EmployeePosition    = x.EmployeePositionName;
                    EDList.Add(edl);
                }
                EDList = EDList.OrderBy(m => m.Department).Where(m => m.Department == dept).ToList();
                ListCollectionView edlcollection = new ListCollectionView(EDList);
                edlcollection.GroupDescriptions.Add(new PropertyGroupDescription("Department"));
                dgEmployeeDepartment.ItemsSource = edlcollection;
                Mouse.OverrideCursor             = null;
            }
            catch (Exception)
            {
                Mouse.OverrideCursor = null;
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemple #2
0
        public void GridRefresh()
        {
            try
            {
                db     = new LetranIntegratedSystemEntities();
                EDList = new List <EmployeeDepartmentList>();

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

                foreach (var x in emp)
                {
                    EmployeeDepartmentList edl = new EmployeeDepartmentList();
                    edl.Department          = x.AcaDepartmentName;
                    edl.EmployeeDesignation = x.EmployeeStatusName;
                    edl.EmployeeLevel       = x.EmployeeLevel;
                    edl.EmployeeName        = x.EmployeeName.ToUpper();
                    edl.EmployeePosition    = x.EmployeePositionName;
                    EDList.Add(edl);
                }
                EDList = EDList.OrderBy(m => m.Department).ToList();
                ListCollectionView edlcollection = new ListCollectionView(EDList);
                edlcollection.GroupDescriptions.Add(new PropertyGroupDescription("Department"));
                dgEmployeeDepartment.ItemsSource = edlcollection;
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void dgAcaDept_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                btnSave.IsEnabled = true;
                btnAdd.IsEnabled  = false;
                using (var db = new LetranIntegratedSystemEntities())
                {
                    if (dgAcaDept.SelectedItem != null)
                    {
                        EDList = new List <EmployeeDepartmentList>();
                        var selectedItem = (AcademicDepartmentList)(dgAcaDept.SelectedItem);

                        lblPos.Content = "List of Current Employees in the Department of: " + selectedItem.Department;
                        //Academic Department
                        var dept = db.AcademicDepartments.Find(selectedItem.DepartmentID);

                        txtDeptName.Text = dept.AcaDepartmentName;
                        txtDeptAcro.Text = dept.AcaAcronym;
                        if (dept.IsAcad == true)
                        {
                            cbIsAcad.Text = "True";
                        }
                        else
                        {
                            cbIsAcad.Text = "False";
                        }
                        //Employee in the Department

                        var empdept = db.Employees.Where(m => m.AcademicDepartment.AcaDeptID == selectedItem.DepartmentID && m.Archive == false).ToList();

                        foreach (var x in empdept)
                        {
                            EmployeeDepartmentList edl = new EmployeeDepartmentList();
                            edl.EmployeeID          = x.EmployeeID;
                            edl.EmployeeNo          = x.EmployeeNo;
                            edl.EmployeeName        = x.LastName.ToUpper() + ", " + x.FirstName.ToUpper();
                            edl.EmployeePosition    = x.EmployeePosition.EmployeePositionName;
                            edl.EmployeeDesignation = x.EmployeeDesignation1.EmployeeDesignationName;
                            edl.EmployeeStatus      = x.EmployeeStatu.EmployeeStatusName;
                            EDList.Add(edl);
                        }
                        dgEmpDept.ItemsSource = EDList.OrderBy(m => m.EmployeeName);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }