示例#1
0
 /// <summary>
 /// 读取数据
 /// </summary>
 private void readData()
 {
     try
     {
         if ((iRetCOM == 1) || (iRetUSB == 1))
         {
             int authenticate = CVRSDK.CVR_Authenticate();
             if (authenticate == 1)
             {
                 int readContent = CVRSDK.CVR_Read_Content(4);
                 if (readContent == 1)
                 {
                     onevent("读卡操作成功", TYPE_STATUS_LABEL);
                     onevent("", TYPE_FILL_DATA);
                 }
                 else
                 {
                     onevent("读卡操作失败", TYPE_STATUS_LABEL);
                 }
             }
             else
             {
                 //onevent("未放卡或卡片放置不正确", TYPE_STATUS_LABEL);
             }
         }
         else
         {
             onevent("初始化失败", TYPE_STATUS_LABEL);
         }
     }
     catch (Exception ex)
     {
         onevent(ex.ToString(), TYPE_STATUS_LABEL);
     }
 }
示例#2
0
        /// <summary>
        /// 填充数据
        /// </summary>
        public void FillData(PeopleInfo toSavePeople)
        {
            toSavePeople.clearInfo();
            try
            {
                byte[] name   = new byte[30];
                int    length = 30;
                CVRSDK.GetPeopleName(ref name[0], ref length);
                //MessageBox.Show();
                byte[] number = new byte[30];
                length = 36;
                CVRSDK.GetPeopleIDCode(ref number[0], ref length);
                byte[] people = new byte[30];
                length = 3;
                CVRSDK.GetPeopleNation(ref people[0], ref length);
                byte[] validtermOfStart = new byte[30];
                length = 16;
                CVRSDK.GetStartDate(ref validtermOfStart[0], ref length);
                byte[] birthday = new byte[30];
                length = 16;
                CVRSDK.GetPeopleBirthday(ref birthday[0], ref length);
                byte[] address = new byte[30];
                length = 70;
                CVRSDK.GetPeopleAddress(ref address[0], ref length);
                byte[] validtermOfEnd = new byte[30];
                length = 16;
                CVRSDK.GetEndDate(ref validtermOfEnd[0], ref length);
                byte[] signdate = new byte[30];
                length = 30;
                CVRSDK.GetDepartment(ref signdate[0], ref length);
                byte[] sex = new byte[30];
                length = 3;
                CVRSDK.GetPeopleSex(ref sex[0], ref length);

                byte[] samid = new byte[32];
                CVRSDK.CVR_GetSAMID(ref samid[0]);
                toSavePeople.sex      = Encoding.GetEncoding("GB2312").GetString(sex).Replace("\0", "").Trim();
                toSavePeople.age      = Convert.ToString(GetAgeByBirthdate(Convert.ToDateTime(Encoding.GetEncoding("GB2312").GetString(birthday).Replace("\0", "").Trim())));
                toSavePeople.cardId   = Encoding.GetEncoding("GB2312").GetString(number).Replace("\0", "").Trim();
                toSavePeople.name     = Encoding.GetEncoding("GB2312").GetString(name).Replace("\0", "").Trim();
                toSavePeople.serialId = Convert.ToString(serialId);// DateTime.Now.ToString("yyyyMMddHHmm");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
示例#3
0
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            RegistryKey reg1 = Registry.CurrentUser;
            RegistryKey reg2 = reg1.CreateSubKey("SoftWare\\" + MY_SOFT_NAME);

            reg2.SetValue("x", this.Location.X);
            reg2.SetValue("y", this.Location.Y);

            if (!isClose)
            {
                try
                {
                    CVRSDK.CVR_CloseComm();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
            notifyIcon1.Dispose();
        }
示例#4
0
        /// <summary>
        /// 初始化 读卡器
        /// </summary>
        private void cvrInit()
        {
            try
            {
                int iPort;
                for (iPort = 1001; iPort <= 1016; iPort++)
                {
                    iRetUSB = CVRSDK.CVR_InitComm(iPort);
                    if (iRetUSB == 1)
                    {
                        break;
                    }
                }
                if (iRetUSB != 1)
                {
                    for (iPort = 1; iPort <= 4; iPort++)
                    {
                        iRetCOM = CVRSDK.CVR_InitComm(iPort);
                        if (iRetCOM == 1)
                        {
                            break;
                        }
                    }
                }

                if ((iRetCOM == 1) || (iRetUSB == 1))
                {
                    isClose = false;
                    this.toolStripStatusLabel1.Text = "CVRSDK 初始化成功!";
                }
                else
                {
                    this.toolStripStatusLabel1.Text = "CVRSDK 初始化失败!";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }