Beispiel #1
0
/// <summary>
/// 批量删除
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
        protected void btn5K_Click(object sender, EventArgs e)
        {
            try
            {
                ButtonOperationContext __ButtonOperationContext = new ButtonOperationContext();

                List <string>   SelectedValues   = (this.divctrl_userquery_view.FindControl("ctrl_userquery_view") as IUserControl).SelectedValues;
                PluginEventArgs __PluginEventArg = new PluginEventArgs()
                {
                    entityModel = null, RedirectURL = string.Empty, CurrentUserID = this.LoginUserID
                };
                {
                    #region  钮前插件
                    if (!__ButtonOperationContext.IsEnd)
                    {
                        try
                        {
                            PagePluginFactory.InvokeBeforePlugins(sender, __PluginEventArg);
                        }
                        catch (MessageException ex)
                        {
                            __ButtonOperationContext.IsEnd        = true;
                            __ButtonOperationContext.AlertMessage = ex.Message;
                        }
                    }
                    #endregion

                    #region 框架自己操作
                    if (!__ButtonOperationContext.IsEnd)
                    {
                        foreach (var ItemID in SelectedValues)
                        {
                            var item = this.GenericHelper.FindById <global::Drision.Framework.Entity.T_User>(ItemID.ToInt());
                            if (item != null)
                            {
                                this.GenericHelper.Delete(item);
                            }
                        }
                    }
                    #endregion

                    #region  钮后插件
                    if (!__ButtonOperationContext.IsEnd)
                    {
                        try
                        {
                            PagePluginFactory.InvokeAfterPlugins(sender, __PluginEventArg);
                        }
                        catch (MessageException ex)
                        {
                            __ButtonOperationContext.IsEnd        = true;
                            __ButtonOperationContext.AlertMessage = ex.Message;
                        }
                    }
                    #endregion
                    //结束事务
                    #region 最后处理
                    if (__ButtonOperationContext.IsEnd)
                    {
                        if (!string.IsNullOrEmpty(__ButtonOperationContext.AlertMessage))
                        {
                            this.AjaxAlert(__ButtonOperationContext.AlertMessage, "EnableButton();");
                            return;
                        }
                    }
                    #endregion
                }
                //重新加载数据
                (this.divctrl_userquery_view.FindControl("ctrl_userquery_view") as IUserControl).InitData();
            }
            catch (Exception ex)
            {
                DrisionLog.Add(ex);
                this.AjaxAlert(ex, "EnableButton();");
            }
        }