Exemple #1
0
        protected void gvToolList_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                CurrentToolData = AllTools[gvToolList.Rows[e.RowIndex].DataItemIndex];

                if (CurrentToolData.ActiveFlag == "T")      //ActiveFlag的判斷,若曾經啟用過則不可刪除
                {
                    throw new Exception(TextMessage.Error.T00714());
                }

                using (CimesTransactionScope cts = CimesTransactionScope.Create())
                {
                    CurrentToolData.DeleteFromDB();
                    AttributeAttributeInfo.DeleteByObjectSIDAndDataClass(CurrentToolData.ID, "ToolAttribute", this.User.Identity.Name, DBCenter.GetSystemTime());
                    LogCenter.LogToDB(CurrentToolData, LogCenter.LogIndicator.Create(ActionType.Remove, User.Identity.Name, DBCenter.GetSystemTime()));
                    cts.Complete();
                }
                CurrentToolData = null;
                gvToolList.ResetCloneDataSource();
                QueryAllTool();
                //BindGridView();
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
Exemple #2
0
        /// <summary>
        /// 刪除檢驗資料
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvToolReport_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                int index = gvToolReport.Rows[e.RowIndex].DataItemIndex;

                var removeData = _ToolReports[index];

                TransactionStamp txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);

                using (var cts = CimesTransactionScope.Create())
                {
                    removeData.DeleteFromDB();

                    LogCenter.LogToDB(removeData, LogCenter.LogIndicator.Create(ActionType.Remove, txnStamp.UserID, txnStamp.RecordTime));

                    cts.Complete();
                }

                //重新取得資料
                GetToolReport(_CurrentToolName);
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
Exemple #3
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));
                        }
                    });
                }
            });
        }
        protected void btnCopy_Click(object sender, EventArgs e)
        {
            try
            {
                //取得登入者資訊
                var recordTime = DBCenter.GetSystemTime();
                var userID     = User.Identity.Name;

                //確認目標料號及機台編號是否已經存在資料
                var toolDevices = CSTToolDeviceInfo.GetDataListByDeviceAndEquipmantName(ddlDevice.SelectedItem.Value, ddlEquipment.SelectedItem.Value);
                if (toolDevices.Count > 0)
                {
                    //料號({0})及機台({1}) 資料已存在,不可執行複製動作!
                    throw new Exception(RuleMessage.Error.C10117(ddlDevice.SelectedItem.Value, ddlEquipment.SelectedItem.Value));
                }

                using (var cts = CimesTransactionScope.Create())
                {
                    //新增一筆CST_TOOL_DEVICE資料
                    var toolDevice = InfoCenter.Create <CSTToolDeviceInfo>();
                    toolDevice.DeviceName    = ddlDevice.SelectedItem.Value;
                    toolDevice.EquipmentName = ddlEquipment.SelectedItem.Value;
                    toolDevice.Tag           = 1;

                    toolDevice.InsertToDB(userID, recordTime);
                    LogCenter.LogToDB(toolDevice, LogCenter.LogIndicator.Create(ActionType.Add, userID, recordTime));

                    //複製CST_TOOL_DEVICE_DETAIL資料
                    _ToolDeviceDetails.ForEach(toolDeviceDetail =>
                    {
                        var newToolDeviceDetail           = InfoCenter.Create <CSTToolDeviceDetailInfo>();
                        newToolDeviceDetail.EquipmentName = toolDevice.EquipmentName;
                        newToolDeviceDetail.Quantity      = toolDeviceDetail.Quantity;
                        newToolDeviceDetail.DeviceName    = toolDevice.DeviceName;
                        newToolDeviceDetail.ToolType      = toolDeviceDetail.ToolType;
                        newToolDeviceDetail.ToolDeviceSID = toolDevice.ToolDeviceSID;

                        newToolDeviceDetail.InsertToDB();

                        LogCenter.LogToDB(newToolDeviceDetail, LogCenter.LogIndicator.Create(ActionType.Add, userID, recordTime));
                    });

                    cts.Complete();
                }

                //INF-00002:{0}儲存成功!
                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00083(""), MessageShowOptions.OnLabel);

                LoadControlDefault();
            }
            catch (Exception E)
            {
                HandleError(E);
            }
        }
