Esempio n. 1
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);
            }
        }
Esempio n. 2
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());
        }