コード例 #1
0
ファイル: IDCard.cs プロジェクト: radtek/HospitalSelfSystem
        /// <summary>
        /// 得到身份证信息
        /// </summary>
        /// <returns>身份证信息实体</returns>
        public IDCardInfo FillData()
        {
            try
            {
                IDCardInfo cardInfo = new IDCardInfo();
                // cardInfo.ImagePath = 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);

                cardInfo.Address   = System.Text.Encoding.GetEncoding("GB2312").GetString(address).Replace("\0", "").Trim();
                cardInfo.Sex       = System.Text.Encoding.GetEncoding("GB2312").GetString(sex).Replace("\0", "").Trim();
                cardInfo.Birthday  = System.Text.Encoding.GetEncoding("GB2312").GetString(birthday).Replace("\0", "").Trim();
                cardInfo.Signdate  = System.Text.Encoding.GetEncoding("GB2312").GetString(signdate).Replace("\0", "").Trim();
                cardInfo.Number    = System.Text.Encoding.GetEncoding("GB2312").GetString(number).Replace("\0", "").Trim();
                cardInfo.Name      = System.Text.Encoding.GetEncoding("GB2312").GetString(name).Replace("\0", "").Trim();
                cardInfo.People    = System.Text.Encoding.GetEncoding("GB2312").GetString(people).Replace("\0", "").Trim();
                cardInfo.ValidDate = System.Text.Encoding.GetEncoding("GB2312").GetString(validtermOfStart).Replace("\0", "").Trim() + "-" + System.Text.Encoding.GetEncoding("GB2312").GetString(validtermOfEnd).Replace("\0", "").Trim();
                return(cardInfo);
            }
            catch (Exception ex)
            {
                throw new  Exception(ex.ToString());
            }
        }
