Example #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);
            }
        }
Example #2
0
        protected void gvQuery_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                int iIndex = gvQuery.Rows[e.RowIndex].DataItemIndex;


                //避免新增未按下儲存就按其他資料的編輯
                string SID, Tag;
                if (ToolTypeList[iIndex].ActiveFlag == "T")     //ActiveFlag的判斷,若曾經啟用過則不可刪除
                {
                    removeListAddandDeletRow();
                    gvQuery.SetDataSource(ToolTypeList);
                    gvQuery.DataBind();
                    throw new Exception(TextMessage.Error.T00714());
                }
                else
                {
                    //  Delete Data
                    SID = ToolTypeList[iIndex].ID;
                    //避免若新增模式時,按下刪除的button,不作動作
                    if (SID.Length == 0)
                    {
                        return;
                    }

                    using (CimesTransactionScope cts = CimesTransactionScope.Create())
                    {
                        if (ToolTypeList[iIndex].DeleteFromDB() == 0)
                        {
                            throw new Exception(TextMessage.Error.T00710(""));
                        }

                        AttributeAttributeInfo.DeleteByObjectSIDAndDataClass(SID, "ToolTypeAttribute", this.User.Identity.Name, DBCenter.GetSystemTime());

                        cts.Complete();
                    }
                    _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00349(ToolTypeList[iIndex].Type));

                    ToolTypeList.RemoveAt(iIndex);

                    removeListAddandDeletRow();
                    gvQuery.SetDataSource(ToolTypeList);

                    gvQuery.EditItemIndex = -1;
                    if (gvQuery.CurrentPageIndex > ((ToolTypeList.Count - 1) / gvQuery.PageSize))
                    {
                        gvQuery.CurrentPageIndex = (ToolTypeList.Count - 1) / gvQuery.PageSize;
                    }
                    gvQuery.DataBind();
                    DisableSubControl();
                    uscAttributeSetupGrid.ClearField();
                }
            }
            catch (Exception ex)
            {
                HandleError(ex, CurrentUpdatePanel, string.Empty, MessageShowOptions.OnLabel);
            }
        }