/// <summary> /// 輸入刀具零組件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ttbToolName_TextChanged(object sender, EventArgs e) { try { _ToolData = ToolInfo.GetToolByName(ttbToolName.Text).ChangeTo <ToolInfoEx>(); //確認刀具零組件是否存在 if (_ToolData == null) { // [00030]{0}:{1}不存在! throw new Exception(TextMessage.Error.T00030(lblToolName.Text, ttbToolName.Text)); } //確認刀具零組件是否啟用 if (_ToolData.UsingStatus == UsingStatus.Disable) { //刀具零組件:{0}已停用,如需使用,請至"刀具零組件進料作業"啟用!! throw new Exception(RuleMessage.Error.C10128(ttbToolName.Text)); } //確認刀具零組件狀態是否可使用,僅REPAIR可執行 if (_ToolData.CurrentState != "REPAIR") { //刀具零組件狀態為{0},不可執行此功能!! throw new Exception(RuleMessage.Error.C10129(_ToolData.CurrentState)); } //萬一在維修客製表找不到資料,就先報錯 _ToolRepairData = CSTToolRepairInfo.GetDataByToolName(_ToolData.ToolName); if (_ToolRepairData == null) { throw new CimesException(RuleMessage.Error.C00046(_ToolData.ToolName)); } //預計回廠日期 ttbBackDate.Text = _ToolData.UserDefineColumn04; btnOK.Enabled = true; } catch (Exception ex) { ClearField(); AjaxFocus(ttbToolName); 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); //確認是否輸入刀具零組件 ttbToolName.Must(lblToolName); //確認檢驗報告是否需要上傳 if (_ToolType.InspectionFlag == "Y") { if (_ToolReports.Count == 0) { //刀具類型:{0} 必須上傳檢驗報告資料 ! throw new Exception(RuleMessage.Error.C10126(_ToolType.Type)); } } using (var cts = CimesTransactionScope.Create()) { #region 更新[CST_TOOL_REPAIR]的實際回廠日 var toolRepair = CSTToolRepairInfo.GetDataByToolName(_ToolData.ToolName); toolRepair.ActualDateOfReturn = txnStamp.RecordTime.Substring(0, 10); toolRepair.UpdateToDB(txnStamp.UserID, txnStamp.RecordTime); //新增一筆[CST_TOOL_REPAIR_LOG] LogCenter.LogToDB(toolRepair, LogCenter.LogIndicator.Create(ActionType.Set, txnStamp.UserID, txnStamp.RecordTime)); #endregion #region 將刀面使用次數歸零 //取得刀面資料清單 var toolLifes = CSTToolLifeInfo.GetToolLifeByToolNmae(_ToolData.ToolName); toolLifes.ForEach(toolLife => { toolLife.UseCount = 0; toolLife.UpdateToDB(txnStamp.UserID, txnStamp.RecordTime); }); #endregion var newStateInfo = ToolStateInfo.GetToolStateByState("IDLE"); if (newStateInfo == null) { //刀具零組件狀態: {0}不存在,請至配件狀態維護新增此狀態!! throw new Exception(RuleMessage.Error.C10149("IDLE")); } //因刀具報表需求,所以在送修時要將使用次數記錄在UDC07 TMSTransaction.ModifyToolSystemAttribute(_ToolData, "USERDEFINECOL07", "0", txnStamp); //變更狀態為IDLE TMSTransaction.ChangeToolState(_ToolData, newStateInfo, txnStamp); //變更LOCATION為Warehouse TMSTransaction.ModifyToolSystemAttribute(_ToolData, "LOCATION", "Warehouse", txnStamp); //變更IDENTITY為維修品 TMSTransaction.ModifyToolSystemAttribute(_ToolData, "IDENTITY", "維修品", txnStamp); //清空預定回廠日 TMSTransaction.ModifyToolSystemAttribute(_ToolData, "USERDEFINECOL04", "", txnStamp); //新增檢驗報告[CST_TOOL_REPORT] _ToolReports.ForEach(toolReport => { toolReport.InsertToDB(txnStamp.UserID, txnStamp.RecordTime); LogCenter.LogToDB(toolReport, LogCenter.LogIndicator.Create(ActionType.Add, txnStamp.UserID, txnStamp.RecordTime)); }); //註記原因碼 var reasonCategory = ReasonCategoryInfo.GetReasonCategoryByCategoryNameAndReason("CustomizeReason", "ToolReturn"); txnStamp.CategoryReasonCode = reasonCategory; txnStamp.Remark = reasonCategory.Reason; //txnStamp.Description = string.Format("刀具零組件[{0}],維修回廠", _ToolData.ToolName); //備註 TMSTransaction.AddToolComment(_ToolData, txnStamp); cts.Complete(); } ClearField(); AjaxFocus(ttbToolName); _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614("")); } catch (Exception ex) { HandleError(ex); } }