/// <summary> /// 輸入模具編號 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ttbToolName_TextChanged(object sender, EventArgs e) { try { _ToolData = ToolInfo.GetToolByName(ttbToolName.Text); #region 驗證模具號正確性 if (_ToolData == null) { //模具:{0}不存在,請確認資料正確性 throw new Exception(RuleMessage.Error.C10016(ttbToolName.Text)); } #endregion #region 驗證模具啟用狀態 if (_ToolData.UsingStatus == UsingStatus.Disable) { //模具:{0}已停用,如需使用,請至"配件資料維護"啟用!! throw new Exception(RuleMessage.Error.C10017(ttbToolName.Text)); } #endregion #region 驗證模具儲位是否可領用,僅Warehouse可執行 if (_ToolData.Location != "Warehouse") { //模具儲位為{0},不在庫房,不須領用!! throw new Exception(RuleMessage.Error.C10018(_ToolData.Location)); } #endregion #region 驗證模具狀態是否可使用,僅IDLE可執行 if (_ToolData.CurrentState != "IDLE") { if (_ToolData.CurrentState == "WaitPM") { //模具狀態為{0},請進行降模或鉗修保養!! throw new Exception(RuleMessage.Error.C10019(_ToolData.CurrentState)); } else { //模具狀態為{0},不可執行此功能!! throw new Exception(RuleMessage.Error.C10020(_ToolData.CurrentState)); } } #endregion ttbToolDescr.Text = _ToolData.Description; ttbToolType.Text = _ToolData.ToolType; btnOK.Enabled = true; } catch (Exception ex) { ClearField(); AjaxFocus(ttbToolName); HandleError(ex); } }
/// <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)); } ////確認刀具零組件的LOCATION是否在Warehouse //if (_ToolData.Location != "Warehouse") //{ // //刀具零組件:{0} 不在庫房,不可執行此功能!! // throw new Exception(RuleMessage.Error.C10127(ttbToolName.Text)); //} //確認刀具零組件狀態是否可使用,僅REPAIR可執行 if (_ToolData.CurrentState != "REPAIR") { //刀具零組件狀態為{0},不可執行此功能!! throw new Exception(RuleMessage.Error.C10129(_ToolData.CurrentState)); } //取得刀具型態資料 _ToolType = ToolTypeInfo.GetToolTypeByType(_ToolData.ToolType).ChangeTo <ToolTypeInfoEx>(); ttbToolType.Text = _ToolType.Type; if (_ToolType.InspectionFlag.ToBool()) { lblInspectionReport.ForeColor = System.Drawing.Color.Red; } else { lblInspectionReport.ForeColor = System.Drawing.Color.Black; } btnOK.Enabled = true; } catch (Exception ex) { ClearField(); AjaxFocus(ttbToolName); HandleError(ex); } }
/// <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)); } ////確認刀具零組件的LOCATION是否在Warehouse //if (_ToolData.Location != "Warehouse") //{ // //刀具零組件:{0} 不在庫房,不可執行此功能!! // throw new Exception(RuleMessage.Error.C10127(ttbToolName.Text)); //} ////確認刀具零組件狀態是否可使用,僅IDLE可執行 //if (_ToolData.CurrentState != "IDLE") //{ // //刀具零組件狀態為{0},不可執行此功能!! // throw new Exception(RuleMessage.Error.C10129(_ToolData.CurrentState)); //} //取得刀面資料清單 _ToolLifeList = CSTToolLifeInfo.GetToolLifeByToolNmae(_ToolData.ToolName); if (_ToolLifeList.Count == 0) { //刀具零組件:{0} 無刀面設定資料!! throw new Exception(RuleMessage.Error.C10130(_ToolData.ToolName)); } gvToolHead.SetDataSource(_ToolLifeList, true); btnOK.Enabled = true; } catch (Exception ex) { ClearField(); AjaxFocus(ttbToolName); HandleError(ex); } }
/// <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 ttbToolName_TextChanged(object sender, EventArgs e) { try { _ToolData = ToolInfo.GetToolByName(ttbToolName.Text); #region 驗證模具號正確性 if (_ToolData == null) { //模具:{0}不存在,請確認資料正確性 throw new Exception(RuleMessage.Error.C10016(ttbToolName.Text)); } #endregion #region 驗證模具啟用狀態 if (_ToolData.UsingStatus == UsingStatus.Disable) { //模具:{0}已停用,如需使用,請至"配件資料維護"啟用!! throw new Exception(RuleMessage.Error.C10017(ttbToolName.Text)); } #endregion #region 驗證模具狀態是否可使用,僅WaitPM可執行 if (_ToolData.CurrentState != "WaitPM") { //模具狀態為{0},不須進行鉗修作業!! throw new Exception(RuleMessage.Error.C10033(_ToolData.CurrentState)); } #endregion ttbToolDescr.Text = _ToolData.Description; ttbToolType.Text = _ToolData.ToolType; btnOK.Enabled = true; } catch (Exception ex) { ClearField(); AjaxFocus(ttbToolName); HandleError(ex); } }
/// <summary> /// 依照輸入LotID取得相關欄位資料及相關Button設定 /// </summary> /// <param name="LotID">批號名稱</param> private void LoadControlByLot(string toolname) { // 清除欄位資訊 ClearField(); var toolInfo = ToolInfo.GetToolByName(toolname); // 若該批號無資料可顯示,離開程式並顯示訊息 if (toolInfo == null) { btnPrint.Enabled = false; AjaxFocus(ttbToolName); throw new Exception(TextMessage.Error.T00060(toolname)); } btnPrint.Enabled = true; toolData = toolInfo; }
/// <summary> /// 輸入刀具零組件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ttbToolName_TextChanged(object sender, EventArgs e) { try { _ToolData = ToolInfo.GetToolByName(ttbToolName.Text.Trim()); # region 確認刀具零組件是否存在 if (_ToolData == null) { // [00030]{0}:{1}不存在! throw new Exception(TextMessage.Error.T00030(lblToolName.Text, ttbToolName.Text)); } #endregion #region 確認刀具零組件是否有 GROUPID if (_ToolData["GROUPID"].ToString() == null || _ToolData["GROUPID"].ToString() == "") { // [C10131]刀具零組件:{0}未領用、不能上機! throw new Exception(RuleMessage.Error.C10131(ttbToolName.Text)); } #endregion # region 搜尋相同 GroupID 的刀具
/// <summary> /// 輸入模具編號 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ttbToolName_TextChanged(object sender, EventArgs e) { try { _ToolData = ToolInfo.GetToolByName(ttbToolName.Text.Trim()); #region 驗證模治具號正確性 if (_ToolData == null) { //模治具:{0}不存在,請確認資料正確性 throw new Exception(RuleMessage.Error.C10029(ttbToolName.Text)); } #endregion #region 驗證模治具啟用狀態 if (_ToolData.UsingStatus == UsingStatus.Disable) { //模治具:{0}已停用,如需使用,請至"配件資料維護"啟用!! throw new Exception(RuleMessage.Error.C10030(ttbToolName.Text)); } #endregion #region 驗證模治具是否在別的機台上,如是要報錯 var equipToolDataList = EquipToolInfo.GetByToolName(_ToolData.ToolName); if (equipToolDataList.Count > 0) { //模治具:{0}已在機台:{1}上,不可再上機!! throw new Exception(RuleMessage.Error.C10023(ttbToolName.Text, equipToolDataList[0].EquipmentName)); } #endregion #region 驗證模治具儲位是否可上機,僅Hub可執行 if (_ToolData.Location != "Hub") { //模治具儲位為{0},尚未領用,不可執行上機!! throw new Exception(RuleMessage.Error.C10024(_ToolData.Location)); } #endregion #region 驗證模治具狀態是否可使用,僅IDLE可執行 if (_ToolData.CurrentState != "IDLE") { //模治具狀態為{0},不可執行此功能!! throw new Exception(RuleMessage.Error.C10022(_ToolData.CurrentState)); } #endregion ttbToolDescr.Text = _ToolData.Description; ttbToolType.Text = _ToolData.ToolType; if (_EquipData != null) { btnOK.Enabled = true; } AjaxFocus(ttbEquip); } catch (Exception ex) { ClearField(); AjaxFocus(ttbToolName); HandleError(ex); } }
/// <summary> /// 輸入刀具零組件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ttbToolName_TextChanged(object sender, EventArgs e) { try { _ToolData = ToolInfo.GetToolByName(ttbToolName.Text.Trim()).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)); } //確認刀具零組件是否為一面刀頭 var toolType = ToolTypeInfo.GetToolTypeByType(_ToolData.ToolType).ChangeTo <ToolTypeInfoEx>(); if (toolType.SideCount == "1") { //刀具零組件:{0} 只有一個刀面,不能更換刀面!! throw new Exception(RuleMessage.Error.C10153(ttbToolName.Text)); } //確認刀具零組件是否已經下機 var equipTools = EquipToolInfo.GetByToolName(_ToolData.ToolName); if (equipTools.Count > 0) { //刀具零組件:{0} 已在機台({1})上,請先執行刀具下機!! throw new Exception(RuleMessage.Error.C10152(ttbToolName.Text, equipTools[0].EquipmentName)); } ////確認刀具零組件的LOCATION是否在Warehouse //if (_ToolData.Location != "Warehouse") //{ // //刀具零組件:{0} 不在庫房,不可執行此功能!! // throw new Exception(RuleMessage.Error.C10127(ttbToolName.Text)); //} //確認刀具零組件狀態是否可使用,僅IDLE可執行 if (_ToolData.CurrentState != "IDLE") { //刀具零組件狀態為{0},不可執行此功能!! throw new Exception(RuleMessage.Error.C10129(_ToolData.CurrentState)); } //取得刀面資料清單 var toolLifeListTmp = CSTToolLifeInfo.GetToolLifeByToolNmae(_ToolData.ToolName); if (toolLifeListTmp.Count == 0) { //刀具零組件:{0} 無刀面設定資料!! throw new Exception(RuleMessage.Error.C10130(_ToolData.ToolName)); } //資料過濾目前設定的刀面 _ToolLifeList = toolLifeListTmp.FindAll(p => p.Head != _ToolData.Head); ttbMainHead.Text = _ToolData.Head; gvToolHead.SetDataSource(_ToolLifeList, true); btnOK.Enabled = true; } catch (Exception ex) { ClearField(); AjaxFocus(ttbToolName); HandleError(ex); } }
/// <summary> /// 輸入刀具零組件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ttbToolName_TextChanged(object sender, EventArgs e) { try { _ToolData = ToolInfo.GetToolByName(ttbToolName.Text.Trim()).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)); } //確認刀具零組件狀態是否可使用,僅IDLE可執行 if (_ToolData.CurrentState != "IDLE") { //刀具零組件狀態為{0},不可執行此功能!! throw new Exception(RuleMessage.Error.C10129(_ToolData.CurrentState)); } #region 機原因碼(DropDownList):依照原因碼工作站設定,帶出原因碼 ddlReason.Items.Clear(); List <BusinessReason> reasonList = ReasonCategoryInfo.GetOperationRuleCategoryReasonsWithReasonDescr(ProgramRight, "ALL", "Default", ReasonMode.Category); if (reasonList.Count > 0) { ddlReason.DataSource = reasonList; ddlReason.DataTextField = "ReasonDescription"; ddlReason.DataValueField = "ReasonCategorySID"; ddlReason.DataBind(); if (ddlReason.Items.Count != 1) { ddlReason.Items.Insert(0, ""); } else { ddlReason.SelectedIndex = 0; } } else { //[00641]規則:{0} 工作站:{1} 使用的原因碼未設定,請洽IT人員! throw new Exception(TextMessage.Error.T00641(ProgramRight, "ALL")); } #endregion btnOK.Enabled = true; } catch (Exception ex) { ClearField(); AjaxFocus(ttbToolName); HandleError(ex); } }
/// <summary> /// 輸入機台 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ttbEquipment_TextChanged(object sender, EventArgs e) { try { //清除資料 _EquipData = null; ttbToolName.Text = ""; _ToolList = new List<ToolInfoEx>(); gvQuery.SetDataSource(_ToolList, true); //確認機台編號是否有輸入 ttbEquipment.Must(lblEquipment); _EquipData = EquipmentInfo.GetEquipmentByName(ttbEquipment.Text); #region 驗證機台正確性 if (_EquipData == null) { //[00885]機台{0}不存在! throw new Exception(TextMessage.Error.T00885(ttbEquipment.Text)); } #endregion #region 驗證機台啟用狀態 if (_EquipData.UsingStatus == UsingStatus.Disable) { //機台:{0}已停用,如需使用,請至"機台資料維護"啟用!! throw new Exception(RuleMessage.Error.C10025(_EquipData.EquipmentName)); } #endregion #region 取得已上機的刀具資料 var equipTools = EquipToolInfo.GetByEquipmentName(_EquipData.EquipmentName); if (equipTools.Count == 0) { //機台編號:{0} 沒有刀具上機資料!! throw new Exception(RuleMessage.Error.C10147(_EquipData.EquipmentName)); } equipTools.ForEach(equipTool => { //取得刀具資料 var toolData = ToolInfo.GetToolByName(equipTool.ToolName).ChangeTo<ToolInfoEx>(); //確認刀具零組件是否存在 if (toolData == null) { // [00030]{0}:{1}不存在! throw new Exception(TextMessage.Error.T00030(lblToolName.Text, ttbToolName.Text)); } //確認刀具零組件狀態是否可使用,僅USED可執行 if (toolData.CurrentState != "USED") { //刀具零組件狀態為{0},不可執行此功能!! throw new Exception(RuleMessage.Error.C10129(toolData.CurrentState)); } #region 確認刀具零組件是否啟用 if (toolData.UsingStatus == UsingStatus.Disable) { //刀具零組件:{0}已停用,如需使用,請至"刀具零組件進料作業"啟用!! throw new Exception(RuleMessage.Error.C10128(toolData.ToolName)); } #endregion _ToolList.Add(toolData); }); #endregion gvQuery.SetDataSource(_ToolList, true); btnOK.Enabled = true; AjaxFocus(ttbToolName); } catch (Exception ex) { ClearField(); AjaxFocus(ttbEquipment); HandleError(ex); } }
protected void btnOK_Click(object sender, EventArgs e) { try { ttbEquipment.Must(lblEquipment); ddlOperation.Must(lblOperation); csReason.Must(lblTakeReason); if (_TakeToolLifeList.Count == 0) { // [00824]請新增[刀頭]! throw new RuleCimesException(TextMessage.Error.T00824(lblMillHeader.Text)); } string groupid = DBCenter.GetSystemID(); var txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName); using (var cts = CimesTransactionScope.Create()) { _TakeToolLifeList.ForEach(tool => { // 變更GROUPID與HEAD系統屬性 // HEAD紀錄目前刀具使用的刀頭 // GROUPID紀錄目前綁定的刀具 var toolInfo = ToolInfo.GetToolByName(tool.ToolName); var modifyAttrList = new List <ModifyAttributeInfo>(); modifyAttrList.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("GROUPID", groupid)); modifyAttrList.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("HEAD", tool.Head)); modifyAttrList.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("LOCATION", "Hub")); //因刀具報表需求,所以在領用時要AddComment,並將刀面及使用次數記錄在UDC06 & UDC07 modifyAttrList.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("USERDEFINECOL06", tool.Head)); modifyAttrList.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("USERDEFINECOL07", tool.UseCount)); modifyAttrList.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("USERDEFINECOL08", tool.Operation)); TMSTransaction.ModifyToolMultipleAttribute(toolInfo, modifyAttrList, txnStamp); txnStamp.Remark = "刀具領用"; var reasonCategory = InfoCenter.GetBySID <ReasonCategoryInfo>(csReason.SelectedValue); txnStamp.CategoryReasonCode = reasonCategory; txnStamp.Description = ""; TMSTransaction.AddToolComment(toolInfo, txnStamp); }); // 寫入CSTToolIssue客製表 var toolIssueInfo = InfoCenter.Create <CSTToolIssueInfo>(); toolIssueInfo.TOTALQTY = _TakeToolLifeList.Count; toolIssueInfo.Reason = csReason.GetBusinessReason().ReasonCode; toolIssueInfo.EquipmentName = _EquipmentInfo == null ? "" : _EquipmentInfo.EquipmentName; toolIssueInfo.LinkSID = txnStamp.LinkSID; toolIssueInfo.Action = "領用"; toolIssueInfo.InsertToDB(txnStamp.UserID, txnStamp.RecordTime); cts.Complete(); } ClearField(); AjaxFocus(ttbMillName); ((ProgramInformationBlock)ProgramInformationBlock1).ShowMessage(TextMessage.Hint.T00057("領用")); } catch (Exception ex) { HandleError(ex); } }
protected void btnSave_Click(object sender, EventArgs e) { try { #region 檢查輸入資料 ttbToolName.Must(lblToolName); ddlType.Must(lblType); if (!rbtDisable.Checked && !rbtEnable.Checked) { throw new CimesException(TextMessage.Error.T00841(lblStates.Text)); } CurrentToolData.ToolName = ttbToolName.Text.Trim(); if (CurrentToolData.InfoState == InfoState.NewCreate) { if (ToolInfo.GetToolByName(CurrentToolData.ToolName) != null) { throw new CimesException(TextMessage.Error.T00710(CurrentToolData.ToolName)); } } ToolAttributeSetup.ValidateCheck(); #endregion //儲存系統屬性 _SystemAttribute.SaveSystemAttribute(CurrentToolData); //預設ActiveFlag = "F" if (CurrentToolData.InfoState == InfoState.NewCreate) { CurrentToolData.ActiveFlag = "F"; CurrentToolData.Location = "Warehouse"; CurrentToolData.ToolClass = "DIE"; } CurrentToolData.UsingStatus = (rbtEnable.Checked ? UsingStatus.Enable : UsingStatus.Disable); CurrentToolData.ToolTypeSID = ddlType.SelectedItem.Value; CurrentToolData.ToolType = ddlType.SelectedItem.Text; if (rbtEnable.Checked) { //若啟用,則ActiveFlag=T CurrentToolData.ActiveFlag = "T"; } if (ddlState.SelectedItem != null && !ddlState.SelectedItem.Value.IsNullOrTrimEmpty()) { CurrentToolData.CurrentState = ddlState.SelectedItem.Text; CurrentToolData.ToolStateSID = ddlState.SelectedItem.Value; } CurrentToolData.Description = ttbDescr.Text.Trim(); #region 將使用次數寫至ToolMaster DropDownList ddlCountType = (DropDownList)FindControl("PMCounterSetup1$ddlCountType"); if (ddlCountType != null) { CurrentToolData.CountType = ddlCountType.Text; } TextBox ttbCountRatio = (TextBox)FindControl("PMCounterSetup1$ttbCountRatio"); if (ttbCountRatio != null) { CheckTextBox(ttbCountRatio, GetUIResource("CountRatio"), CheckDataType.GreaterEqualZeroDecimal); CurrentToolData.CountRatio = ttbCountRatio.Text.ToDecimal(); } TextBox ttbTotalCount = (TextBox)FindControl("PMCounterSetup1$ttbTotalCount"); if (ttbTotalCount != null) { CheckTextBox(ttbTotalCount, GetUIResource("TotalCount"), CheckDataType.GreaterEqualZeroDecimal); CurrentToolData.TotalCount = ttbTotalCount.Text.ToDecimal(); } TextBox ttbScrapCount = (TextBox)FindControl("PMCounterSetup1$ttbScrapCount"); if (ttbScrapCount != null) { CheckTextBox(ttbScrapCount, GetUIResource("ScrapCount"), CheckDataType.GreaterEqualZeroDecimal); CurrentToolData.ScrapCount = ttbScrapCount.Text.ToDecimal(); } #endregion ToolInfo toolData = (ToolInfo)CurrentToolData.DeepCopy(); bool bCheckPMSSetup = true; TransactionStamp txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, this.ApplicationName); using (CimesTransactionScope cts = CimesTransactionScope.Create()) { //UserDefineColumnSet1.ModifyInfoRecordWithoutUpdate(toolData); if (toolData.InfoState == InfoState.NewCreate) { toolData.InsertImmediately(this.User.Identity.Name, DBCenter.GetSystemTime()); LogCenter.LogToDB(toolData, LogCenter.LogIndicator.Default); if (PMSSetupInfo.GetSetupData("TOOL", "Type", toolData.ToolType).Count == 0) { bCheckPMSSetup = false; } } else { if (toolData.UpdateImmediately(this.User.Identity.Name, DBCenter.GetSystemTime()) != 1) { throw new CimesException(TextMessage.Error.T00747("")); } LogCenter.LogToDB(toolData, LogCenter.LogIndicator.Create(ActionType.Set)); if (PMSSetupInfo.GetSetupData("TOOL", "Type", toolData.ToolType).Count == 0 && PMSSetupInfo.GetSetupData("TOOL", "ID", toolData.ToolName).Count == 0) { bCheckPMSSetup = false; } } ToolAttributeSetup.ExcuteTransaction(toolData.ID); if (bCheckPMSSetup == true) { PMCounterSetupInterface.SyncSettingToDB(toolData.ID, "ToolID", txnStamp); } cts.Complete(); } CurrentToolData = (ToolInfoEx)toolData.DeepCopy(); BindDataByCurrentToolData(); gvToolList.ResetCloneDataSource(); //QueryAllTool(); //001 AllTools = ToolInfoEx.GetToolByToolClass("DIE"); int index = AllTools.FindIndex(p => p.ID == CurrentToolData.ID); //int pageIndex = index / gvToolList.PageSize; int selectedIndex = index % gvToolList.PageSize; //換頁要放在bind資料前 //指定選擇行放在bind資料後 gvToolList.PageIndex = gvToolList.CurrentPageIndex; gvToolList.SetDataSource(AllTools, true); gvToolList.SelectedIndex = selectedIndex; DisableTab(); _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00083("")); } catch (Exception ex) { HandleError(ex); } }
/// <summary> /// 輸入刀具零組件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ttbToolName_TextChanged(object sender, EventArgs e) { try { _ToolData = ToolInfo.GetToolByName(ttbToolName.Text); # region 確認刀具零組件是否存在 if (_ToolData == null) { // [00030]{0}:{1}不存在! throw new Exception(TextMessage.Error.T00030(lblToolName.Text, ttbToolName.Text)); } #endregion #region 搜尋相同 GroupID 的刀具 if (_ToolData["GROUPID"].ToString() == null || _ToolData["GROUPID"].ToString() == "") { // [C10131]刀具零組件:{0}沒有刀具群組編號資訊! //throw new Exception(RuleMessage.Error.C10131(ttbToolName.Text)); _ToolGroupData = new List <ToolInfoEx>(); _ToolGroupData.Add(_ToolData.ChangeTo <ToolInfoEx>()); } else { _ToolGroupData = ToolInfoEx.GetToolListByGroupID(_ToolData["GROUPID"].ToString()); } foreach (var tool in _ToolGroupData) { //尚未確認刀具在產線的判斷 #region 確認刀具零組件是否啟用 if (tool.UsingStatus == UsingStatus.Disable) { //刀具零組件:{0}已停用,如需使用,請至"刀具零組件進料作業"啟用!! throw new Exception(RuleMessage.Error.C10128(tool.ToolName)); } #endregion #region 確認刀具零組件的LOCATION是否為Hub if (tool.Location != "Hub") { //{0}: {1} 狀態不為: {2},不可使用! throw new Exception(RuleMessage.Error.C00006(lblToolName.Text, tool.ToolName, "Hub")); } #endregion #region 驗證模治具是否在別的機台上,如是要報錯 var equipToolDataList = EquipToolInfo.GetByToolName(tool.ToolName); if (equipToolDataList.Count > 0) { //[C10138]刀具零組件:{0}已在機台:{1}上,不可執行刀具零組件歸還! throw new Exception(RuleMessage.Error.C10138(tool.ToolName, equipToolDataList[0].EquipmentName)); } #endregion } #endregion gvQuery.SetDataSource(_ToolGroupData, true); btnOK.Enabled = true; }
protected void ttbMillName_TextChanged(object sender, EventArgs e) { try { ddlMillHeader.Items.Clear(); if (ttbMillName.Text.Trim().IsNullOrTrimEmpty()) { ttbMillName.Text = string.Empty; return; } string sToolName = ttbMillName.Text.Trim(); _CurrentToolInfo = ToolInfo.GetToolByName(sToolName); if (_CurrentToolInfo == null) { throw new RuleCimesException(TextMessage.Error.T00030(lblMillName.Text, sToolName)); } #region 依照刀具目前儲位及狀態做基礎判斷 if (_CurrentToolInfo.Location != "Warehouse") { // 刀具:{0} 位置:{1} 不可領用 ! throw new RuleCimesException(RuleMessage.Error.C10124(sToolName, _CurrentToolInfo.Location)); } if (_CurrentToolInfo.CurrentState.ToUpper() == "SCRAP") { throw new CimesException(RuleMessage.Error.C00044(_CurrentToolInfo.ToolName)); } if (_CurrentToolInfo.CurrentState.ToUpper() == "REPAIR") { throw new CimesException(RuleMessage.Error.C00045(_CurrentToolInfo.ToolName)); } if (_CurrentToolInfo.UsingStatus.ToCimesString().ToUpper() != "ENABLE") { //T01677, {0}:{1}未啟用,不可使用! throw new CimesException(TextMessage.Error.T01677(GetUIResource("MillNumber"), _CurrentToolInfo.ToolName)); } #endregion ttbIdentity.Text = _CurrentToolInfo["IDENTITY"].ToString(); _CurrentToolLifeList = CSTToolLifeInfo.GetToolLifeByToolNmae(_CurrentToolInfo.ToolName); if (_CurrentToolLifeList.Count == 0) { // 刀具:{0}找不到刀頭資料 ! throw new RuleCimesException(RuleMessage.Error.C10123(sToolName)); } _CurrentToolLifeList.ForEach(toollife => { ddlMillHeader.Items.Add(new ListItem(toollife.Head, toollife.ID)); }); //如果只有單頭,就預帶刀面數 if (ddlMillHeader.Items.Count != 1) { ddlMillHeader.Items.Insert(0, ""); } else { ddlMillHeader.SelectedIndex = 0; } AjaxFocus(ddlMillHeader.ClientID); } catch (Exception ex) { HandleError(ex, ttbMillName.ClientID); } }
protected void btnOK_Click(object sender, EventArgs e) { try { ttbEquipmentName.Must(lblEquipment); ttbDevice1.Must(lblDevice1); //料號1一定要有資料 if (_DeviceInfo1 == null) { throw new RuleCimesException(TextMessage.Error.T00826(lblDevice1.Text)); } //一定要輸入一種料號 if (_dtVerifiy1 == null) { throw new RuleCimesException(TextMessage.Error.T00826(lblDevice1.Text)); } //若有輸入料號1則需驗證應領數量與領用數量是否相同 if (_dtVerifiy1 != null) { _dtVerifiy1.Rows.LoopDo <DataRow>((p, i) => { if (p["NEEDQTY"].ToDecimal() != p["EQPTOOLCOUNT"].ToDecimal()) { throw new RuleCimesException(RuleMessage.Error.C10141(_EquipmentInfo.EquipmentName, _DeviceInfo1.DeviceName, p["TOOLTYPE"].ToString(), p["NEEDQTY"].ToString())); } }); } //若有輸入料號2則需驗證應領數量與領用數量是否相同 if (_dtVerifiy2 != null) { _dtVerifiy2.Rows.LoopDo <DataRow>((p, i) => { if (p["NEEDQTY"].ToDecimal() != p["EQPTOOLCOUNT"].ToDecimal()) { throw new RuleCimesException(RuleMessage.Error.C10141(_EquipmentInfo.EquipmentName, _DeviceInfo1.DeviceName, p["TOOLTYPE"].ToString(), p["NEEDQTY"].ToString())); } }); } string sReleaseID = DBCenter.GetSystemID(); TransactionStamp txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName); using (var cts = CimesTransactionScope.Create()) { //先將舊的資料刪除 var lstEqpToolRelease = CSTEquipmentToolReleaseInfo.GetDataByEquipment(_EquipmentInfo.EquipmentName); lstEqpToolRelease.ForEach(p => { p.DeleteFromDB(); LogCenter.LogToDB(p, LogCenter.LogIndicator.Create(ActionType.Remove, txnStamp.UserID, txnStamp.RecordTime)); }); var lstEqpTool = EquipToolInfo.GetByEquipmentName(_EquipmentInfo.EquipmentName); lstEqpTool.ForEach(p => { //取得配件資訊 var toolInfo = ToolInfo.GetToolByName(p.ToolName); //新增至CST_EQP_TOOL_RELEASE的Info物件 var eqpToolReleaseInfo = InfoCenter.Create <CSTEquipmentToolReleaseInfo>(); eqpToolReleaseInfo.EquipmentName = _EquipmentInfo.EquipmentName; eqpToolReleaseInfo.ToolName = toolInfo.ToolName; eqpToolReleaseInfo.HEAD = toolInfo["HEAD"].ToString(); eqpToolReleaseInfo.RELEASEID = sReleaseID; eqpToolReleaseInfo["OPERATION"] = toolInfo.UserDefineColumn08; eqpToolReleaseInfo.InsertToDB(txnStamp.UserID, txnStamp.RecordTime); LogCenter.LogToDB(eqpToolReleaseInfo, LogCenter.LogIndicator.Create(ActionType.Add, txnStamp.UserID, txnStamp.RecordTime)); //異動Tool的RELEASEID欄位 TMSTransaction.ModifyToolSystemAttribute(toolInfo, "RELEASEID", sReleaseID, txnStamp); }); //先將舊的資料刪除 var lstEqpDeviceRelease = CSTEquipmentDeviceReleaseInfo.GetDataByEquipment(_EquipmentInfo.EquipmentName); lstEqpDeviceRelease.ForEach(p => { p.DeleteFromDB(); LogCenter.LogToDB(p, LogCenter.LogIndicator.Create(ActionType.Remove, txnStamp.UserID, txnStamp.RecordTime)); }); if (_dtVerifiy1 != null) { //新增至CST_EQP_DEVICE_RELEASE的Info物件 var eqpDeviceReleaseInfo = InfoCenter.Create <CSTEquipmentDeviceReleaseInfo>(); eqpDeviceReleaseInfo.EquipmentName = _EquipmentInfo.EquipmentName; eqpDeviceReleaseInfo.DeviceName = _DeviceInfo1.DeviceName; eqpDeviceReleaseInfo.RELEASEID = sReleaseID; eqpDeviceReleaseInfo.InsertToDB(txnStamp.UserID, txnStamp.RecordTime); LogCenter.LogToDB(eqpDeviceReleaseInfo, LogCenter.LogIndicator.Create(ActionType.Add, txnStamp.UserID, txnStamp.RecordTime)); } if (_dtVerifiy2 != null) { //新增至CST_EQP_DEVICE_RELEASE的Info物件 var eqpDeviceReleaseInfo = InfoCenter.Create <CSTEquipmentDeviceReleaseInfo>(); eqpDeviceReleaseInfo.EquipmentName = _EquipmentInfo.EquipmentName; eqpDeviceReleaseInfo.DeviceName = _DeviceInfo2.DeviceName; eqpDeviceReleaseInfo.RELEASEID = sReleaseID; eqpDeviceReleaseInfo.InsertToDB(txnStamp.UserID, txnStamp.RecordTime); LogCenter.LogToDB(eqpDeviceReleaseInfo, LogCenter.LogIndicator.Create(ActionType.Add, txnStamp.UserID, txnStamp.RecordTime)); } cts.Complete(); } ((ProgramInformationBlock)ProgramInformationBlock1).ShowMessage(TextMessage.Hint.T00057(GetUIResource("ToolVerifiy"))); ClearField(); AjaxFocus(ttbEquipmentName); } catch (Exception ex) { HandleError(ex); } }
/// <summary> /// 依照檢驗計畫取得該物件的datatable /// </summary> /// <param name="QCTypeData"></param> /// <param name="objectName"></param> /// <returns></returns> public static DataTable GetInspectionData(QCTypeInfo QCTypeData, string objectName) { string sql = ""; DataTable dtQCTarget = null; #region 依照檢驗計畫取得該物件的datatable switch (QCTypeData.QCTarget) { case "MES_WIP_LOT": { LotInfo lot = LotInfo.GetLotByLot(objectName); if (lot == null) { throw new Exception(TextMessage.Error.T00378(objectName)); } dtQCTarget = lot.CopyDataToTable(lot.ID); } break; case "MES_WIP_COMP": { //取得component資訊以及所在的工作站 sql = @"SELECT L.OPERATION,C.* FROM MES_WIP_COMP C INNER JOIN MES_WIP_LOT L ON C.CURRENTLOT = L.LOT WHERE COMPONENTID = #[STRING]"; ComponentInfo comp = InfoCenter.GetBySQL <ComponentInfo>(sql, objectName); if (comp == null) { throw new Exception(TextMessage.Error.T00154(objectName)); } dtQCTarget = comp.CopyDataToTable(comp.ID); } break; case "MES_CMS_CAR": { CarrierInfo carrier = CarrierInfo.GetCarrierByCarrierNo(objectName); if (carrier == null) { throw new RuleCimesException(TextMessage.Error.T00725(objectName)); } dtQCTarget = carrier.CopyDataToTable(carrier.ID); } break; case "MES_TOOL_MAST": { ToolInfo tool = ToolInfo.GetToolByName(objectName); if (tool == null) { throw new Exception(TextMessage.Error.T00592(objectName)); } dtQCTarget = tool.CopyDataToTable(tool.ID); } break; case "MES_MMS_MLOT": { MaterialLotInfo mlot = MaterialLotInfo.GetMaterialLotByMaterialLot(objectName); if (mlot == null) { throw new Exception(TextMessage.Error.T00512(objectName)); } dtQCTarget = mlot.CopyDataToTable(mlot.ID); } break; case "MES_EQP_EQP": { EquipmentInfo equipment = EquipmentInfo.GetEquipmentByName(objectName); if (equipment == null) { throw new Exception(TextMessage.Error.T00885(objectName)); } dtQCTarget = equipment.CopyDataToTable(equipment.ID); } break; default: { sql = string.Format("SELECT * FROM {0} WHERE {1} = #[STRING]", QCTypeData.QCTarget, QCTypeData.IdentityColumn); dtQCTarget = DBCenter.GetDataTable(sql, objectName); if (dtQCTarget == null || dtQCTarget.Rows.Count == 0) { throw new Exception(TextMessage.Error.T00030("InspectionTarget", objectName)); } } break; } #endregion return(dtQCTarget); }
/// <summary> /// 輸入模具編號 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ttbToolName_TextChanged(object sender, EventArgs e) { try { string equipmentName = ""; _ToolData = ToolInfo.GetToolByName(ttbToolName.Text); #region 驗證模治具號正確性 if (_ToolData == null) { //模治具:{0}不存在,請確認資料正確性 throw new Exception(RuleMessage.Error.C10029(ttbToolName.Text)); } #endregion #region 驗證模治具啟用狀態 if (_ToolData.UsingStatus == UsingStatus.Disable) { //模治具:{0}已停用,如需使用,請至"配件資料維護"啟用!! throw new Exception(RuleMessage.Error.C10030(ttbToolName.Text)); } #endregion #region 驗證模治具是否在別的機台上,如是要報錯 var equipToolDataList = EquipToolInfo.GetByToolName(_ToolData.ToolName); if (equipToolDataList.Count == 0) { //模治具:{0}不在機台上,不須下機!! throw new Exception(RuleMessage.Error.C10031(ttbToolName.Text)); } equipmentName = equipToolDataList[0].EquipmentName; #endregion #region 機原因碼(DropDownList):依照原因碼工作站設定,帶出原因碼 ddlCheckOutReasonCode.Items.Clear(); List <BusinessReason> reasonList = ReasonCategoryInfo.GetOperationRuleCategoryReasonsWithReasonDescr(ProgramRight, "ALL", "Default", ReasonMode.Category); if (reasonList.Count > 0) { ddlCheckOutReasonCode.DataSource = reasonList; ddlCheckOutReasonCode.DataTextField = "ReasonDescription"; ddlCheckOutReasonCode.DataValueField = "ReasonCategorySID"; ddlCheckOutReasonCode.DataBind(); if (ddlCheckOutReasonCode.Items.Count != 1) { ddlCheckOutReasonCode.Items.Insert(0, ""); } else { ddlCheckOutReasonCode.SelectedIndex = 0; } } else { //[00641]規則:{0} 工作站:{1} 使用的原因碼未設定,請洽IT人員! throw new Exception(TextMessage.Error.T00641(ProgramRight, "ALL")); } #endregion ttbToolDescr.Text = _ToolData.Description; ttbToolType.Text = _ToolData.ToolType; ttbEquip.Text = equipmentName; btnOK.Enabled = true; } catch (Exception ex) { ClearField(); AjaxFocus(ttbToolName); HandleError(ex); } }