Пример #1
0
        /// <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);
            }
        }
Пример #2
0
        /// <summary>
        /// 流程切換
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ddlRoute_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                //清除資料
                ddlRouteOperation.Items.Clear();
                ddlRouteOperation.Enabled = false;

                //確認是否有選擇流程
                ddlRoute.Must(lblRoute);

                //取得所選擇的流程資料
                var routeData = InfoCenter.GetBySID <RouteInfo>(ddlRoute.SelectedValue);

                //取得所選擇流程目前線上版本資料
                var routeVersionData = RouteVersionInfo.GetActiveRouteVersion(routeData);

                //取得所選擇流程目前線上版本的所有工作站資料
                var routeOperationList = RouteOperationInfo.GetRouteAllOperations(routeVersionData);
                if (routeOperationList.Count > 0)
                {
                    List <RouteOperationData> routeOperationDataList = new List <RouteOperationData>();

                    //轉換型態
                    routeOperationList.ForEach(data =>
                    {
                        var operData = OperationInfo.GetOperationByName(data.OperationName);

                        //CNC的站點不可併批(需排除),因為CNC後才能併批
                        if (operData["AUTOMERGE"].ToBool() == false && operData["FAIFLAG"].ToBool() == false && operData["MAIN_EQUIP"].ToBool() == false)
                        {
                            RouteOperationData routeOperationData = new RouteOperationData();
                            routeOperationData.OperationName      = string.Format("[{0}]{1}", data.OperationSequence, data.OperationName);
                            routeOperationData.RouteOperationSID  = data.RouteOperationSID;

                            routeOperationDataList.Add(routeOperationData);
                        }
                    });

                    ddlRouteOperation.DataSource     = routeOperationDataList;
                    ddlRouteOperation.DataTextField  = "OperationName";
                    ddlRouteOperation.DataValueField = "RouteOperationSID";
                    ddlRouteOperation.DataBind();

                    if (ddlRouteOperation.Items.Count != 1)
                    {
                        ddlRouteOperation.Items.Insert(0, "");
                    }
                    else
                    {
                        ddlRouteOperation.SelectedIndex = 0;
                    }

                    ddlRouteOperation.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }