Ejemplo n.º 1
0
        public void GetEmployeeHistory()
        {
            try
            {
                using (var db = new LetranIntegratedSystemEntities())
                {
                    lEmployeeHistoryList = new List <EmployeHistoryList>();
                    var emphistory = db.EmployeeHistories.ToList();

                    foreach (var x in emphistory)
                    {
                        EmployeHistoryList eh = new EmployeHistoryList();
                        var emp = db.Employees.Where(m => m.EmployeeID == x.EmployeeID).FirstOrDefault();
                        var dep = db.AcademicDepartments.Where(m => m.AcaDeptID == x.DepartmentID).FirstOrDefault();
                        var pos = db.EmployeePositions.Where(m => m.EmployeePositionID == x.EmployeePositionID).FirstOrDefault();

                        eh.EmployeeName = emp.LastName + ", " + emp.FirstName;
                        eh.EmployeeNo   = emp.EmployeeNo;
                        eh.Remark       = x.Remark;
                        eh.Department   = dep.AcaAcronym;
                        eh.Position     = pos.EmployeePositionName;
                        eh.StartDate    = x.StartDate.Value.Date;
                        eh.EndDate      = x.EndDate.Value.Date;

                        lEmployeeHistoryList.Add(eh);
                    }
                    dgEmployeeHistory.ItemsSource = lEmployeeHistoryList.OrderBy(m => m.EmployeeName);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var db = new LetranIntegratedSystemEntities())
                {
                    lEmployeeHistoryList = new List <EmployeHistoryList>();
                    var emphistory = db.EmployeeHistories.ToList();

                    foreach (var x in emphistory)
                    {
                        EmployeHistoryList eh = new EmployeHistoryList();
                        var emp = db.Employees.Where(m => m.EmployeeID == x.EmployeeID).FirstOrDefault();
                        var dep = db.AcademicDepartments.Where(m => m.AcaDeptID == x.DepartmentID).FirstOrDefault();
                        var pos = db.EmployeePositions.Where(m => m.EmployeePositionID == x.EmployeePositionID).FirstOrDefault();

                        eh.EmployeeName = emp.LastName + ", " + emp.FirstName;
                        eh.EmployeeNo   = emp.EmployeeNo;
                        eh.Remark       = x.Remark;
                        eh.Department   = dep.AcaAcronym;
                        eh.Position     = pos.EmployeePositionName;
                        eh.StartDate    = x.StartDate.Value.Date;
                        eh.EndDate      = x.EndDate.Value.Date;

                        lEmployeeHistoryList.Add(eh);
                    }


                    if (rbEmpname.IsChecked == true)
                    {
                        lEmployeeHistoryList = lEmployeeHistoryList.Where(m => m.EmployeeName.Contains(txtSearch.Text)).ToList();
                    }
                    else if (rbEmpn.IsChecked == true)
                    {
                        lEmployeeHistoryList = lEmployeeHistoryList.Where(m => m.EmployeeNo.Contains(txtSearch.Text)).ToList();
                    }

                    dgEmployeeHistory.ItemsSource = lEmployeeHistoryList.OrderBy(m => m.EmployeeName);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }