AddAdimistrator.aspx.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
namespace MyPetShop
{
    public partial class AddAdimistrator : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // 下载于www.51aspx.com
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            DB db = new DB();
            SqlConnection con = db.GetCon();//连接数据库
            con.Open();//打开连接
            //SqlConnection con = new SqlConnection();
            //con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\MyPetShop.mdf;Integrated Security=True;User Instance=True";
            //con.Open ();
            SqlCommand cmd = new SqlCommand("select AdmName from Admin", con);
            SqlDataReader sdr = cmd.ExecuteReader();
            int i = 0;

            while (sdr.Read())
            {
                if (txtName.Text.Equals(sdr["AdmName"]))
                {
                    i = 1; break;
                }
                else
                {
                    i = 0; continue;
                }
            }
            sdr.Close();
            if (i == 1)
                Page.ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('该用户已经注册!');</script>");
            if (i == 0)
            {
                if (txtCode.Text.ToUpper() == Session["validateNum"].ToString())
                {
                    SqlCommand cmd1 = new SqlCommand("insert into Admin(AdmName,AdmPwd,AdmQes,AdmAns,AdmEmail) values('" + txtName.Text.ToString() + "','" + txtPwd.Text.ToString() + "','" + txtQue.Text.ToString() + "','" + txtAns.Text.ToString() + "','" + txtEmail.Text.ToString() + "')", con);
                    cmd1.ExecuteNonQuery();
                    Page.ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('恭喜你,注册成功!');</script>");
                    txtName.Text = "";
                    txtPwd.Text = "";
                    txtpwdq.Text = "";
                    txtQue.Text = "";
                    txtAns.Text = "";
                    txtEmail.Text = "";
                    txtCode.Text = "";
                    //Response.Redirect("~/Login.aspx");
                }
            }
后面还有 3 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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