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); } #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); } }
/// <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); } }