Exemple #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);

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

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

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

                using (var cts = CimesTransactionScope.Create())
                {
                    #region 更新[CST_TOOL_REPAIR]的預計回廠日
                    _ToolRepairData.EstimateDateOfReturn = ttbDate.Text;
                    _ToolRepairData.UpdateToDB(txnStamp.UserID, txnStamp.RecordTime);

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

                    #endregion

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

                    cts.Complete();
                }

                ClearField();

                AjaxFocus(ttbToolName);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
Exemple #6
0
        /// <summary>
        /// 更新FAI,檢驗完成回壓FAICount,第一次首件回壓FAIDevice
        /// </summary>
        /// <param name="equipmentName"></param>
        /// <param name="lot"></param>
        public static void UpdateFAI(string equipmentName, string lot, bool initFlag, TransactionStamp txs)
        {
            //取得批號資料
            var lotData = LotInfo.GetLotByLot(lot);

            var faiData = CSTEquipmentFAIInfo.GetDataByEquipmentAndDevice(equipmentName, lotData.DeviceName);

            if (faiData == null)
            {
                return;
            }

            if (faiData.INSPTYPE == FAIType.CN.ToCimesString())
            {
                #region 連N測試,只要一支NG,就要reset檢驗次數,重新送件

                //判定NG的時候回壓初始化FAICount,判定OK則WAITFAICOUNT減1
                if (initFlag) //NG
                {
                    //取得料號版本的資料
                    var deviceVerExData = DeviceVersionInfo.GetDeviceVersion(lotData.DeviceName, lotData.DeviceVersion).ChangeTo <DeviceVersionInfoEx>();

                    //檢查料號的FAICount有無設定
                    if (deviceVerExData.FAICount.ToString().IsNullOrTrimEmpty())
                    {
                        //T00541
                        //料號:xxx的系統屬性:xxx 未設定,請洽IT人員!) error code:T00031
                        throw new Exception(TextMessage.Error.T00541(deviceVerExData.DeviceName, "FAICount"));
                    }

                    faiData.WAITFAICOUNT = deviceVerExData.FAICount;
                }
                else //OK
                {
                    faiData.WAITFAICOUNT = faiData.WAITFAICOUNT - 1;
                }
                #endregion
            }
            else
            {
                //首N測試,判定OK將WAITFAICOUNT減1就好,判定NG不須動作
                if (!initFlag)
                {
                    faiData.WAITFAICOUNT = faiData.WAITFAICOUNT - 1;
                }
            }

            faiData.UpdateToDB(txs.UserID, txs.RecordTime);
            LogCenter.LogToDB(faiData, LogCenter.LogIndicator.Create(ActionType.Set, txs.UserID, txs.RecordTime));
        }
Exemple #7
0
        /// <summary>
        /// 儲存刀壽
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="recordTime"></param>
        private void SaveToolLife(string toolType, string userID, string recordTime)
        {
            //例外處理資料刪除的部份
            _SourceToolTypeLifes.ForEach(toolTypeLife =>
            {
                toolTypeLife.DeleteFromDB();

                LogCenter.LogToDB(toolTypeLife, LogCenter.LogIndicator.Create(ActionType.Remove, userID, recordTime));
            });

            //新增刀壽設定清單
            _ModifyToolTypeLifes.ForEach(toolTypeLife =>
            {
                //註記刀壽設定LOG的狀態
                ActionType actionType = new ActionType();

                if (toolTypeLife.InfoState == InfoState.NewCreate)
                {
                    //新增資料
                    toolTypeLife.ToolType = toolType;
                    toolTypeLife.InsertToDB(userID, recordTime);
                    actionType = ActionType.Add;

                    //更新刀具已設定的刀壽次數
                    UpdateToolLifes(toolTypeLife, userID, recordTime);
                }
                else if (toolTypeLife.InfoState == InfoState.Modified)
                {
                    //更改資料
                    toolTypeLife.ToolType = toolType;
                    toolTypeLife.UpdateToDB(userID, recordTime);
                    actionType = ActionType.Set;
                    _SourceToolTypeLifes.Remove(toolTypeLife);

                    //更新刀具已設定的刀壽次數
                    UpdateToolLifes(toolTypeLife, userID, recordTime);
                }
                else if (toolTypeLife.InfoState == InfoState.Unchanged)
                {
                    _SourceToolTypeLifes.Remove(toolTypeLife);
                }

                //紀錄歷史紀錄[CST_TOOL_TYPE_LIFE_LOG]
                if (actionType != ActionType.None)
                {
                    LogCenter.LogToDB(toolTypeLife, LogCenter.LogIndicator.Create(actionType, userID, recordTime));
                }
            });
        }
