コード例 #1
0
ファイル: Form1.cs プロジェクト: kobezhaoyu/DuanRuo
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         if ((iRetCOM == 1) || (iRetUSB == 1))
         {
             int authenticate = CVRSDK.CVR_Authenticate();
             if (authenticate == 1)
             {
                 int readContent = CVRSDK.CVR_Read_Content(4);
                 if (readContent == 1)
                 {
                     this.label10.Text = "读卡操作成功!";
                     FillData();
                 }
                 else
                 {
                     this.label10.Text = "读卡操作失败!";
                 }
             }
             else
             {
                 MessageBox.Show("未放卡或卡片放置不正确");
             }
         }
         else
         {
             MessageBox.Show("初始化失败!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
コード例 #2
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     try
     {
         CVRSDK.CVR_CloseComm();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
コード例 #3
0
        /// <summary>
        /// 得到身份证上的信息
        /// </summary>
        public void getFillIdCardData(bool isFirst)
        {
            pictureBox1.ImageLocation = Application.StartupPath + "\\zp.bmp";
            //if (isFirst)//如果是第一次刷卡,则把照片保存到本地磁盘
            //{
            //    pictureBox1.Image.Save(GetUpLoadPath() + DateTime.Now.ToString("yyyyMMddHHmmssffff") + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
            //}

            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]);


            lblAddress.Text   = System.Text.Encoding.GetEncoding("GB2312").GetString(address).Replace("\0", "").Trim();
            lblSex.Text       = System.Text.Encoding.GetEncoding("GB2312").GetString(sex).Replace("\0", "").Trim();
            lblBirthday.Text  = System.Text.Encoding.GetEncoding("GB2312").GetString(birthday).Replace("\0", "").Trim();
            lblDept.Text      = System.Text.Encoding.GetEncoding("GB2312").GetString(signdate).Replace("\0", "").Trim();
            lblIdCard.Text    = System.Text.Encoding.GetEncoding("GB2312").GetString(number).Replace("\0", "").Trim();
            lblName.Text      = System.Text.Encoding.GetEncoding("GB2312").GetString(name).Replace("\0", "").Trim();
            lblNation.Text    = System.Text.Encoding.GetEncoding("GB2312").GetString(people).Replace("\0", "").Trim();
            label11.Text      = "安全模块号:" + System.Text.Encoding.GetEncoding("GB2312").GetString(samid).Replace("\0", "").Trim();
            lblValidDate.Text = System.Text.Encoding.GetEncoding("GB2312").GetString(validtermOfStart).Replace("\0", "").Trim() + "-" + System.Text.Encoding.GetEncoding("GB2312").GetString(validtermOfEnd).Replace("\0", "").Trim();

            idcardnum = System.Text.Encoding.GetEncoding("GB2312").GetString(number).Replace("\0", "").Trim();
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: kobezhaoyu/DuanRuo
        public string validtermOfEnd;   //有效截止日期,在识别护照时为空

        public void FillData()
        {
            try
            {
                pictureBox1.ImageLocation = Application.StartupPath + "\\zp.bmp";
                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]);


                lblAddress.Text   = System.Text.Encoding.GetEncoding("GB2312").GetString(address).Replace("\0", "").Trim();
                lblSex.Text       = System.Text.Encoding.GetEncoding("GB2312").GetString(sex).Replace("\0", "").Trim();
                lblBirthday.Text  = System.Text.Encoding.GetEncoding("GB2312").GetString(birthday).Replace("\0", "").Trim();
                lblDept.Text      = System.Text.Encoding.GetEncoding("GB2312").GetString(signdate).Replace("\0", "").Trim();
                lblIdCard.Text    = System.Text.Encoding.GetEncoding("GB2312").GetString(number).Replace("\0", "").Trim();
                lblName.Text      = System.Text.Encoding.GetEncoding("GB2312").GetString(name).Replace("\0", "").Trim();
                lblNation.Text    = System.Text.Encoding.GetEncoding("GB2312").GetString(people).Replace("\0", "").Trim();
                label11.Text      = "安全模块号:" + System.Text.Encoding.GetEncoding("GB2312").GetString(samid).Replace("\0", "").Trim();
                lblValidDate.Text = System.Text.Encoding.GetEncoding("GB2312").GetString(validtermOfStart).Replace("\0", "").Trim() + "-" + System.Text.Encoding.GetEncoding("GB2312").GetString(validtermOfEnd).Replace("\0", "").Trim();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #5
0
 private void button2_Click(object sender, EventArgs e)
 {
     try
     {
         int isSuccess = CVRSDK.CVR_CloseComm();
         this.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
コード例 #6
0
 /// <summary>
 /// 获取身份证卡的信息 - 身份证号码
 /// </summary>
 /// <returns></returns>
 public string GetCVR_Idcard()
 {
     try
     {
         int    length = 30;
         byte[] number = new byte[30];
         length = 36;
         CVRSDK.GetPeopleIDCode(ref number[0], ref length);
         return(System.Text.Encoding.GetEncoding("GB2312").GetString(number).Replace("\0", "").Trim());
     }
     catch
     {
         return("");
     }
 }
コード例 #7
0
ファイル: MainWnd.cs プロジェクト: tomcat0506/readdll
        private void buttonReadCard_Click(object sender, EventArgs e)
        {
            try
            {
                int iPort, iRetUSB = 0;
                for (iPort = 1001; iPort <= 1016; iPort++)
                {
                    iRetUSB = CVRSDK.CVR_InitComm(iPort);
                    if (iRetUSB == 1)
                    {
                        break;
                    }
                }

                if (iRetUSB == 1)
                {
                    this.labelOpResult.Text = "初始化成功!";
                }
                else
                {
                    this.labelOpResult.Text = "初始化失败!";
                }

                int authenticate = CVRSDK.CVR_Authenticate();
                if (authenticate == 1)
                {
                    int readContent = CVRSDK.CVR_Read_FPContent();
                    if (readContent == 1)
                    {
                        this.labelOpResult.Text = "读卡操作成功!";
                        FillData();
                    }
                    else
                    {
                        this.labelOpResult.Text = "读卡操作失败!";
                    }
                }
                else
                {
                    MessageBox.Show("未放卡或卡片放置不正确");
                }
                CVRSDK.CVR_CloseComm();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #8
0
        private void personInfo_Load(object sender, EventArgs e)
        {
            pictureBox1.ImageLocation = Application.StartupPath + "\\zp.bmp";

            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))
                {
                    this.label9.Text = "初始化成功!";
                }
                else
                {
                    this.label9.Text = "初始化失败!";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #9
0
ファイル: Form1.cs プロジェクト: kobezhaoyu/DuanRuo
        private void Form1_Load(object sender, EventArgs e)
        {
            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))
                {
                    this.label9.Text = "初始化成功!";
                }
                else
                {
                    this.label9.Text = "初始化失败!";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #10
0
ファイル: MainWnd.cs プロジェクト: tomcat0506/readdll
        public void FillData()
        {
            try
            {
                byte[] imgData = new byte[40960];
                int    length  = 40960;
                CVRSDK.GetBMPData(ref imgData[0], ref length);
                MemoryStream myStream = new MemoryStream();
                for (int i = 0; i < length; i++)
                {
                    myStream.WriteByte(imgData[i]);
                }
                Image myImage = Image.FromStream(myStream);
                pictureBoxPhoto.Image = myImage;

                byte[] name = new byte[128];
                length = 128;
                CVRSDK.GetPeopleName(ref name[0], ref length);

                byte[] cnName = new byte[128];
                length = 128;
                CVRSDK.GetPeopleChineseName(ref cnName[0], ref length);

                byte[] number = new byte[128];
                length = 128;
                CVRSDK.GetPeopleIDCode(ref number[0], ref length);

                byte[] peopleNation = new byte[128];
                length = 128;
                CVRSDK.GetPeopleNation(ref peopleNation[0], ref length);

                byte[] peopleNationCode = new byte[128];
                length = 128;
                CVRSDK.GetNationCode(ref peopleNationCode[0], ref length);

                byte[] validtermOfStart = new byte[128];
                length = 128;
                CVRSDK.GetStartDate(ref validtermOfStart[0], ref length);

                byte[] birthday = new byte[128];
                length = 128;
                CVRSDK.GetPeopleBirthday(ref birthday[0], ref length);

                byte[] address = new byte[128];
                length = 128;
                CVRSDK.GetPeopleAddress(ref address[0], ref length);

                byte[] validtermOfEnd = new byte[128];
                length = 128;
                CVRSDK.GetEndDate(ref validtermOfEnd[0], ref length);

                byte[] signdate = new byte[128];
                length = 128;
                CVRSDK.GetDepartment(ref signdate[0], ref length);

                byte[] sex = new byte[128];
                length = 128;
                CVRSDK.GetPeopleSex(ref sex[0], ref length);

                byte[] samid = new byte[128];
                CVRSDK.CVR_GetSAMID(ref samid[0]);

                bool   bCivic   = true;
                byte[] certType = new byte[32];
                length = 32;
                CVRSDK.GetCertType(ref certType[0], ref length);

                string strType = System.Text.Encoding.ASCII.GetString(certType);
                int    nStart  = strType.IndexOf("I");
                if (nStart != -1)
                {
                    bCivic = false;
                }

                if (bCivic)
                {
                    labelCnName.Visible  = false;
                    labelAddress.Visible = true;
                    labelName.Text       = "姓名:" + System.Text.Encoding.GetEncoding("GB2312").GetString(name);
                    labelSex.Text        = "性别:" + System.Text.Encoding.GetEncoding("GB2312").GetString(sex).Replace("\0", "").Trim();
                    labelNation.Text     = "民族:" + System.Text.Encoding.GetEncoding("GB2312").GetString(peopleNation).Replace("\0", "").Trim();
                    labelNationCode.Text = "民族代码:" + System.Text.Encoding.GetEncoding("GB2312").GetString(peopleNationCode).Replace("\0", "").Trim();
                    labelBirthday.Text   = "出生日期:" + System.Text.Encoding.GetEncoding("GB2312").GetString(birthday).Replace("\0", "").Trim();
                    labelIdCardNo.Text   = "身份证号:" + System.Text.Encoding.GetEncoding("GB2312").GetString(number).Replace("\0", "").Trim();
                    labelAddress.Text    = "地址:" + System.Text.Encoding.GetEncoding("GB2312").GetString(address).Replace("\0", "").Trim();
                    labelDepartment.Text = "签发机关:" + System.Text.Encoding.GetEncoding("GB2312").GetString(signdate).Replace("\0", "").Trim();
                    labelValidDate.Text  = "有效期限:" + System.Text.Encoding.GetEncoding("GB2312").GetString(validtermOfStart).Replace("\0", "").Trim() + "-" + System.Text.Encoding.GetEncoding("GB2312").GetString(validtermOfEnd).Replace("\0", "").Trim();
                    labelSamID.Text      = "安全模块号:" + System.Text.Encoding.GetEncoding("GB2312").GetString(samid).Replace("\0", "").Trim();
                }
                else
                {
                    labelCnName.Visible  = true;
                    labelAddress.Visible = false;
                    labelName.Text       = "姓名:" + System.Text.Encoding.GetEncoding("GB2312").GetString(name).Replace("\0", "").Trim();
                    labelCnName.Text     = "中文姓名:" + System.Text.Encoding.GetEncoding("GB2312").GetString(cnName).Replace("\0", "").Trim();
                    labelSex.Text        = "性别:" + System.Text.Encoding.GetEncoding("GB2312").GetString(sex).Replace("\0", "").Trim();
                    labelNation.Text     = "国籍:" + System.Text.Encoding.GetEncoding("GB2312").GetString(peopleNation).Replace("\0", "").Trim();
                    labelNationCode.Text = "国籍代码:" + System.Text.Encoding.GetEncoding("GB2312").GetString(peopleNationCode).Replace("\0", "").Trim();
                    labelBirthday.Text   = "出生日期:" + System.Text.Encoding.GetEncoding("GB2312").GetString(birthday).Replace("\0", "").Trim();
                    labelIdCardNo.Text   = "证件号码:" + System.Text.Encoding.GetEncoding("GB2312").GetString(number).Replace("\0", "").Trim();
                    labelDepartment.Text = "签发机关:" + System.Text.Encoding.GetEncoding("GB2312").GetString(signdate).Replace("\0", "").Trim();
                    labelValidDate.Text  = "有效期限:" + System.Text.Encoding.GetEncoding("GB2312").GetString(validtermOfStart).Replace("\0", "").Trim() + "-" + System.Text.Encoding.GetEncoding("GB2312").GetString(validtermOfEnd).Replace("\0", "").Trim();
                    labelSamID.Text      = "安全模块号:" + System.Text.Encoding.GetEncoding("GB2312").GetString(samid).Replace("\0", "").Trim();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #11
0
        public string printStuNo;       //打印准考证号

        #endregion

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if ((iRetCOM == 1) || (iRetUSB == 1))
                {
                    int authenticate = CVRSDK.CVR_Authenticate();
                    if (authenticate == 1)
                    {
                        int readContent = CVRSDK.CVR_Read_Content(4);
                        if (readContent == 1)
                        {
                            getFillIdCardData(false);

                            this.label10.Text = "读卡操作成功!";
                            //判断刷卡人是否已录入考试名单
                            string _sql         = "select kaochangName from db_exam where idcard='" + GetCVR_Idcard() + "' and examNameID='" + publicModel.examName + "'";
                            string kaochangName = Convert.ToString(DbHelperOleDb.GetSingle(_sql));
                            if (!string.IsNullOrEmpty(kaochangName))
                            {
                                DataTable dt       = DbHelperOleDb.Query("select * from db_students where IdCard='" + GetCVR_Idcard() + "' and examNameID='" + publicModel.examName + "'").Tables[0];
                                int       selCount = dt.Rows.Count;
                                if (selCount > 0)
                                {
                                    lblExamNo.Visible = true;
                                    lblExamNo.Text    = dt.Rows[0]["stuNo"].ToString();
                                    MessageBox.Show("此身份证已签到!");
                                    newflag = true;
                                }
                                else
                                {
                                    if (getStuExamRandomNum(kaochangName))
                                    {
                                        newflag = false;
                                        FillData(kaochangName);

                                        db_exam modelexam = new db_exam(GetCVR_Idcard(), publicModel.examName);
                                        //更改签到学生的签到状态
                                        modelexam.status = "已签到";
                                        modelexam.Update();
                                    }
                                }
                            }
                            else
                            {
                                MessageBox.Show("“" + publicModel.examName + "” 考试名单中无此人信息!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                return;
                            }
                        }
                        else
                        {
                            this.label10.Text = "读卡操作失败!";
                        }
                    }
                    else
                    {
                        MessageBox.Show("未放卡或卡片放置不正确", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    MessageBox.Show("初始化失败!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }