Exemple #1
0
        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);
            }
        }
Exemple #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());
        }