private void 位ToolStripMenuItem_Click(object sender, EventArgs e) { card_conn = false; g_retCode = ACR110U.ACR110_Reset(g_hReader); textBox1.AppendText("[DEBUG] RESET " + g_hReader + " = " + g_retCode + "\n"); }
bool select_login() { nowsn = ""; g_retCode = ACR110U.ACR110_Select(g_hReader, ref tagType[0], ref tagLen, ref tagSN[0]); textBox1.AppendText("[DEBUG] SELECT CARD = " + g_retCode + "\n"); textBox1.AppendText("[DEBUG] CARD TYPE = " + ACR110U.GetTagType1(tagType[0]) + "\n"); string str = ""; for (int i = 0; i < tagLen; i++) { str += tagSN[i].ToString("X2") + " "; } nowsn = str; textBox1.AppendText("[DEBUG] CARD SN = " + str + "\n"); if (g_retCode == 0) { byte[] key = new byte[6] { 0xab, 0xab, 0xab, 0xab, 0xab, 0xab }; g_retCode = ACR110U.ACR110_Login(g_hReader, 1, ACR110U.ACR110_LOGIN_KEYTYPE_A, 0, ref key[0]); textBox1.AppendText("[DEBUG] LOGIN = "******"\n"); if (g_retCode == 0) { return(true); } } return(false); }
void make_room_card(ushort r, DateTime dt) { //制房间卡按钮 byte[] tb = new byte[16]; tb[0] = 4; tb[1] = (byte)(r >> 8); tb[2] = (byte)r; tb[3] = (byte)(dt.Year >> 8); tb[4] = (byte)dt.Year; tb[5] = (byte)dt.Month; tb[6] = (byte)dt.Day; tb[7] = (byte)dt.Hour; tb[8] = (byte)dt.Minute; tb[9] = (byte)dt.Second; g_retCode = ACR110U.ACR110_Write(g_hReader, 4, ref tb[0]); if (g_retCode == 0) { //textBox1.AppendText("[DEBUG] MAKE TIME CARD = " + g_retCode + "\n"); System.IO.File.WriteAllText(nowsn + ".dat", dt + ""); int i = findIndexByRoomName(r + ""); if (i >= 0) { rooms[i].card_count = 1; saveRooms(); room_ref(); } System.IO.File.AppendAllText("oplog\\" + dt.ToString("yyyy_MM_dd") + ".dat", dt + ": make room card sn=" + nowsn + ", room=" + r + "\r\n"); textBox1.AppendText("[DEBUG] MAKE ROOM CARD DONE\n"); } }
void make_useless_card() {//制管理卡按钮 byte[] tb = new byte[16]; tb[0] = 0; //tb[3] = (byte)(ushort.Parse(textBox2.Text) >> 8); //tb[4] = (byte)ushort.Parse(textBox2.Text); //tb[5] = byte.Parse(textBox3.Text); //tb[6] = byte.Parse(textBox4.Text); //tb[7] = byte.Parse(textBox5.Text); //tb[8] = byte.Parse(textBox6.Text); //tb[9] = byte.Parse(textBox7.Text); g_retCode = ACR110U.ACR110_Write(g_hReader, 4, ref tb[0]); if (g_retCode == 0) { //textBox1.AppendText("[DEBUG] MAKE TIME CARD = " + g_retCode + "\n"); textBox1.AppendText("[DEBUG] MAKE USELESS CARD DONE\n"); } }
void make_floor_card(byte floor) { //制楼层卡按钮 byte[] tb = new byte[16]; tb[0] = 2; tb[2] = floor; //tb[3] = (byte)(ushort.Parse(textBox2.Text) >> 8); //tb[4] = (byte)ushort.Parse(textBox2.Text); //tb[5] = byte.Parse(textBox3.Text); //tb[6] = byte.Parse(textBox4.Text); //tb[7] = byte.Parse(textBox5.Text); //tb[8] = byte.Parse(textBox6.Text); //tb[9] = byte.Parse(textBox7.Text); g_retCode = ACR110U.ACR110_Write(g_hReader, 4, ref tb[0]); if (g_retCode == 0) { //textBox1.AppendText("[DEBUG] MAKE TIME CARD = " + g_retCode + "\n"); textBox1.AppendText("[DEBUG] MAKE FLOOR CARD DONE\n"); } }
public Form1() { InitializeComponent(); g_hReader = -1; g_hReader = ACR110U.ACR110_Open(ACR110U.ACR110_USB1); textBox1.AppendText("[DEBUG] OPEN USB1 = " + g_hReader + "\n"); if (g_hReader == 0) { toolStripStatusLabel1.Text = "读卡器已连接"; } else { toolStripStatusLabel1.Text = "读卡器未连接"; } tabControl1.SelectTab(0); room_init(); room_ref(); }
private void textBox1_KeyUp(object sender, KeyEventArgs e) { if (e.KeyValue == 13) { string line = get_last_line(textBox1.Lines); if (line == "CARD_INIT") { { g_retCode = ACR110U.ACR110_Select(g_hReader, ref tagType[0], ref tagLen, ref tagSN[0]); textBox1.AppendText("[DEBUG] SELECT CARD = " + g_retCode + "\n"); textBox1.AppendText("[DEBUG] CARD TYPE = " + ACR110U.GetTagType1(tagType[0]) + "\n"); string str = ""; for (int i = 0; i < tagLen; i++) { str += tagSN[i].ToString("X2") + " "; } textBox1.AppendText("[DEBUG] CARD SN = " + str + "\n"); byte[] key = new byte[6] { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; g_retCode = ACR110U.ACR110_Login(g_hReader, 1, ACR110U.ACR110_LOGIN_KEYTYPE_A, 0, ref key[0]); if (g_retCode == 0) { byte[] wbuf = new byte[16] { 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xff, 0x07, 0x80, 0x69, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; g_retCode = ACR110U.ACR110_Write(g_hReader, 7, ref wbuf[0]); if (g_retCode == 0) { textBox1.AppendText("CARD_INIT DONE\n"); } else { textBox1.AppendText("CARD_INIT ERR 2\n"); } } else { textBox1.AppendText("CARD_INIT ERR 1\n"); } } } else if (line == "CARD_ADMIN") { //if (!card_conn) //{ // card_conn = //} //if (card_conn) { select_login(); make_admin_card(); } } else if (line.StartsWith("CARD_FLOOR ")) { string[] words = line.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); if (words.Length == 2) { byte f = byte.Parse(words[1]); //if (!card_conn) //{ // card_conn = select_login(); //} //if (card_conn) { select_login(); make_floor_card(f); } } } else if (line == "CLS") { textBox1.Clear(); } } }
private void 连接ToolStripMenuItem_Click(object sender, EventArgs e) { g_hReader = ACR110U.ACR110_Open(ACR110U.ACR110_USB1); textBox1.AppendText("[DEBUG] OPEN USB1 = " + g_hReader + "\n"); }
void read_card() { textBox8.Clear(); g_retCode = ACR110U.ACR110_Read(g_hReader, (byte)4, ref rblock[0]); if (g_retCode == 0) { textBox8.Clear(); CARD_TYPE = rblock[0]; textBox8.AppendText("卡类型:"); if (CARD_TYPE == 1) { textBox8.AppendText("管理卡\n"); textBox8.AppendText("权 限:全部"); } else if (CARD_TYPE == 2) { textBox8.AppendText("楼层卡\n"); CARD_ROOM = rblock[1]; CARD_ROOM <<= 8; CARD_ROOM |= rblock[2]; textBox8.AppendText("权 限:楼层"); textBox8.AppendText("" + CARD_ROOM); } else if (CARD_TYPE == 3) { textBox8.AppendText("时间卡\n"); CARD_YER = rblock[3]; CARD_YER <<= 8; CARD_YER |= rblock[4]; CARD_MON = rblock[5]; CARD_DAY = rblock[6]; CARD_HOU = rblock[7]; CARD_MIN = rblock[8]; CARD_SEC = rblock[9]; textBox8.AppendText("时 间:"); textBox8.AppendText(CARD_YER + "-" + CARD_MON + "-" + CARD_DAY + " " + CARD_HOU + ":" + CARD_MIN + ":" + CARD_SEC + ""); } else if (CARD_TYPE == 4) { textBox8.AppendText("普通卡\n"); textBox8.AppendText("权 限:房间"); CARD_ROOM = rblock[1]; CARD_ROOM <<= 8; CARD_ROOM |= rblock[2]; textBox8.AppendText("" + CARD_ROOM + "\n"); textBox8.AppendText("有效期:"); CARD_YER = rblock[3]; CARD_YER <<= 8; CARD_YER |= rblock[4]; CARD_MON = rblock[5]; CARD_DAY = rblock[6]; CARD_HOU = rblock[7]; CARD_MIN = rblock[8]; CARD_SEC = rblock[9]; textBox8.AppendText(CARD_YER + "-" + CARD_MON + "-" + CARD_DAY + " " + CARD_HOU + ":" + CARD_MIN + ":" + CARD_SEC + ""); } else { textBox8.AppendText("无效卡\n"); } } }