Пример #1
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);

                //確認是否輸入刀具零組件
                ttbToolName.Must(lblToolName);

                //確認是否選擇報廢原因
                ddlReason.Must(lblReason);

                using (var cts = CimesTransactionScope.Create())
                {
                    var newStateInfo = ToolStateInfo.GetToolStateByState("SCRAP");
                    if (newStateInfo == null)
                    {
                        //刀具零組件狀態: {0}不存在,請至配件狀態維護新增此狀態!!
                        throw new Exception(RuleMessage.Error.C10149("SCRAP"));
                    }

                    //因刀具報表需求,所以在報廢時要將使用次數記錄在UDC07
                    var toolLifeList = CSTToolLifeInfo.GetToolLifeByToolNmae(_ToolData.ToolName);
                    var toolLifeData = toolLifeList.Find(p => p.Head == _ToolData.Head);
                    TMSTransaction.ModifyToolSystemAttribute(_ToolData, "USERDEFINECOL07", toolLifeData.UseCount.ToCimesString(), txnStamp);

                    //變更刀具 GROUPID
                    TMSTransaction.ModifyToolSystemAttribute(_ToolData, "GROUPID", "", txnStamp);

                    //變更IDENTITY為報廢品
                    TMSTransaction.ModifyToolSystemAttribute(_ToolData, "IDENTITY", "報廢品", txnStamp);

                    //變更狀態為SCRAP
                    TMSTransaction.ChangeToolState(_ToolData, newStateInfo, txnStamp);

                    //註記原因碼
                    var reasonCategory = InfoCenter.GetBySID <ReasonCategoryInfo>(ddlReason.SelectedValue);
                    txnStamp.CategoryReasonCode = reasonCategory;
                    txnStamp.Description        = "";

                    //備註
                    TMSTransaction.AddToolComment(_ToolData, txnStamp);

                    cts.Complete();
                }

                ClearField();

                AjaxFocus(ttbToolName);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            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);

                List <decimal> lsLife = new List <decimal>();

                //確認是否輸入刀具零組件
                ttbToolName.Must(lblToolName);

                #region 確認是否有勾選任一刀面設定
                string mainHead = "";
                for (int i = 0; i < gvToolHead.Rows.Count; i++)
                {
                    CheckBox ckbSelect = gvToolHead.Rows[i].FindControl("ckbSelect") as CheckBox;

                    if (ckbSelect.Checked == true)
                    {
                        mainHead = _ToolLifeList[i].Head;
                    }
                }

                if (mainHead.IsNullOrTrimEmpty())
                {
                    //[00841]請選擇一個 {0}!
                    throw new Exception(TextMessage.Error.T00841(lblMainHead.Text));
                }
                #endregion

                using (var cts = CimesTransactionScope.Create())
                {
                    //變更主刀面
                    TMSTransaction.ModifyToolSystemAttribute(_ToolData, "HEAD", mainHead, txnStamp);

                    //因刀具報表需求,所以在送修時要將使用次數記錄在UDC07
                    var toolLifeList = CSTToolLifeInfo.GetToolLifeByToolNmae(_ToolData.ToolName);
                    var toolLifeData = toolLifeList.Find(p => p.Head == _ToolData.Head);
                    TMSTransaction.ModifyToolSystemAttribute(_ToolData, "USERDEFINECOL06", _ToolData.Head, txnStamp);
                    TMSTransaction.ModifyToolSystemAttribute(_ToolData, "USERDEFINECOL07", toolLifeData.UseCount.ToCimesString(), txnStamp);

                    //註記原因碼
                    var reasonCategory = ReasonCategoryInfo.GetReasonCategoryByCategoryNameAndReason("CustomizeReason", "刀具換面");
                    if (reasonCategory == null)
                    {
                        throw new CimesException(RuleMessage.Error.C00053("CustomizeReason", "刀具換面"));
                    }
                    txnStamp.CategoryReasonCode = reasonCategory;
                    txnStamp.Remark             = reasonCategory.Reason;
                    //備註
                    TMSTransaction.AddToolComment(_ToolData, txnStamp);

                    cts.Complete();
                }

                ClearField();

                AjaxFocus(ttbToolName);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
Пример #3
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);

                List <decimal> lsLife = new List <decimal>();

                //確認是否輸入刀具零組件
                ttbToolName.Must(lblToolName);

                //確認變更刀壽次數資料是否正確
                for (int i = 0; i < gvToolHead.Rows.Count; i++)
                {
                    TextBox ttbChangeLife = gvToolHead.Rows[i].FindControl("ttbChangeLife") as TextBox;

                    //確認刀壽是否為正整數
                    ttbChangeLife.MustInt(GetUIResource("ChangeLife"));
                    int lifeCount = Convert.ToInt32(ttbChangeLife.Text);
                    if (lifeCount <= 0)
                    {
                        AjaxFocus(ttbChangeLife);

                        //[00916]輸入值必須為數字且必須大於等於0!!
                        throw new Exception(TextMessage.Error.T00916());
                    }

                    lsLife.Add(lifeCount.ToCimesDecimal());
                }

                using (var cts = CimesTransactionScope.Create())
                {
                    for (int i = 0; i < gvToolHead.Rows.Count; i++)
                    {
                        //原刀壽次數
                        string life = _ToolLifeList[i].Life.ToString();

                        //更新刀壽資料
                        _ToolLifeList[i].Life = lsLife[i];
                        _ToolLifeList[i].UpdateToDB(txnStamp.UserID, txnStamp.RecordTime);

                        //紀錄歷史紀錄[CST_TOOL_TYPE_LIFE_LOG]
                        LogCenter.LogToDB(_ToolLifeList[i], LogCenter.LogIndicator.Create(ActionType.Set, txnStamp.UserID, txnStamp.RecordTime));

                        //註記原因碼
                        var reasonCategory = ReasonCategoryInfo.GetReasonCategoryByCategoryNameAndReason("CustomizeReason", "AlterToolLife");
                        txnStamp.CategoryReasonCode = reasonCategory;
                        //txnStamp.Description = string.Format("刀具零組件[{0}],刀面[{1}],原刀壽次數[{2}],設定刀壽次數[{3}]",
                        //    _ToolData.ToolName, _ToolLifeList[i].Head, life, _ToolLifeList[i].Life.ToString());

                        //備註
                        TMSTransaction.AddToolComment(_ToolData, txnStamp);
                    }
                    cts.Complete();
                }

                ClearField();

                AjaxFocus(ttbToolName);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
