/// <summary> /// 依照檢驗計畫取得該物件的datatable /// </summary> /// <param name="QCTypeData"></param> /// <param name="objectName"></param> /// <returns></returns> public static DataTable GetInspectionData(QCTypeInfo QCTypeData, string objectName) { string sql = ""; DataTable dtQCTarget = null; #region 依照檢驗計畫取得該物件的datatable switch (QCTypeData.QCTarget) { case "MES_WIP_LOT": { LotInfo lot = LotInfo.GetLotByLot(objectName); if (lot == null) { throw new Exception(TextMessage.Error.T00378(objectName)); } dtQCTarget = lot.CopyDataToTable(lot.ID); } break; case "MES_WIP_COMP": { //取得component資訊以及所在的工作站 sql = @"SELECT L.OPERATION,C.* FROM MES_WIP_COMP C INNER JOIN MES_WIP_LOT L ON C.CURRENTLOT = L.LOT WHERE COMPONENTID = #[STRING]"; ComponentInfo comp = InfoCenter.GetBySQL <ComponentInfo>(sql, objectName); if (comp == null) { throw new Exception(TextMessage.Error.T00154(objectName)); } dtQCTarget = comp.CopyDataToTable(comp.ID); } break; case "MES_CMS_CAR": { CarrierInfo carrier = CarrierInfo.GetCarrierByCarrierNo(objectName); if (carrier == null) { throw new RuleCimesException(TextMessage.Error.T00725(objectName)); } dtQCTarget = carrier.CopyDataToTable(carrier.ID); } break; case "MES_TOOL_MAST": { ToolInfo tool = ToolInfo.GetToolByName(objectName); if (tool == null) { throw new Exception(TextMessage.Error.T00592(objectName)); } dtQCTarget = tool.CopyDataToTable(tool.ID); } break; case "MES_MMS_MLOT": { MaterialLotInfo mlot = MaterialLotInfo.GetMaterialLotByMaterialLot(objectName); if (mlot == null) { throw new Exception(TextMessage.Error.T00512(objectName)); } dtQCTarget = mlot.CopyDataToTable(mlot.ID); } break; case "MES_EQP_EQP": { EquipmentInfo equipment = EquipmentInfo.GetEquipmentByName(objectName); if (equipment == null) { throw new Exception(TextMessage.Error.T00885(objectName)); } dtQCTarget = equipment.CopyDataToTable(equipment.ID); } break; default: { sql = string.Format("SELECT * FROM {0} WHERE {1} = #[STRING]", QCTypeData.QCTarget, QCTypeData.IdentityColumn); dtQCTarget = DBCenter.GetDataTable(sql, objectName); if (dtQCTarget == null || dtQCTarget.Rows.Count == 0) { throw new Exception(TextMessage.Error.T00030("InspectionTarget", objectName)); } } break; } #endregion return(dtQCTarget); }