private void Bgw_DoWork(object sender, DoWorkEventArgs e) { ShowLoading("开始载入工单,请稍后..."); moduleID = CDBConnection._GetModuleID("Program List Registration"); strLbl2 = CDBConnection._GetLabelsTxt(CDBConnection._GetModuleID("上料防错"), 100); strLbl3 = CDBConnection._GetLabelsTxt(CDBConnection._GetModuleID("上料防错"), 101); // 枚举程序名称列表 CDBConnection.SQL = "SELECT DISTINCT Code FROM TB_QMS_ProgramList WHERE ModuleID='" + moduleID + "' AND IsEnable=1"; dtProgramName = CDBConnection._GetGrdInfo(CDBConnection.SQL); }
/// <summary> /// 按小时查询设备效率比例值 /// </summary> /// <param name="StartTime"></param> /// <param name="EndTime"></param> /// <returns></returns> public DataTable QueryEquipmentPerformancebyHour(DateTime StartTime, DateTime EndTime) { // 查询设备ID string SQL = "SELECT DISTINCT B.ID FROM TB_QMS_ProgramList A,TB_Assembly_Builder B " + "WHERE A.Code ='" + this.programName + "' AND B.Code =SUBSTRING(A.Name,0, CHARINDEX('---',A.Name)) " + "AND B.IsEnable =1 AND B.ModuleID ='e42e041b-12a5-4b92-b8c1-257a2adb2e63'"; DataTable dt = CDBConnection._GetGrdInfo(SQL); string EquipmentID = dt.Rows[0][0].ToString(); SqlParameter[] parameter = new SqlParameter[] { new SqlParameter("@startTime", StartTime), new SqlParameter("@endTime", EndTime), new SqlParameter("@equipmentId ", EquipmentID) }; DataSet ds = new DataSet(); ds = SqlHelper.ExecuteDataSet(CDBConnection._GetDBConn(), CommandType.StoredProcedure, "status_min_proportion_byHour", parameter); return(ds.Tables[0]); }
/// <summary> /// 加载栈料列表+低料预警列表 /// </summary> private void LoadStackMaterialList(string programName) { if (programName == string.Empty) { return; } CDBConnection.SQL = "SELECT A.Code PROGRAM_NAME, B.ID,B.Code, B.[Address], B.CompoentNO, B.QTY-B.UsedQTY AS QTY " + "FROM TB_QMS_ProgramList A, TB_QMS_ProgramList B " + "WHERE A.Code ='" + programName + "' and A.ID=B.ParentID"; DataTable dtStack = CDBConnection._GetGrdInfo(CDBConnection.SQL); // 加载栈位物料列表 TreeListView.NodeCollection collection = this.listMaterial.Nodes; this.listMaterial.BeginUpdate(); collection.Clear(); foreach (DataRow drStack in dtStack.Rows) { string ID = drStack[1].ToString(); string address = drStack[3].ToString(); string material = drStack[4].ToString(); int QTY; try { QTY = Int32.Parse(drStack[5].ToString()); } catch { QTY = 0; } // 添加栈位物料父节点 // Node.m_data[3] = { staclID, MaterialName, QTY } Node node = new Node(new object[3] { address, material, QTY.ToString() }); node.TextColor = (QTY > 0) ? Color.Green : Color.Black; // 加载替换物料子节点 CDBConnection.SQL = "SELECT CompoentNO from TB_QMS_ReplaceComponentList where MainID='" + ID + "'"; DataTable dtSub = CDBConnection._GetGrdInfo(CDBConnection.SQL); foreach (DataRow drSub in dtSub.Rows) { Node subNode = new Node(new object[2] { address, drSub[0].ToString() }); node.Nodes.Add(subNode); } collection.Add(node); } this.listMaterial.EndUpdate(); // 加载低料预警列表 this.chartWarning.Clear(); foreach (DataRow drQty in dtStack.Rows) { string stackNO = drQty[3].ToString().Trim(); if (stackNO == null || stackNO == string.Empty) { continue; } string strQTY = drQty[5].ToString().Trim(); if (strQTY == null || strQTY == string.Empty) { continue; } int QTY = int.Parse(strQTY.ToString()); int MinQTY = 100; // assume this.chartWarning.Add(QTY, MinQTY, stackNO); } RedrawWarningChart(); }