module_add.aspx.cs.svn-base

来自「很好的OA框架,使用ASP.NET+C#+sqlserver2005」· SVN-BASE 代码 · 共 82 行

SVN-BASE
82
字号
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Sovo.OA.BLL;
using Sovo.OA.BLL.Utils;
using Sovo.OA.Model;

public partial class Admin_System_module_add : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ModuleBLL mBLL = new ModuleBLL();
        GridView1.DataSource = mBLL.getAllModulesForDS();
        GridView1.DataBind();
    }
    protected void ddlParentModule_DataBound(object sender, EventArgs e)
    {
        //加入所有权限的根目录
        ddlParentModule.Items.Insert(0, new ListItem("root", "100"));
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        ModuleBLL mBLL = new ModuleBLL();
        String parentID = ddlParentModule.SelectedItem.Value;
        String moduleID = mBLL.getNextID(parentID);
        lblMsg.Text = "parentID=" + parentID + "moduleID=" + moduleID;

        String moduleName = txtModuleName.Text;
        String description = txtModuleDescription.Text;
        String link = txtLink.Text;

        //--再数据库中新增Module
        mBLL.addModule(moduleID, moduleName, parentID, description, link);

        ddlParentModule.DataSourceID = "";
        ddlParentModule.DataSource = mBLL.getFristModules();
        ddlParentModule.DataBind();

        GridView1.DataSource = mBLL.getAllModulesForDS();
        GridView1.DataBind();

        
    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int index = Convert.ToInt32(e.CommandArgument.ToString());
        String moduleID = Convert.ToString(GridView1.DataKeys[index].Value);
        if (e.CommandName == "deleteModule")
        {
            ModuleBLL mBLL = new ModuleBLL();
            DBResult result = mBLL.deleteModuleByID(moduleID);
            Literal txtMsg = new Literal();
            if (result == DBResult.Success)
            {
                txtMsg.Text = "<script>alert('删除成功!')</script>";
                Page.Controls.Add(txtMsg);
            }
            else
            {
                txtMsg.Text = "<script>alert('删除失败!')</script>";
                Page.Controls.Add(txtMsg);
            }

            GridView1.DataSource = mBLL.getAllModulesForDS();
            GridView1.DataBind();

            ddlParentModule.DataSourceID = "";
            ddlParentModule.DataSource = mBLL.getFristModules();
            ddlParentModule.DataBind();


        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?