コード例 #1
0
        public void GetBiometrics()
        {
            //try
            //{
            db    = new LetranIntegratedSystemEntities();
            sof   = new softrakEntities();
            BList = new List <BiometricList>();


            if (!String.IsNullOrEmpty(cbEmployee.Text))
            {
                string empno = Convert.ToString(cbEmployee.SelectedValue);

                DateTime startdate = Convert.ToDateTime(sdate.SelectedDate);
                DateTime enddate   = Convert.ToDateTime(edate.SelectedDate);
                BList = new List <BiometricList>();

                var attendance = db.GetEmployeeAttendanceByEmployeeNumber(Convert.ToString(sdate), Convert.ToString(edate), empno).OrderBy(m => m.DATE);
                var employee   = db.Employees.Where(m => m.EmployeeNo == empno).FirstOrDefault();
                foreach (var x in attendance)
                {
                    BiometricList bl = new BiometricList();

                    bl.BiometricDate  = Convert.ToDateTime(x.DATE);
                    bl.DayOfWeek      = x.DATE.Value.ToString("ddd");
                    bl.TimeIn         = x.TIMEIN;
                    bl.BreakOut       = x.BREAKOUT;
                    bl.BreakIn        = x.BREAKIN;
                    bl.TimeOut        = x.TIMEOUT;
                    bl.Remarks        = x.REMARK;
                    bl.EmployeeName   = employee.LastName + ", " + employee.FirstName;
                    bl.EmployeeNumber = Convert.ToString(empno);
                    bl.StarDate       = Convert.ToDateTime(sdate.SelectedDate);
                    bl.EndDate        = Convert.ToDateTime(edate.SelectedDate);


                    bl.TimeinID   = Convert.ToInt32(x.TimeinID);
                    bl.BreakOutID = Convert.ToInt32(x.BreakoutID);
                    bl.BreakInID  = Convert.ToInt32(x.BreakinID);
                    bl.TimeOutID  = Convert.ToInt32(x.TimeoutID);
                    BList.Add(bl);
                }

                dgTurnstile.ItemsSource = BList.OrderByDescending(m => m.BiometricDate);
            }
            else
            {
                MessageBox.Show("Employee cannot be empty.", "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            //}
            //catch (Exception)
            //{
            //    MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Warning);
            //}
        }