Example #1
0
        /// <summary>
        /// 依照輸入LotID取得相關欄位資料及相關Button設定
        /// </summary>
        /// <param name="LotID">批號名稱</param>
        private void LoadControlByLot(string LotID)
        {
            // 清除欄位資訊
            ClearField();
            if (cbxWO.Checked)
            {
                _LotData = LotInfoEx.GetLotByWorkOrderLot(LotID);
            }

            if (cbxLot.Checked)
            {
                _LotData = LotInfoEx.GetLotByLot(LotID);
            }

            if (cbxSN.Checked)
            {
                var lot = CustomizeFunction.ConvertDMCCode(LotID);

                var compInfo = ComponentInfoEx.GetComponentByComponentID(lot);
                if (compInfo == null)
                {
                    var compList = ComponentInfoEx.GetComponentByDMCCode(lot);
                    if (compList.Count != 0)
                    {
                        compInfo = compList[0];
                    }
                }

                if (compInfo != null)
                {
                    _LotData = LotInfo.GetLotByLot(compInfo.CurrentLot).ChangeTo <LotInfoEx>();
                }
            }

            // 若該批號無資料可顯示,離開程式並顯示訊息
            if (_LotData == null)
            {
                btnPrint.Enabled = false;
                AjaxFocus(ttbWOLot);
                throw new Exception(TextMessage.Error.T00060(LotID));
            }

            btnPrint.Enabled = true;
        }