Пример #4
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);

                //確認是否輸入刀具零組件
                ttbToolName.Must(lblToolName);

                //確認是否選擇維修原因
                ddlReason.Must(lblReason);

                //確認是否有選擇預定回廠日
                var date = ttbDate.MustDate(lblDate);

                //取得系統時間
                var sysDate = Convert.ToDateTime(DBCenter.GetSystemDateTime().ToString("yyyy/MM/dd"));

                //確認預定回廠日是否大於等於當天日期
                if (date < sysDate)
                {
                    //預定回廠日必須大於等於{0} !
                    throw new Exception(RuleMessage.Error.C10159(sysDate.ToString("yyyy/MM/dd")));
                }

                using (var cts = CimesTransactionScope.Create())
                {
                    //取得原因碼資料
                    var reasonCategory = InfoCenter.GetBySID <ReasonCategoryInfo>(ddlReason.SelectedValue);

                    //取得刀面資料清單
                    var toolLifes = CSTToolLifeInfo.GetToolLifeByToolNmae(_ToolData.ToolName);
                    toolLifes.Sort(data => data.Head);

                    //新增一筆[CST_TOOL_REPAIR]
                    var newToolRePair = InfoCenter.Create <CSTToolRepairInfo>();
                    newToolRePair.EstimateDateOfReturn = ttbDate.Text;
                    newToolRePair.Parts          = ttbRepairPart.Text;
                    newToolRePair.Reason         = reasonCategory.Reason;
                    newToolRePair.ReasonCategory = reasonCategory.Category;
                    newToolRePair.RepairTime     = txnStamp.RecordTime;
                    newToolRePair.RepairUser     = txnStamp.UserID;
                    newToolRePair.ToolName       = _ToolData.ToolName;
                    newToolRePair.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);

                    //新增一筆[CST_TOOL_REPAIR_LOG]
                    LogCenter.LogToDB(newToolRePair, LogCenter.LogIndicator.Create(ActionType.Add, txnStamp.UserID, txnStamp.RecordTime));

                    //新增[CST_TOOL_REPAIR_LIFE]
                    toolLifes.ForEach(toolLife =>
                    {
                        var newToolRePairLife           = InfoCenter.Create <CSTToolRepairLifeInfo>();
                        newToolRePairLife.Head          = toolLife.Head;
                        newToolRePairLife.Life          = toolLife.UseCount.ToString();
                        newToolRePairLife.ToolRepairSID = newToolRePair.ToolRepairSID;
                        newToolRePairLife.InsertToDB();
                    });

                    var newStateInfo = ToolStateInfo.GetToolStateByState("REPAIR");
                    if (newStateInfo == null)
                    {
                        //刀具零組件狀態: {0}不存在,請至配件狀態維護新增此狀態!!
                        throw new Exception(RuleMessage.Error.C10149("REPAIR"));
                    }

                    //因刀具報表需求,所以在送修時要將使用次數記錄在UDC07
                    var toolLifeData = toolLifes.Find(p => p.Head == _ToolData.Head);
                    TMSTransaction.ModifyToolSystemAttribute(_ToolData, "USERDEFINECOL07", toolLifeData.UseCount.ToCimesString(), txnStamp);

                    //變更狀態為REPAIR
                    TMSTransaction.ChangeToolState(_ToolData, newStateInfo, txnStamp);

                    int maintainCount = _ToolData.MaintainCount;

                    //維修次數+1
                    TMSTransaction.ModifyToolSystemAttribute(_ToolData, "MAINTAINCOUNT", (maintainCount + 1).ToString(), txnStamp);

                    //預定回廠日
                    TMSTransaction.ModifyToolSystemAttribute(_ToolData, "USERDEFINECOL04", ttbDate.Text, txnStamp);

                    //註記原因碼
                    txnStamp.CategoryReasonCode = reasonCategory;
                    txnStamp.Description        = "";

                    //備註
                    TMSTransaction.AddToolComment(_ToolData, txnStamp);

                    cts.Complete();
                }

                ClearField();

                AjaxFocus(ttbToolName);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
Пример #5
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);

                //確認是否輸入刀具零組件
                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);
            }
        }
Пример #6
0
        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);
            }
        }