예제 #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";

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

                    //確認是否有選擇原因碼
                    ddlFAIReasonCode.Must(lblFAIReasonCode);
                }
                #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(ddlFAIReasonCode.SelectedValue) == false)
                    {
                        reason = InfoCenter.GetBySID <ReasonCategoryInfo>(ddlFAIReasonCode.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 更新機台資訊

                    //取得相同BatchID的檢驗資料
                    var QCDataList = QCInspectionInfoEx.GetDataListByBatchID(_SelectedQCData.BatchID);

                    //相同BatchID都已完成檢驗旗標
                    bool isAllFinish = true;

                    QCDataList.ForEach(p =>
                    {
                        if (!(p.Status == "Finished"))
                        {
                            isAllFinish = false;
                        }
                    });

                    //取得lot資料
                    var lot = InfoCenter.GetBySID <LotInfo>(_SelectedQCData.ObjectSID);

                    //更新機台屬性[FAICOUNT]
                    CustomizeFunction.UpdateFAI(_SelectedQCData.EquipmentName, lot.Lot, (rdbNG.Checked) ? true : false, txnStamp);

                    //如果相同的BatchID都檢驗完成或選擇結果為NG時,則更新狀態為IDLE及更新FAICOUNT
                    if (isAllFinish)
                    {
                        //取得機台狀態資料
                        var newStateInfo = EquipmentStateInfo.GetEquipmentStateByState("IDLE");

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

                        //更新機台狀態
                        EMSTransaction.ChangeState(equipData, newStateInfo, 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);
            }
        }
예제 #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);
            }
        }