Exemple #1
0
        private void cbDepartment_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var deptid = Convert.ToInt32(cbDepartment.SelectedValue);

            try
            {
                using (var db = new LetranIntegratedSystemEntities())
                {
                    lEmployeeShiftList = new List <HRiSClass.EmployeeShiftList>();
                    var empSchedule = db.GetEmployeeSchedules().Where(m => m.AcaDeptID == deptid).ToList().OrderBy(m => m.Name);

                    foreach (var x in empSchedule)
                    {
                        HRiSClass.EmployeeShiftList employeeShift = new HRiSClass.EmployeeShiftList();

                        employeeShift.EmployeeNo   = x.Employeeno;
                        employeeShift.EmployeeName = x.Name;
                        employeeShift.ShiftCode    = x.EmployeeShiftCode;
                        employeeShift.EmployeeID   = x.EmployeeID;
                        employeeShift.Department   = x.AcaAcronym;

                        lEmployeeShiftList.Add(employeeShift);
                    }

                    dgEmployeeScheduleList.ItemsSource = lEmployeeShiftList.OrderBy(m => m.EmployeeName);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #2
0
        //public void GetEmployeeScheduleList()
        //{
        //    try
        //    {
        //        using (var db = new LetranIntegratedSystemEntities())
        //        {
        //            lEmployeeShiftList = new List<HRiSClass.EmployeeShiftList>();
        //            var empSchedule = (from a in db.HRISEmployeeSchedules
        //                               join b in db.Employees on a.EmployeeNumber equals b.EmployeeNo
        //                               join c in db.HRISShifts on a.ShiftCode equals c.ShiftCode
        //                               where b.Archive == false
        //                               select new { b.EmployeeNo, EmployeeName = b.LastName.ToUpper() + ", " + b.FirstName.ToUpper(), a.ShiftCode, c.StartTime, c.EndTime }).ToList();

        //            foreach (var x in empSchedule)
        //            {

        //                HRiSClass.EmployeeShiftList employeeShift = new HRiSClass.EmployeeShiftList();
        //                employeeShift.EmployeeNo = x.EmployeeNo;
        //                employeeShift.EmployeeName = x.EmployeeName;
        //                employeeShift.ShiftCode = x.ShiftCode;
        //                employeeShift.StartTime = x.StartTime;
        //                employeeShift.EndTime = x.EndTime;

        //                lEmployeeShiftList.Add(employeeShift);
        //            }

        //            dgEmployeeScheduleList.ItemsSource = lEmployeeShiftList.OrderBy(m => m.EmployeeName);

        //        }
        //    }
        //    catch (Exception)
        //    {

        //        throw;
        //    }
        //}

        private void GetEmployeeSchedules()
        {
            try
            {
                using (var db = new LetranIntegratedSystemEntities())
                {
                    lEmployeeShiftList = new List <HRiSClass.EmployeeShiftList>();
                    var empSchedule = db.GetEmployeeSchedules().ToList().OrderBy(m => m.Name);

                    foreach (var x in empSchedule)
                    {
                        HRiSClass.EmployeeShiftList employeeShift = new HRiSClass.EmployeeShiftList();

                        employeeShift.EmployeeNo   = x.Employeeno;
                        employeeShift.EmployeeName = x.Name;
                        employeeShift.ShiftCode    = x.EmployeeShiftCode;
                        employeeShift.EmployeeID   = x.EmployeeID;
                        employeeShift.Department   = x.AcaAcronym;
                        lEmployeeShiftList.Add(employeeShift);
                    }

                    dgEmployeeScheduleList.ItemsSource = lEmployeeShiftList.OrderBy(m => m.EmployeeName);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }