/// <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); }
private DataSet GetRunCardDataSource(LotInfo LotData) { string sql = ""; #region 定義 LOTDATA 資料表 DataTable dtLotData = LotData.CopyDataToTable("LOTDATA"); dtLotData.Columns.Add("CartonNo"); dtLotData.Columns.Add("DeviceDescr1"); dtLotData.Columns.Add("DeviceDescr2"); dtLotData.Columns.Add("CustomerNo1"); dtLotData.Columns.Add("CustomerNo2"); dtLotData.Columns.Add("Device1"); dtLotData.Columns.Add("Device2"); dtLotData.Columns.Add("Quantity1"); dtLotData.Columns.Add("Quantity2"); dtLotData.Columns.Add("Remark"); dtLotData.Columns.Add("Inspectors"); dtLotData.Columns.Add("Packers"); dtLotData.Columns.Add("InspectionDate"); #endregion #region 定義 COMPDATA 資料表 DataTable dtCompData = new DataTable("COMPDATA"); dtCompData.Columns.Add("ComponentID1"); dtCompData.Columns.Add("ComponentID2"); dtCompData.Columns.Add("Quantity1"); dtCompData.Columns.Add("Quantity2"); #endregion dtLotData.Rows[0]["CartonNo"] = LotData.Lot; dtLotData.Rows[0]["Remark"] = ""; var packInfo = CSTWIPPackInfo.GetPackInfoByBoxNo(LotData.Lot); dtLotData.Rows[0]["Inspectors"] = packInfo.INSPUSER; dtLotData.Rows[0]["Packers"] = packInfo.UserID; dtLotData.Rows[0]["InspectionDate"] = packInfo.UpdateTime.Replace("/", "-"); sql = @" SELECT DEVICE,COUNT(*) QTY FROM CST_WIP_PACK INNER JOIN CST_WIP_PACK_DATA ON CST_WIP_PACK.WIP_PACK_SID = CST_WIP_PACK_DATA.WIP_PACK_SID WHERE BOXNO = #[STRING] GROUP BY DEVICE"; DataTable dtData = DBCenter.GetDataTable(sql, LotData.Lot); int iIndex = 1; for (int i = 0; i < dtData.Rows.Count; i++) { if (i >= 2) { break; } iIndex = i + 1; dtLotData.Rows[0]["Quantity" + iIndex.ToCimesString()] = dtData.Rows[i]["QTY"].ToCimesString(); var DeviceData = DeviceVersionInfoEx.GetActiveDeviceVersion(dtData.Rows[i]["DEVICE"].ToCimesString()).ChangeTo <DeviceVersionInfoEx>(); if (DeviceData != null) { dtLotData.Rows[0]["DeviceDescr" + iIndex.ToCimesString()] = DeviceData.Description; dtLotData.Rows[0]["CustomerNo" + iIndex.ToCimesString()] = DeviceData["CustomerNo"].ToCimesString(); dtLotData.Rows[0]["Device" + iIndex.ToCimesString()] = DeviceData.DeviceName; } #region 入庫批號 sql = @"SELECT DMC,COUNT(*) COMPONENTQTY FROM CST_WIP_PACK INNER JOIN CST_WIP_PACK_DATA ON CST_WIP_PACK.WIP_PACK_SID = CST_WIP_PACK_DATA.WIP_PACK_SID WHERE BOXNO = #[STRING] AND DEVICE = #[STRING] GROUP BY DMC ORDER BY DMC "; var dt = DBCenter.GetDataTable(sql, LotData.Lot, DeviceData.DeviceName); if (dt.Rows.Count > dtCompData.Rows.Count) { int iRowCount = dt.Rows.Count - dtCompData.Rows.Count; for (int j = 0; j < iRowCount; j++) { DataRow dr = dtCompData.NewRow(); dtCompData.Rows.Add(dr); } } for (int k = 0; k < dt.Rows.Count; k++) { dtCompData.Rows[k]["ComponentID" + iIndex.ToCimesString()] = dt.Rows[k]["DMC"].ToString(); dtCompData.Rows[k]["Quantity" + iIndex.ToCimesString()] = dt.Rows[k]["COMPONENTQTY"].ToString(); } #endregion } dtCompData.AcceptChanges(); DataSet dsReportData = new DataSet(); dsReportData.Tables.Add(dtLotData); dsReportData.Tables.Add(dtCompData); return(dsReportData); }