LOGO OA教程 ERP教程 模切知识交流 PMS教程 CRM教程 开发文档 其他文档  
 
网站管理员

中控考勤机二次开发小记

admin
2017年11月10日 9:0 本文热度 7155

上图

读取考勤数据代码 :


axCZKEM1.EnableDevice(iMachineNumber, false);//disable the device
                if (axCZKEM1.ReadGeneralLogData(iMachineNumber))
//读取所有考勤数据到内存缓存
                {
                    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))
//从内存缓存取得所有的考勤记录数据
                    {
                         
                        iGLCount++;
                        lv_kq.Items.Add(iGLCount.ToString());
                        lv_kq.Items[iIndex].SubItems.Add(sdwEnrollNumber);//modify by Darcy on Nov.26 2009
                        lv_kq.Items[iIndex].SubItems.Add(idwVerifyMode.ToString());
                        lv_kq.Items[iIndex].SubItems.Add(idwInOutMode.ToString());
//这里有点悲剧,中控SDK提供的API读取时间是int类型的,如果时间01,05等以0开头的时间或分钟,会变成单个0,或单个1.如:2017-08-31 12:01:09 会变成:2017-08-31 12:1:9 很难看,所以需要在此转换。
                        if (idwMinute < 10)
                        {
                            strMinute = "0" + idwMinute.ToString();
 
                        }
                        else { strMinute = idwMinute.ToString(); }
                        if (idwSecond < 10)
                        {
 
                            strSecond = "0" + idwSecond.ToString();
                        }
                        else { strSecond = idwSecond.ToString(); }
 
                        if(idwHour<10){
                         
                        strHour="0"+idwHour.ToString();
                         
                        }else{
                         
                            strHour=idwHour.ToString();
                         
                        }
 
                        lv_kq.Items[iIndex].SubItems.Add(idwYear.ToString() + "-" + idwMonth.ToString() + "-" + idwDay.ToString() + " " + strHour + ":" + strMinute + ":" + strSecond);
                        lv_kq.Items[iIndex].SubItems.Add(idwWorkcode.ToString());
                        iIndex++;
                    }
                }
                else
                {
                    Cursor = Cursors.Default;
                    axCZKEM1.GetLastError(ref idwErrorCode);
 
                    if (idwErrorCode != 0)
                    {
                        MessageBox.Show("Reading data from terminal failed,ErrorCode: " + idwErrorCode.ToString(), "Error");
                    }
                    else
                    {
                        MessageBox.Show("No data from terminal returns!", "Error");
                    }
                }
                axCZKEM1.EnableDevice(iMachineNumber, true);//enable the device
                Cursor = Cursors.Default;
 
//读取用户数据
 
 axCZKEM1.EnableDevice(iMachineNumber, false);
                Cursor = Cursors.WaitCursor;
 
                axCZKEM1.ReadAllUserID(iMachineNumber);
//读取所有卡机上的用户信息到内存缓存
                axCZKEM1.ReadAllTemplate(iMachineNumber);
//读取所有的指纹模板到内存缓存
                while (axCZKEM1.SSR_GetAllUserInfo(iMachineNumber, out sdwEnrollNumber, out sName, out sPassword, out iPrivilege, out bEnabled))//get all the users'' information from the memory
                {
 
                    for (idwFingerIndex = 0; idwFingerIndex < 10; idwFingerIndex++)
                    {
                        if (axCZKEM1.SSR_GetUserTmpStr(iMachineNumber, sdwEnrollNumber, idwFingerIndex, out sTmpData, out iTmpLength))
 
                        {
 
                            ListViewItem list = new ListViewItem();
 
                            list.Text = iSn.ToString();
                            list.SubItems.Add(sdwEnrollNumber);
                            list.SubItems.Add(sName);
                            list.SubItems.Add(idwFingerIndex.ToString());
                            list.SubItems.Add(sTmpData);
                            list.SubItems.Add(iPrivilege.ToString());
                            list.SubItems.Add(sPassword);
                            if (bEnabled == true)
                            {
                                list.SubItems.Add("true");
                            }
                            else
                            {
                                list.SubItems.Add("false");
                            }
                            list.SubItems.Add(iFlag.ToString());
                            lv_finger.Items.Add(list);
                        }
                       
                    }
                    iSn++;
                }
                lv_finger.EndUpdate();
                axCZKEM1.EnableDevice(iMachineNumber, true);
                Cursor = Cursors.Default;
            }
 
            CardConn.DisConn();
 
 
//连接中控考勤机,通过IP
 
 private void conn_card(string ip, string port)
        {
            //string ip = "", port = "";
 
            if (ip == "" || port == "")
            {
                MessageBox.Show("IP地址或端口不能为空", "错误");
                return;
            }
            int idwErrorCode = 0;
 
            Cursor = Cursors.WaitCursor;
            bIsConnected = axCZKEM1.Connect_Net(ip.Trim(), Convert.ToInt32(port.Trim()));
 
            if (bIsConnected == true)
            {
 
                //status_lbl.Text = "当前状态:连接成功。";
                iMachineNumber = 1;
//In fact,when you are using the tcp/ip communication,this parameter will be ignored,that is any integer will all right.Here we use 1.
                axCZKEM1.RegEvent(iMachineNumber, 65535);
//在这里注册卡机的实时事件使用65535参数注册的是全部)
            }
            else
            {
                axCZKEM1.GetLastError(ref idwErrorCode);
                MessageBox.Show("不能连接到此设置,错误码=" + idwErrorCode.ToString(), "Error");
            }
            Cursor = Cursors.Default;
        }

该文章在 2017/11/10 9:00:52 编辑过
关键字查询
相关文章
正在查询...
点晴ERP是一款针对中小制造业的专业生产管理软件系统,系统成熟度和易用性得到了国内大量中小企业的青睐。
点晴PMS码头管理系统主要针对港口码头集装箱与散货日常运作、调度、堆场、车队、财务费用、相关报表等业务管理,结合码头的业务特点,围绕调度、堆场作业而开发的。集技术的先进性、管理的有效性于一体,是物流码头及其他港口类企业的高效ERP管理信息系统。
点晴WMS仓储管理系统提供了货物产品管理,销售管理,采购管理,仓储管理,仓库管理,保质期管理,货位管理,库位管理,生产管理,WMS管理系统,标签打印,条形码,二维码管理,批号管理软件。
点晴免费OA是一款软件和通用服务都免费,不限功能、不限时间、不限用户的免费OA协同办公管理系统。
Copyright 2010-2024 ClickSun All Rights Reserved