Beispiel #1
0
        private void btnView_Click(object sender, RoutedEventArgs e)
        {
            Mouse.OverrideCursor = Cursors.Wait;
            try
            {
                db     = new LetranIntegratedSystemEntities();
                LUList = new List <LeaveUsageList>();

                DateTime startDate = Convert.ToDateTime(dpStart.SelectedDate);
                DateTime endDate   = Convert.ToDateTime(dpEnd.SelectedDate);

                if (!String.IsNullOrEmpty(dpStart.Text) && !String.IsNullOrEmpty(dpEnd.Text))
                {
                    var query = db.GetHRiSLeaveUsage(startDate, endDate).ToList();

                    foreach (var x in query)
                    {
                        LeaveUsageList lul = new LeaveUsageList();
                        lul.EmployeeID     = x.EmployeeID;
                        lul.EmployeeNumber = x.EmployeeNo;
                        lul.EmployeeName   = x.EmployeeName.ToUpper();
                        lul.Department     = x.Department;
                        lul.Designation    = x.Designation;
                        lul.DesignationID  = x.EmployeeDesignationID;
                        lul.SL             = x.SL.HasValue ? x.SL.Value : 0;
                        lul.SIL            = x.SIL.HasValue ? x.SIL.Value : 0;
                        lul.VL             = x.VL.HasValue ? x.VL.Value : 0;
                        LUList.Add(lul);
                    }
                    if (rbAll.IsChecked == true)
                    {
                        LUList = LUList.ToList();
                    }
                    if (rbAdmin.IsChecked == true)
                    {
                        LUList = LUList.Where(m => m.DesignationID == 1).ToList();
                    }
                    if (rbFaculty.IsChecked == true)
                    {
                        LUList = LUList.Where(m => m.DesignationID == 2).ToList();
                    }
                    if (rbNT.IsChecked == true)
                    {
                        LUList = LUList.Where(m => m.DesignationID == 3).ToList();
                    }

                    dgLeaveUsage.ItemsSource = LUList;
                }
                else
                {
                    MessageBox.Show("Date/s cannot be empty.", "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong!", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            Mouse.OverrideCursor = null;
        }