Exemple #1
0
        /// <summary>
        /// 更新刀具已設定的刀壽次數
        /// </summary>
        /// <param name="toolTypeLife"></param>
        /// <param name="userID"></param>
        /// <param name="recordTime"></param>
        private void UpdateToolLifes(CSTToolTypeLifeInfo toolTypeLife, string userID, string recordTime)
        {
            //依據刀具型態及供應商取得有刀具清單
            var toolList = ToolInfoEx.GetToolByToolTypeAndVendor(toolTypeLife.ToolType, toolTypeLife.Supplier);

            //執行更新每支刀具對應的基本刀壽次數
            toolList.ForEach(tool =>
            {
                //取得刀具基本刀壽資料
                var toolLifeList = CSTToolLifeInfo.GetToolLifeByToolNmae(tool.ToolName);

                //取得此刀具所在的機台清單
                var equipToolList = EquipToolInfo.GetByToolName(tool.ToolName);

                //如果此刀具沒有在任何機台上,則進行修改基本刀壽次數
                if (equipToolList.Count == 0)
                {
                    toolLifeList.ForEach(toolLife =>
                    {
                        //確認基本刀壽次數是否一致,如果不一致,則直接更新資料
                        if (toolLife.Life != toolTypeLife.Life)
                        {
                            //更新基本刀壽次數
                            toolLife.Life = toolTypeLife.Life;
                            toolLife.UpdateToDB(userID, recordTime);

                            //記錄LOG
                            LogCenter.LogToDB(toolLife, LogCenter.LogIndicator.Create(ActionType.Set, userID, recordTime));
                        }
                    });
                }
            });
        }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
        /// <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);
            }
        }
Exemple #4
0
        /// <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);
            }
        }
Exemple #5
0
        /// <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);
            }
        }
Exemple #6
0
        /// <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;
            }
Exemple #7
0
        /// <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);
            }
        }