C#获取考勤机中的数据

         DH_WorkAttend attend = new DH_WorkAttend();

        protected void btnGetData_Click(object sender, EventArgs e)
        {

            string sdwEnrollNumber = "";
            int idwTMachineNumber = 0;
            int idwEMachineNumber = 0;
            int idwVerifyMode = 0;
            int idwInOutMode = 0;
            int idwYear = 0;
            int idwMonth = 0;
            int idwDay = 0;
            int idwHour = 0;
            int idwMinute = 0;
            int idwSecond = 0;
            int idwWorkcode = 0;

            int idwErrorCode = 0;
            int iGLCount = 0;
            int iIndex = 0;
            int iMachineNumber = int.Parse(txtiMachineNumber.Text.Trim());

            bool bIsConnected = axCZKEM1.Connect_Net(txtIP.Text, Convert.ToInt32(txtPort.Text));


            if (bIsConnected == true)
            {
                axCZKEM1.EnableDevice(iMachineNumber, false);//disable the device
                if (axCZKEM1.ReadGeneralLogData(iMachineNumber))//read all the attendance records to the memory
                {
                    while (axCZKEM1.SSR_GetGeneralLogData(iMachineNumber, out sdwEnrollNumber, out idwVerifyMode,
                               out idwInOutMode, out idwYear, out idwMonth, out idwDay, out idwHour, out idwMinute, out idwSecond, ref idwWorkcode))//get records from the memory
                    {

                        decimal UserID = decimal.Parse(sdwEnrollNumber);
                        iMachineNumber = int.Parse(txtiMachineNumber.Text.Trim());
                        string IPAdd = txtIP.Text.Trim();
                        string workDates = idwYear.ToString() + "-" + idwMonth.ToString() + "-" + idwDay.ToString() + " " + idwHour.ToString() + ":" + idwMinute.ToString() + ":" + idwSecond.ToString();
                        DateTime workDate = DateTime.Parse(workDates);
                        DateTime InputDate = DateTime.Now;

                        attend.DH_AttendanceEmpOriginalInsert(UserID, workDate, iMachineNumber, IPAdd, InputDate);

                    }
                }
                else
                {

                    axCZKEM1.GetLastError(ref idwErrorCode);

                    if (idwErrorCode != 0)
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('Reading data from terminal failed')", true);

                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('No data from terminal returns!')", true);

                    }
                }

                if (axCZKEM1.ClearGLog(iMachineNumber))
                {
                    axCZKEM1.RefreshData(iMachineNumber);

                }
                axCZKEM1.EnableDevice(iMachineNumber, true);
                axCZKEM1.Disconnect();
                BindGridView(pageSize, 1, SearchTerms);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('设备连接失败!')", true);
            }


        }

 

评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值