C#的管理系统 用户权限菜单管理(1)

这是一个C#编写的用户登录管理系统,包含用户登录检查、数据交互及操作功能,如新增、编辑、删除用户。通过datagrid展示数据,并提供分页、查询功能。用户权限通过角色与菜单关联进行管理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>login</title>
    <link href="content/login/css/component.css" rel="stylesheet" type="text/css" />
    <link href="content/login/css/demo.css" rel="stylesheet" type="text/css" />
    <link href="content/login/css/normalize.css" rel="stylesheet" type="text/css" />
    <script src="jquery-3.3.1.min.js"></script>
    <script>
        $(function () {
            $('#btnOK').click(function () {
                var usercode = $('#txtlogname').val();
                var password = $('#txtlogpass').val();
                $.ajax({
                    type: "post",
                    url: "Login.aspx?action=login",
                    data: { usercode: usercode, password: password },
                    //contentType: 'application/json',
                    dataType: 'json',
                    success: function (data) {

                        if (data.isSuccessed) {
                            location.href = "Main.aspx";
                        }
                        else
                            alert(data.Message);

                    },
                    error: function (xmlReq, err, c) {
                        alert("error:" + err);
                    }
                });
            })

        })
    </script>
</head>
<body>
    <div class="container demo-1">
        <div class="content">
            <div id="large-header" class="large-header">
                <canvas id="demo-canvas"></canvas>
                <div class="logo_box">
                    <h3>校园招聘信息系统</h3>
                    <form action="#" name="f" method="post">
                        <div class="input_outer">
                            <span class="u_user"></span>
                            <input id="txtlogname" name="txtlogname" class="text" style="color: #FFFFFF !important" type="text" placeholder="请输入账户" />
                        </div>
                        <div class="input_outer">
                            <span class="us_uer"></span>
                            <input id="txtlogpass" name="txtlogpass" class="text" style="color: #FFFFFF !important; position: absolute; z-index: 100;" value="" type="password" placeholder="请输入密码" />
                        </div>
                        <%--<input id ="btnOK" value="登录" style="width:100%;" type="button" class="act-but submit"/>--%>
                        <div class="mb2">
                            <input id="btnOK" value="登录" style="width: 100%;" type="button" class="act-but submit" />-</div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!-- /container -->
    <script src="content/login/js/TweenLite.min.js"></script>
    <script src="content/login/js/EasePack.min.js"></script>
    <script src="content/login/js/rAF.js"></script>
    <script src="content/login/js/demo-1.js"></script>
    <div style="text-align: center;">
    </div>
</body>

</html>

public partial class Login : BasePage
{

        protected void Page_Load(object sender, EventArgs e)
        {
            string action = Request.QueryString["action"] == null ? "" : Request.QueryString["action"];
            switch (action)
            {
                case "login":
                    CheckLogin();
                    break;
            }
        }
        private void CheckLogin()
        {
            string strusercode, strpassword;
            strusercode = Request.Form["usercode"];
            strpassword = Request.Form["password"];
            SQLHelper db = new SQLHelper();
            string strSql = "select * from sysuser where usercode='{0}' and pwd='{1}'";
            strSql = string.Format(strSql, strusercode, strpassword);

            DataTable dt = db.ExecuteQuery(strSql, CommandType.Text);
            if (dt.Rows.Count == 1)
            {
                Session["usercode"] = dt.Rows[0]["usercode"].ToString();
                Session["username"] = dt.Rows[0]["username"].ToString();
                WriteMessage(true, "");
            }
            else
            {
                WriteMessage(false, "登录失败!");
            }
        }
    }

///事件

 <script>
        $(function () {
            loaddata();


            $('#btnQuery').on('click', function () {
                $('#dg').datagrid('options').queryParams = condition();
                $("#dg").datagrid('reload');
            })

            //获取页大小变化事件
            var pg = $("#dg").datagrid("getPager");
            if (pg) {
                $(pg).pagination({
                    onChangePageSize: function () {
                        $('#dg').datagrid('options').queryParams = condition();
                        $("#dg").datagrid('reload');
                        //alert('pagesize changed');
                    }
                });
            }
            //新增事件  begin
            $('#btnAdd').on('click', function () {
                $('#w').dialog({
                    title: '新增数据',
                    width: 400,
                    height: 200,
                    closed: false,
                    cache: false,
                    href: 'useredit.aspx?action=add',
                    modal: true,
                    buttons: [{
                        text: '确定',
                        iconCls: 'icon-ok',
                        handler: function () {
                            //数据保存代码                            
                            $('#ff').form('submit', {
                                url: "useredit.aspx?action=addrecord",    //表单提交地址 并带参数
                                onSubmit: function () {
                                    return $(this).form('validate');  //验证表单是否通过验证规则
                                },
                                success: function (returndata) {
                                    var obj = eval("(" + returndata + ")")
                                    if (obj.isSuccessed) {
                                        $('#dg').datagrid('reload');   //刷新数据表格datagrid
                                        $('#w').dialog('close');    //关闭弹出新增窗口
                                        $.messager.show({
                                            title: '提示',
                                            msg: obj.Message,
                                            timeout: 2000,
                                            showType: 'show'
                                        });
                                    }
                                    else {
                                        alert('保存失败!');
                                    }
                                }
                            });
                        }
                    }, {
                        text: '关闭',
                        iconCls: 'icon-delete',
                        handler: function () {
      &nbs

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值