예제 #1
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);
            }
        }
예제 #2
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);
            }
        }