Exemple #1
0
        /// <summary>
        /// 確定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                #region 確認選擇結果,如果是選擇NG,確認是否有選擇原因碼
                string result = "";
                if (rdbOK.Checked)
                {
                    result = "OK";
                }
                else if (rdbNG.Checked)
                {
                    result = "NG";

                    //確認是否有選擇原因碼
                    ddlPQCReasonCode.Must(lblPQCReasonCode);
                }
                #endregion

                TransactionStamp txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);

                using (var cts = CimesTransactionScope.Create())
                {
                    #region 更新檢驗主檔[MES_QC_INSP]
                    //取得檢驗主檔資料
                    var QCInsepctionData = InfoCenter.GetBySID <QCInspectionInfo>(_SelectedQCData.QCInspectionSID).ChangeTo <QCInspectionInfoEx>();

                    //有選擇原因碼才更新[NG_Category]及[NG_Reason]
                    if (string.IsNullOrEmpty(ddlPQCReasonCode.SelectedValue) == false)
                    {
                        var reason = InfoCenter.GetBySID <ReasonCategoryInfo>(ddlPQCReasonCode.SelectedValue);
                        QCInsepctionData.NG_Category = reason.Category;
                        QCInsepctionData.NG_Reason   = reason.Reason;
                    }

                    QCInsepctionData.NG_Description = ttbDescr.Text;
                    QCInsepctionData.Result         = result;
                    QCInsepctionData.Status         = "Finished";

                    QCInsepctionData.UpdateToDB(txnStamp.UserID, txnStamp.RecordTime);

                    #endregion

                    #region 更新自主檢數據內容[CST_EDC_COMP]
                    bool inSpec = true;

                    gvComponentEDC.Rows.LoopDo <GridViewRow>((p, i) => {
                        // 取得TextBox Control
                        var ttbEDC = p.FindControl("ttbEDC") as TextBox;
                        if (ttbEDC.Text.IsNullOrEmpty())
                        {
                            AjaxFocus(ttbEDC);
                            throw new Exception(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 lotData = ComponentInfo.GetComponentByComponentID(_SelectedQCData.ComponentLot);

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

                    #region 更新機台狀態及更新檢驗單對應的批號資料

                    //如果選擇結果為NG時,則更新機台狀態及更新檢驗單對應的批號資料
                    if (rdbNG.Checked)
                    {
                        //取得機台狀態資料
                        var newStateInfo = EquipmentStateInfo.GetEquipmentStateByState("DOWN");

                        var equipData = EquipmentInfo.GetEquipmentByName(_SelectedQCData.EquipmentName);

                        //如果機台狀態為IDLE,則變更狀態為DOWN
                        if (equipData.CurrentState == "IDLE")
                        {
                            //更新機台狀態
                            EMSTransaction.ChangeState(equipData, newStateInfo, txnStamp);
                        }
                        else
                        {
                            //如果機台狀態不為IDLE,則註記機台[USERDEFINECOL01]為Y
                            EMSTransaction.ModifyEquipmentSystemAttribute(equipData, "USERDEFINECOL01", "Y", txnStamp);
                        }

                        //上一次的檢驗單號資料
                        QCInspectionInfoEx previousInspectionData = null;

                        //依據機台及料號查詢,然後用建立時間逆排序,找出所有FAI及MPQC的檢驗單號資料
                        var QCDataList = QCInspectionInfoEx.GetInspDataListByEquipmentAndDevice(QCInsepctionData.EquipmentName, QCInsepctionData.DeviceName);

                        //如果筆數大於1,則目前檢驗單號的索引值
                        if (QCDataList.Count > 1)
                        {
                            //找出目前檢驗單號的索引值
                            var NGIndex = QCDataList.FindIndex(p => p.InspectionNo == QCInsepctionData.InspectionNo);

                            //如果找到的索引值不是最後一筆的話,則找出上一次的檢驗單號資料
                            if (NGIndex != (QCDataList.Count - 1))
                            {
                                //找出上一次的檢驗單號資料
                                previousInspectionData = QCDataList[NGIndex + 1];
                            }
                        }

                        //取得目前檢驗單號的批號子單元資料
                        var componentList = ComponentInfoEx.GetDataByInspectionNo(QCInsepctionData.InspectionNo);
                        componentList.ForEach(component =>
                        {
                            //取得批號資料
                            var lotData = LotInfo.GetLotByLot(component.CurrentLot);

                            //更新欄位[PQCNGFLAG]
                            WIPTransaction.ModifyLotComponentSystemAttribute(lotData, component, "PQCNGFLAG", "Y", txnStamp);

                            //更新欄位[PQCNGNO]
                            WIPTransaction.ModifyLotComponentSystemAttribute(lotData, component, "PQCNGNO", QCInsepctionData.InspectionNo, txnStamp);
                        });

                        if (previousInspectionData != null)
                        {
                            //取得上一次檢驗單號的批號子單元資料
                            var previousComponentList = ComponentInfoEx.GetDataByInspectionNo(previousInspectionData.InspectionNo);

                            //取得不需要註記的ComponentID
                            var passInspectionDataList = QCInspectionObjectInfo.GetInspectionObjects(previousInspectionData);

                            previousComponentList.ForEach(component =>
                            {
                                //確認是否為不需要註記的ComponentID
                                if (passInspectionDataList.FindIndex(p => p.ItemName1 == component.ComponentID) == -1)
                                {
                                    //取得批號資料
                                    var lotData = LotInfo.GetLotByLot(component.CurrentLot);

                                    //更新欄位[PQCNGFLAG]
                                    WIPTransaction.ModifyLotComponentSystemAttribute(lotData, component, "PQCNGFLAG", "Y", txnStamp);

                                    //更新欄位[PQCNGNO]
                                    WIPTransaction.ModifyLotComponentSystemAttribute(lotData, component, "PQCNGNO", QCInsepctionData.InspectionNo, txnStamp);
                                }
                            });
                        }
                    }
                    #endregion

                    cts.Complete();
                }

                ClearField();
                AjaxFocus(ttbLot);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
Exemple #2
0
        /// <summary>
        /// 確定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                #region 確認選擇結果,如果是選擇NG,確認是否有選擇原因碼
                string result = "";
                if (rdbOK.Checked)
                {
                    result = "OK";
                }
                else if (rdbNG.Checked)
                {
                    result = "NG";

                    //確認是否有選擇原因碼
                    ddlPQCReasonCode.Must(lblPQCReasonCode);
                }
                else if (rdbCLOSE.Checked)
                {
                    result = "CLOSE";

                    //確認是否有選擇原因碼
                    ddlPQCReasonCode.Must(lblPQCReasonCode);
                }
                #endregion

                TransactionStamp txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);

                using (var cts = CimesTransactionScope.Create())
                {
                    #region 更新檢驗主檔[MES_QC_INSP]
                    //取得檢驗主檔資料
                    var QCInsepctionData = InfoCenter.GetBySID <QCInspectionInfo>(_SelectedQCData.QCInspectionSID).ChangeTo <QCInspectionInfoEx>();

                    //原因碼
                    ReasonCategoryInfo reason = null;

                    //有選擇原因碼才更新[NG_Category]及[NG_Reason]
                    if (string.IsNullOrEmpty(ddlPQCReasonCode.SelectedValue) == false)
                    {
                        reason = InfoCenter.GetBySID <ReasonCategoryInfo>(ddlPQCReasonCode.SelectedValue);
                        QCInsepctionData.NG_Category = reason.Category;
                        QCInsepctionData.NG_Reason   = reason.Reason;
                    }

                    //如果判定結果為結單的話,則必須把結單時間及人員資料寫回資料庫
                    if (result == "CLOSE")
                    {
                        QCInsepctionData.FINISHTIME = txnStamp.RecordTime;
                        QCInsepctionData.FINISHUSER = txnStamp.UserID;
                    }

                    QCInsepctionData.NG_Description = ttbDescr.Text;
                    QCInsepctionData.Result         = result;
                    QCInsepctionData.Status         = "Finished";

                    QCInsepctionData.UpdateToDB(txnStamp.UserID, txnStamp.RecordTime);

                    #endregion

                    #region 更新機台檢驗主檔[CST_WIP_CMM]

                    if (_CSTWIPCMMList != null)
                    {
                        //更新檢驗主檔的QCInspectionSID欄位
                        _CSTWIPCMMList.ForEach(data =>
                        {
                            data.QCInspectionSID = QCInsepctionData.ID;
                            data.UpdateToDB();
                        });
                    }

                    #endregion

                    #region 更新機台狀態及更新檢驗單對應的批號資料

                    //如果選擇結果為NG時,則更新機台狀態及更新檢驗單對應的批號資料
                    if (rdbNG.Checked)
                    {
                        //取得機台狀態資料
                        var newStateInfo = EquipmentStateInfo.GetEquipmentStateByState("DOWN");

                        var equipData = EquipmentInfo.GetEquipmentByName(_SelectedQCData.EquipmentName);

                        //如果機台狀態為IDLE,則變更狀態為DOWN
                        if (equipData.CurrentState == "IDLE")
                        {
                            //更新機台狀態
                            EMSTransaction.ChangeState(equipData, newStateInfo, txnStamp);
                        }
                        else
                        {
                            //如果機台狀態不為IDLE,則註記機台[USERDEFINECOL01]為Y
                            EMSTransaction.ModifyEquipmentSystemAttribute(equipData, "USERDEFINECOL01", "Y", txnStamp);
                        }

                        //上一次的檢驗單號資料
                        QCInspectionInfoEx previousInspectionData = null;

                        //依據機台及料號查詢,然後用建立時間逆排序,找出所有FAI及PQC的檢驗單號資料
                        var QCDataList = QCInspectionInfoEx.GetInspDataListByEquipmentAndDevice(QCInsepctionData.EquipmentName, QCInsepctionData.DeviceName);

                        //如果筆數大於1,則目前檢驗單號的索引值
                        if (QCDataList.Count > 1)
                        {
                            //找出目前檢驗單號的索引值
                            var NGIndex = QCDataList.FindIndex(p => p.InspectionNo == QCInsepctionData.InspectionNo);

                            //如果找到的索引值不是最後一筆的話,則找出上一次的檢驗單號資料
                            if (NGIndex != (QCDataList.Count - 1))
                            {
                                //找出上一次的檢驗單號資料
                                previousInspectionData = QCDataList[NGIndex + 1];
                            }
                        }

                        //取得目前檢驗單號的批號子單元資料
                        var componentList = ComponentInfoEx.GetDataByInspectionNo(QCInsepctionData.InspectionNo);
                        componentList.ForEach(component =>
                        {
                            //取得批號資料
                            var lotData = LotInfo.GetLotByLot(component.CurrentLot);

                            //更新欄位[PQCNGFLAG]
                            WIPTransaction.ModifyLotComponentSystemAttribute(lotData, component, "PQCNGFLAG", "Y", txnStamp);

                            //更新欄位[PQCNGNO]
                            WIPTransaction.ModifyLotComponentSystemAttribute(lotData, component, "PQCNGNO", QCInsepctionData.InspectionNo, txnStamp);
                        });

                        if (previousInspectionData != null)
                        {
                            //取得上一次檢驗單號的批號子單元資料
                            var previousComponentList = ComponentInfoEx.GetDataByInspectionNo(previousInspectionData.InspectionNo);

                            //取得不需要註記的ComponentID
                            var passInspectionDataList = QCInspectionObjectInfo.GetInspectionObjects(previousInspectionData);

                            previousComponentList.ForEach(component =>
                            {
                                //確認是否為不需要註記的ComponentID
                                if (passInspectionDataList.FindIndex(p => p.ItemName1 == component.ComponentID) == -1)
                                {
                                    //取得批號資料
                                    var lotData = LotInfo.GetLotByLot(component.CurrentLot);

                                    //更新欄位[PQCNGFLAG]
                                    WIPTransaction.ModifyLotComponentSystemAttribute(lotData, component, "PQCNGFLAG", "Y", txnStamp);

                                    //更新欄位[PQCNGNO]
                                    WIPTransaction.ModifyLotComponentSystemAttribute(lotData, component, "PQCNGNO", QCInsepctionData.InspectionNo, txnStamp);
                                }
                            });
                        }
                    }
                    #endregion

                    //如果判定結果選擇為NG,則必須拆批送待判
                    if (rdbNG.Checked)
                    {
                        //判定NG直接拆批及送待判工作站
                        CustomizeFunction.SplitDefectLot(_SelectedQCData.ComponentLot, ttbDescr.Text, reason, txnStamp);
                    }

                    cts.Complete();
                }

                ClearField();
                AjaxFocus(ttbLot);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }