public void Read_RFID_And_UPDATE_UserInfo() { if (!g_isConnected) { RFID_conn(); //MessageBox.Show("RFID 연결상태를 확인해주세요."); } else { byte[] TagLength = new byte[51]; byte TagFound = 0; byte[] TagType = new byte[51]; byte[] SN = new byte[451]; int ctr; snstr = ""; g_retCode = ACR120U.ACR120_ListTags(g_rHandle, ref TagFound, ref TagType[0], ref TagLength[0], ref SN[0]); if (g_retCode < 0) { ; } else { for (ctr = 0; ctr < TagLength[0]; ctr++) { snstr = snstr + string.Format("{0:X2} ", SN[ctr]); //userinfo.SnStr = snstr; } //userinfo.SnStr = snstr; /* Detail_Page DP = new Detail_Page(); * DP.Passvalue = snstr; // 전달자(Passvalue)를 통해서 dp페이지로 전달*/ conn = new MySqlConnection(strConn); cmd = new MySqlCommand(); conn.Open(); cmd.Connection = conn; cmd.CommandText = ($"select rfid from emp_info"); rdr = cmd.ExecuteReader(); string Emp_id = ""; string Emp_name = ""; string rfid = ""; while (rdr.Read()) { rfid = rdr["rfid"] as string; Console.WriteLine(rfid); } rdr.Close(); conn.Close(); } } }
private void RFID_conn() { int ctr = 0; byte[] FirmwareVer = new byte[31]; byte[] FirmwareVer1 = new byte[20]; byte infolen = 0x00; string FirmStr; ACR120U.tReaderStatus ReaderStat = new ACR120U.tReaderStatus(); g_rHandle = ACR120U.ACR120_Open(0); if (g_rHandle != 0) { //DisplayMessage("[X] " + ACR120U.GetErrMsg(g_rHandle)); } else { //DisplayMessage("Connected to USB" + string.Format("{0}", 0 + 1)); g_isConnected = true; //Get the DLL version the program is using g_retCode = ACR120U.ACR120_RequestDLLVersion(ref infolen, ref FirmwareVer[0]); if (g_retCode < 0) { ; } //DisplayMessage("[X] " + ACR120U.GetErrMsg(g_retCode)); else { FirmStr = ""; for (ctr = 0; ctr < Convert.ToInt16(infolen) - 1; ctr++) { FirmStr = FirmStr + char.ToString((char)(FirmwareVer[ctr])); } //DisplayMessage("DLL Version : " + FirmStr); } //Routine to get the firmware version. g_retCode = ACR120U.ACR120_Status(g_rHandle, ref FirmwareVer1[0], ref ReaderStat); if (g_retCode < 0) { ; } //DisplayMessage("[X] " + ACR120U.GetErrMsg(g_retCode)); else { FirmStr = ""; for (ctr = 0; ctr < Convert.ToInt16(infolen); ctr++) { if ((FirmwareVer1[ctr] != 0x00) && (FirmwareVer1[ctr] != 0xFF)) { FirmStr = FirmStr + char.ToString((char)(FirmwareVer1[ctr])); } } //DisplayMessage("Firmware Version : " + FirmStr); } } }
public void Read_RFID_And_UPDATE_UserInfo() { if (!g_isConnected) { RFID_conn(); //MessageBox.Show("RFID 연결상태를 확인해주세요."); } else { byte[] TagLength = new byte[51]; byte TagFound = 0; byte[] TagType = new byte[51]; byte[] SN = new byte[451]; int ctr; snstr = ""; g_retCode = ACR120U.ACR120_ListTags(g_rHandle, ref TagFound, ref TagType[0], ref TagLength[0], ref SN[0]); if (g_retCode < 0) { ; } else { for (ctr = 0; ctr < TagLength[0]; ctr++) { snstr = snstr + string.Format("{0:X2} ", SN[ctr]); //userinfo.SnStr = snstr; } //userinfo.SnStr = snstr; /* Detail_Page DP = new Detail_Page(); * DP.Passvalue = snstr; // 전달자(Passvalue)를 통해서 dp페이지로 전달*/ conn = new MySqlConnection(strConn); cmd = new MySqlCommand(); conn.Open(); cmd.Connection = conn; cmd.CommandText = ($"select rfid from emp_info"); rdr = cmd.ExecuteReader(); string Emp_id = ""; string Emp_name = ""; string rfid = ""; while (rdr.Read()) { rfid = rdr["rfid"] as string; Console.WriteLine(rfid); } rdr.Close(); //snstr = rfid; /* while (rdr.Read()) * { * * Emp_id = rdr["emp_id"].ToString(); * Emp_name = rdr["emp_name"] as string; * * } * rdr.Close();*/ //Emp_Update f1 = new Emp_Update(userinfo); /* if (work == 1) * { * cmd.CommandText = $"insert into attendance_check (emp_id, emp_name, time) " + * $"values('{Emp_id}','{Emp_name}','{time}')"; * cmd.ExecuteNonQuery(); * }*/ /* if (string.IsNullOrEmpty(snstr) == false) * { * timer1.Stop(); * Delay(2000); * timer1.Start(); * return; * }*/ conn.Close(); } } }
public void Read_RFID_And_UPDATE_UserInfo() { conn = new MySqlConnection(strConn); cmd = new MySqlCommand(); conn.Open(); cmd.Connection = conn; cmd.CommandText = ($"select RFID_STATE from RFID_STATE"); rdr = cmd.ExecuteReader(); while (rdr.Read()) { RFID_STATE = rdr["RFID_STATE"].ToString(); } rdr.Close(); if (RFID_STATE == "0") { ; } else { if (!g_isConnected) { RFID_conn(); //MessageBox.Show("RFID 연결상태를 확인해주세요."); } else { string time = System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); byte[] TagLength = new byte[51]; byte TagFound = 0; byte[] TagType = new byte[51]; byte[] SN = new byte[451]; byte portState = 0x00; int ctr; string snstr; g_retCode = ACR120U.ACR120_ListTags(g_rHandle, ref TagFound, ref TagType[0], ref TagLength[0], ref SN[0]); if (g_retCode < 0) { //DisplayMessage(ACR120U.GetErrMsg(g_retCode)); } else { snstr = ""; for (ctr = 0; ctr < TagLength[0]; ctr++) { snstr = snstr + string.Format("{0:X2} ", SN[ctr]); } cmd.CommandText = ($"select rfid from emp_info"); rdr = cmd.ExecuteReader(); int work = 0; string Emp_id = ""; string Emp_name = ""; string rfid = ""; while (rdr.Read()) { // Emp_id = rdr["emp_id"].ToString(); // Emp_name = rdr["emp_name"] as string; rfid = rdr["rfid"] as string; Console.WriteLine(rfid); if (rfid == snstr) { work = 1; } } rdr.Close(); label3.Text = snstr; cmd.CommandText = ($"select emp_id, emp_name from emp_info where rfid = '{snstr} '"); rdr = cmd.ExecuteReader(); while (rdr.Read()) { Emp_id = rdr["emp_id"].ToString(); Emp_name = rdr["emp_name"] as string; } rdr.Close(); if (work == 1) { cmd.CommandText = $"insert into attendance_check (emp_id, emp_name, time,io) " + $"values('{Emp_id}','{Emp_name}','{time}',{inout})"; cmd.ExecuteNonQuery(); } if (string.IsNullOrEmpty(snstr) == false && work == 1) { portState = Convert.ToByte(4);// 0(소리X led X) ,4(소리 O) ,64(led O), 68(LED,소리O) g_retCode = ACR120U.ACR120_WriteUserPort(g_rHandle, portState); Thread.Sleep(300); //Delay(300); portState = Convert.ToByte(64); g_retCode = ACR120U.ACR120_WriteUserPort(g_rHandle, portState); //Delay(2000); Thread.Sleep(2000); // thread delay(test) return; } else if (string.IsNullOrEmpty(snstr) == false && work == 1) { } } } } conn.Close(); }