Example #2
0
        protected void ttbWOLot_TextChanged(object sender, EventArgs e)
        {
            try
            {
                /***************************************************************************************
                 * 依照PRODTYP不同,做不同畫面的處置:
                 * S:有序號,一律刷入DMC處理。
                 * G:僅有鍛造批,選擇要判定的工作站,系統找出該工作站所有的COMPONENT,順排取最後一個
                 * W:沒有刻字,選擇要判定的工作站,系統找出該工作站所有的COMPONENT,順排取最後一個
                 * B:有刻字,但序號無意義。
                 *    在刻字站前因為未刻字所以選擇要判定的工作站,系統找出該工作站所有的COMPONENT,順排取最後一個
                 *    刻字後,直接刷入DMC處理
                 **********************************************************/
                // 清除資料與使用者介面
                ClearField();

                LoadDefaultControl();

                string sWOLot = ttbWOLot.Text.Trim();
                if (sWOLot.IsNullOrEmpty())
                {
                    return;
                }

                #region 找出料號型態
                // 小工單號找批號,此處找批號只是為了找出料號,也順便可以確認線上還有批號可以做送待判這件事
                ProcessLotData = LotInfoEx.GetLotByWorkOrderLot(sWOLot);
                if (ProcessLotData == null)
                {
                    ProcessLotData = LotInfoEx.GetLotByLot(sWOLot);
                }

                if (ProcessLotData == null)
                {
                    ttbWOLot.Text = "";
                    AjaxFocus(ttbWOLot);
                    throw new RuleCimesException(TextMessage.Error.T00030(GetUIResource("WOLot"), sWOLot));
                }

                //取得小工單號的料號版本
                var deviceVersionInfo = DeviceVersionInfo.GetLotCurrentDeviceVersion(ProcessLotData).ChangeTo <DeviceVersionInfoEx>();
                if (deviceVersionInfo == null)
                {
                    throw new CimesException(TextMessage.Error.T00537(ProcessLotData.DeviceName));
                }

                if (deviceVersionInfo.ProdType.IsNullOrTrimEmpty())
                {
                    ttbWOLot.Text = "";
                    AjaxFocus(ttbWOLot);
                    throw new RuleCimesException(TextMessage.Error.T00031(GetUIResource("Device"), deviceVersionInfo.DeviceName, "PRODTYPE"));
                }
                _ProdType = deviceVersionInfo.ProdType;
                #endregion

                #region 取得工作站
                ddlOperation.Items.Clear();
                var lstLotRouteOperation = RouteOperationInfo.GetLotDefaultOperations(ProcessLotData).OrderBy(p => p.OperationSequence).ToList();
                lstLotRouteOperation.ForEach(oper => {
                    ddlOperation.Items.Add(new ListItem(oper.OperationName + "[" + oper.OperationSequence + "]", oper.OperationName));
                });
                ddlOperation.Items.Insert(0, "");
                #endregion

                #region 原因碼選項
                ddlDefectReason.Items.Clear();
                List <BusinessReason> reason = ReasonCategoryInfo.GetOperationRuleCategoryReasonsWithReasonDescr(ProgramRight, ProcessLotData.OperationName, "Default", ReasonMode.Category);
                if (reason.Count == 0)
                {
                    reason = ReasonCategoryInfo.GetOperationRuleCategoryReasonsWithReasonDescr(ProgramRight, "ALL", "Default", ReasonMode.Category);
                }

                if (reason.Count > 0)
                {
                    ddlDefectReason.DataSource     = reason;
                    ddlDefectReason.DataTextField  = "ReasonDescription";
                    ddlDefectReason.DataValueField = "ReasonCategorySID";
                    ddlDefectReason.DataBind();

                    if (ddlDefectReason.Items.Count != 1)
                    {
                        ddlDefectReason.Items.Insert(0, "");
                    }
                    else
                    {
                        ddlDefectReason.SelectedIndex = 0;
                    }
                }
                else
                {
                    //[00641]規則:{0} 工作站:{1} 使用的原因碼未設定,請洽IT人員!
                    throw new Exception(TextMessage.Error.T00641(ProgramRight, ProcessLotData.OperationName));
                }
                #endregion

                #region 依照PRODTYPE處理介面
                ttbDefectDesc.ReadOnly  = false;
                ddlDefectReason.Enabled = true;

                if (_ProdType == CustomizeFunction.ProdType.S.ToCimesString())
                {
                    ddlOperation.Enabled  = false;
                    ttbWorkpiece.ReadOnly = false;
                }

                if (_ProdType == CustomizeFunction.ProdType.W.ToCimesString() || _ProdType == CustomizeFunction.ProdType.G.ToCimesString())
                {
                    ttbWorkpiece.ReadOnly = true;
                    ddlOperation.Enabled  = true;
                }

                if (_ProdType == CustomizeFunction.ProdType.B.ToCimesString())
                {
                    ttbWorkpiece.ReadOnly = false;
                    ddlOperation.Enabled  = true;
                }
                #endregion

                #region 找出待判站
                //在系統資料維護裡,取得此批號對應製程(CPC/CPF)的待判工作站名稱
                List <WpcExClassItemInfo> operationList      = WpcExClassItemInfo.GetExtendItemListByClassAndRemarks("SAIJudgeOperation");
                WpcExClassItemInfo        judgeOperationData = operationList.Find(p => p.Remark01 == ProcessLotData.Process);
                if (judgeOperationData == null)
                {
                    //找不到待判站資訊,請至系統資料維護增加資訊,屬性:{0}
                    throw new Exception(RuleMessage.Error.C10014(ProcessLotData.Process));
                }

                //取得待判工作站名稱
                _JudgeOperationName = judgeOperationData.Remark02;

                #endregion

                if (ttbWorkpiece.Enabled)
                {
                    AjaxFocus(ttbWorkpiece);
                }
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
Example #3
0
        /// <summary>
        /// 確定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            /*******************************************************************
             * PPK判定後須執行事項:
             * 1. 依照判定的BATCHID+料號,將所屬單號資料更新。
             * 2. 依照判定狀態更新CST_WIP_PPK結果。
             * 3. 如同一個BATCHID都判定完成,變更機台狀態,從PPK變IDLE。
             *    如一個BATCHID有兩個料號,需兩個料號都判定完成才可以變更機台狀態。
             ******************************************************************/
            try
            {
                //取得所選擇的料號名稱
                var deviceName = ddlDevice.SelectedValue;

                #region 確認選擇結果,如果是選擇NG,確認是否有選擇原因碼及選擇結果及檢驗清單的勾選是否符合
                string result = "";
                if (rdbOK.Checked)
                {
                    result = "OK";
                }
                else if (rdbNG.Checked)
                {
                    result = "NG";

                    //確認是否有選擇原因碼
                    ddlPPKReasonCode.Must(lblPPKReasonCode);

                    if (SelectedNGData() == false)
                    {
                        //PPK結果選擇NG,檢驗清單至少勾選一筆資料!
                        throw new Exception(RuleMessage.Error.C10070());
                    }
                }
                else if (rdbCLOSE.Checked)
                {
                    result = "CLOSE";

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

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

                using (var cts = CimesTransactionScope.Create())
                {
                    #region 更新檢驗主檔清單[MES_QC_INSP]
                    _QCInspectionDataList.ForEach(QCInspectionData =>
                    {
                        //符合選擇的料號才進行資料更新
                        if (QCInspectionData.DeviceName == deviceName)
                        {
                            //有選擇原因碼才更新[NG_Category]及[NG_Reason]
                            if (string.IsNullOrEmpty(ddlPPKReasonCode.SelectedValue) == false)
                            {
                                var reason = InfoCenter.GetBySID <ReasonCategoryInfo>(ddlPPKReasonCode.SelectedValue);
                                QCInspectionData.NG_Category = reason.Category;
                                QCInspectionData.NG_Reason   = reason.Reason;
                            }

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

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

                            QCInspectionData.UpdateToDB(txnStamp.UserID, txnStamp.RecordTime);
                        }
                    });
                    #endregion

                    #region 更新機台資訊及檢驗工件結果

                    //取某一支工件序號的資料來傳入UpdatePPK
                    var updateLot = InfoCenter.GetBySID <LotInfo>(_QCInspectionObjDataList[0].OBJECTSID).ChangeTo <LotInfoEx>();

                    //更新[CST_WIP_PPK.PPKCOUNT]
                    CustomizeFunction.UpdatePPK(_QCInspectionDataList[0].EquipmentName, updateLot.DeviceName, updateLot.DeviceVersion, (rdbNG.Checked) ? "false" : "true");

                    //將介面上所勾選/不勾選的資料對應到MES_QC_INSP_OBJ.ITEM4的欄位
                    for (int i = 0; i < gvQC.Rows.Count; i++)
                    {
                        var thisCheckBox = (CheckBox)gvQC.Rows[i].FindControl("ckbDefectSelect");

                        if (thisCheckBox.Checked)
                        {
                            _QCInspectionObjDataList[i].ItemName4 = "NG";
                        }
                        else
                        {
                            _QCInspectionObjDataList[i].ItemName4 = "OK";
                        }

                        _QCInspectionObjDataList[i].UpdateToDB(txnStamp.UserID, txnStamp.RecordTime);
                    }

                    //更新機台檢驗主檔
                    _CSTWIPCMMList.ForEach(data =>
                    {
                        data.UpdateToDB();
                    });

                    //取得相同BatchID的檢驗資料 (理論上應該都完成檢驗...)
                    //如果是雙料號,每次判定要分料號判定
                    var QCDataList = QCInspectionInfoEx.GetDataListByBatchIDAndDeviceName(_QCInspectionDataList[0].BatchID, deviceName);
                    //如果是雙料號,每次判定要分料號判定,但是機台的狀態要該batchID都判定通過,才算PPK完成
                    var QCDAllataList = QCInspectionInfoEx.GetDataListByBatchID(_QCInspectionDataList[0].BatchID);

                    #region 如果相同的BatchID都檢驗完成時,則更新機台狀態為IDLE
                    //相同BatchID都已完成檢驗旗標
                    //如果是雙料號,每次判定要分料號判定,但是機台的狀態要該batchID都判定通過,才算PPK完成
                    bool isAllFinish = true;

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

                    if (isAllFinish)
                    {
                        //取得機台狀態資料
                        var newStateInfo = EquipmentStateInfo.GetEquipmentStateByState("IDLE");

                        //檢查機台是否存在
                        var equipData = EquipmentInfo.GetEquipmentByName(_QCInspectionDataList[0].EquipmentName);
                        if (equipData == null)
                        {
                            //[00885]機台{0}不存在!
                            throw new Exception(TextMessage.Error.T00885(_QCInspectionDataList[0].EquipmentName));
                        }

                        //更新機台狀態
                        EMSTransaction.ChangeState(equipData, newStateInfo, txnStamp);
                    }
                    #endregion

                    #region 如果相同的BatchID都檢驗完成且結果都為OK時,則更新機台檢驗資料及更新COUNT
                    //相同BatchID都已完成檢驗及結果都為OK旗標
                    bool isAllFinishAndOK = true;
                    QCDataList.ForEach(p =>
                    {
                        if (!(p.Status == "Finished" && p.Result == "OK"))
                        {
                            isAllFinishAndOK = false;
                        }
                    });

                    if (isAllFinishAndOK)
                    {
                        //取得AutoMerge原因碼
                        var reasonCategory = ReasonCategoryInfo.GetReasonCategoryByCategoryNameAndReason("CustomizeReason", "AutoMerge");
                        if (reasonCategory == null)
                        {
                            //[00030]{0}:{1}不存在!
                            throw new Exception(TextMessage.Error.T00030("", "CustomizeReason- AutoMerge"));
                        }

                        _QCInspectionObjDataList.ForEach(Data =>
                        {
                            //更新機台檢驗資料
                            Data.UpdateToDB(txnStamp.UserID, txnStamp.RecordTime);
                        });

                        var mergeList = _QCInspectionObjDataList.Select(p => p.ItemName2).Distinct().ToList();

                        foreach (var lot in mergeList)
                        {
                            var lotData = LotInfoEx.GetLotByWorkOrderLot(lot);

                            //確認FAI是否已經檢驗完成
                            if (CustomizeFunction.CheckFAI(_QCInspectionDataList[0].EquipmentName, lotData.Lot))
                            {
                                //執行AutoMerge
                                CustomizeFunction.AutoMerge(lotData.InventoryLot, txnStamp, reasonCategory);
                            }
                        }
                    }
                    #endregion

                    #endregion

                    cts.Complete();
                }

                ClearField();
                AjaxFocus(ttbEquipOrCompLot);

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