Exemple #8
0
        protected void gvQuery_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                int dataIndex = gvQuery.Rows[e.RowIndex].DataItemIndex;

                //取得登入者資訊
                var recordTime = DBCenter.GetSystemTime();
                var userID     = User.Identity.Name;

                using (CimesTransactionScope cts = CimesTransactionScope.Create())
                {
                    //刪除主檔資料
                    _ToolDevices[dataIndex].DeleteFromDB();

                    LogCenter.LogToDB(_ToolDevices[dataIndex], LogCenter.LogIndicator.Create(ActionType.Remove, userID, recordTime));

                    //取得明細資料
                    var toolDeviceDetails = CSTToolDeviceDetailInfo.GetDataListByToolDeviceSID(_ToolDevices[dataIndex].ToolDeviceSID);
                    toolDeviceDetails.ForEach(toolDeviceDetail =>
                    {
                        //刪除明細資料
                        toolDeviceDetail.DeleteFromDB();

                        LogCenter.LogToDB(toolDeviceDetail, LogCenter.LogIndicator.Create(ActionType.Remove, userID, recordTime));
                    });

                    cts.Complete();
                }

                QueryData();
            }
            catch (Exception E)
            {
                HandleError(E);
            }
        }
Exemple #9
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 #10
0
        /// <summary>
        /// 確認
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                //確認是否輸入機台
                ttbEquipment.Must(lblEquipment);

                int checkedCount = 0;

                #region 確認是否有勾選資料
                for (int i = 0; i < gvQuery.Rows.Count; i++)
                {
                    var thisCheckBox = (CheckBox)gvQuery.Rows[i].FindControl("ckbSelect");
                    if (thisCheckBox.Checked)
                    {
                        checkedCount++;
                    }
                }

                if(checkedCount == 0)
                {
                    // [00816]請至少選取一個{0}!
                    throw new Exception(TextMessage.Error.T00816(GetUIResource("ToolName")));
                }
                #endregion

                TransactionStamp txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);

                using (var cts = CimesTransactionScope.Create())
                {
                    //新的群組ID
                    string newGroupID = DBCenter.GetSystemID();

                    for (int i = 0; i < gvQuery.Rows.Count; i++)
                    {
                        var thisCheckBox = (CheckBox)gvQuery.Rows[i].FindControl("ckbSelect");

                        //只有勾選的刀具才要下機
                        if (thisCheckBox.Checked)
                        {
                            //因刀具報表需求,所以在下機時要將當下的使用次數記錄在UDC07
                            var toolLifeList = CSTToolLifeInfo.GetToolLifeByToolNmae(_ToolList[i].ToolName);
                            var toolLife = toolLifeList.Find(p => p.Head == _ToolList[i].Head);
                            TMSTransaction.ModifyToolSystemAttribute(_ToolList[i], "USERDEFINECOL07", toolLife.UseCount.ToCimesString(), txnStamp);

                            //因為下機後在tool_hist會沒有機台資訊,所以在下機前把機台資訊記到remark(刀具報表需要用到)
                            txnStamp.Remark = _EquipData.EquipmentName;
                            //刀具下機台
                            TMSTxn.Default.RemoveToolFromEquipment(_ToolList[i], _EquipData, txnStamp);

                            //變更刀具 GROUPID
                            TMSTransaction.ModifyToolSystemAttribute(_ToolList[i], "GROUPID", newGroupID, txnStamp);

                            //變更儲位為Hub
                            TMSTransaction.ModifyToolSystemAttribute(_ToolList[i], "Location", "Hub", txnStamp);

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

                            //變更配件狀態為USED
                            TMSTransaction.ChangeToolState(_ToolList[i], newStateInfo, txnStamp);
                        }
                    }

                    //依據機台編號資料刪除[CST_EQP_TOOL_RELEASE]
                    var lstEqpToolRelease = CSTEquipmentToolReleaseInfo.GetDataByEquipment(_EquipData.EquipmentName);
                    lstEqpToolRelease.ForEach(p => {
                        p.DeleteFromDB();
                        LogCenter.LogToDB(p, LogCenter.LogIndicator.Create(ActionType.Remove, txnStamp.UserID, txnStamp.RecordTime));
                    });

                    //依據機台編號資料刪除[CST_EQP_DEVICE_RELEASE]
                    var lstEqpDeviceRelease = CSTEquipmentDeviceReleaseInfo.GetDataByEquipment(_EquipData.EquipmentName);
                    lstEqpDeviceRelease.ForEach(p => {
                        p.DeleteFromDB();
                        LogCenter.LogToDB(p, LogCenter.LogIndicator.Create(ActionType.Remove, txnStamp.UserID, txnStamp.RecordTime));
                    });

                    cts.Complete();
                }

                ClearField();

                AjaxFocus(ttbEquipment);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
