示例#1
0
    protected void OnCommandHandler(object sender, CommandEventArgs e)
    {
        using (_session = new Session())
        {
            if (e.CommandName == "DeleteSubItem")
            {
                string         itemCode = e.CommandArgument.ToString();
                DictionaryItem item     = DictionaryItem.Retrieve(_session, itemCode);
                if (item != null)
                {
                    if (item.Delete(_session))
                    {
                        QueryAndBindData(this.magicPagerMain.CurrentPageIndex, this.magicPagerMain.PageSize, true);
                    }
                }

                WebUtil.ShowMsg(this, "删除成功!");
            }
        }
        WebUtil.ShowMsg(this, e.CommandName);
    }
示例#2
0
    //MagicToolbar's MagicItem OnClick Event Handler, it's for both the top one and the bottom one.
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        try
        {
            if (e.CommandName == "Delete")
            {             // do delete
                using (_session = new Session())
                {
                    foreach (RepeaterItem item in this.rptDictionaryItem.Items)
                    {
                        HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox;
                        if (chk != null && chk.Checked)
                        {
                            string itemCode = Cast.String(chk.Attributes["itemCode"]);

                            DictionaryItem.Delete(_session, itemCode);
                        }
                    }

                    QueryAndBindData(1, this.magicPagerMain.PageSize, true);
                }
            }
        }
        catch (UnauthorizedException ex)
        {
            WebUtil.ShowMsg(this, ex.Message, "警告");
        }
        catch (ApplicationException ex)
        {
            WebUtil.ShowMsg(this, ex.Message, "提示");
        }
        catch (Exception ex)
        {
            logger.Info("删除DictionaryItem", ex);
            WebUtil.ShowError(this, ex);
        }
    }