예제 #1
0
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                EquipmentInfo equipmentData = EquipmentInfo.GetEquipmentByName(mEQP.EquipmentName);

                if (mEQP.Tag != equipmentData.Tag)
                {
                    throw new RuleCimesException(TextMessage.Error.T00747(""));
                }

                string             EqpID          = ciEquipment.Must(lblEquipment);
                string             Reason         = csReason.Must(lblReasonCode).Value;
                EquipmentStateInfo equipmentState = EquipmentStateInfo.GetEquipmentStateByState(ddlNewState.Must(lblNewState).Text);

                var txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, this.ApplicationName);
                var rcData   = csReason.GetBusinessReason().CategoryReason;
                txnStamp.CategoryReasonCode = rcData;
                txnStamp.Description        = ttbDesc.Text.Trim();

                #region 檢查是否有設定機台變更狀態警報,若有,則發送警報
                //使用Function取得ALM設定,可彈性使用
                //取得機台狀態警報設定,預設是抓取系統資料設定[EquipStateAlarm]
                AlarmTypeInfo AlarmType = RuleExtendManager.GetEquipmentChangeStateAlarm(equipmentData, ddlNewState.Must(lblNewState).Text);
                string        ALMsg     = @"[Subject:{0}][Content:{1}:{2};   {3}:{4};   {5}:{6};   {7}:{8};   {9}:{10}]";
                if (AlarmType != null)
                {
                    // "[Content:TEST][Subject:TEST]"
                    ALMsg = string.Format(ALMsg, ProgramInformationBlock1.Caption, lblEquipment.Text, mEQP.EquipmentName, lblOldState.Text, mEQP.CurrentState, lblNewState.Text, equipmentState.State, lblReasonCode.Text, rcData.Reason, lblDescription.Text, txnStamp.Description);
                }
                #endregion

                using (var cts = CimesTransactionScope.Create())
                {
                    EMSTransaction.ChangeState(equipmentData, equipmentState, txnStamp);
                    RuleExtendManager.EquipmentTxnEnd(equipmentData);
                    cts.Complete();
                }

                #region 發送警報
                if (AlarmType != null)
                {
                    AlarmService WebServiceALM = new AlarmService();

                    string url = "http://" + Request.Url.Host + Request.ApplicationPath + "/ALM/Services/AlarmService.asmx";

                    WebServiceALM.Url = url;
                    string ReturnMsg = WebServiceALM.LaunchAlarm(AlarmType.GroupRights, AlarmType.TYPE, ALMsg, txnStamp.RecordTime, "UI", User.Identity.Name);
                }
                #endregion

                Response.Redirect(ciMes.Security.UserSetting.GetPreviousListPage(this), false);
            }
            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
            {
                TransactionStamp txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);

                //檢查機台/序號是否有輸入
                ttbEquipOrCompLot.Must(lblEquipOrCompLot);

                using (var cts = CimesTransactionScope.Create())
                {
                    string equipmentState = "Wait" + _QCType;

                    #region 更新機台狀態為WaitFAI
                    //只有FAI需要變更機台狀態,如果QCType參數為PPK或PQC,則不需更新機台狀態
                    if (_QCType.Equals(CustomizeFunction.QCType.FAI.ToCimesString()))
                    {
                        //取得機台狀態資料
                        var newStateInfo = EquipmentStateInfo.GetEquipmentStateByState(equipmentState);
                        if (newStateInfo == null)
                        {
                            //C00028 無機台狀態{0}的設定資料!
                            throw new CimesException(RuleMessage.Error.C00028(equipmentState));
                        }

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

                    #region 更新單號狀態為WaitFAI/WaitPPK
                    foreach (DataRow dr in _QCTable.Rows)
                    {
                        var qcInspectionData = InfoCenter.GetBySID <QCInspectionInfo>(dr["QCINSPSID"].ToString()).ChangeTo <QCInspectionInfoEx>();

                        qcInspectionData.Status      = equipmentState;
                        qcInspectionData.ReceiveTime = txnStamp.RecordTime;
                        qcInspectionData.ReceiveUser = txnStamp.UserID;
                        qcInspectionData.UpdateToDB(txnStamp.UserID, txnStamp.RecordTime);
                    }
                    #endregion

                    cts.Complete();
                }

                ClearField();
                AjaxFocus(ttbEquipOrCompLot);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
예제 #3
0
        /// <summary>
        /// 退回
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnReject_Click(object sender, EventArgs e)
        {
            try
            {
                TransactionStamp txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);

                //檢查機台/序號是否有輸入
                ttbEquipOrCompLot.Must(lblEquipOrCompLot);

                string status = "ToBeSent" + _QCType;

                using (var cts = CimesTransactionScope.Create())
                {
                    #region 更新單號狀態為ToBeSentFAI及設置PASSFLAG = N
                    foreach (DataRow dr in _QCTable.Rows)
                    {
                        var qcInspectionData = InfoCenter.GetBySID <QCInspectionInfo>(dr["QCINSPSID"].ToString()).ChangeTo <QCInspectionInfoEx>();

                        qcInspectionData.Status       = status;
                        qcInspectionData.PassFlag     = "N";
                        qcInspectionData.QCRejectTime = txnStamp.RecordTime;
                        qcInspectionData.QCRejectUser = txnStamp.UserID;
                        qcInspectionData.UpdateToDB(txnStamp.UserID, txnStamp.RecordTime);
                    }
                    #endregion

                    #region 更新機台狀態
                    //取得機台狀態資料
                    var newStateInfo = EquipmentStateInfo.GetEquipmentStateByState(status);
                    if (newStateInfo == null)
                    {
                        //C00028 無機台狀態{0}的設定資料!
                        throw new CimesException(RuleMessage.Error.C00028(status));
                    }

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

                    cts.Complete();
                }

                ClearField();
                AjaxFocus(ttbEquipOrCompLot);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
예제 #4
0
        /// <summary>
        /// 確認出站後是否有下一站的預約紀錄,如果有,則將批號進站至下一個工作站
        /// </summary>
        /// <param name="txnLotData">機加批號</param>
        /// <param name="txnStamp"></param>
        public void CheckNextReserveCheckIn(LotInfoEx txnLotData, TransactionStamp txnStamp)
        {
            //取得預約工作站資料
            var WIPNextReserveList = CSTWIPReserveCheckInInfo.GetDataByLot(txnLotData.Lot);

            if (WIPNextReserveList.Count > 0)
            {
                //下一個預約工作站資料
                var reserveData = WIPNextReserveList[0];

                //將預約的進站時間回寫到hist的Remark01
                txnStamp.Remark01 = reserveData.InTime;

                //取得機台資料
                var equipData = EquipmentInfo.GetEquipmentByName(reserveData.Equipment);
                if (equipData == null)
                {
                    //[00885]機台{0}不存在!
                    throw new Exception(TextMessage.Error.T00885(reserveData.Equipment));
                }

                //取得機台狀態資料
                var newStateInfo = EquipmentStateInfo.GetEquipmentStateByState("RUN");

                if (equipData.CurrentState != "RUN")
                {
                    //更新機台狀態
                    EMSTransaction.ChangeState(equipData, newStateInfo, txnStamp);
                }

                //批號上機台
                EMSTxn.Default.AddLotToEquipment(txnLotData, equipData, txnStamp);

                //批號進站
                WIPTransaction.CheckIn(txnLotData, equipData.EquipmentName, "", "", LotDefaultStatus.Run.ToString(), txnStamp);

                //將批號Dispatch到下一規則
                WIPTransaction.DispatchLot(txnLotData, txnStamp);
            }
        }
예제 #5
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);
            }
        }
예제 #6
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);
            }
        }
예제 #7
0
        /// <summary>
        /// 確定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                /*  1.	如有不良數量,先確認有待判站。
                 * 2.	待判站找尋方式:到系統資料設定(MES_WPC_EXTENDITEM)裡找尋屬性SAIJudgeOperation,依照process找出待判站的名稱。如找不到要報錯。(找不到待判站資訊,請至系統資料維護增加資訊,屬性:xxxx。)
                 *  拿MES_WIP_LOT_PROCESS 跟系統資料設定裡的REMARK01比對後,找出工作站點(REMARK02)
                 * 3.	將批號出站。(CheckOut)
                 * 4.	將批號下機。(EQPRemoveLot)
                 * 5.	判定機台容量如果為0,將機台狀態變更為IDLE。(ChangeStaus)
                 *  機台容量判定方式:MES_EQP_EQP. CAPACITY = 0。
                 * 6.	將CST_WIP_RESERVE_CHECKIN_INFO搬移至CST_WIP_RESERVE_CHECKIN_INFO_LOG。
                 *  資料條件:Lot + Operation
                 * 7.	如有不良數量,拆一個不良批號,將批號送到待判站。(Defect、SplitLot、ReassignOperation)
                 * 8.	將原批號派送至下一規則。(Dispatch)
                 */

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

                using (var cts = CimesTransactionScope.Create())
                {
                    //取得批號資料
                    var txnLotData = _LotData;

                    //取得批號上機台資料
                    var equipmentLotData = EquipmentLotInfo.GetEquipmentLotByLot(txnLotData.Lot);

                    //如果批號上機台是有資料,表示必須執行機台相關的交易
                    if (equipmentLotData != null)
                    {
                        var newStateInfo = EquipmentStateInfo.GetEquipmentStateByState("IDLE");

                        var equipment = EquipmentInfo.GetEquipmentByName(txnLotData.ResourceName);
                        if (equipment == null)
                        {
                            //[00885]機台{0}不存在!
                            throw new Exception(TextMessage.Error.T00885(txnLotData.ResourceName));
                        }

                        //機台移批號
                        EMSTransaction.RemoveLotFromEquipment(txnLotData, equipment, txnStamp);

                        //確認機台的最大容量是否為零,如果不是,則執行變更機台狀態
                        if (equipment.Capacity == 0)
                        {
                            //變更機台狀態 Run=>IDLE
                            EMSTransaction.ChangeState(equipment, newStateInfo, txnStamp);
                        }
                    }

                    //更新預約資料
                    UpdateReserveCheckInData(txnLotData, txnLotData.OperationName, txnStamp);

                    //批號出站
                    WIPTransaction.CheckOut(txnLotData, txnStamp);

                    //如果有不良數量,則拆號及送待判工作站
                    if (_DefectGridData != null && _DefectGridData.Count > 0)
                    {
                        SplitDefectLotList(txnLotData, _DefectGridData, txnStamp);
                    }

                    //將批號Dispatch到下一規則
                    WIPTransaction.DispatchLot(txnLotData, txnStamp);

                    //檢查是否還有預約工作站資料
                    CheckNextReserveCheckIn(txnLotData, txnStamp);

                    cts.Complete();
                }

                ClearField();
                AjaxFocus(ttbLot);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
예제 #8
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);
            }
        }
예제 #9
0
        /// <summary>
        /// 確定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                /*  1.	檢查畫面上所有輸入欄位是否都已輸入。
                 *  2.	如為當站進站(批號狀態為Wait),則將批號進站併上機台。(EquipmentAddLot、CheckIn、Dispatch)。
                 *  3.	如為預約進站,則將預約資訊塞入客製表,做批號備註。(AddComment)
                 *  4.	清空畫面,游標停在機加批號。
                 */
                string           equipmentName = "";
                EquipmentInfo    equipData     = null;
                TransactionStamp txnStamp      = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);

                //檢查機台是否有輸入
                if (ttbLot.Text.IsNullOrEmpty() || _LotData == null)
                {
                    AjaxFocus(ttbLot);
                    throw new Exception(TextMessage.Error.T00030(GetUIResource("LotCheckInLot"), ""));
                }

                //如果機台下拉式清單Enabled為TRUE,則必須檢查是否有選擇機台
                if (ddlEquip.Enabled)
                {
                    ddlEquip.Must(lblEquip);

                    //取得機台資訊
                    equipData = EquipmentInfo.GetEquipmentByID(ddlEquip.SelectedValue);

                    //註記機台名稱
                    equipmentName = equipData.EquipmentName;
                }

                using (var cts = CimesTransactionScope.Create())
                {
                    //批號狀態為Wait時,表示目前要執行進站
                    if (_LotData.Status == LotDefaultStatus.Wait.ToString())
                    {
                        CheckBom(_LotData.OperationName, equipData, _LotData);

                        if (equipData != null)
                        {
                            //批號上機台
                            EMSTxn.Default.AddLotToEquipment(_LotData, equipData, txnStamp);

                            //取得機台狀態資料
                            var newStateInfo = EquipmentStateInfo.GetEquipmentStateByState("RUN");

                            if (equipData.CurrentState != "RUN")
                            {
                                //更新機台狀態
                                EMSTransaction.ChangeState(equipData, newStateInfo, txnStamp);
                            }
                        }

                        //批號進站
                        WIPTransaction.CheckIn(_LotData, equipmentName, "", "", LotDefaultStatus.Run.ToString(), txnStamp);

                        //將批號Dispatch到下一規則
                        WIPTransaction.DispatchLot(_LotData, txnStamp);
                    }
                    else
                    {
                        CheckBom(_WIPReserveCheckInData.OperationName, equipData, _LotData);

                        //執行預約進站功能
                        _WIPReserveCheckInData.Equipment = equipmentName;
                        _WIPReserveCheckInData.InTime    = DBCenter.GetSystemTime();
                        _WIPReserveCheckInData.InsertToDB();

                        //做批號備註。(AddComment)
                        var reason  = ReasonCategoryInfo.GetReasonCategoryByCategoryNameAndReason("CustomizeReason", "ReserveLotCheckIn");
                        var massage = "";

                        WIPTransaction.AddLotComment(_LotData, reason, massage, txnStamp);
                    }
                    cts.Complete();
                }

                ClearField();
                AjaxFocus(ttbLot);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
예제 #10
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);
            }
        }