Ejemplo n.º 1
0
 public static string Init()
 {
     for (int port = 1001; port <= 1016; port++)
     {
         RetUsb = CVRSDK.CVR_InitComm(port);
         if (RetUsb == 1)
         {
             break;
         }
     }
     for (int com = 1; com <= 4; com++)
     {
         RetCom = CVRSDK.CVR_InitComm(com);
         if (RetCom == 1)
         {
             break;
         }
     }
     if (RetCom == 1 || RetUsb == 1)
     {
         return("初始化成功");
     }
     else
     {
         return("初始化失败");
     }
 }
Ejemplo n.º 2
0
        private void fillData()
        {
            idCard            = CVRSDK.getFarmerCard();
            tName.Text        = idCard.tName.Trim();
            tSex.Text         = idCard.tSex.Trim();
            tNation.Text      = idCard.tNation.Trim();
            tCode.Text        = idCard.tCode.Trim();
            tAddress.Text     = idCard.tAddress.Trim();
            tBrith.Text       = GetTime(idCard.tBirth.ToString()).ToString().Substring(0, 10);
            tInstitution.Text = idCard.tInstitution.Trim();
            tValidity.Text    = idCard.tValidity.Trim();
            //pictureBox1.Image.Tag = idCard.tPhotoBox1.Trim();

            // pictureBox1.Image = idCard.tPhotoBox1;
        }
Ejemplo n.º 3
0
        private void UserControl1_Load(object sender, EventArgs e)
        {
            //读取文字、信息自定义内存缓冲
            char a, b;

            a = '1';
            b = '2';
            int result = CVRSDK.CVR_ReadBaseMsg(a, 10, b, 10, 3);

            if (result == 1)
            {
                MessageBox.Show("成功");
            }
            else
            {
                MessageBox.Show("失败");
            }
        }
Ejemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            int result = CVRSDK.ReadCard();

            if (result == -1)
            {
                label6.Text = "卡放置位置不对";
            }
            else if (result == 1)
            {
                label6.Text = "读卡成功";
                //将读取数据存入相对的文字框中
                fillData();
                //MessageBox.Show(idCard.tPhotoBox1);
            }
            else
            {
                label6.Text = "读卡失败";
            }
        }
Ejemplo n.º 5
0
        //读取身份证信息
        public static int ReadCard()
        {
            //用于读卡器与身份证建立连接
            int authen = CVRSDK.CVR_Authenticate();

            if (authen != 1)
            {
                return(-1);            //卡片放置位置不正确
            }
            else
            {
                int readContent = CVRSDK.CVR_Read_Content(4);
                if (readContent == 2)
                {
                    return(1);//"读卡操作成功!";
                }
                else
                {
                    return(0); //"读卡操作失败!";
                }
            }
        }
Ejemplo n.º 6
0
        private void button3_Click(object sender, EventArgs e)
        {
            string reuslt = CVRSDK.Init();

            label6.Text = reuslt;
        }
Ejemplo n.º 7
0
        public static IDCard getFarmerCard()
        {
            IDCard idCard = new IDCard();

            try
            {
                //pictureBox1.ImageLocation = Application.StartupPath + "\\zp.bmp";
                byte[] tName  = new byte[30];
                int    length = 20;
                CVRSDK.GetPeopleName(ref tName[0], ref length);

                byte[] idCode = new byte[30];
                length = 36;
                CVRSDK.GetPeopleIDCode(ref idCode[0], ref length);

                byte[] tNation = new byte[30];
                length = 3;
                CVRSDK.GetPeopleNation(ref tNation[0], ref length);

                byte[] tValidity = new byte[30];
                length = 16;
                CVRSDK.GetEndDate(ref tValidity[0], ref length);

                byte[] tBirth = new byte[30];
                length = 16;
                CVRSDK.GetPeopleBirthday(ref tBirth[0], ref length);

                byte[] tAddress = new byte[50];
                length = 70;
                CVRSDK.GetPeopleAddress(ref tAddress[0], ref length);

                byte[] tInstitution = new byte[30];
                length = 30;
                CVRSDK.GetDepartment(ref tInstitution[0], ref length);

                byte[] tSex = new byte[30];
                length = 3;
                CVRSDK.GetPeopleSex(ref tSex[0], ref length);

                //byte[] tPhoto = new byte[200];
                //length = 200;
                //CVRSDK.GetPhotoBMP(tPhoto[0], length);



                //对获取到的人的身份证信息字符串进行处理

                idCard.tName = Encoding.GetEncoding("GB2312").GetString(tName);

                idCard.tSex = Encoding.GetEncoding("GB2312").GetString(tSex);

                idCard.tCode = Encoding.GetEncoding("GB2312").GetString(idCode);

                idCard.tNation = Encoding.GetEncoding("GB2312").GetString(tNation);

                idCard.tValidity = Encoding.GetEncoding("GB2312").GetString(tValidity);

                string str = Encoding.GetEncoding("GB2312").GetString(tBirth);
                str           = str.Substring(0, 10);
                idCard.tBirth = ConvertDateTimeInt(Convert.ToDateTime(str));

                idCard.tAddress = Encoding.GetEncoding("GB2312").GetString(tAddress);

                //string range = card.ValidTermOfStart + "-" + card.ValidTermOfEnd;
                //range += "- " + card.ValidTermOfEnd;

                idCard.tInstitution = Encoding.GetEncoding("GB2312").GetString(tInstitution);

                //idCard.tPhotoBox1 = Encoding.GetEncoding("GB2312").GetString(tPhoto);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            return(idCard);
        }
Ejemplo n.º 8
0
 public void CloseCommunite()
 {
     CVRSDK.CVR_CloseComm();
 }