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


                var query = db.GetHRiSLeaveTransactionReport().ToList();

                foreach (var x in query)
                {
                    TransactionList tl = new TransactionList();
                    tl.Days         = x.Days.Value;
                    tl.Designation  = x.Designation;
                    tl.EmployeeName = x.EmployeeName;
                    tl.EmployeeNo   = x.EmployeeNo;
                    tl.EndDate      = x.EndDate.Value;
                    tl.FiledDate    = x.FiledDate.Value;
                    tl.RangeDate    = x.RangeDate;
                    tl.Reason       = x.Reason;
                    tl.StartDate    = x.StartDate.Value;
                    tl.Type         = x.Type;
                    TList.Add(tl);
                }

                if (rbSpecific.IsChecked == true)
                {
                    if (!String.IsNullOrEmpty(dpEnd.Text) && !String.IsNullOrEmpty(dpStart.Text))
                    {
                        DateTime StartDate = Convert.ToDateTime(dpStart.SelectedDate);
                        DateTime EndDate   = Convert.ToDateTime(dpEnd.SelectedDate);

                        TList = TList.Where(m => m.StartDate >= StartDate && m.StartDate <= EndDate).ToList();
                    }
                    else
                    {
                        MessageBox.Show("Date/s cannot be empty", "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }
                }
                if (rbToday.IsChecked == true)
                {
                    TList = TList.Where(m => m.StartDate == DateTime.Now.Date).ToList();
                }
                if (rbMonth.IsChecked == true)
                {
                    TList = TList.Where(m => m.StartDate.Month == DateTime.Now.Month && m.StartDate.Year == DateTime.Now.Year).ToList();
                }
                if (rbYear.IsChecked == true)
                {
                    TList = TList.Where(m => m.StartDate.Year == DateTime.Now.Year).ToList();
                }

                dgLeaveTransaction.ItemsSource = TList;
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }