private void btnReadWithPhoto_Click_1(object sender, EventArgs e) { ThaiIDCard idcard = new ThaiIDCard(); idcard.eventPhotoProgress += new handlePhotoProgress(photoProgress); Personal personal = idcard.readAllPhoto(); if (personal != null) { lbl_cid.Text = personal.Citizenid; lbl_birthday.Text = personal.Birthday.ToString("dd/MM/yyyy"); lbl_sex.Text = personal.Sex; lbl_th_prefix.Text = personal.Th_Prefix; lbl_th_firstname.Text = personal.Th_Firstname; lbl_th_lastname.Text = personal.Th_Lastname; lbl_en_prefix.Text = personal.En_Prefix; lbl_en_firstname.Text = personal.En_Firstname; lbl_en_lastname.Text = personal.En_Lastname; lbl_issue.Text = personal.Issue.ToString("dd/MM/yyyy"); lbl_expire.Text = personal.Expire.ToString("dd/MM/yyyy"); pictureBox1.Image = personal.PhotoBitmap; } else if (idcard.ErrorCode() > 0) { MessageBox.Show(idcard.Error()); } }
private void btnRead_Click(object sender, EventArgs e) { ThaiIDCard idcard = new ThaiIDCard(); Personal personal = idcard.readAll(); if (personal != null) { lbl_cid.Text = personal.Citizenid; lbl_birthday.Text = personal.Birthday.ToString("dd/MM/yyyy"); lbl_sex.Text = personal.Sex; lbl_th_prefix.Text = personal.Th_Prefix; lbl_th_firstname.Text = personal.Th_Firstname; lbl_th_lastname.Text = personal.Th_Lastname; lbl_en_prefix.Text = personal.En_Prefix; lbl_en_firstname.Text = personal.En_Firstname; lbl_en_lastname.Text = personal.En_Lastname; lbl_issue.Text = personal.Issue.ToString("dd/MM/yyyy"); lbl_expire.Text = personal.Expire.ToString("dd/MM/yyyy"); // ขี้เกรียจวาด label แล้ว LogLine(personal.Address); LogLine(personal.addrHouseNo); // บ้านเลขที่ LogLine(personal.addrVillageNo); // หมู่ที่ LogLine(personal.addrLane); // ซอย LogLine(personal.addrRoad); // ถนน LogLine(personal.addrTambol); LogLine(personal.addrAmphur); LogLine(personal.addrProvince); } else if (idcard.ErrorCode() > 0) { MessageBox.Show(idcard.Error()); } }
public void readCard() { ThaiIDCard idcard = new ThaiIDCard(); Personal personal = idcard.readAllPhoto(); if (personal != null) { tbPersonFirstname.Text = personal.Th_Firstname; tbPersonLastname.Text = personal.Th_Lastname; tbPersonTitle.Text = personal.Th_Prefix; tbPersonCard.Text = personal.Citizenid; tbPersonBirthday.Text = personal.Birthday.ToString("yyyy-MM-dd"); tbPersonAddress.Text = personal.Address; pictureBox_Person.Image = ByteToImage1(personal.PhotoRaw); // Convert byte[] to Base64 String base64String = Convert.ToBase64String(personal.PhotoRaw); // Write the bytes (as a Base64 string) to the textbox //Console.WriteLine(base64String); } else if (idcard.ErrorCode() > 0) { Console.WriteLine(idcard.Error()); } }
public void readCard() { Personal personal = idcard.readAll(); if (personal != null) { Console.WriteLine(personal.Citizenid); Console.WriteLine(personal.Birthday.ToString("dd/MM/yyyy")); Console.WriteLine(personal.Sex); Console.WriteLine(personal.Th_Prefix); Console.WriteLine(personal.Th_Firstname); Console.WriteLine(personal.Th_Lastname); Console.WriteLine(personal.En_Prefix); Console.WriteLine(personal.En_Firstname); Console.WriteLine(personal.En_Lastname); Console.WriteLine(personal.Issue.ToString("dd/MM/yyyy")); // วันออกบัตร Console.WriteLine(personal.Expire.ToString("dd/MM/yyyy")); // วันหมดอายุ Console.WriteLine(personal.Address); Console.WriteLine(personal.addrHouseNo); // บ้านเลขที่ Console.WriteLine(personal.addrVillageNo); // หมู่ที่ Console.WriteLine(personal.addrLane); // ซอย Console.WriteLine(personal.addrRoad); // ถนน Console.WriteLine(personal.addrTambol); Console.WriteLine(personal.addrAmphur); Console.WriteLine(personal.addrProvince); } else if (idcard.ErrorCode() > 0) { Console.WriteLine(idcard.Error()); } }
public void readCard() { ThaiIDCard idcard = new ThaiIDCard(); Personal personal = idcard.readAll(true); if (personal != null) { lbCard.Text = personal.Citizenid; lbBirth.Text = personal.Birthday.ToString("dd/MM/yyyy"); lbPrefix.Text = personal.Th_Prefix; lbName.Text = personal.Th_Firstname; lbSurname.Text = personal.Th_Lastname; Console.WriteLine(personal.En_Prefix); Console.WriteLine(personal.En_Firstname); Console.WriteLine(personal.En_Lastname); Console.WriteLine(personal.Issue.ToString("dd/MM/yyyy")); // วันออกบัตร Console.WriteLine(personal.Expire.ToString("dd/MM/yyyy")); // วันหมดอายุ lbAddress.Text = personal.Address; Console.WriteLine(personal.addrHouseNo); // บ้านเลขที่ Console.WriteLine(personal.addrVillageNo); // หมู่ที่ Console.WriteLine(personal.addrLane); // ซอย Console.WriteLine(personal.addrRoad); // ถนน Console.WriteLine(personal.addrTambol); Console.WriteLine(personal.addrAmphur); Console.WriteLine(personal.addrProvince); picCard.Image = (Image)personal.PhotoBitmap; } else if (idcard.ErrorCode() > 0) { Console.WriteLine(idcard.Error()); } }
private void btnRead_Click(object sender, EventArgs e) { try { lbl_cid.Text = "Reading..."; Refresh(); Personal personal = idcard.readAll(); if (personal != null) { lbl_cid.Text = personal.Citizenid; lbl_birthday.Text = personal.Birthday.ToString("dd/MM/yyyy"); lbl_sex.Text = personal.Sex; lbl_th_prefix.Text = personal.Th_Prefix; lbl_th_firstname.Text = personal.Th_Firstname; lbl_th_lastname.Text = personal.Th_Lastname; lbl_en_prefix.Text = personal.En_Prefix; lbl_en_firstname.Text = personal.En_Firstname; lbl_en_lastname.Text = personal.En_Lastname; lbl_issue.Text = personal.Issue.ToString("dd/MM/yyyy"); lbl_expire.Text = personal.Expire.ToString("dd/MM/yyyy"); lbl_address.Text = personal.Address; saveFile(); LogLine(personal.Address); LogLine(personal.addrHouseNo); // บ้านเลขที่ LogLine(personal.addrVillageNo); // หมู่ที่ LogLine(personal.addrLane); // ซอย LogLine(personal.addrRoad); // ถนน LogLine(personal.addrTambol); LogLine(personal.addrAmphur); LogLine(personal.addrProvince); LogLine(personal.Issuer); } else if (idcard.ErrorCode() > 0) { MessageBox.Show(idcard.Error()); } else { MessageBox.Show("Catch all"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
//new function by prkasit on Nov'14 2019 private void ReadNewPIDCard() { try { CARD = new PIDCard(); CARD_TYPE = "PID"; Personal personal = idcard.readAllPhoto(); if (personal != null) { CARD.NO = personal.Citizenid; CARD.TH_TITLE = personal.Th_Prefix; CARD.TH_FIRST_NAME = personal.Th_Firstname; CARD.TH_LAST_NAME = personal.Th_Lastname; CARD.EN_TITLE = personal.En_Prefix; CARD.EN_FIRST_NAME = personal.En_Firstname; CARD.EN_LAST_NAME = personal.En_Lastname; CARD.BIRTH_DATE = CardHelper.DateFormat(personal.Birthday.ToString("yyyyMMdd")); CARD.HOME_NO = personal.addrHouseNo; CARD.MOO = personal.addrVillageNo; CARD.SOI = personal.addrLane; CARD.ROAD = personal.addrRoad; CARD.TUMBON = personal.addrTambol; CARD.AMPHOE = personal.addrAmphur; CARD.PROVINCE = personal.addrProvince; CARD.GENDER = personal.Sex; CARD.PHOTO = personal.PhotoBitmap; CARD.CARD_IMAGE = personal.PhotoBitmap; try { byte[] byteImage = null; byteImage = personal.PhotoRaw;// stream.ToArray(); CARD.BYTE_IMAGE = byteImage; } catch (Exception ex) { } READ_CARD_STATUS = true; } else if (idcard.ErrorCode() > 0) { MessageBox.Show(idcard.Error()); } } catch (Exception ex) { READ_CARD_STATUS = false; MessageBox.Show("ไม่พบเครื่องอ่านบัตรประชาชน หรืออ่านบัตรไม่สำเร็จ!!! " + ex.Message); } }
// LoadCard private void LoadIDCard() { thaiIDCard = new ThaiIDCard(); thaiIDCard.eventPhotoProgress += new handlePhotoProgress(photoProgress); try { Personal personal = thaiIDCard.readAllPhoto(); if (personal != null) { IDCardModel readFormIdcard = new IDCardModel(); readFormIdcard.NationalID = personal.Citizenid; readFormIdcard.CardType = "01"; readFormIdcard.ThaiFirstName = personal.Th_Firstname; readFormIdcard.ThaiLastName = personal.Th_Lastname; readFormIdcard.ThaiMiddleName = personal.Th_Middlename; readFormIdcard.ThaiTitleName = personal.Th_Prefix; readFormIdcard.EnglishTitleName = personal.En_Prefix; readFormIdcard.EnglishFirstName = personal.En_Firstname; readFormIdcard.EnglishLastName = personal.En_Lastname; readFormIdcard.Address = personal.addrHouseNo; readFormIdcard.Amphur = personal.addrAmphur; readFormIdcard.AtrString = AtrString; readFormIdcard.Birthdate = personal.Birthday.ToString("dd/MM/yyyy"); readFormIdcard.ChipID = ""; readFormIdcard.EnglishMiddleName = personal.En_Middlename; readFormIdcard.ExpireDate = personal.Expire.ToString("dd/MM/yyyy");; readFormIdcard.FormatVersion = "0003"; readFormIdcard.IssueDate = personal.Issue.ToString("dd/MM/yyyy"); readFormIdcard.IssuePlace = personal.Expire.ToString("dd/MM/yyyy"); readFormIdcard.IssuerCode = ""; readFormIdcard.LaserID = personal.En_Middlename; readFormIdcard.Moo = personal.addrVillageNo; readFormIdcard.PhotoRefNo = ""; readFormIdcard.Province = personal.addrProvince; readFormIdcard.RequestNo = personal.En_Middlename; readFormIdcard.Sex = personal.Sex; readFormIdcard.Soi = personal.addrLane; readFormIdcard.Thanon = personal.addrRoad; readFormIdcard.Trok = personal.En_Middlename; readFormIdcard.Tumbol = personal.addrTambol; // readFormIdcard lbIdcard.Text = personal.Citizenid; lbFullname.Text = personal.En_Firstname + " " + personal.En_Lastname; bitmapCard.Image = personal.PhotoBitmap; var jsonConverter = JsonConvert.SerializeObject(readFormIdcard); btnLoadCard.Text = "Save to Mock"; isHaveData = true; jsonIdCardReader = jsonConverter.ToString(); Debug.WriteLine(JsonConvert.DeserializeObject(personal.ToString())); } else if (thaiIDCard.ErrorCode() > 0) { MessageBox.Show("Error :" + thaiIDCard.Error()); MessageBox.Show("Error :" + thaiIDCard.ErrorCode()); Console.WriteLine(thaiIDCard.Error()); } } catch (Exception ex) { MessageBox.Show("Error" + ex.Message); } }