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


            if (!String.IsNullOrEmpty(cbEmployee.Text))
            {
                var biometricLogData = (from a in db.BiometricsLogDatas
                                        join b in db.Employees on a.EMPN equals b.bioid
                                        select new { a.Id, b.EmployeeNo, EmployeeName = b.LastName.ToUpper() + ", " + b.FirstName.ToUpper(), a.DTIME, a.MODE }).ToList();

                foreach (var x in biometricLogData)
                {
                    BiometricList bl = new BiometricList();
                    bl.AttendanceID   = x.Id;
                    bl.EmployeeNumber = x.EmployeeNo;
                    bl.EmployeeName   = x.EmployeeName;
                    bl.BiometricDate  = x.DTIME.Date;
                    bl.DayOfWeek      = x.DTIME.Date.DayOfWeek.ToString().ToUpper();
                    bl.Month          = x.DTIME.Date.ToString("MMMM").ToUpper();


                    ////bl.BiometricTime = x.DTIME.
                    ;
                    //if (x.MODE == "I")
                    //{
                    //    bl.Type = "IN";
                    //}
                    //else if (x.MODE == "BO")
                    //{
                    //    bl.Type = "BREAK OUT";
                    //}
                    //else if (x.MODE == "BI")
                    //{
                    //    bl.Type = "BREAK IN";
                    //}
                    //else if (x.MODE == "O")
                    //{
                    //    bl.Type = "OUT";
                    //}


                    BList.Add(bl);
                }

                dgTurnstile.ItemsSource = BList.OrderByDescending(m => m.BiometricDate);
            }
            //}
            //catch (Exception)
            //{
            //    MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Warning);
            //}
        }
コード例 #2
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);
            //}
        }
コード例 #3
0
        public void GetBiometricsLogData()
        {
            try
            {
                int    idwEnrollNumber = 0;
                int    idwVerifyMode   = 0;
                int    idwInOutMode    = 0;
                int    idwErrorCode    = 0;
                string TimeStr         = "";
                ConnectBiometrics();
                BList = new List <BiometricList>();
                axCZKEM1.EnableDevice(iMachineNumber, false);//disable the device


                if (axCZKEM1.ReadGeneralLogData(iMachineNumber))//read all the attendance records to the memory
                {
                    int count = 0;
                    BackgroundWorker worker = new BackgroundWorker();
                    worker.DoWork += (o, ea) =>
                    {
                        //int dwMachineNumber, ref int dwTMachineNumber, ref int dwEnrollNumber, ref int dwEMachineNumber, ref int dwVerifyMode, ref int dwInOutMode, ref int dwYear, ref int dwMonth, ref int dwDay, ref int dwHour, ref int dwMinute
                        while (axCZKEM1.GetGeneralLogDataStr(iMachineNumber, ref idwEnrollNumber, ref idwVerifyMode, ref idwInOutMode, ref TimeStr))    //get records from the memory
                        {
                            DateTime      biometricDate = Convert.ToDateTime(TimeStr);
                            BiometricList bl            = new BiometricList();

                            if (idwInOutMode == 1)
                            {
                                bl.Type = "O";
                            }
                            else if (idwInOutMode == 0)
                            {
                                bl.Type = "I";
                            }
                            else if (idwInOutMode == 2)
                            {
                                bl.Type = "BO";
                            }
                            else if (idwInOutMode == 3)
                            {
                                bl.Type = "BI";
                            }

                            bl.EnrollNumber  = idwEnrollNumber;
                            bl.BiometricDate = biometricDate;
                            bl.DayOfWeek     = biometricDate.DayOfWeek.ToString().ToUpper();
                            bl.Month         = biometricDate.Date.ToString("MMMM");
                            bl.Year          = biometricDate.Date.ToString("yyyy").ToUpper();
                            bl.BiometricTime = biometricDate.TimeOfDay;

                            //insert to db
                            var exists = db.BiometricsLogDatas.Where(m => m.EMPN == bl.EnrollNumber && m.DTIME == bl.BiometricDate).FirstOrDefault();
                            if (exists == null)
                            {
                                InsertoDB(bl.EnrollNumber, bl.BiometricDate, bl.Type);
                                count++;
                            }

                            Dispatcher.Invoke((System.Action)(() => bi.BusyContent = string.Format("Data Exported: " + count)));
                            BList.Add(bl);
                        }
                    };

                    worker.RunWorkerCompleted += (o, ea) =>
                    {
                        bi.IsBusy               = false;
                        lblCount.Content        = "Count: " + BList.Count.ToString();
                        dgTurnstile.ItemsSource = BList.OrderByDescending(m => m.BiometricDate);

                        MessageBox.Show("Export success." + " " + count + " data exported.", "System Success!", MessageBoxButton.OK, MessageBoxImage.Information);
                    };
                    bi.IsBusy = true;
                    worker.RunWorkerAsync();
                }

                else
                {
                    axCZKEM1.GetLastError(ref idwErrorCode);

                    if (idwErrorCode != 0)
                    {
                        MessageBox.Show("Reading data from terminal failed,ErrorCode: " + idwErrorCode.ToString(), "Error");

                        return;
                    }
                    else
                    {
                        MessageBox.Show("No data from terminal returns!", "Error");

                        return;
                    }
                }
                axCZKEM1.EnableDevice(iMachineNumber, true);    //enable the device

                Mouse.OverrideCursor = Cursors.Arrow;
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong!", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }