//发卡 private void MakeCard() { string s = ""; if (state1.Checked == true) { s = "固定卡"; } else if (state2.Checked == true) { s = "临时卡"; } int icdev = DCHelper.dc_init(100, 115200); if (icdev > 0) { long snr = 0; int dccard = DCHelper.dc_card(icdev, 0, ref snr); if (dccard == 0) { byte[] password = new byte[] { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; int dckey = DCHelper.dc_load_key(icdev, 0, 1, password); if (dckey == 0) { int authkey = DCHelper.dc_authentication(icdev, 0, 1); if (authkey == 0) { int dcwrity = DCHelper.dc_write(icdev, 4, icNo.Text); if (dcwrity == 0) { int i = (int)BikeInfoManag.MakeCard(icNo.Text, bikeNo.Text, bikeOwerName.Text, bikeOwerTel.Text, bikeOwerAddr.Text, icStateTime.Value, icExpireTime.Value, s, ".\\images\\" + bikeNo.Text + ".jpg", userInfo.Username); if (i > 0) { int m = (int)SpaceInfoManag.updateSpaceInfo(icNo.Text, s); DCHelper.dc_beep(icdev, 100); MessageBox.Show("发卡成功"); } } } } } else { MessageBox.Show("请正确放置卡!"); } } else { MessageBox.Show("请检查设备!"); } }
private void Readcard_Click(object sender, EventArgs e) { int icdev = DCHelper.dc_init(100, 115200); if (icdev > 0) { long snr = 0; int dccard = DCHelper.dc_card(icdev, 0, ref snr); if (dccard == 0) { byte[] password = new byte[] { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; int dckey = DCHelper.dc_load_key(icdev, 0, 1, password); if (dckey == 0) { int authkey = DCHelper.dc_authentication(icdev, 0, 1); if (authkey == 0) { byte[] data = new byte[16]; int dread = DCHelper.dc_read(icdev, 4, data); string s = System.Text.Encoding.Default.GetString(data); SqlDataReader r = BikeInfoManag.getDataReader(s); if (dread == 0) { icno.Text = s; if (r.Read()) { bikeno.Text = r["bikeNo"].ToString(); pictureBox1.Image = Image.FromFile(r["bikePhoto"].ToString()); time.Text = System.DateTime.Now.ToString(); r.Close(); SqlDataReader rr = BikeInfoManag.getType(s); if (rr.Read()) { icstate.Text = rr["spaceType"].ToString(); } rr.Close(); DCHelper.dc_beep(icdev, 100); } else { MessageBox.Show("该卡无效"); for (int i = 0; i < 3; i++) { DCHelper.dc_beep(icdev, 10); } } } } } } else { MessageBox.Show("请正确放置卡!"); } } else { MessageBox.Show("请检查设备!"); } }