コード例 #2
0
ファイル: Frm_Register.cs プロジェクト: anrk0451/White
        private void FillData()
        {
            try
            {
                int length;

                IDC_FLAG = true;

                // 照片保存在当前目录
                String szXPPath          = "zp.bmp";
                System.Drawing.Image img = System.Drawing.Image.FromFile(szXPPath);
                System.Drawing.Image bmp = new System.Drawing.Bitmap(img);
                img.Dispose();
                pictureEdit1.Image = bmp;


                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[] Uid = new byte[128];
                length = 128;

                //CVRSDK.GetIDCardUID(ref Uid[0], 128);

                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 (ic01 == null)
                {
                    ic01       = new Ic01();
                    ic01.ic001 = Tools.GetEntityPK("IC01");
                }

                ic01.ic000 = "0";                                                        //0-逝者 1-家属
                ic01.ic003 = System.Text.Encoding.GetEncoding("GB2312").GetString(name); //姓名
                ic01.ic002 = System.Text.Encoding.GetEncoding("GB2312").GetString(sex).Replace("\0", "").Trim() == "男" ? "0" : "1";

                //出生日期
                string s_birth = System.Text.Encoding.GetEncoding("GB2312").GetString(birthday).Replace("\0", "").Trim();
                ic01.ic004 = Convert.ToDateTime(s_birth.Substring(0, 4) + "-" + s_birth.Substring(4, 2) + "-" + s_birth.Substring(6));

                //身份证号
                ic01.ic014 = System.Text.Encoding.GetEncoding("GB2312").GetString(number).Replace("\0", "").Trim();

                //地址
                ic01.ic016 = System.Text.Encoding.GetEncoding("GB2312").GetString(address).Replace("\0", "").Trim();

                //签发机关
                ic01.ic017 = System.Text.Encoding.GetEncoding("GB2312").GetString(signdate).Replace("\0", "").Trim();

                //有效期限
                ic01.ic018 = System.Text.Encoding.GetEncoding("GB2312").GetString(validtermOfStart).Replace("\0", "").Trim() + "-" + System.Text.Encoding.GetEncoding("GB2312").GetString(validtermOfEnd).Replace("\0", "").Trim();

                txtEdit_rc003.EditValue = ic01.ic003;
                rg_rc002.EditValue      = ic01.ic002;

                txtEdit_rc004.EditValue = MiscAction.Calc_Age_Via_Birth(ic01.ic004.ToString("yyyy-MM-dd"));
                txtedit_rc014.EditValue = ic01.ic014;
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.ToString(), "读卡错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #3
0
        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();
                 */

                string address1          = System.Text.Encoding.GetEncoding("GB2312").GetString(address).Replace("\0", "").Trim();
                string sex1              = System.Text.Encoding.GetEncoding("GB2312").GetString(sex).Replace("\0", "").Trim();
                string birthday1         = System.Text.Encoding.GetEncoding("GB2312").GetString(birthday).Replace("\0", "").Trim();
                string signdate1         = System.Text.Encoding.GetEncoding("GB2312").GetString(signdate).Replace("\0", "").Trim();
                string number1           = System.Text.Encoding.GetEncoding("GB2312").GetString(number).Replace("\0", "").Trim();
                string name1             = System.Text.Encoding.GetEncoding("GB2312").GetString(name).Replace("\0", "").Trim();
                string people1           = System.Text.Encoding.GetEncoding("GB2312").GetString(people).Replace("\0", "").Trim();
                string samid1            = System.Text.Encoding.GetEncoding("GB2312").GetString(samid).Replace("\0", "").Trim();
                string validtermOfStart1 = System.Text.Encoding.GetEncoding("GB2312").GetString(validtermOfStart).Replace("\0", "").Trim() + "-" + System.Text.Encoding.GetEncoding("GB2312").GetString(validtermOfEnd).Replace("\0", "").Trim();

                tbxIdCardNo.Text = number1;
                tbxName.Text     = name1;

                if (sex1.Equals("男"))
                {
                    cbxGender.SelectedIndex = 0;
                }
                if (sex1.Equals("女"))
                {
                    cbxGender.SelectedIndex = 1;
                }

                getClientInfoAfterReadCard(null, null);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #4
0
ファイル: Form2.cs プロジェクト: ztxyzu/QueueSystem
        private void ReadIDCard()
        {
            int time = 0;

            while (isread)
            {
                time++;
                int isHaveCard = CVRSDK.CVR_Authenticate();
                if (isHaveCard == 1)
                {
                    int readOk = CVRSDK.CVR_Read_Content(4);
                    if (readOk == 1)
                    {
                        #region
                        byte[] name   = new byte[30];
                        int    length = 30;
                        CVRSDK.GetPeopleName(ref name[0], ref length);
                        byte[] number = new byte[30];
                        length = 36;
                        CVRSDK.GetPeopleIDCode(ref number[0], ref length);
                        byte[] address = new byte[30];
                        length = 70;
                        CVRSDK.GetPeopleAddress(ref address[0], ref length);
                        var iCard   = System.Text.Encoding.GetEncoding("GB2312").GetString(number).Replace("\0", "").Trim();
                        var iName   = System.Text.Encoding.GetEncoding("GB2312").GetString(name).Replace("\0", "").Trim();
                        var iAdress = System.Text.Encoding.GetEncoding("GB2312").GetString(address).Replace("\0", "").Trim();
                        if (iCard != "")
                        {
                            int t = time;
                            new Thread(() =>
                            {
                                BeginInvoke(new Action(() =>
                                {
                                    this.BeginInvoke(new Action(() => { this.richTextBox1.AppendText(DateTime.Now.ToString("HH:mm:ss:fff") + string.Format("身份证读卡成功:本次读卡循环读取了{3}次,证件号码{0} 姓名{1} 地址{2}\r\n", iCard, iName, iAdress, t)); }));
                                }));
                            })
                            {
                                IsBackground = true
                            }.Start();
                            time = 0;
                        }
                        else
                        {
                            BeginInvoke(new Action(() =>
                            {
                                this.richTextBox1.AppendText(DateTime.Now.ToString("HH:mm:ss:fff") + " 未读取到身份证号码\r\n");
                            }));
                        }

                        #endregion
                    }
                    else
                    {
                        BeginInvoke(new Action(() =>
                        {
                            this.richTextBox1.AppendText(DateTime.Now.ToString("HH:mm:ss:fff") + " 读卡操作失败!请重新放上卡片。\r\n");
                        }));
                    }
                }
                else
                {
                    BeginInvoke(new Action(() =>
                    {
                        this.richTextBox1.AppendText(DateTime.Now.ToString("HH:mm:ss:fff") + " 未放卡或卡片放置不正确,请重新放上卡片。\r\n");
                    }));
                }
                Thread.Sleep(jg);
            }
        }
コード例 #5
0
        private IDCard GetData()
        {
            try
            {
                //byte[] imgData = new byte[40960];
                int length = 40960;
                //CVRSDK.Getbase64BMPData(ref imgData[0], ref length);

                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;
                }

                Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
                var encoding = Encoding.GetEncoding("GB18030");
                if (bCivic)
                {
                    IDCard card = new IDCard()
                    {
                        //ImgString = Encoding.GetEncoding("GB2312").GetString(imgData).Trim('\0'),
                        sex              = Encoding.GetEncoding("GB2312").GetString(sex).Trim('\0'),
                        name             = Encoding.GetEncoding("GB18030").GetString(name).Trim('\0'),
                        number           = Encoding.GetEncoding("GB18030").GetString(number).Trim('\0'),
                        peopleNation     = Encoding.GetEncoding("GB18030").GetString(peopleNation).Trim('\0'),
                        birthday         = Encoding.GetEncoding("GB18030").GetString(birthday).Trim('\0'),
                        address          = Encoding.GetEncoding("GB18030").GetString(address).Trim('\0'),
                        signdate         = Encoding.GetEncoding("GB18030").GetString(signdate).Trim('\0'),
                        validtermOfStart = Encoding.GetEncoding("GB18030").GetString(validtermOfStart).Trim('\0'),
                        samid            = Encoding.GetEncoding("GB18030").GetString(samid).Trim('\0'),
                    };
                    return(card);
                }
            }
            catch (Exception)
            {
                //MessageBox.Show(ex.ToString());
            }
            return(new IDCard());
        }
コード例 #6
0
ファイル: personRegist.cs プロジェクト: zuyunfei/zkhw
        public void FillData()
        {
            try
            {
                byte[] name   = new byte[30];
                int    length = 30;
                CVRSDK.GetPeopleName(ref name[0], ref length);
                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]);
                richTextBox1.Text = Encoding.GetEncoding("GB2312").GetString(address).Replace("\0", "").Trim();
                textBox9.Text     = Encoding.GetEncoding("GB2312").GetString(sex).Replace("\0", "").Trim();
                textBox8.Text     = Encoding.GetEncoding("GB2312").GetString(birthday).Replace("\0", "").Trim();
                textBox4.Text     = Encoding.GetEncoding("GB2312").GetString(signdate).Replace("\0", "").Trim();
                textBox3.Text     = Encoding.GetEncoding("GB2312").GetString(number).Replace("\0", "").Trim();
                textBox1.Text     = Encoding.GetEncoding("GB2312").GetString(name).Replace("\0", "").Trim();
                textBox2.Text     = Encoding.GetEncoding("GB2312").GetString(people).Replace("\0", "").Trim();
                //label11.Text = "安全模块号:" + System.Text.Encoding.GetEncoding("GB2312").GetString(samid).Replace("\0", "").Trim();
                //textBox8.Text = Encoding.GetEncoding("GB2312").GetString(validtermOfStart).Replace("\0", "").Trim() + "-" + Encoding.GetEncoding("GB2312").GetString(validtermOfEnd).Replace("\0", "").Trim();
                richTextBox1.Text = richTextBox1.Text.Replace("?", "号");
                //把身份证图片名称zp.bpm 修改为对应的名称
                string   pName = Application.StartupPath + "\\zp.bmp";
                FileInfo inf   = new FileInfo(pName);
                if (textBox3.Text != null && !"".Equals(textBox3.Text) && textBox3.Text.Length == 18)
                {
                    if (File.Exists(Application.StartupPath + "\\cardImg\\" + textBox3.Text + ".jpg"))
                    {
                        File.Delete(Application.StartupPath + "\\cardImg\\" + textBox3.Text + ".jpg");
                    }
                    inf.MoveTo(Application.StartupPath + "\\cardImg\\" + textBox3.Text + ".jpg");

                    pictureBox1.ImageLocation = Application.StartupPath + "\\cardImg\\" + textBox3.Text + ".jpg";
                    if (File.Exists(pName))
                    {
                        File.Delete(pName);
                    }
                    DataTable dt = grjddao.judgeRepeat(textBox3.Text);
                    if (dt.Rows.Count > 0)
                    {
                        textBox1.Text = dt.Rows[0][0].ToString();
                        textBox9.Text = dt.Rows[0][1].ToString();
                        textBox8.Text = dt.Rows[0][2].ToString();
                        textBox3.Text = dt.Rows[0][3].ToString();
                        //richTextBox1.Text = dt.Rows[0][4].ToString();
                        //textBox2.Text = dt.Rows[0][5].ToString();
                        //textBox4.Text = dt.Rows[0][6].ToString();
                        pictureBox1.ImageLocation = Application.StartupPath + "\\cardImg\\" + dt.Rows[0][4].ToString();
                        textBox5.Text             = dt.Rows[0][5].ToString();
                    }
                    ;
                    this.label41.Text = "读卡成功!";
                }
                else
                {
                    inf.MoveTo(Application.StartupPath + "\\cardImg\\123.jpg");
                    if (File.Exists(pName))
                    {
                        File.Delete(pName);
                    }
                    pictureBox1.ImageLocation = Application.StartupPath + "\\cardImg\\123.jpg";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #7
0
        public void FillData()
        {
            try
            {
                byte[] name   = new byte[30];
                int    length = 30;
                CVRSDK.GetPeopleName(ref name[0], ref length);
                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[50];
                length = 100;//40 80
                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]);
                richTextBox1.Text = Encoding.GetEncoding("GB2312").GetString(address).Replace("\0", "").Trim();
                //textBox9.Text = Encoding.GetEncoding("GB2312").GetString(sex).Replace("\0", "").Trim();
                this.comboBox1.Text = Encoding.GetEncoding("GB2312").GetString(sex).Replace("\0", "").Trim();
                textBox8.Text       = Encoding.GetEncoding("GB2312").GetString(birthday).Replace("\0", "").Trim();
                textBox4.Text       = Encoding.GetEncoding("GB2312").GetString(signdate).Replace("\0", "").Trim();
                textBox3.Text       = Encoding.GetEncoding("GB2312").GetString(number).Replace("\0", "").Trim();
                textBox1.Text       = Encoding.GetEncoding("GB2312").GetString(name).Replace("\0", "").Trim();
                //textBox2.Text = Encoding.GetEncoding("GB2312").GetString(people).Replace("\0", "").Trim();
                string tmp = Encoding.GetEncoding("GB2312").GetString(people).Replace("\0", "").Trim();
                if (tmp.IndexOf("族") < 0)
                {
                    tmp = tmp + "族";
                }
                comboBox2.Text = tmp;
                //label11.Text = "安全模块号:" + System.Text.Encoding.GetEncoding("GB2312").GetString(samid).Replace("\0", "").Trim();
                //textBox8.Text = Encoding.GetEncoding("GB2312").GetString(validtermOfStart).Replace("\0", "").Trim() + "-" + Encoding.GetEncoding("GB2312").GetString(validtermOfEnd).Replace("\0", "").Trim();
                richTextBox1.Text = richTextBox1.Text.Replace("?", "号");
                //把身份证图片名称zp.bpm 修改为对应的名称
                string   pName = Application.StartupPath + "\\zp.bmp";
                FileInfo inf   = new FileInfo(pName);
                if (textBox1.Text != null && !"".Equals(textBox1.Text) && textBox8.Text != null && !"".Equals(textBox8.Text))
                {
                    if (textBox3.Text != null && !"".Equals(textBox3.Text))
                    {
                        if (File.Exists(Application.StartupPath + "\\cardImg\\" + textBox3.Text + ".jpg"))
                        {
                            File.Delete(Application.StartupPath + "\\cardImg\\" + textBox3.Text + ".jpg");
                        }
                        inf.MoveTo(Application.StartupPath + "\\cardImg\\" + textBox3.Text + ".jpg");

                        pictureBox1.ImageLocation = Application.StartupPath + "\\cardImg\\" + textBox3.Text + ".jpg";

                        DataTable dt = grjddao.judgeRepeat(textBox3.Text);
                        if (dt.Rows.Count > 0)
                        {
                            textBox1.Text = dt.Rows[0][0].ToString();
                            //textBox9.Text = dt.Rows[0][1].ToString();
                            string sexflag = dt.Rows[0][1].ToString();
                            if (sexflag == "1")
                            {
                                this.comboBox1.Text = "男";
                            }
                            else if (sexflag == "2")
                            {
                                this.comboBox1.Text = "女";
                            }
                            textBox8.Text             = dt.Rows[0][2].ToString();
                            textBox3.Text             = dt.Rows[0][3].ToString();
                            pictureBox1.ImageLocation = Application.StartupPath + "\\cardImg\\" + dt.Rows[0][4].ToString();
                            textBox5.Text             = dt.Rows[0][5].ToString();
                        }
                        ;
                        this.label41.Text = "读卡成功!";
                        checkPerson();//判断居民一周内是否做过体检
                    }
                    else
                    {
                        if (File.Exists(Application.StartupPath + "\\cardImg\\" + textBox1.Text + textBox8.Text + ".jpg"))
                        {
                            File.Delete(Application.StartupPath + "\\cardImg\\" + textBox1.Text + textBox8.Text + ".jpg");
                        }
                        inf.MoveTo(Application.StartupPath + "\\cardImg\\" + textBox1.Text + textBox8.Text + ".jpg");

                        pictureBox1.ImageLocation = Application.StartupPath + "\\cardImg\\" + textBox1.Text + textBox8.Text + ".jpg";

                        DataTable dt = grjddao.judgeRepeatBync(textBox1.Text, textBox8.Text);
                        if (dt.Rows.Count > 0)
                        {
                            textBox1.Text = dt.Rows[0][0].ToString();
                            //textBox9.Text = dt.Rows[0][1].ToString();
                            string sexflag = dt.Rows[0][1].ToString();
                            if (sexflag == "1")
                            {
                                this.comboBox1.Text = "男";
                            }
                            else if (sexflag == "2")
                            {
                                this.comboBox1.Text = "女";
                            }
                            textBox8.Text             = dt.Rows[0][2].ToString();
                            textBox3.Text             = dt.Rows[0][3].ToString();
                            pictureBox1.ImageLocation = Application.StartupPath + "\\cardImg\\" + dt.Rows[0][4].ToString();
                            richTextBox1.Text         = dt.Rows[0][5].ToString();
                            tmp = dt.Rows[0][6].ToString();
                            if (tmp == "")
                            {
                                tmp = "1";
                            }
                            DataRow[] drw = dtno.Select("id='" + tmp + "'");
                            if (drw != null)
                            {
                                comboBox2.Text = drw[0]["Name"].ToString();
                            }

                            textBox5.Text = dt.Rows[0][7].ToString();
                        }
                        ;
                    }
                    if (File.Exists(pName))
                    {
                        File.Delete(pName);
                    }
                }
                else
                {
                    inf.MoveTo(Application.StartupPath + "\\cardImg\\123.jpg");
                    if (File.Exists(pName))
                    {
                        File.Delete(pName);
                    }
                    pictureBox1.ImageLocation = Application.StartupPath + "\\cardImg\\123.jpg";
                }
                jkjcheckdao.updateShDevice(1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
            }
            catch (Exception ex)
            {
                loginLogBean lb = new loginLogBean();
                lb.name       = frmLogin.name;
                lb.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                lb.eventInfo  = "身份证读卡失败!";
                lb.type       = "3";
                logservice.addCheckLog(lb);
            }
        }
コード例 #8
0
        private void ReadIDCard()
        {
            int time = 0;

            while (true)
            {
                time++;
                int isHaveCard = CVRSDK.CVR_Authenticate();
                if (isHaveCard == 1)
                {
                    int readOk = CVRSDK.CVR_Read_Content(4);
                    if (readOk == 1)
                    {
                        #region
                        byte[] name   = new byte[30];
                        int    length = 30;
                        CVRSDK.GetPeopleName(ref name[0], ref length);
                        byte[] number = new byte[30];
                        length = 36;
                        CVRSDK.GetPeopleIDCode(ref number[0], ref length);
                        byte[] address = new byte[30];
                        length = 70;
                        CVRSDK.GetPeopleAddress(ref address[0], ref length);
                        var iCard   = System.Text.Encoding.GetEncoding("GB2312").GetString(number).Replace("\0", "").Trim();
                        var iName   = System.Text.Encoding.GetEncoding("GB2312").GetString(name).Replace("\0", "").Trim();
                        var iAdress = System.Text.Encoding.GetEncoding("GB2312").GetString(address).Replace("\0", "").Trim();
                        if (iCard != "")
                        {
                            int t = time;
                            new Thread(() =>
                            {
                                //写入共享内存
                                var p = new Person()
                                {
                                    idcard = iCard, name = iName, address = iAdress
                                };
                                var bytes = FormatterMessageBytes(p);
                                share.Write(bytes, 0, bytes.Length);
                                BeginInvoke(new Action(() =>
                                {
                                    ShowMsg(string.Format("身份证读卡成功:本次读卡循环读取了{3}次,证件号码{0} 姓名{1} 地址{2}\r\n", iCard, iName, iAdress, t), false);
                                }));
                            })
                            {
                                IsBackground = true
                            }.Start();
                            time = 0;
                        }
                        else
                        {
                            BeginInvoke(new Action(() =>
                            {
                                ShowMsg("未读取到身份证号码", false);
                            }));
                        }

                        #endregion
                    }
                    else
                    {
                        BeginInvoke(new Action(() =>
                        {
                            ShowMsg("读卡操作失败!请重新放上卡片。", false);
                        }));
                    }
                }
                else
                {
                    BeginInvoke(new Action(() =>
                    {
                        ShowMsg("未放卡或卡片放置不正确,请重新放上卡片。", false);
                    }));
                }
                Thread.Sleep(50);
            }
        }