/// <summary> /// 加载所有工具柜 /// </summary> //public void LoadBox() //{ // try // { // #region 工具柜门禁 // if (boxDoorWatching != null) // { // boxDoorWatching.PauseWatch(); // if (clsWgWatchingBox.listWg.Count > 0) // { // lock (clsWgWatchingBox.listWg) // { // clsWgWatchingBox.listWg.Clear(); // } // } // } // string strSql = "select tvChildId,AreaName,PlaceName,DoorIp,DoorSn,BoxHasRfid,BoxRfidMain from tb_Tools where " + // "IsArea='" + ToolAreaType.工具柜.ToString() + "' and HasDoor='" + DeviceUsing.启用.ToString() + "' "; // DataTable dt = datalogic.GetDataTable(strSql); // foreach (DataRow datarow in dt.Rows) // { // string strChildId = datarow["tvChildId"].ToString(); // string strArea = datarow["AreaName"].ToString(); // string strName = datarow["PlaceName"].ToString(); // string strIp = datarow["DoorIp"].ToString(); // string strSn = datarow["DoorSn"].ToString(); // string strHasRfid = datarow["BoxHasRfid"].ToString(); // string strRfidMain = datarow["BoxRfidMain"].ToString(); // uint iSn = 0; // if (!string.IsNullOrEmpty(strSn)) // { // iSn = Convert.ToUInt32 (strSn); // } // else // { // MessageUtil.ShowTips(strName + " 工具柜门禁SN为空"); // } // clsDoorBox boxDoor = new clsDoorBox(strIp, iSn, strName, strArea); // boxDoor.StrChildId = strChildId; // boxDoor.StrHasRfid = strHasRfid; // boxDoor.StrRfidMain = strRfidMain; // lock (clsWgWatchingBox.listWg) // { // clsWgWatchingBox.listWg.Add(boxDoor); // } // } // if (clsWgWatchingBox.listWg.Count > 0) // { // if (boxDoorWatching == null) // { // boxDoorWatching = new clsWgWatchingBox(); // } // boxDoorWatching.StartWatch(); // frmMain.UsingBox = DeviceUsing.启用; // } // else // { // frmMain.UsingBox = DeviceUsing.未启用; // if (boxDoorWatching != null) // { // boxDoorWatching.StopWatch(); // boxDoorWatching = null; // } // } // #endregion // #region // //#region 工具柜RFID // //if (listBoxRfid.Count > 0) // //{ // // lock (listBoxRfid) // // { // // for (int iIndexRfid = 0; iIndexRfid < listBoxRfid.Count; iIndexRfid++) // // { // // if (listBoxRfid[iIndexRfid] != null) // // { // // if (listBoxRfid[iIndexRfid].StateMainRead != BoxRfidState.不读) // // listBoxRfid[iIndexRfid].StateMainRead = BoxRfidState.不读; // // if (listBoxRfid[iIndexRfid].StateSlaveRead != BoxRfidState.不读) // // listBoxRfid[iIndexRfid].StateSlaveRead = BoxRfidState.不读; // // if (listBoxRfid[iIndexRfid].timerRfidFast.State == TimerState.Running) // // listBoxRfid[iIndexRfid].StopRead(); // // if (listBoxRfid[iIndexRfid].BlConnent) // // { // // listBoxRfid[iIndexRfid].CloseNetPort(); // // } // // if (listBoxRfid[iIndexRfid].timerRfidFast != null) // // listBoxRfid[iIndexRfid].timerRfidFast = null; // // listBoxRfid[iIndexRfid] = null; // // } // // } // // listBoxRfid.Clear(); // // } // //} // //strSql = "select tvChildId,AreaName,PlaceName,BoxRfidIp,BoxRfidPort,BoxRfidMain,BoxRfidAnt1,BoxRfidAnt2,BoxRfidAnt3,BoxRfidAnt4 from tb_Tools where " + // // "IsArea='" + ToolAreaType.工具柜.ToString() + "' and BoxHasRfid='" + DeviceUsing.启用.ToString() + "' "; // //dt = datalogic.GetDataTable(strSql); // //foreach (DataRow datarow in dt.Rows) // //{ // // string strId = datarow["tvChildId"].ToString(); // // string strArea = datarow["AreaName"].ToString(); // // string strName = datarow["PlaceName"].ToString(); // // string strIp = datarow["BoxRfidIp"].ToString(); // // string strPort = datarow["BoxRfidPort"].ToString(); // // string strMain = datarow["BoxRfidMain"].ToString(); // // #region 天线 // // DeviceUsing ant1 = DeviceUsing.未启用; // // DeviceUsing ant2 = DeviceUsing.未启用; // // DeviceUsing ant3 = DeviceUsing.未启用; // // DeviceUsing ant4 = DeviceUsing.未启用; // // string strAnt = datarow["BoxRfidAnt1"].ToString(); // // if (strAnt == DeviceUsing.启用.ToString()) // // ant1 = DeviceUsing.启用; // // else // // ant1 = DeviceUsing.未启用; // // strAnt = datarow["BoxRfidAnt2"].ToString(); // // if (strAnt == DeviceUsing.启用.ToString()) // // ant2 = DeviceUsing.启用; // // else // // ant2 = DeviceUsing.未启用; // // strAnt = datarow["BoxRfidAnt3"].ToString(); // // if (strAnt == DeviceUsing.启用.ToString()) // // ant3 = DeviceUsing.启用; // // else // // ant3 = DeviceUsing.未启用; // // strAnt = datarow["BoxRfidAnt4"].ToString(); // // if (strAnt == DeviceUsing.启用.ToString()) // // ant4 = DeviceUsing.启用; // // else // // ant4 = DeviceUsing.未启用; // // #endregion // // bool blHas = false; // // int iPort = 0; // // if (!string.IsNullOrEmpty(strPort)) // // { // // iPort = Convert.ToInt32(strPort); // // } // // else // // { // // MessageUtil.ShowTips(strName + " 工具柜RFID端口号为空"); // // } // // #region 已有 // // if (listBoxRfid.Count > 0) // // { // // int iCount = listBoxRfid.Count; // // for (int iIndex = 0; iIndex < iCount; iIndex++) // // { // // if (listBoxRfid[iIndex].StrIp == strIp && listBoxRfid[iIndex].IPort == iPort) // // { // // blHas = true; // // if (listBoxRfid[iIndex].StrChildIdMain == null) // // { // // listBoxRfid[iIndex].StrChildIdMain = strId; // // listBoxRfid[iIndex].StrNameMain = strName; // // listBoxRfid[iIndex].AntMain1 = ant1; // // listBoxRfid[iIndex].AntMain2 = ant2; // // } // // else if (listBoxRfid[iIndex].StrChildIdSlave == null) // // { // // listBoxRfid[iIndex].StrChildIdSlave = strId; // // listBoxRfid[iIndex].StrNameSlave = strName; // // listBoxRfid[iIndex].AntSlave1 = ant3; // // listBoxRfid[iIndex].AntSlave2 = ant4; // // } // // } // // } // // } // // #endregion // // #region 无,添加 // // if (blHas == false) // // { // // RfidReadBox rfidRead = new RfidReadBox(); // // rfidRead.StrIp = strIp; // // rfidRead.IPort = iPort; // // if (strMain == BoxRfidMain.主机.ToString()) // // { // // rfidRead.StrChildIdMain = strId; // // rfidRead.StrNameMain = strName; // // rfidRead.AntMain1 = ant1; // // rfidRead.AntMain2 = ant2; // // } // // else if (strMain == BoxRfidMain.从机.ToString()) // // { // // rfidRead.StrChildIdSlave = strId; // // rfidRead.StrNameSlave = strName; // // rfidRead.AntSlave1 = ant3; // // rfidRead.AntSlave2 = ant4; // // } // // lock (listBoxRfid) // // { // // listBoxRfid.Add(rfidRead); // // } // // } // // #endregion // //} // ////设置工具柜RFID天线 // ////for (int iIndex = 0; iIndex < listBoxRfid.Count; iIndex++) // ////{ // //// DeviceUsing ant1 = listBoxRfid[iIndex].AntMain1; // //// DeviceUsing ant2 = listBoxRfid[iIndex].AntMain2; // //// DeviceUsing ant3 = listBoxRfid[iIndex].AntSlave1; // //// DeviceUsing ant4 = listBoxRfid[iIndex].AntSlave2; // ////} // ////if (listBoxDoor.Count > 0) // ////{ // //// //timerBoxDoor.Start(); // ////} // ////else // ////{ // //// //timerBoxDoor.Stop(); // ////} // //#endregion // #endregion // } // catch (Exception ex) // { // if (frmMain.blDebug) // MessageUtil.ShowTips(ex.Message); // } //} /// <summary> /// 加载 所有工具 /// </summary> public void LoadAllTools() { try { #region 加载所有工器具 string strSql = "select tvParent,ToolID,RFIDCoding,BorrowReturnTime,IsInStore,ToolType,ToolName,BorrowPeople,StoragePlace" + " from tb_Tools where IsArea='" + ToolAreaType.工具.ToString() + "' and RFIDCoding <> '' "; DataTable dt = datalogic.GetDataTable(strSql); listTools.Clear(); if (dicTools != null && dicTools.Count > 0) { dicTools.Clear(); } foreach (DataRow dr in dt.Rows)//dtTools ToolID RfidCoding ToolBR TimeBR ToolType ToolName { string strType = dr["ToolType"].ToString(); string strName = dr["ToolName"].ToString(); string strId = dr["ToolID"].ToString(); string strRfid = dr["RFIDCoding"].ToString(); string strTime = dr["BorrowReturnTime"].ToString(); string strState = dr["IsInStore"].ToString(); string strPeo = dr["BorrowPeople"].ToString(); string strTimeBorr = dr["BorrowReturnTime"].ToString(); string strParent = dr["tvParent"].ToString(); string strStation = dr["StoragePlace"].ToString(); ToolsState state = (ToolsState)Enum.Parse(typeof(ToolsState), strState); DateTime dtime = DateTime.Now; if (!string.IsNullOrEmpty(strTime)) { dtime = Convert.ToDateTime(strTime); } ToolInfo toolsInfo = new ToolInfo(strId, strType, strName, strRfid, state, dtime, strPeo, "", strParent, strStation); listTools.Add(toolsInfo); if (!dicTools.ContainsKey(strRfid)) { dicTools.Add(strRfid, toolsInfo); } } #endregion } catch (Exception ex) { if (frmMain.blDebug) { MessageUtil.ShowTips(ex.Message); } } }
public ToolInfo(string strId, string strType, string strName, string strRfid, ToolsState tState, DateTime time, string strPeo, string LastActId, string parent, string station) { strToolId = strId; strToolType = strType; strToolName = strName; strRfidCode = strRfid; toolState = tState; timeBorrRet = time; strPeopel = strPeo; strLastActId = LastActId; strParent = parent; strStation = station; //strNowActId = NowActId; }
private void GenToolRorrRetRecord(ToolsState stateOfTool, string strTime, string strEpc, string strToolType, string strToolName, string strToolID) { // 记录 和 事件显示 commonCls.NewToolBorrowRet(stateOfTool, strTime, strEpc, strToolType, strToolName, strToolID, strOpenUser); if (NewEventShowEvent != null) { string strContent = ""; if (stateOfTool == ToolsState.借出) { strContent = stateOfTool.ToString(); } else if (stateOfTool == ToolsState.在库) { strContent = EventContent.归还.ToString(); } NewEventShowEvent(new NewEventEventArgs(EventType.工具借还, strToolID, strContent, strOpenUser, "", DateTime.Now)); } }
/// <summary> /// 工具借还记录 /// </summary> public void NewToolBorrowRet(ToolsState state, string strTime, string strEpc, string strToolType, string strToolName, string strToolID, string strUser) { if (state == ToolsState.借出) { string strSql = strSql = "update tb_Tools set IsInStore='" + state.ToString() + "',BorrowReturnTime='" + strTime + "' where RFIDCoding='" + strEpc + "' "; datalogic.SqlComNonQuery(strSql); //tb_RecordBorrow ID ToolType ToolName ToolID RFIDCoding PeopleBorrow BorrowTime PeopleReturn ReturnTime BorrowDuration strSql = "insert into tb_RecordBorrow (ToolType,ToolName,ToolID,RFIDCoding,PeopleBorrow,BorrowTime,PeopleReturn,ReturnTime,BorrowDuration)" + "values ('" + strToolType + "','" + strToolName + "','" + strToolID + "','" + strEpc + "','" + strUser + "','" + strTime + "'," + "'','','')"; datalogic.SqlComNonQuery(strSql); } else if (state == ToolsState.在库) { string strSql = strSql = "update tb_Tools set IsInStore='" + state + "',BorrowReturnTime='" + strTime + "' where RFIDCoding='" + strEpc + "' "; datalogic.SqlComNonQuery(strSql); strSql = "update tb_RecordBorrow set PeopleReturn='" + strUser + "',ReturnTime='" + strTime + "'," + "BorrowDuration='' where RFIDCoding='" + strEpc + "' and ReturnTime='' "; datalogic.SqlComNonQuery(strSql); } }