Exemple #11
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);
            }
        }
Exemple #12
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);
            }
        }
Exemple #13
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);
            }
        }
Exemple #14
0
        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);
            }
        }
Exemple #15
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                //取得登入者資訊
                var recordTime = DBCenter.GetSystemTime();
                var userID     = User.Identity.Name;

                //確認是否有資料
                if (_ModifyToolDeviceDetails.Count == 0)
                {
                    //請新增一筆刀具類型資料!
                    throw new Exception(RuleMessage.Error.C10122());
                }

                using (var cts = CimesTransactionScope.Create())
                {
                    CSTToolDeviceInfo toolDevice = null;

                    //如果傳入ToolDeviceSID為NULL,表示要新增一筆CST_TOOL_DEVICE資料
                    if (_CurrentToolDeviceSID.IsNullOrTrimEmpty())
                    {
                        toolDevice               = InfoCenter.Create <CSTToolDeviceInfo>();
                        toolDevice.DeviceName    = ttbDevice.Text;
                        toolDevice.EquipmentName = ttbEquipment.Text;
                        toolDevice.Tag           = 1;

                        toolDevice.InsertToDB(userID, recordTime);
                        LogCenter.LogToDB(toolDevice, LogCenter.LogIndicator.Create(ActionType.Add, userID, recordTime));
                    }
                    else
                    {
                        toolDevice = InfoCenter.GetBySID <CSTToolDeviceInfo>(_CurrentToolDeviceSID);
                    }

                    #region 更新資料清單
                    _ModifyToolDeviceDetails.ForEach(deviceDetail =>
                    {
                        //註記資料LOG的狀態
                        ActionType deviceDetailActionType = new ActionType();

                        if (deviceDetail.InfoState == InfoState.NewCreate)
                        {
                            deviceDetail.ToolDeviceSID = toolDevice.ToolDeviceSID;

                            //新增資料
                            deviceDetail.InsertToDB(userID, recordTime);
                            deviceDetailActionType = ActionType.Add;
                        }
                        else if (deviceDetail.InfoState == InfoState.Modified)
                        {
                            //更改資料
                            deviceDetail.UpdateToDB(userID, recordTime);
                            deviceDetailActionType = ActionType.Set;
                            _SourceToolDeviceDetails.Remove(deviceDetail);
                        }
                        else if (deviceDetail.InfoState == InfoState.Unchanged)
                        {
                            _SourceToolDeviceDetails.Remove(deviceDetail);
                        }

                        //紀錄歷史紀錄[CST_TOOL_DEVICE_DETAIL_LOG],有異動資料才更新
                        if (deviceDetailActionType != ActionType.None)
                        {
                            LogCenter.LogToDB(deviceDetail, LogCenter.LogIndicator.Create(deviceDetailActionType, userID, recordTime));
                        }
                    });
                    #endregion

                    #region 處理資料刪除的部份
                    _SourceToolDeviceDetails.ForEach(deviceDetail =>
                    {
                        deviceDetail.DeleteFromDB();

                        LogCenter.LogToDB(deviceDetail, LogCenter.LogIndicator.Create(ActionType.Remove, userID, recordTime));
                    });
                    #endregion

                    cts.Complete();
                }

                //INF-00002:{0}儲存成功!
                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00083(""), MessageShowOptions.OnLabel);

                ClearData();

                LoadControlDefault();

                QueryData();

                btnExit_Click(null, EventArgs.Empty);
            }
            catch (Exception E)
            {
                HandleError(E);
            }
        }