ShopAdmin/AdminInfo/AddAdmin.aspx.cs

(完整代码) 1KB

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Model;
using BLL;

namespace ShopAdmin.AdminInfo
{
    public partial class AddAdmin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (SubTool.CheckAdminLogin("20"))
            {
                if (!this.IsPostBack)
                {
                    btnAdd.Attributes.Add("onclick", "return jsCheck();");
                }
            }

        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            
            D_AdminInfo aInfo = new D_AdminInfo();
            aInfo.AdminName = WebUtility.CheckStr(txtAdminName.Text);
            aInfo.AdminPwd = StringHelper.MD5String(WebUtility.CheckStr(txtPwd1.Text));
            aInfo.AdminType =Int16.Parse(ddlType.SelectedValue);
            aInfo.AdminGroupId = 0;
            aInfo.LastLoginIp = "";
            aInfo.IsEnabled = 1;

            if (aInfo.AdminName == "" || aInfo.AdminPwd == "")
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", WebUtility.Alert("带*号项必须填写!!"));
                return;
            }

            int exeResult = new D_Admin().Insert(aInfo);
            switch (exeResult)
            {
                case 1:
                    ClientScript.RegisterStartupScript(this.GetType(), "", WebUtility.AlertUrl("添加管理员成功!!", "AddAdmin.aspx"));
                    break;
                case -2:
                    ClientScript.RegisterStartupScript(this.GetType(), "", WebUtility.Alert("管理员用户名已经存在,添加失败!!"));
                    break;
                default:
                    ClientScript.RegisterStartupScript(this.GetType(), "", WebUtility.Alert("添加管理员失败!!"));
                    break;
            }
            
            
        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。