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()); } }
private void Form2_Load(object sender, EventArgs e) { showUserLogin.BeginInvoke(new MethodInvoker(delegate { showUserLogin.Text = fullname; })); showHosName.BeginInvoke(new MethodInvoker(delegate { showHosName.Text = hosName; })); userFullName.BeginInvoke(new MethodInvoker(delegate { userFullName.Text = ""; })); userIdcard.BeginInvoke(new MethodInvoker(delegate { userIdcard.Text = ""; })); userDiag.BeginInvoke(new MethodInvoker(delegate { userDiag.Text = ""; })); userRegular.BeginInvoke(new MethodInvoker(delegate { userRegular.Text = ""; })); userDoctor.BeginInvoke(new MethodInvoker(delegate { userDoctor.Text = ""; })); userAddress.BeginInvoke(new MethodInvoker(delegate { userAddress.Text = ""; })); userDateDiag.BeginInvoke(new MethodInvoker(delegate { userDateDiag.Text = ""; })); userHos.BeginInvoke(new MethodInvoker(delegate { userHos.Text = ""; })); try { Console.WriteLine("Form1 was loaded"); idcard = new ThaiIDCard(); cardReaders = idcard.GetReaders(); idcard.MonitorStart(cardReaders[0].ToString()); idcard.eventCardInserted += new handleCardInserted(CardInsertedCallback); idcard.eventCardRemoved += new handleCardRemoved(CardRemoveCallback); } catch (Exception ex) { notify.ForeColor = System.Drawing.Color.Red; notify.Text = "ไม่พบเครื่องอ่านบัตรสมาร์ตการ์ด"; } }
private void btnRefreshReaderList_Click_1(object sender, EventArgs e) { cbxReaderList.Items.Clear(); cbxReaderList.SelectedIndex = -1; cbxReaderList.SelectedText = String.Empty; cbxReaderList.Text = string.Empty; cbxReaderList.Refresh(); try { ThaiIDCard idcard = new ThaiIDCard(); string[] readers = idcard.GetReaders(); if (readers == null) { return; } foreach (string r in readers) { cbxReaderList.Items.Add(r); } cbxReaderList.DroppedDown = true; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
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 chkBoxMonitor_CheckedChanged_1(object sender, EventArgs e) { ThaiIDCard idcard = new ThaiIDCard(); if (chkBoxMonitor.Checked) { if (cbxReaderList.SelectedItem == null) { MessageBox.Show("No reader select to monitoring."); chkBoxMonitor.Checked = false; return; } idcard.MonitorStart(cbxReaderList.SelectedItem.ToString()); //idcard.eventCardInsertedWithPhoto += new handleCardInserted(CardInserted); //Read data with photo, it's take long time. idcard.eventCardInserted += new handleCardInserted(CardInserted); //Read data no photo, that is fast. idcard.eventCardRemoved += new handleCardRemoved(CardRemoved); idcard.eventPhotoProgress += new handlePhotoProgress(photoProgress); } else { if (cbxReaderList.SelectedItem != null) { idcard.MonitorStop(cbxReaderList.SelectedItem.ToString()); } } }
public ActionResult Read() { Person person = new Person() { id = "11", Birthday = "10/10/2000", Sex = "M", Th_Prefix = "Mr.", Th_Firstname = "Test", Th_Lastname = "test" }; ThaiIDCard idcard = new ThaiIDCard(); Personal personal = idcard.readAll(); return(RedirectToAction("Test", "Home")); if (personal != null) { person.id = personal.Citizenid; person.Birthday = personal.Birthday.ToString("dd/MM/yyyy"); person.Sex = personal.Sex; person.Th_Prefix = personal.Th_Prefix; person.Th_Firstname = personal.Th_Firstname; person.Th_Lastname = personal.Th_Lastname; } else { } return(View("Test", person)); }
public IHttpActionResult getReaderCard() { ThaiIDCard idcard = new ThaiIDCard(); Personal personal = idcard.readAllPhoto(); return(Json(personal)); }
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 Personal GetPersonalCardreader() { idcard = new ThaiIDCard(); Personal person = idcard.readAllPhoto(); return(person); }
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()); } }
public void RefreshDriver() { CheckedListBox_Driver.Items.Clear(); try { Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); idcard = new ThaiIDCard(); string[] readers = idcard.GetReaders(); if (readers.Length <= 0) { config.AppSettings.Settings.Remove("Driver"); config.AppSettings.Settings.Add("Driver", ""); config.Save(ConfigurationSaveMode.Modified); // Force a reload of a changed section. ConfigurationManager.RefreshSection("appSettings"); return; } foreach (string r in readers) { CheckedListBox_Driver.Items.Add(r); } for (int i = 0; i < CheckedListBox_Driver.Items.Count; i++) { CheckedListBox_Driver.SetItemChecked(i, true); } string item = ""; if (CheckedListBox_Driver.CheckedItems != null) { foreach (object itemChecked in CheckedListBox_Driver.CheckedItems) { if (item == "") { item = itemChecked.ToString(); } else { item += "," + itemChecked.ToString(); } //idcard.MonitorStart(itemChecked.ToString()); } } // Add an Application Setting. config.AppSettings.Settings.Remove("Driver"); config.AppSettings.Settings.Add("Driver", item); config.Save(ConfigurationSaveMode.Modified); // Force a reload of a changed section. ConfigurationManager.RefreshSection("appSettings"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
internal void ReadCard() { string status = ""; string data = ""; try { if (IDCardReader == null) { IDCardReader = new ThaiIDCard(); } string[] readers = IDCardReader.GetReaders(); if (readers == null || readers.Length == 0) { status = "Card reader not found. Please try plug out/in again."; return; } Personal personData = IDCardReader.readAll(); if (personData == null) { status = "Cannot read card. Please try again."; return; } data = "เลบบัตรประชาชน: " + personData.Citizenid + "\n" + "วันเกิด: " + personData.Birthday.ToString("dd/MM/yyyy") + "\n" + "เพศ: " + personData.Sex + "\n" + "ชื่อไทย: " + personData.Th_Prefix + personData.Th_Firstname + " " + personData.Th_Lastname + "\n" + "Name: " + personData.En_Prefix + personData.En_Firstname + " " + personData.En_Lastname + "\n" + "วันออกบัตร: " + personData.Issue.ToString("dd/MM/yyyy") + "\n" + "ผู้ออกบัตร: " + personData.Issuer + "\n" + "วันหมดอายุ: " + personData.Expire.ToString("dd/MM/yyyy") + "\n" + "ที่อยู่: " + personData.Address + "\n" + "บ้านเลขที่: " + personData.addrHouseNo + "\n" + "หมู่ที่: " + personData.addrVillageNo + "\n" + "ซอย: " + personData.addrLane + "\n" + "ถนน: " + personData.addrRoad + "\n" + "ตำบล: " + personData.addrTambol + "\n" + "อำเถอ: " + personData.addrAmphur + "\n" + "จังหวัด: " + personData.addrProvince + "\n"; } catch (Exception e) { status = e.Message; } finally { // update UI in main thread. Dispatcher.Invoke(() => { ProgressLabel.Content = status; CardData.Document.Blocks.Clear(); CardData.Document.Blocks.Add(new Paragraph(new Run(data))); }); } }
private void frmMain_Load(object sender, EventArgs e) { ThaiIDCard idcard = new ThaiIDCard(); //lbLibVersion.Text = "LibThaiIDCard version: " + idcard.Version(); string[] readers = idcard.GetReaders(); foreach (string r in readers) { idcard.MonitorStart(r); idcard.eventCardInsertedWithPhoto += new handleCardInserted(CardInserted); idcard.eventPhotoProgress += new handlePhotoProgress(photoProgress); } }
private void btnSmartCard_Click(object sender, EventArgs e) { btnSmartCard.Enabled = false; ThaiIDCard idcard = new ThaiIDCard(); Personal personal = idcard.readAll(); Personal personal_photo = idcard.readAllPhoto(); if (personal != null) { btnSelectImage.Visible = false; txtCitizenId.Text = personal.Citizenid; txtName.Text = personal.Th_Firstname; txtLastname.Text = personal.Th_Lastname; rdbMan.Checked = personal.Sex == "1"; rdbWoman.Checked = personal.Sex != "1"; cbbProvince.SelectedItem = personal.addrProvince.Replace("จังหวัด", ""); //lblProvince.Text = personal.addrAmphur + " " + personal.addrProvince personal.addrTambol; string[] address = personal.Address.Replace(personal.addrTambol, "").Replace(personal.addrAmphur, "").Replace(personal.addrProvince, "").Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); StringBuilder sb = new StringBuilder(address[0]); for (int i = 1; i < address.Length; i++) { sb.Append(" " + address[i]); } txtAddress1.Text = sb.ToString(); txtSubDistrict.Text = personal.addrTambol.Replace("แขวง", "").Replace("ตำบล", ""); cbbDistrict.SelectedItem = personal.addrAmphur.Replace("เขต", "").Replace("อำเภอ", ""); //txtAddress.Text = personal.Address.Replace(personal.addrTambol, "").Replace(personal.addrAmphur, "").Replace(personal.addrProvince, "").Trim(); //txtSubDistrict.Text = personal.addrTambol; //dtBirthday.Value = personal.Birthday; //dtIssue.Value = personal.Issue; //dtExpire.Value = personal.Expire; _PHOTO = personal_photo.PhotoBitmap; ptbPhoto.Image = personal_photo.PhotoBitmap; Thread.CurrentThread.CurrentCulture = new CultureInfo("th-TH"); dtpBarthday.Text = personal.Birthday.ToString("d MMMM yyyy"); LoadCustomerData(sender, e, "CitizenID", txtCitizenId.Text.Trim()); } else { MessageBox.Show("ไม่สามารถอ่านข้อมูลได้\nกรุณาติดตั้งเครื่องอ่าน Smart Card ให้เรียบร้อย\nแล้วลองใหม่อีกครั้ง", "มีข้อผิดพลาดเกิดขึ้น", MessageBoxButtons.OK, MessageBoxIcon.Error); } btnSmartCard.Enabled = true; }
private void Form1_Load(object sender, EventArgs e) { idcard = new ThaiIDCard(); lbLibVersion.Text = "LibThaiIDCard version: " + idcard.Version(); timer1 = new System.Windows.Forms.Timer(); timer1.Tick += new EventHandler(timer1_Tick); timer1.Interval = 2000; // in miliseconds timer1.Start(); timer2 = new System.Windows.Forms.Timer(); timer2.Tick += new EventHandler(timer2_Tick); timer2.Interval = 10000; // in miliseconds timer2.Start(); clearDefault(); }
private void Form1_Load_1(object sender, EventArgs e) { pictureBox1.Visible = false; //this.TopMost = true; //this.FormBorderStyle = FormBorderStyle.None; //this.WindowState = FormWindowState.Maximized; try { Console.WriteLine("Form1 was loaded"); idcard = new ThaiIDCard(); cardReaders = idcard.GetReaders(); idcard.MonitorStart(cardReaders[0].ToString()); idcard.eventCardInserted += new handleCardInserted(CardInsertedCallback); idcard.eventCardRemoved += new handleCardRemoved(CardRemoveCallback); } catch (Exception ex) { Console.WriteLine(ex.Message); label1.Text = "ไม่พบเครื่องอ่านบัตรสมาร์ตการ์ด"; } }
// ปุ่มเช็กสิทธิ private async void button12_Click(object sender, EventArgs e) { label2.Text = "ระบบกำลังตรวจสอบสิทธิ กรุณารอสักครู่..."; pictureBox1.Visible = true; Refresh(); string textBoxTest = textBox1.Text; string hosPtRight = ""; string idcard = ""; responseOpcard resultOpcard = new responseOpcard(); // ตรวจสอบข้อมูลเบื้องต้นจาก HN และเลขบัตรประชาชน // ถ้าเป็น hn จะมีขีดกลาง if (Regex.IsMatch(textBoxTest, "-", RegexOptions.IgnoreCase)) { Console.WriteLine($"Manual ค้นหาจาก HN {smConfig.searchOpcardUrl}"); // ตรวจสอบ HN string testOpcard = await Task.Run(() => searchFromSmByHn(smConfig.searchOpcardUrl, textBoxTest)); if (!string.IsNullOrEmpty(testOpcard)) { resultOpcard = JsonConvert.DeserializeObject <responseOpcard>(testOpcard); if (resultOpcard.opcardStatus == "n") { label2.Text = resultOpcard.errorMsg; pictureBox1.Visible = false; return; } idcard = resultOpcard.idcard; hosPtRight = resultOpcard.hosPtRight; } } else { Console.WriteLine($"Manual ค้นหาจาก idcard {smConfig.searchOpcardUrl}"); if (textBoxTest.Length != 13) { label2.Text = "หมายเลขบัตรประชาชนไม่ครบ13หลัก\nกรุณาตรวจสอบหมายเลขบัตรของท่านอีกครั้ง"; pictureBox1.Visible = false; this.ActiveControl = textBox1; return; } string testOpcard = await Task.Run(() => searchFromSm(smConfig.searchOpcardUrl, textBoxTest)); if (!string.IsNullOrEmpty(testOpcard)) { resultOpcard = JsonConvert.DeserializeObject <responseOpcard>(testOpcard); if (resultOpcard.opcardStatus == "n") { label2.Text = resultOpcard.errorMsg; pictureBox1.Visible = false; return; } idcard = resultOpcard.idcard; hosPtRight = resultOpcard.hosPtRight; } } Console.WriteLine(idcard); string moreTxt = ""; if (resultOpcard.PtRightMain != resultOpcard.PtRightSub) { label2.Text = "แจ้งเตือน! : สิทธิหลักและสิทธิรองไม่ตรงกัน กรุณาติดต่อห้องทะเบียนเพื่อทบทวนสิทธิ\n"; pictureBox1.Visible = false; return; } // ดึง Token จากเครื่องแม่ Console.WriteLine("ตรวจสอบ Token จากเครื่องห้องทะเบียน"); // ดึง Token จากเครื่องแม่ string nhsoContent = await Task.Run(() => LoadRegisterToken($"http://{smConfig.ipUc}/getvalue.php")); if (string.IsNullOrEmpty(nhsoContent)) { nhsoContent = await Task.Run(() => LoadRegisterToken($"http://{smConfig.ipUc2}/getvalue.php")); if (string.IsNullOrEmpty(nhsoContent)) { nhsoContent = await Task.Run(() => LoadRegisterToken($"http://{smConfig.ipUc3}/getvalue.php")); } } if (String.IsNullOrEmpty(nhsoContent)) { label2.Text = "กรุณาติดต่อห้องทะเบียน เพื่อทำการขอรหัส Authentication"; pictureBox1.Visible = false; return; } string[] nhso = nhsoContent.Split('#'); string staffIdCard = nhso[0]; string nhsoToken = nhso[1]; // ดึงข้อมูลสิทธิการรักษาจาก สปสช try { Console.WriteLine("ทำการเชื่อมต่อกับ WebService สปสช"); UCWSTokenP1Client soapClient = new UCWSTokenP1Client(); pt = new nhsoDataSetC1(); pt = soapClient.searchCurrentByPID(staffIdCard, nhsoToken, idcard); if (pt == null || pt.ws_status == "NHSO-00003") { label2.Text = "TOKEN หมดอายุการใช้งาน ติดต่อทะเบียนเพื่อเปิดใช้ UcAuthentication อีกครั้ง"; pictureBox1.Visible = false; return; } } catch (Exception ex) { Console.WriteLine(ex.Message); label2.Text = "ไม่สามารถติดต่อกับ WebService สปสช ได้"; pictureBox1.Visible = false; return; } // ถ้า maininscl เป็นค่าว่างแสดงว่าไม่มีสิทธิอะไรเลย ให้สงสัยก่อนว่าเป็นเงินสด // ถ้ามี new_maininscl แสดงว่ามีสิทธิใหม่เกิดขึ้น เช่น หมดสิทธิ ปกส. แล้วไปใช้ 30บาท หรืออื่นๆ if (String.IsNullOrEmpty(pt.maininscl) || !String.IsNullOrEmpty(pt.new_maininscl)) { label2.Text = "สิทธิหลักของท่านมีการเปลี่ยนแปลง กรุณาติดต่อห้องทะเบียน\nเพื่อทำการตรวจสอบสิทธิ"; pictureBox1.Visible = false; return; } if ((!String.IsNullOrEmpty(pt.hmain) && pt.hmain != "11512") || (!String.IsNullOrEmpty(pt.new_hmain) && pt.new_hmain != "11512")) { moreTxt = "แจ้งเตือน! : สถานพยาบาลหลักของท่านไม่ใช่ โรงพยาบาลค่ายสุรศักดิ์มนตรี ท่านจะได้สิทธิเป็นเงินสด"; } Console.WriteLine($"ค้นหาการนัด {smConfig.searchAppointUrl} {idcard}"); responseAppoint result = new responseAppoint(); // ตรวจสอบการนัดหมาย string content = await Task.Run(() => searchFromSm(smConfig.searchAppointUrl, idcard)); Console.WriteLine(content); string appointContent = ""; int appointCount = 0; string appointStatus = ""; if (!string.IsNullOrEmpty(content)) { result = JsonConvert.DeserializeObject <responseAppoint>(content); appointStatus = result.appointStatus; if (appointStatus == "y") { appointContent = result.appointContent; appointCount = int.Parse(result.appointCount); appoint = result.appoint; } else { label2.Text = result.errorMsg; pictureBox1.Visible = false; return; } } // string maininscl = ""; string maininsclCode = ""; if (!String.IsNullOrEmpty(pt.maininscl)) { maininsclCode = pt.maininscl; maininscl = $"( { pt.maininscl } ) { pt.maininscl_name }"; } else if (!String.IsNullOrEmpty(pt.new_maininscl)) { maininsclCode = pt.new_maininscl; maininscl = $"( { pt.new_maininscl } ) { pt.new_maininscl_name }"; } string subinscl = ""; if (!String.IsNullOrEmpty(pt.subinscl)) { subinscl = $"( { pt.subinscl } ) { pt.subinscl_name }"; } else if (!String.IsNullOrEmpty(pt.new_subinscl)) { subinscl = $"( { pt.new_subinscl } ) { pt.new_subinscl_name }"; } string hmain = ""; if (!String.IsNullOrEmpty(pt.hmain)) { hmain = $"( { pt.hmain } ) { pt.hmain_name }"; } else if (!String.IsNullOrEmpty(pt.new_hmain)) { hmain = $"( { pt.new_hmain } ) { pt.new_hmain_name }"; } Bitmap origin = (Bitmap)Image.FromFile("Images/avatar.png"); Bitmap Photo1 = new Bitmap(origin, new Size(160, 200)); Form2 frm = new Form2(); frm.fullname = pt.fname + " " + pt.lname; frm.idcard = idcard; frm.mainInSclName = maininscl; frm.subInSclName = subinscl; frm.hMainName = hmain; frm.personImage = Photo1; frm.ptRight = maininsclCode; frm.hn = resultOpcard.hn; frm.ptname = resultOpcard.ptname; frm.appointStatus = appointStatus; frm.appointContent = appointContent; frm.appointCount = appointCount; frm.appoint = appoint; frm.moreTxt = moreTxt; frm.hosPtRight = hosPtRight; label2.Text = ""; frm.ShowDialog(); this.Close(); }
private void frmMain_Load(object sender, EventArgs e) { idcard = new ThaiIDCard(); lbLibVersion.Text = "LibThaiIDCard version: " + idcard.Version(); }
private void LoadDeviceIdCard() { cbo_DeviceName.Items.Clear(); cbo_DeviceName.SelectedText = String.Empty; cbo_DeviceName.Text = string.Empty; cbo_DeviceName.Refresh(); var contextFactory = ContextFactory.Instance; using (var context = contextFactory.Establish(SCardScope.System)) { Console.WriteLine("Currently connected readers: "); var readerNames = context.GetReaders(); foreach (var readerName in readerNames) { try { using (var reader = context.ConnectReader(readerName, SCardShareMode.Shared, SCardProtocol.Any)) { var status = reader.GetStatus(); Debug.WriteLine(JsonConvert.SerializeObject(status)); AtrString = BitConverter.ToString(status.GetAtr()).Replace("-", ""); } } catch (Exception exception) { Debug.WriteLine( "No card inserted or reader '{0}' is reserved exclusively by another application.", readerName); Debug.WriteLine("Error message: {0} ({1})\n", exception.Message, exception.GetType()); } } } try { ThaiIDCard idcard = new ThaiIDCard(); string[] readers = idcard.GetReaders(); if (readers == null) { btnLoadCard.Enabled = false; return; } btnLoadCard.Enabled = true; foreach (string r in readers) { cbo_DeviceName.Items.Add(r); } Debug.WriteLine("Count", cbo_DeviceName.Items.Count.ToString()); if (cbo_DeviceName.Items.Count > 0) { cbo_DeviceName.SelectedIndex = 0; } else { cbo_DeviceName.Items.Add("None"); } cbo_DeviceName.DroppedDown = true; } catch (Exception ex) { cbo_DeviceName.Items.Add("None"); cbo_DeviceName.SelectedIndex = 0; Debug.WriteLine(ex.ToString()); } }
// 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); } }
private void btnRefreshReaderList_Click_1(object sender, EventArgs e) { cbxReaderList.Items.Clear(); cbxReaderList.SelectedIndex = -1; cbxReaderList.SelectedText = String.Empty; cbxReaderList.Text = string.Empty; cbxReaderList.Refresh(); ThaiIDCard idcard = new ThaiIDCard(); string[] readers = idcard.GetReaders(); if (readers == null) return; foreach (string r in readers) { cbxReaderList.Items.Add(r); } cbxReaderList.DroppedDown = true; }
private void chkBoxMonitor_CheckedChanged_1(object sender, EventArgs e) { ThaiIDCard idcard = new ThaiIDCard(); if (chkBoxMonitor.Checked) { if (cbxReaderList.SelectedItem == null) { MessageBox.Show("No reader select to monitoring."); chkBoxMonitor.Checked = false; return; } idcard.MonitorStart(cbxReaderList.SelectedItem.ToString()); //idcard.eventCardInsertedWithPhoto += new handleCardInserted(CardInserted); //Read data with photo, it's take long time. idcard.eventCardInserted += new handleCardInserted(CardInserted); //Read data no photo, that is fast. idcard.eventCardRemoved += new handleCardRemoved(CardRemoved); idcard.eventPhotoProgress += new handlePhotoProgress(photoProgress); } else { if (cbxReaderList.SelectedItem != null) idcard.MonitorStop(cbxReaderList.SelectedItem.ToString()); } }
public Scancardsetting(ThaiIDCard card) { idcard = card; InitializeComponent(); LoadConfig(); }
private void CardSelection_Load(object sender, EventArgs e) { idcard = new ThaiIDCard(); }
public Form3() { InitializeComponent(); idcard = new ThaiIDCard(); }