private void SetDeviceTime(object sender, EventArgs e) { IntPtr hPort; String TimeString; Boolean Right; TimeString = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString().PadLeft(2, '0') + DateTime.Now.Day.ToString().PadLeft(2, '0') + DateTime.Now.Hour.ToString().PadLeft(2, '0') + DateTime.Now.Minute.ToString().PadLeft(2, '0') + DateTime.Now.Second.ToString().PadLeft(2, '0'); hPort = EastRiver.OpenCommPort(1, 9600); EastRiver.CallClock(hPort, 1); Right = EastRiver.SetClockTimeString(hPort, TimeString); if (Right == true) { tsMsg.Text = "设备时间设置成功"; } else { tsMsg.Text = "设备时间设置失败"; } EastRiver.ClosePortHandle(hPort); }
/// <summary> /// 读取设备参数 /// </summary> private void ReadDeviceParm(int iPort, int iRate, int iClockID) { uint Mode, ExtraMode, SystemMode, RingMode; IntPtr hPort = EastRiver.OpenCommPort(iPort, iRate); EastRiver.CallClock(hPort, iClockID); EastRiver.ReadClockModeEx(hPort, out Mode, out ExtraMode, out SystemMode, out RingMode); switch (Mode) { case 1: break; case 2: break; case 3: break; case 4: break; case 5: break; case 6: break; case 7: break; } switch (ExtraMode) { case 1: break; } switch (SystemMode) { case 1: break; } switch (RingMode) { case 1: break; } }
private void btnRead_Click(object sender, EventArgs e) { //Int64 iSerialNo = 0; StringBuilder CardNo = new StringBuilder(); StringBuilder CardName = new StringBuilder(); int money = 0, Times = 0, Ver = 2; IntPtr hPort = EastRiver.OpenCommPort(iPort, iRate); EastRiver.ReadICCard(hPort, CardNo, CardName, ref money, ref Times, ref Ver); //EastRiver.ReadICCardEx(hPort, sCardNo, sCardName, sPwd, ref money, ref Times, ref day_con, ref day_times, ref c_month, // ref c_day, ref c_flag, ref groupstation, ref groupid, 0); //if (EastRiver.ReadICCardSerialNo(hPort, ref iSerialNo, true) == true) //{ editControl1.SetValue(CardNo.ToString()); //} EastRiver.CloseCommPort(hPort); }
private void ReadCard() { Int64 iSerialNo = 0; IntPtr hPort = EastRiver.OpenCommPort(iPort, iRate); if (EastRiver.ReadICCardSerialNo(hPort, ref iSerialNo, true) == true) { editControl1.SetValue(iSerialNo.ToString()); string sSQL = "select F_ID,F_Name from t_Emp where F_CardNo = '" + iSerialNo.ToString() + "'"; DataLib.DataHelper myHelper = new DataLib.DataHelper(); DataSet dsEmp = myHelper.GetDs(sSQL); if (dsEmp.Tables[0].Rows.Count > 0) { editControl4.SetValue(dsEmp.Tables[0].Rows[0]["F_ID"].ToString()); editControl2.SetValue(dsEmp.Tables[0].Rows[0]["F_Name"].ToString()); } } }
private void SetDeviceNo(object sender, EventArgs e) { IntPtr hPort; hPort = EastRiver.OpenCommPort(iPort, iRate); EastRiver.CallClock(hPort, iClockID); int Clock_ID = EastRiver.GetClockID(hPort, iRate); frmSetDeviceNo F = new frmSetDeviceNo(); F.textBox1.Text = Clock_ID.ToString(); if (F.ShowDialog() == DialogResult.OK) { EastRiver.SetClockID(hPort, Convert.ToInt32(F.textBox1.Text)); } F.Dispose(); }
/// <summary> /// 设置管理卡 /// </summary> private void SetSysCard(object sender, EventArgs e) { IntPtr hPort; Boolean Right; hPort = EastRiver.OpenCommPort(iPort, iRate); EastRiver.CallClock(hPort, iClockID); Right = EastRiver.SetManagerCard(hPort, ""); if (Right == true) { tsMsg.Text = "设置设备管理卡号成功"; } else { tsMsg.Text = "设置设备管理卡号失败"; } EastRiver.ClosePortHandle(hPort); }
private void ReadDeviceTime(object sender, EventArgs e) { IntPtr hPort; String TimeString = ""; Boolean Right; hPort = EastRiver.OpenCommPort(1, 9600); EastRiver.CallClock(hPort, 1); Right = EastRiver.ReadClockTimeString(hPort, out TimeString); if (Right == true) { tsMsg.Text = "设备时间:" + "20" + TimeString.Substring(1, 2) + "年" + TimeString.Substring(3, 2) + TimeString.Substring(5, 2) + "月" + TimeString.Substring(5, 2) + "日" + TimeString.Substring(7, 2) + "时" + TimeString.Substring(9, 2) + "分" + TimeString.Substring(9, 2) + "秒"; } EastRiver.ClosePortHandle(hPort); }
private void FindDevice() { int iPort = cbPort.SelectedIndex + 1; int iClockID = 0; int iModel = 0, cls = 0; double ver = 0; IntPtr hPort = EastRiver.OpenCommPort(iPort, Convert.ToInt32(cbRate.Text)); int iBegin = Convert.ToInt32(txtBegin.Text), iEnd = Convert.ToInt32(txtEnd.Text), iCnt = 0; for (int i = iBegin; i < iEnd; i++) { if (EastRiver.CallClock(hPort, Convert.ToInt32(i)) == true) { EastRiver.GetClockModel(hPort, ref iModel, ref ver, ref cls); iClockID = i; iCnt++; } } MessageBox.Show("搜索到" + iCnt.ToString() + "台设备!", "提示"); if (drDevice != null && iCnt > 0) { if (cls == 0) { drDevice["F_Model"] = "ER-" + iModel.ToString() + "D"; } else { drDevice["F_Model"] = "ER-" + iModel.ToString() + "C"; } drDevice["F_Port"] = cbPort.Text; drDevice["F_Rate"] = Convert.ToInt32(cbRate.Text); drDevice["F_ID"] = iClockID.ToString().PadLeft(2, '0'); } }
private void ReadCard() { StringBuilder CardNo = new StringBuilder(); StringBuilder CardName = new StringBuilder(); int Money = 0, Times = 0, Ver = 0; IntPtr hPort = EastRiver.OpenCommPort(iPort, iRate); if (EastRiver.ReadICCard(hPort, CardNo, CardName, ref Money, ref Times, ref Ver) == true) { editControl1.SetValue(CardNo.ToString()); string sSQL = "select F_ID,F_Name from t_Emp where F_CardNo = '" + CardNo.ToString() + "'"; DataLib.DataHelper myHelper = new DataLib.DataHelper(); DataSet dsEmp = myHelper.GetDs(sSQL); if (dsEmp.Tables[0].Rows.Count > 0) { editControl4.SetValue(dsEmp.Tables[0].Rows[0]["F_ID"].ToString()); editControl2.SetValue(dsEmp.Tables[0].Rows[0]["F_Name"].ToString()); } } EastRiver.CloseCommPort(hPort); }
/// <summary> /// 读数据 /// </summary> private void ReadData(object sender, EventArgs e) { Boolean Flag; ulong Rst; uint Count = 0, action; string Records; action = 0; Flag = true; IntPtr hPort = EastRiver.OpenCommPort(iPort, iRate); EastRiver.CallClock(hPort, iClockID); while (Flag == true) { Application.DoEvents(); Rst = EastRiver.BatchReadRecordEx(hPort, action, 16, out Count, out Records); if (Rst != 0) { Flag = false; } else { /* * 格式:卡号+TAB制表符+日期+TAB制表符+状态+TAB制表符+标志+',' * Style: CardNo+TAB+DateTime+TAB+State+TAB+Flag(Flag=0 for OK) */ if (Count > 0) { //lb_1.additem(Records); action = 1; //如果确认记录保存成功时就=1,否则=0重读上一批,注意:每读完一批后就会删除这一批 } else { Flag = false; } } } EastRiver.ClosePortHandle(hPort); //Beep(2500,100) }
/// <summary> /// 发卡 /// </summary> /// <returns></returns> private bool SendCard() { if (lupEmp.GetValue() == DBNull.Value) { MessageBox.Show(this, "工号不能为空!", "提示"); lupEmp.Focus(); return(false); } if (editControl1.GetValue() == DBNull.Value) { MessageBox.Show(this, "卡号不能为空!", "提示"); editControl1.Focus(); return(false); } IntPtr hPort = EastRiver.OpenCommPort(iPort, iRate); if (EastRiver.SetAllowedCard(hPort, editControl1.GetValue().ToString(), lupEmp.GetValue().ToString(), editControl1.GetValue().ToString()) == true) { string strSQL = "update t_Emp set F_CardNo = '" + editControl1.GetValue().ToString() + "' where F_ID = '" + lupEmp.GetValue().ToString() + "'"; DataLib.DataHelper myHelper = new DataLib.DataHelper(); if (myHelper.ExecuteSQL(strSQL) == 0) { return(true); } else { return(false); } } else { return(false); } }
private void Del() { if (viewCard.FocusedRowHandle < 0) { return; } if (MessageBox.Show(this, "真的要删除本卡记录吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No) { return; } DataRow dr = viewCard.GetDataRow(viewCard.FocusedRowHandle); IntPtr hPort = EastRiver.OpenCommPort(iPort, iRate); if (EastRiver.DeleteAllBlackCard(hPort, dr["F_CarNo"].ToString()) == true) { DataLib.DataHelper myHelper = new DataLib.DataHelper(); if (myHelper.ExecuteSQL("delete from t_SendCard where F_CardNo = '" + dr["F_CardNo"].ToString() + "' and F_Date = '" + dr["F_Date"].ToString() + "'") == 0) { DataBind(); } } }