/// <summary> /// 確定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnOK_Click(object sender, EventArgs e) { try { //確認是否輸入工件序號 ttbCompLot.Must(lblCompLot); //確認是否有選擇流程 ddlRoute.Must(lblRoute); //確認是否有選擇流程工作站 ddlRouteOperation.Must(lblRouteOperation); TransactionStamp txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName); using (var cts = CimesTransactionScope.Create()) { //以第一個工件序號為拆批的母批 var txnLotData = _MergeLotDataList[0]; //取得原因碼資料 var reasonData = ReasonCategoryInfo.GetReasonCategoryByCategoryNameAndReason("Common", "OTHER"); #region 執行拆批 //批號子單元清單 var lsComponetData = ComponentInfoEx.GetDataByCurrentLot(txnLotData.Lot); //取得併批批號名稱 var splitLotNaming = GetNamingRule("SplitLot", txnStamp.UserID, txnLotData); //批號拆批 var splitLot = SplitLotInfo.CreateSplitLotByLotAndQuantity(txnLotData.Lot, splitLotNaming.First[0], lsComponetData, reasonData, reasonData.Description); WIPTxn.Default.SplitLot(txnLotData, splitLot, WIPTxn.SplitIndicator.Create(null, null, null, TerminateBehavior.TerminateWithHistory), txnStamp); //將批號的UDC08註記N WIPTransaction.ModifyLotSystemAttribute(splitLot, "USERDEFINECOL08", "N", txnStamp); if (splitLotNaming.Second != null && splitLotNaming.Second.Count != 0) { DBCenter.ExecuteSQL(splitLotNaming.Second); } #endregion #region 執行併批 //移除第一個工件序號(因為拆批已處理過了) _MergeLotDataList.RemoveAt(0); List <MergeLotInfo> lsMergeLots = new List <MergeLotInfo>(); foreach (var mergeLot in _MergeLotDataList) { //批號子單元清單 var componetDataList = ComponentInfoEx.GetDataByCurrentLot(mergeLot.Lot); //加入併批清單 lsMergeLots.Add(MergeLotInfo.GetMergeLotByLotAndQuantity(mergeLot.Lot, componetDataList, reasonData, reasonData.Description)); } //將數量合併到在狀態為Run的批號上 if (lsMergeLots.Count > 0) { WIPTransaction.MergeLot(splitLot, lsMergeLots, txnStamp); } #endregion #region 變更流程 //取得料號版本資料 var deviceVersionData = DeviceVersionInfo.GetDeviceVersion(splitLot.DeviceName, splitLot.DeviceVersion); //取得所選擇的流程資料 var routeData = InfoCenter.GetBySID <RouteInfo>(ddlRoute.SelectedValue); //取得所選擇流程目前線上版本資料 var routeVersionData = RouteVersionInfo.GetActiveRouteVersion(routeData); //取得所選擇的流程工作站資料 var routeOpeartionData = InfoCenter.GetBySID <RouteOperationInfo>(ddlRouteOperation.SelectedValue); WIPTransaction.ReassignRoute(splitLot, deviceVersionData, routeVersionData, routeOpeartionData, reasonData, reasonData.Description, txnStamp); #endregion cts.Complete(); } ClearField(); AjaxFocus(ttbCompLot); _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614("")); } catch (Exception ex) { HandleError(ex); } }