private void timer_regist_Tick(object sender, EventArgs e) { if (nfc.IsCurrentCard && this.timer_lock == false) { try { timer_lock = true; this.form_polling_disable(); this.tbox_user.Text = ""; ASCIIEncoding asciiEncoding = new ASCIIEncoding(); byte[] recv;// = new byte[262]; string tmp; byte[] send = null; //UID send = new byte[] { 0xff, 0xca, 0x00, 0x00 }; recv = nfc.SendCommand2(send); tmp = BitConverter.ToString(recv).Replace("-", ""); this.lbl_11.Text = tmp; Debug.WriteLine("CARD_UID:" + tmp); //PMm send = new byte[] { 0xff, 0xca, 0x01, 0x00 }; recv = nfc.SendCommand2(send); tmp = BitConverter.ToString(recv).Replace("-", ""); this.lbl_12.Text = tmp; Debug.WriteLine("CARD_PMm:" + tmp); //識別ID send = new byte[] { 0xff, 0xca, 0xf0, 0x00 }; recv = nfc.SendCommand2(send); tmp = BitConverter.ToString(recv).Replace("-", ""); this.lbl_13.Text = tmp; Debug.WriteLine("CARD_CID:" + tmp); //カード種類 send = new byte[] { 0xff, 0xca, 0xf3, 0x00 }; recv = nfc.SendCommand2(send); tmp = BitConverter.ToString(recv).Replace("-", ""); this.lbl_14.Text = tmp; Debug.WriteLine("CARD_TYPE:" + tmp); //名称 send = new byte[] { 0xff, 0xca, 0xf1, 0x00 }; recv = nfc.SendCommand2(send); tmp = asciiEncoding.GetString(recv); this.lbl_15.Text = tmp; Debug.WriteLine("CARD_NAME:" + tmp); Debug.WriteLine(""); this.timer_regist.Enabled = false; } catch (ApplicationException) { //null Debug.WriteLine("ApplicationException:RegistForm"); } } }
private void timer_delete_Tick(object sender, EventArgs e) { if (nfc.IsCurrentCard && this.timer_lock == false) { try { timer_lock = true; OleDbDataReader reader; byte[] recv; byte[] send = null; //UID send = new byte[] { 0xff, 0xca, 0x00, 0x00 }; recv = nfc.SendCommand2(send); uid = BitConverter.ToString(recv).Replace("-", ""); Debug.WriteLine("CARD_UID:" + uid); if (uid.Length > 0) { user = ""; string sql = "select user from parsonal where uid = '" + uid + "'"; reader = mdb.executeQuery(sql); while (reader.Read()) { user = (string)reader.GetValue(0); } if (user != "") { this.tbox_user.Text = user; this.timer_delete.Enabled = false; this.form_polling_disable(); } else { this.tbox_user.Text = "該当なし"; } } } catch (ApplicationException) { //null Debug.WriteLine("ApplicationException:DeleteForm"); } } //timer_lock = false; }
private void timer_add_Tick(object sender, EventArgs e) { if (nfc.IsCurrentCard && this.timer_lock == false) { try { int result; string user; OleDbDataReader reader; DateTime addDate; timer_lock = true; byte[] recv; byte[] send = null; //UID send = new byte[] { 0xff, 0xca, 0x00, 0x00 }; recv = nfc.SendCommand2(send); uid = BitConverter.ToString(recv).Replace("-", ""); Debug.WriteLine("CARD_UID:" + uid); string sql = "select count(1) from parsonal where uid = '" + uid + "'"; reader = mdb.executeQuery(sql); reader.Read(); result = (int)reader.GetValue(0); if (result > 0) { foreach (UserInval v in user_list) { if (v.uid == uid) { Debug.WriteLine("時間内DB追加無し"); return; } } sql = "select user from parsonal where uid = '" + uid + "'"; reader = mdb.executeQuery(sql); reader.Read(); user = (string)reader.GetValue(0); addDate = DateTime.Now; sql = "select count(1) from timedata where uid = '" + uid + "'"; reader = mdb.executeQuery(sql); reader.Read(); result = (int)reader.GetValue(0); sql = "insert into timedata values (" + "'" + uid + "'," + (result + 1) + "," + "'" + DateTime.Now + "')"; result = mdb.executeNonQuery(sql); if (result > 0) { //正常登録 this.lbl_name.Text = user; this.lbl_timer2.Text = addDate.ToLongTimeString(); this.lbl_timer2.ForeColor = Color.Red; this.timer.Enabled = false; this.timer_interval.Enabled = true; Debug.WriteLine("正常登録:" + uid); Debug.WriteLine(""); user_list.Add(new UserInval(uid, DateTime.Now)); } } } catch (ApplicationException) { //null Debug.WriteLine("ApplicationException:MainForm"); } } if (nfc.IsReaderRemoved == true) { this.sttl_status.Text = "カードリーダーが接続されていません"; app_failed = true; } else if (nfc.IsNfcFaild == true) { this.Close(); } else { if (app_failed == false) { this.sttl_status.Text = "ポーリング中"; } } timer_lock = false; }