Exemplo n.º 1
0
        private void btnView_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                SAList = new List <ServiceAwardeeList>();
                using (var db = new LetranIntegratedSystemEntities())
                {
                    if (!String.IsNullOrEmpty(txtYear.Text))
                    {
                        int y;
                        if (Int32.TryParse(txtYear.Text, out y))
                        {
                            var getservice = db.GetHRiSServiceAwardees(y).ToList();

                            foreach (var x in getservice)
                            {
                                ServiceAwardeeList sal = new ServiceAwardeeList();
                                sal.EmployeeID   = x.EmployeeID;
                                sal.EmployeeNo   = x.EmployeeNo;
                                sal.Title        = x.Title;
                                sal.EmployeeName = x.EmployeeName;
                                sal.Department   = x.Department;
                                sal.DateHired    = x.DateHired.Value;
                                sal.YearEntry    = y;
                                sal.Year         = x.YR.ToString() + " Years";
                                SAList.Add(sal);
                            }
                            dgServiceAwardee.ItemsSource = SAList;
                        }
                        else
                        {
                            MessageBox.Show("Not a valid number.", "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Year cannot be empty.", "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }