예제 #1
0
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                // 子單元不存在拋錯
                if (ComponentInfo == null)
                {
                    throw new RuleCimesException(TextMessage.Error.T00045(GetUIResource("Component")));
                }
                // 批號不存在拋錯
                if (ProcessLotData == null)
                {
                    throw new RuleCimesException(TextMessage.Error.T00045(GetUIResource("Lot")));
                }
                // 定義交易戳記
                var txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);
                using (var cts = CimesTransactionScope.Create())
                {
                    bool inSpec = true;
                    if (_CenterHoleFlag != "N")
                    {
                        gvComponentEDC.Rows.LoopDo <GridViewRow>((p, i) => {
                            // 取得TextBox Control
                            var ttbEDC = p.FindControl("ttbEDC") as TextBox;
                            if (ttbEDC.Text.IsNullOrEmpty())
                            {
                                throw new RuleCimesException(TextMessage.Error.T00043(GetUIResource("CenterHoleData")));
                            }
                            // 是否符合規格判斷
                            var measureVal = ttbEDC.Text.ToDecimal();
                            if (measureVal > SAICenterHole.Remark02.ToDecimal())
                            {
                                inSpec = false;
                            }

                            if (measureVal < SAICenterHole.Remark03.ToDecimal())
                            {
                                inSpec = false;
                            }
                            // 將量測資料記錄到客製表
                            var edcCompInfo              = InfoCenter.Create <CSTEDCComponentInfo>();
                            edcCompInfo.ComponentID      = ComponentInfo.ComponentID;
                            edcCompInfo.Data             = measureVal;
                            edcCompInfo.UpSpecification  = SAICenterHole.Remark02.ToDecimal();
                            edcCompInfo.LowSpecification = SAICenterHole.Remark03.ToDecimal();
                            edcCompInfo.INSPEC           = inSpec == true ? "OK" : "NG";
                            edcCompInfo.Lot              = ProcessLotData.Lot;
                            edcCompInfo["LINKSID"]       = txnStamp.LinkSID;
                            edcCompInfo["PARAMETER"]     = "SC" + (i + 1).ToString();
                            edcCompInfo.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                        });
                    }

                    if (!ttbTemperature.Text.IsNullOrEmpty())
                    {
                        // 溫度必須是數值
                        ttbTemperature.MustDecimal(lblTemperature);
                        // 將量測資料記錄到客製表
                        var edcCompInfo = InfoCenter.Create <CSTEDCComponentInfo>();
                        edcCompInfo.ComponentID  = ComponentInfo.ComponentID;
                        edcCompInfo.Data         = ttbTemperature.Text.ToDecimal();
                        edcCompInfo.Lot          = ProcessLotData.Lot;
                        edcCompInfo["LINKSID"]   = txnStamp.LinkSID;
                        edcCompInfo["PARAMETER"] = "Temperature";
                        edcCompInfo.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                    }

                    var lstCompAttr = new List <ModifyAttributeInfo>();
                    // 紀錄子單元量測時間
                    lstCompAttr.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("CENTER_HOLE_TIME", txnStamp.RecordTime));
                    lstCompAttr.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("DMC", ttbWorkpiece.Text.Trim()));
                    if (inSpec)
                    {
                        // 修改子單元系統屬性
                        lstCompAttr.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("CENTER_HOLE_FLAG", "OK"));
                        WIPTransaction.ModifyLotComponentMultipleAttribute(ProcessLotData, ComponentInfo, lstCompAttr, txnStamp);
                    }
                    else
                    {
                        // 修改子單元系統屬性
                        lstCompAttr.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("CENTER_HOLE_FLAG", "NG"));
                        WIPTransaction.ModifyLotComponentMultipleAttribute(ProcessLotData, ComponentInfo, lstCompAttr, txnStamp);

                        #region 若不在規格範圍內則拆批至待判站點
                        var                  lstSourceLot         = new List <LotInfo>();
                        List <SqlAgent>      splitLotArchiSQLList = new List <SqlAgent>();
                        List <ComponentInfo> lsComponentDatas     = new List <ComponentInfo>();
                        lsComponentDatas.Add(ComponentInfo);

                        var generator = NamingIDGenerator.GetRule("SplitLot");
                        if (generator == null)
                        {
                            //WRN-00411,找不到可產生的序號,請至命名規則維護設定,規則名稱:{0}!!!
                            throw new Exception(TextMessage.Error.T00437("SplitLot"));
                        }
                        var serialData = generator.GenerateNextIDs(1, ProcessLotData, new string[] { }, User.Identity.Name);
                        splitLotArchiSQLList = serialData.Second;
                        var splitLotID = serialData.First[0];

                        var          reasonCategoryInfo = ReasonCategoryInfo.GetReasonCategoryByCategoryNameAndReason("Common", "OTHER");
                        SplitLotInfo splitLotData       = SplitLotInfo.CreateSplitLotByLotAndQuantity(ProcessLotData.Lot, splitLotID, lsComponentDatas, reasonCategoryInfo, "EDC");

                        WIPTxn.SplitIndicator splitInd = WIPTxn.SplitIndicator.Create();
                        WIPTxn.Default.SplitLot(ProcessLotData, splitLotData, splitInd, txnStamp);

                        //若子單元為自動產生,更新序號至DB
                        if (splitLotArchiSQLList != null && splitLotArchiSQLList.Count > 0)
                        {
                            DBCenter.ExecuteSQL(splitLotArchiSQLList);
                        }
                        #endregion

                        var splitLotInfo = LotInfo.GetLotByLot(splitLotID);

                        // 新增Defect
                        List <ComponentDefectObject> lstCompDefectObj = new List <ComponentDefectObject>();
                        var reason = ReasonCategoryInfo.GetReasonCategoryByCategoryNameAndReason("CustomizeReason", "MeasureNG_MES");
                        lstCompDefectObj.Add(ComponentDefectObject.Create(ComponentInfo, 1, 0, reason, "CENTER_HOLE_FLAG:NG"));
                        WIPTransaction.DefectComponent(splitLotInfo, lstCompDefectObj, WIPTransaction.DefectIndicator.Create(), txnStamp);

                        #region ReassignOperation
                        // 取得待判站點設定
                        var saiJudgeOperation = WpcExClassItemInfo.GetExClassItemInfo("SAIJudgeOperation", splitLotInfo["PROCESS"].ToString());
                        if (saiJudgeOperation.Count == 0)
                        {
                            throw new RuleCimesException(TextMessage.Error.T00555("SAIJudgeOperation", splitLotInfo["PROCESS"].ToString()));
                        }
                        var reassignOperationInfo = RouteOperationInfo.GetLotAllRouteOperations(splitLotInfo).Find(oper => oper.OperationName == saiJudgeOperation[0].Remark02);
                        if (reassignOperationInfo == null)
                        {
                            throw new RuleCimesException(RuleMessage.Error.C10050());
                        }

                        var lstLotAttr = new List <ModifyLotAttributeInfo>();
                        // 修改批號系統屬性
                        lstLotAttr.Add(ModifyLotAttributeInfo.CreateLotSystemAttributeInfo("USERDEFINECOL01", "Y"));
                        lstLotAttr.Add(ModifyLotAttributeInfo.CreateLotSystemAttributeInfo("USERDEFINECOL02", splitLotInfo.OperationSequence));
                        lstLotAttr.Add(ModifyLotAttributeInfo.CreateLotSystemAttributeInfo("USERDEFINECOL03", splitLotInfo.OperationName));
                        WIPTransaction.ModifyLotMultipleAttribute(splitLotInfo, lstLotAttr, txnStamp);
                        WIPTransaction.ReassignOperation(splitLotInfo, reassignOperationInfo, reasonCategoryInfo, "EDCSplitReassignOperation", txnStamp);
                        WIPTransaction.ResetLotRule(splitLotInfo, txnStamp);
                        #endregion
                    }
                    cts.Complete();
                }

                ClearUI();
                AjaxFocus(ttbWorkpiece);
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
예제 #2
0
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                ttbEquipment.Must(lblEquipment);
                ddlOperation.Must(lblOperation);
                csReason.Must(lblTakeReason);

                if (_TakeToolLifeList.Count == 0)
                {
                    // [00824]請新增[刀頭]!
                    throw new RuleCimesException(TextMessage.Error.T00824(lblMillHeader.Text));
                }

                string groupid  = DBCenter.GetSystemID();
                var    txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);
                using (var cts = CimesTransactionScope.Create())
                {
                    _TakeToolLifeList.ForEach(tool =>
                    {
                        // 變更GROUPID與HEAD系統屬性
                        // HEAD紀錄目前刀具使用的刀頭
                        // GROUPID紀錄目前綁定的刀具
                        var toolInfo       = ToolInfo.GetToolByName(tool.ToolName);
                        var modifyAttrList = new List <ModifyAttributeInfo>();
                        modifyAttrList.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("GROUPID", groupid));
                        modifyAttrList.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("HEAD", tool.Head));
                        modifyAttrList.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("LOCATION", "Hub"));
                        //因刀具報表需求,所以在領用時要AddComment,並將刀面及使用次數記錄在UDC06 & UDC07
                        modifyAttrList.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("USERDEFINECOL06", tool.Head));
                        modifyAttrList.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("USERDEFINECOL07", tool.UseCount));
                        modifyAttrList.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("USERDEFINECOL08", tool.Operation));
                        TMSTransaction.ModifyToolMultipleAttribute(toolInfo, modifyAttrList, txnStamp);

                        txnStamp.Remark             = "刀具領用";
                        var reasonCategory          = InfoCenter.GetBySID <ReasonCategoryInfo>(csReason.SelectedValue);
                        txnStamp.CategoryReasonCode = reasonCategory;
                        txnStamp.Description        = "";
                        TMSTransaction.AddToolComment(toolInfo, txnStamp);
                    });

                    // 寫入CSTToolIssue客製表
                    var toolIssueInfo = InfoCenter.Create <CSTToolIssueInfo>();
                    toolIssueInfo.TOTALQTY      = _TakeToolLifeList.Count;
                    toolIssueInfo.Reason        = csReason.GetBusinessReason().ReasonCode;
                    toolIssueInfo.EquipmentName = _EquipmentInfo == null ? "" : _EquipmentInfo.EquipmentName;
                    toolIssueInfo.LinkSID       = txnStamp.LinkSID;
                    toolIssueInfo.Action        = "領用";
                    toolIssueInfo.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                    cts.Complete();
                }

                ClearField();
                AjaxFocus(ttbMillName);

                ((ProgramInformationBlock)ProgramInformationBlock1).ShowMessage(TextMessage.Hint.T00057("領用"));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }