/// <summary> /// 輸入不良說明 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ttbComponentId_TextChanged(object sender, EventArgs e) { try { _SelectedComponetData = null; if (ttbComponentId.Text.IsNullOrEmpty()) { throw new Exception(TextMessage.Error.T00826(lblComponentId.Text)); } //驗證component合法性。 //找不到component。(序號:xxx不存在。) //輸入的component不屬於這個批號。(序號:xxx所屬批號為xxx,請確認資料正確性!!) var component = ComponentInfoEx.GetComponentByComponentID(ttbComponentId.Text); if (component != null) { if (_LotData.Lot != component.CurrentLot) { //序號:{0}所屬批號為{1},請確認資料正確性! throw new Exception(RuleMessage.Error.C10010(component.ComponentID, component.CurrentLot)); } _SelectedComponetData = component; } else { //序號:{0}不存在 throw new Exception(RuleMessage.Error.C10009(ttbComponentId.Text)); } } catch (Exception ex) { HandleError(ex); } }
protected void ddlOperation_SelectedIndexChanged(object sender, EventArgs e) { try { btnOK.Enabled = false; if (ddlOperation.SelectedValue.IsNullOrEmpty()) { if (_ProdType == CustomizeFunction.ProdType.B.ToCimesString()) { ttbWorkpiece.ReadOnly = false; ttbWorkpiece.Text = ""; } return; } ttbWorkpiece.ReadOnly = true; //用小工單號找出所有的component,逆排後找出第一個符合選擇站點的component為送待判的對象 var compList = ComponentInfoEx.GetAllComponentByWOLot(ttbWOLot.Text.Trim()).OrderByDescending(p => p.ComponentID).ToList(); ProcessLotData = null; foreach (var p in compList) { var tempLot = LotInfoEx.GetLotByLot(p.CurrentLot); //第一個找到站點符合的component就不用再找了 if (tempLot.OperationName == ddlOperation.SelectedValue) { ProcessLotData = tempLot; break; } } if (ProcessLotData == null) { AjaxFocus(ddlOperation); ttbWOLot.Text = string.Empty; throw new RuleCimesException(RuleMessage.Error.C00050(ttbWOLot.Text, ddlOperation.SelectedValue)); } // 取得子單元 var lstComponents = ComponentInfo.GetLotAllComponents(ProcessLotData).OrderByDescending(p => p.ComponentID).ToList(); _ComponentInfo = lstComponents.Count == 0 ? null : lstComponents[0].ChangeTo <ComponentInfoEx>(); // 判斷子單元是否存在 if (_ComponentInfo == null) { throw new CimesException(RuleMessage.Error.C00039(ProcessLotData.Lot)); } ttbWorkpiece.ReadOnly = true; ttbWorkpiece.Text = _ComponentInfo.ComponentID; btnOK.Enabled = true; } catch (Exception ex) { HandleError(ex); } }
/// <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; }
protected void ttbWorkpiece_TextChanged(object sender, EventArgs e) { try { btnOK.Enabled = false; if (ttbWorkpiece.Text.Trim().IsNullOrEmpty()) { if (_ProdType == CustomizeFunction.ProdType.B.ToCimesString()) { ddlOperation.Enabled = true; ddlOperation.ClearSelection(); } return; } string componentid = CustomizeFunction.ConvertDMCCode(ttbWorkpiece.Text.Trim()); //僅有B跟S型態會刷DMC,故只需針對兩種CASE處理 if (_ProdType == CustomizeFunction.ProdType.B.ToCimesString()) { _ComponentInfo = ComponentInfoEx.GetOneComponentByDMCCode(componentid); if (_ComponentInfo == null) { throw new RuleCimesException(RuleMessage.Error.C00049(ttbWorkpiece.Text)); } } else if (_ProdType == CustomizeFunction.ProdType.S.ToCimesString()) { _ComponentInfo = ComponentInfoEx.GetComponentByComponentID(componentid); if (_ComponentInfo == null) { throw new RuleCimesException(RuleMessage.Error.C10047(ttbWorkpiece.Text)); } } // 找不到工件 if (_ComponentInfo == null) { throw new RuleCimesException(RuleMessage.Error.C10047(ttbWorkpiece.Text)); } ddlOperation.Enabled = false; ProcessLotData = LotInfoEx.GetLotByLot(_ComponentInfo.CurrentLot); if (ProcessLotData == null) { AjaxFocus(ttbWorkpiece); throw new RuleCimesException(TextMessage.Error.T00030(lblWOLot.Text + "(" + ttbWOLot.Text.Trim() + ")" + lblttbWorkpiece.Text + "(" + componentid + ")", GetUIResource("Lot")), ttbWorkpiece); } if (ProcessLotData.OperationName == _JudgeOperationName) { AjaxFocus(ttbWorkpiece); throw new RuleCimesException(RuleMessage.Error.C10175(_JudgeOperationName), ttbWorkpiece); } var item = ddlOperation.Items.FindByValue(ProcessLotData.OperationName); if (item != null) { ddlOperation.ClearSelection(); item.Selected = true; } btnOK.Enabled = true; } catch (Exception ex) { HandleError(ex); AjaxFocus(ttbWorkpiece); } }
/// <summary> /// 輸入機加批號 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ttbLot_TextChanged(object sender, EventArgs e) { try { #region 驗證批號存在性 _LotData = LotInfoEx.GetLotByLot(ttbLot.Text); if (_LotData == null) { //[00030]{0}:{1}不存在! throw new Exception(TextMessage.Error.T00030(lblLot.Text, ttbLot.Text)); } #endregion #region 驗證批號狀態,Run的批號 if (_LotData.Status != LotDefaultStatus.Run.ToString()) { //狀態為{0},不可執行 throw new Exception(RuleMessage.Error.C10003(_LotData.Status)); } #endregion #region 驗證currentRule if (_LotData.CurrentRuleName != _ProgramInformationBlock.ProgramRight) { //該批號作業為XXXX,不為此功能,請遵循作業規範 throw new Exception(RuleMessage.Error.C10004(_LotData.CurrentRuleName)); } #endregion #region 維修原因碼(DropDownList):依照原因碼工作站設定,帶出原因碼 ddlRepairReasonCode.Items.Clear(); List <BusinessReason> reasonList = ReasonCategoryInfo.GetOperationRuleCategoryReasonsWithReasonDescr(_LotData.CurrentRuleName, _LotData.OperationName, "Default", ReasonMode.Category); if (reasonList.Count > 0) { ddlRepairReasonCode.DataSource = reasonList; ddlRepairReasonCode.DataTextField = "ReasonDescription"; ddlRepairReasonCode.DataValueField = "ReasonCategorySID"; ddlRepairReasonCode.DataBind(); if (ddlRepairReasonCode.Items.Count != 1) { ddlRepairReasonCode.Items.Insert(0, ""); } else { ddlRepairReasonCode.SelectedIndex = 0; } } else { //[00641]規則:{0} 工作站:{1} 使用的原因碼未設定,請洽IT人員! throw new Exception(TextMessage.Error.T00641(ProgramRight, _LotData.OperationName)); } #endregion //取得工件序號 var componentDataList = ComponentInfoEx.GetDataByCurrentLot(_LotData.Lot); if (componentDataList.Count > 0) { ttbItemSN.Text = componentDataList[0].ComponentID; } //取得送待判原因 var lotDefectData = LotDefectInfoEx.GetDataByLotAndComponentID(_LotData.Lot, ttbItemSN.Text); if (lotDefectData != null) { _DefectJudgementData = CSTWIPDefectJudgementInfo.GetDataByWIPDefectSID(lotDefectData.DefectSID); if (_DefectJudgementData != null) { ttbJudgeReason.Text = _DefectJudgementData.Reason; } } ttbRepairDescr.Text = ""; btnOK.Enabled = true; } catch (Exception ex) { ClearField(); AjaxFocus(ttbLot); HandleError(ex); } }
/// <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); //確認是否有選擇送待判原因 ddlJudgeDefect.Must(lblJudgeDefect); #region 檢查判定結果是否有選擇 if (rdbGoods.Checked == false && rdbRepair.Checked == false && rdbDefectInv.Checked == false && rdbScrapInv.Checked == false) { throw new Exception(TextMessage.Error.T00841(lblJudgeResult.Text)); } #endregion //檢查判定原因是否有選擇 ddlJudgeReason.Must(lblJudgeReason); using (var cts = CimesTransactionScope.Create()) { #region 依照選擇的判定結果,對批號進行不同的處置 //選取的判定結果 string result = ""; //選取的原因碼 var reasonCategory = InfoCenter.GetBySID <ReasonCategoryInfo>(ddlJudgeReason.SelectedValue); #region 良品:依照批號的UDC02(工作站序號)+UDC03(工作站名稱)找出預設流程的下一站點,將批號跳站至該站 if (rdbGoods.Checked) { result = "Good"; //取得流程線上版本 取得目前Lot的所有流程(所有工作站) RouteVersionInfo RouteVersion = RouteVersionInfo.GetRouteActiveVersion(_LotData.RouteName); //取得設定包裝工作站名稱 var packingOperation = WpcExClassItemInfo.GetExtendItemListByClassAndRemarks("SAIPackingOperation"); if (packingOperation.Count == 0) { //T00555:查無資料,請至系統資料維護新增類別{0}、項目{1}! throw new CimesException(TextMessage.Error.T00555("SAIPackingOperation", "")); } var reassignOperation = packingOperation[0]; //如果送待判站之前記錄的是包裝站,則直接跳至包裝站,反之,跳至下一站 if (reassignOperation.Remark01 == _LotData.UserDefineColumn03) { //取得包裝站名稱 string qcOperationName = reassignOperation.Remark01; //取得包裝工作站資訊 var operation = OperationInfo.GetOperationByName(qcOperationName); if (operation == null) { //T00171, 工作站:{0}不存在!! throw new CimesException(TextMessage.Error.T00171(qcOperationName)); } //根據指定的流程名稱、流程版本、工作站名稱, 找出第一個符合的流程工作站,新的站點包裝 var newOperation = RouteOperationInfo.GetRouteOperationByOperationName(_LotData.RouteName, _LotData.RouteVersion, qcOperationName); //將批號的UDC02清空 WIPTransaction.ModifyLotSystemAttribute(_LotData, "USERDEFINECOL02", "", txnStamp); //將批號的UDC03清空 WIPTransaction.ModifyLotSystemAttribute(_LotData, "USERDEFINECOL03", "", txnStamp); //變更至指定工作站 WIPTransaction.ReassignOperation(_LotData, newOperation, reasonCategory, ttbJudgeDescr.Text, txnStamp); } else { //以此工作站名稱去查詢在流程中的序號 var routeOperation = RouteOperationInfo.GetRouteAllOperations(RouteVersion).Find(p => p.OperationName == _LotData.UserDefineColumn03); var lastOperationSeq = string.Format("{0:000}", (Convert.ToDecimal(routeOperation.OperationSequence) + 1)); //下一個工作站 用LOT和流程中下一站的序號去查出下一個工作站資訊 var NextRouteOperation = RouteOperationInfo.GetRouteOperationByLotSequence(_LotData, lastOperationSeq); if (NextRouteOperation == null) { //批號:{0}已無下個工作站點,請確認[流程設定] throw new Exception(RuleMessage.Error.C10008(_LotData.Lot)); } //將批號的UDC02清空 WIPTransaction.ModifyLotSystemAttribute(_LotData, "USERDEFINECOL02", "", txnStamp); //將批號的UDC03清空 WIPTransaction.ModifyLotSystemAttribute(_LotData, "USERDEFINECOL03", "", txnStamp); WIPTransaction.ReassignOperation(_LotData, NextRouteOperation, reasonCategory, ttbJudgeDescr.Text, txnStamp); } } #endregion #region 維修:紀錄維修及將批號派送至下一規則 if (rdbRepair.Checked) { result = "Repair"; List <WIPRepairInfo> repairDatas = new List <WIPRepairInfo>(); var componentData = ComponentInfoEx.GetDataByCurrentLot(_LotData.Lot)[0]; var repairData = WIPRepairInfo.CreateInfo(_LotData, componentData, componentData.ComponentQuantity, reasonCategory, _LotData.OperationName, _LotData.ResourceName, string.Empty, string.Empty); repairDatas.Add(repairData); var issueOperation = OperationInfo.GetOperationByName(_LotData.OperationName); WIPTransaction.RepairAdd(_LotData, repairDatas, issueOperation, txnStamp); WIPTransaction.DispatchLot(_LotData, txnStamp); } #endregion #region 良品入庫:將批號狀態變更為DefectInv if (rdbDefectInv.Checked) { result = "DefectInv"; WIPTransaction.ModifyLotSystemAttribute(_LotData, "STATUS", "DefectInv", txnStamp); } #endregion #region 報廢品入庫:將批號狀態變更為ScrapInv if (rdbScrapInv.Checked) { result = "ScrapInv"; WIPTransaction.ModifyLotSystemAttribute(_LotData, "STATUS", "ScrapInv", txnStamp); } #endregion #endregion #region 將判定結果紀錄在CST_WIP_DEFECT_JUDGEMENT,Result:良品(Goods)、維修(Repair)、不良品入庫(DefectInv)、報廢入庫(ScrapInv) var insertData = InfoCenter.Create <CSTWIPDefectJudgementInfo>(); insertData.WIPDefectSID = _LotDefectData.DefectSID; insertData["REASONCATEGORY"] = reasonCategory.Category; insertData["LOT"] = _LotData.Lot; insertData.Reason = reasonCategory.Reason; insertData.Result = result; insertData.Description = ttbJudgeDescr.Text; insertData.LinkSID = WIPHistoryInfo.GetLotFirstHistory(_LotData.Lot).LinkSID; insertData.InsertToDB(txnStamp.UserID, txnStamp.RecordTime); #endregion cts.Complete(); } ttbLot.Text = ""; ClearField(); AjaxFocus(ttbLot); _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614("")); } catch (Exception ex) { HandleError(ex); } }
/// <summary> /// 切換不同的送待判原因 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ddlJudgeDefect_SelectedIndexChanged(object sender, EventArgs e) { try { //確認是否有選擇送待判原因 ddlJudgeDefect.Must(lblJudgeDefect); //取得批號資訊 _LotDefectData = InfoCenter.GetBySID <LotDefectInfo>(ddlJudgeDefect.SelectedValue); _LotData = LotInfoEx.GetLotByLot(_LotDefectData.Lot).ChangeTo <LotInfoEx>(); #region 判定原因碼(DropDownList):依照原因碼工作站設定,帶出原因碼 ddlJudgeReason.Items.Clear(); List <BusinessReason> reasonList = ReasonCategoryInfo.GetOperationRuleCategoryReasonsWithReasonDescr(_LotData.CurrentRuleName, _LotData.OperationName, "Default", ReasonMode.Category); if (reasonList.Count > 0) { ddlJudgeReason.DataSource = reasonList; ddlJudgeReason.DataTextField = "ReasonDescription"; ddlJudgeReason.DataValueField = "ReasonCategorySID"; ddlJudgeReason.DataBind(); if (ddlJudgeReason.Items.Count != 1) { ddlJudgeReason.Items.Insert(0, ""); } else { ddlJudgeReason.SelectedIndex = 0; } } else { //[00641]規則:{0} 工作站:{1} 使用的原因碼未設定,請洽IT人員! throw new Exception(TextMessage.Error.T00641(ProgramRight, _LotData.OperationName)); } #endregion //數量 ttbQty.Text = _LotData.Quantity.ToString(); //取得工件序號 var componentDataList = ComponentInfoEx.GetDataByCurrentLot(_LotData.Lot); if (componentDataList.Count > 0) { ttbItemSN.Text = componentDataList[0].ComponentID; } ttbJudgeDescr.Text = ""; btnOK.Enabled = true; btnPrint.Enabled = true; } catch (Exception ex) { ttbItemSN.Text = ""; ttbQty.Text = ""; ttbJudgeDescr.Text = ""; ddlJudgeReason.Items.Clear(); btnOK.Enabled = false; btnPrint.Enabled = false; _LotData = null; _LotDefectData = null; HandleError(ex); } }
/// <summary> /// 確認此批號是否為COMPONENTID /// </summary> /// <param name="lot"></param> /// <returns></returns> private bool CheckComponentID(string lot) { //確認此批號是否為COMPONENTID var component = ComponentInfo.GetComponentByComponentID(lot); if (component == null) { return(false); } //取得批號資料 var lotData = LotInfoEx.GetLotByLot(component.CurrentLot).ChangeTo <LotInfoEx>(); if (lotData == null) { return(false); } //驗證批號狀態,Wait的批號 if (lotData.Status != LotDefaultStatus.Wait.ToString()) { //狀態為{0},不可執行 throw new Exception(RuleMessage.Error.C10003(lotData.Status)); } //驗證currentRule if (lotData.CurrentRuleName != _ProgramInformationBlock.ProgramRight) { //該批號作業為XXXX,不為此功能,請遵循作業規範 throw new Exception(RuleMessage.Error.C10004(lotData.CurrentRuleName)); } //取得工件序號 var componentDataList = ComponentInfoEx.GetDataByCurrentLot(lotData.Lot); if (componentDataList.Count > 0) { ttbItemSN.Text = componentDataList[0].ComponentID; } //取得送待判原因 var lotDefectData = LotDefectInfoEx.GetDataByLotAndComponentID(lotData.Lot, ttbItemSN.Text); if (lotDefectData != null) { var reason = ReasonInfo.GetReasonByName(lotDefectData.ReasonCode); if (reason == null) { throw new CimesException(RuleMessage.Error.C00051(lotDefectData.ReasonCode)); } //格式:(批號) 原因碼_說明_備註 string defectText = "(" + lotDefectData.Lot + ")"; defectText += " " + lotDefectData.ReasonCode; if (!reason.Description.IsNullOrTrimEmpty()) { defectText += "_" + reason.Description; } if (!lotDefectData.Description.IsNullOrTrimEmpty()) { defectText += "_" + lotDefectData.Description; } ddlJudgeDefect.Items.Add(new ListItem(defectText, lotDefectData.ID)); ddlJudgeDefect_SelectedIndexChanged(null, EventArgs.Empty); } else { //查無送待判原因! throw new Exception(RuleMessage.Error.C10187()); } return(true); }
/// <summary> /// 確定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnOK_Click(object sender, EventArgs e) { try { //確認是否輸入工件序號 ttbCompLot.Must(lblCompLot); //確認是否有選擇流程 ddlRoute.Must(lblRoute); //確認是否有選擇流程工作站 ddlRouteOperation.Must(lblRouteOperation); TransactionStamp txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName); using (var cts = CimesTransactionScope.Create()) { //以第一個工件序號為拆批的母批 var txnLotData = _MergeLotDataList[0]; //取得原因碼資料 var reasonData = ReasonCategoryInfo.GetReasonCategoryByCategoryNameAndReason("Common", "OTHER"); #region 執行拆批 //批號子單元清單 var lsComponetData = ComponentInfoEx.GetDataByCurrentLot(txnLotData.Lot); //取得併批批號名稱 var splitLotNaming = GetNamingRule("SplitLot", txnStamp.UserID, txnLotData); //批號拆批 var splitLot = SplitLotInfo.CreateSplitLotByLotAndQuantity(txnLotData.Lot, splitLotNaming.First[0], lsComponetData, reasonData, reasonData.Description); WIPTxn.Default.SplitLot(txnLotData, splitLot, WIPTxn.SplitIndicator.Create(null, null, null, TerminateBehavior.TerminateWithHistory), txnStamp); //將批號的UDC08註記N WIPTransaction.ModifyLotSystemAttribute(splitLot, "USERDEFINECOL08", "N", txnStamp); if (splitLotNaming.Second != null && splitLotNaming.Second.Count != 0) { DBCenter.ExecuteSQL(splitLotNaming.Second); } #endregion #region 執行併批 //移除第一個工件序號(因為拆批已處理過了) _MergeLotDataList.RemoveAt(0); List <MergeLotInfo> lsMergeLots = new List <MergeLotInfo>(); foreach (var mergeLot in _MergeLotDataList) { //批號子單元清單 var componetDataList = ComponentInfoEx.GetDataByCurrentLot(mergeLot.Lot); //加入併批清單 lsMergeLots.Add(MergeLotInfo.GetMergeLotByLotAndQuantity(mergeLot.Lot, componetDataList, reasonData, reasonData.Description)); } //將數量合併到在狀態為Run的批號上 if (lsMergeLots.Count > 0) { WIPTransaction.MergeLot(splitLot, lsMergeLots, txnStamp); } #endregion #region 變更流程 //取得料號版本資料 var deviceVersionData = DeviceVersionInfo.GetDeviceVersion(splitLot.DeviceName, splitLot.DeviceVersion); //取得所選擇的流程資料 var routeData = InfoCenter.GetBySID <RouteInfo>(ddlRoute.SelectedValue); //取得所選擇流程目前線上版本資料 var routeVersionData = RouteVersionInfo.GetActiveRouteVersion(routeData); //取得所選擇的流程工作站資料 var routeOpeartionData = InfoCenter.GetBySID <RouteOperationInfo>(ddlRouteOperation.SelectedValue); WIPTransaction.ReassignRoute(splitLot, deviceVersionData, routeVersionData, routeOpeartionData, reasonData, reasonData.Description, txnStamp); #endregion cts.Complete(); } ClearField(); AjaxFocus(ttbCompLot); _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614("")); } catch (Exception ex) { HandleError(ex); } }
/// <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); } }
protected void ttbWorkpiece_TextChanged(object sender, EventArgs e) { try { // 若卡控需輸入料號 if (ttbDeviceName.Text.Trim().IsNullOrEmpty() && !ckbNoControl.Checked) { throw new RuleCimesException(TextMessage.Error.T00043(lblDeviceName.Text)); } // 取得輸入工件 string inputObject = ttbWorkpiece.Text.Trim(); if (inputObject.IsNullOrEmpty()) { return; } ComponentInfo componentInfo = null; LotInfo lotInfo = null; var lstDMCComponent = ComponentInfoEx.GetComponentByDMCCode(inputObject).OrderBy(p => p.ComponentID).ToList(); if (lstDMCComponent.Count == 0) { var compID = CustomizeFunction.ConvertDMCCode(inputObject); lstDMCComponent = ComponentInfoEx.GetComponentListByComponentID(compID).OrderBy(p => p.ComponentID).ToList(); } lstDMCComponent.ForEach(comp => { // 若DMC是唯一值可以檢查是否已經重複 if (_ProdType == "S" || _ProdType == "B") { // 取得批號資料 lotInfo = LotInfo.GetLotByLot(comp.CurrentLot); // 自動線沒有DMCCode if (lotInfo.UserDefineColumn08 == "Y" && comp["DMC"].ToString().IsNullOrEmpty()) { var txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName); using (var cts = CimesTransactionScope.Create()) { WIPTransaction.ModifyLotComponentSystemAttribute(lotInfo, comp, "DMC", inputObject, txnStamp); cts.Complete(); } } #region 檢查子單元資料是否重複 if (lotInfo.DeviceName == _DeviceName) { _PackingList.ForEach(p => { if (p.ComponentID == comp.ComponentID) { throw new RuleCimesException(TextMessage.Error.T00033(lblWorkpiece.Text, comp.ComponentID)); } }); } else if (lotInfo.DeviceName == _RelativeDeviceName) { _RelativePackingList.ForEach(p => { if (p.ComponentID == comp.ComponentID) { throw new RuleCimesException(TextMessage.Error.T00033(lblWorkpiece.Text, comp.ComponentID)); } }); } #endregion componentInfo = comp; } else { if (_PackingList.Find(p => p.ComponentID == comp.ComponentID) == null && _RelativePackingList.Find(p => p.ComponentID == comp.ComponentID) == null && componentInfo == null) { componentInfo = comp; // 取得批號資料 lotInfo = LotInfo.GetLotByLot(componentInfo.CurrentLot); } } }); // 找不到子單元需拋錯 if (componentInfo == null) { throw new RuleCimesException(TextMessage.Error.T00045(GetUIResource("Workpiece"))); } // 找不到批號需拋錯 if (lotInfo == null) { throw new RuleCimesException(TextMessage.Error.T00045(GetUIResource("Lot"))); } // 檢查CurrentRule是否正確 if (lotInfo.CurrentRuleName != ProgramInformationBlock1.ProgramRight) { throw new RuleCimesException(TextMessage.Error.T00384(lotInfo.CurrentRuleName, ProgramInformationBlock1.ProgramRight)); } // 若需卡控 if (!ckbNoControl.Checked) { // 檢查批號型號與輸入的型號是否相同 if (_PackType == "Standard" && lotInfo.DeviceName != _DeviceName) { throw new RuleCimesException(RuleMessage.Error.C10041(_DeviceName)); } // 如果為包裝方式為Mix(左右手),則對應料號與對應料號須符合 if (_PackType == "Mix" && lotInfo.DeviceName != _DeviceName && lotInfo.DeviceName != _RelativeDeviceName) { throw new RuleCimesException(RuleMessage.Error.C10042(_DeviceName, _RelativeDeviceName)); } } var packTempInfo = CSTWIPPackTempInfo.GetPackTempByComponentID(componentInfo.ComponentID); if (packTempInfo != null) { ttbWorkpiece.Text = ""; throw new RuleCimesException(RuleMessage.Error.C10093()); } // 新增PackingInfo物件 var newPackItem = new PackingInfo(); newPackItem.ComponentID = componentInfo.ComponentID; newPackItem.ComponentInfo = componentInfo; newPackItem.LotInfo = lotInfo; newPackItem.DMC = componentInfo["DMC"].ToString(); // 將PackingInfo物件加入包裝清單全域變數 if (_PackType == "Standard" || (_PackType == "Mix" && lotInfo.DeviceName == _DeviceName) || ckbNoControl.Checked) { // 工件數量({0})達到滿箱數量({1}) ! if (!ckbNoControl.Checked && _PackingList.Count >= ttbMaxPackSize.Text.ToDecimal()) { throw new RuleCimesException(RuleMessage.Error.C10092(_PackingList.Count.ToString(), ttbMaxPackSize.Text)); } newPackItem.Device = lotInfo.DeviceName; newPackItem.Item = (_PackingList.Count + 1).ToString(); _PackingList.Add(newPackItem); } // 將PackingInfo物件加入對應料號包裝清單全域變數 else { // 工件數量({0})達到滿箱數量({1}) ! if (!ckbNoControl.Checked && _RelativePackingList.Count >= ttbMaxPackSize.Text.ToDecimal()) { throw new RuleCimesException(RuleMessage.Error.C10092(_RelativePackingList.Count.ToString(), ttbMaxPackSize.Text)); } newPackItem.Device = lotInfo.DeviceName; newPackItem.Item = (_RelativePackingList.Count + 1).ToString(); _RelativePackingList.Add(newPackItem); } // 將目前已經輸入的物件顯示至畫面上 _PackingList = _PackingList.OrderByDescending(p => p.Item.ToDecimal()).ToList(); gvWorkpiece.DataSource = _PackingList; gvWorkpiece.DataBind(); // 將目前已經輸入的物件顯示至畫面上 _RelativePackingList = _RelativePackingList.OrderByDescending(p => p.Item.ToDecimal()).ToList(); gvRelativeWorkpiece.DataSource = _RelativePackingList; gvRelativeWorkpiece.DataBind(); // 清除工件欄位 ttbWorkpiece.Text = ""; // 將指標焦點放工件欄位輸入框 AjaxFocus(ttbWorkpiece); if (_PackingList.Count != 0 || _RelativePackingList.Count != 0) { ttbTempWorkpiece.ReadOnly = true; } else { ttbTempWorkpiece.ReadOnly = false; } // 取得BatchID if (_BatchID == "") { var cstWIPPackTempInfo = InfoCenter.GetBySQL <CSTWIPPackTempInfo>("SELECT * FROM CST_WIP_PACK_TEMP WHERE COMPONENTID = #[STRING]", inputObject); _BatchID = (cstWIPPackTempInfo == null) ? "" : cstWIPPackTempInfo.BatchID; } #region ProcessWorkTime string sysTime = DBCenter.GetSystemTime(); var usrWorkTime = InfoCenter.Create <CSTUserWorkTimeInfo>(); usrWorkTime.WorkOrder = lotInfo.WorkOrder; usrWorkTime.WorkUserID = User.Identity.Name; usrWorkTime.StartTime = _StartTime; usrWorkTime.EndTime = DateTime.Parse(sysTime).AddSeconds(-1).ToString("yyyy/MM/dd HH:mm:ss"); usrWorkTime.EXECUTEFLAG = "N"; usrWorkTime.SHIFTDATE = _ShiftDate; usrWorkTime.SHIFT = _Shift; usrWorkTime.Lot = lotInfo.Lot; usrWorkTime["OPERATION"] = lotInfo.OperationName; _StartTime = sysTime; _UserWorkTimeList.Add(usrWorkTime); #endregion } catch (Exception ex) { HandleError(ex, ttbWorkpiece.ClientID); } }
/// <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); } }