⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 show.aspx.cs

📁 可以实现用户的添加、修改及模糊搜索及登陆验证 将DB_51aspx文件里面的 数据库文件 附加就可以了 数据库为(Sqlserver 2005 ) 帐号/密码: 51aspx/51aspx We
💻 CS
字号:
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;

public partial class show : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
        UserLogin.LoginNo();
        if (!Page.IsPostBack)
        {
        Getinfo();
        Panel2.Visible = false;
        if (Request.QueryString["ac"]=="edit")
        {
            Panel2.Visible = true;
        }
        }
        

    }
    protected void Getinfo()
    {
        string urlid = Request.QueryString["id"];
        string urlac=Request.QueryString["ac"];
        if (urlid != string.Empty)
        {
            Info info = new Info();
            info.ID = Convert.ToInt32(urlid);
            Dal dal = new Dal();
            DataTable Dt = dal.Getinfo(info);
            if (urlac != "edit")
            {
                Panel1.Visible = true;
                Panel2.Visible = false;
                name.Text = Dt.Rows[0]["I_UserName"].ToString();
                pwd.Text = Dt.Rows[0]["I_Userpwd"].ToString();
                isadmin.Text = Dt.Rows[0]["I_IsAdmin"].ToString();
            }
            else if (urlac == "edit")
            {
                Panel2.Visible = true;
                Panel1.Visible = false;
                nametext.Text = Dt.Rows[0]["I_UserName"].ToString();
                pwdtext.Text = Dt.Rows[0]["I_Userpwd"].ToString();
                admintext.Text = Dt.Rows[0]["I_IsAdmin"].ToString();
            }
        }
        else
        {
            Response.Write("没有任何值!");
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        string url=Request.RawUrl;
        Panel1.Visible = false;
        Response.Redirect(url+"&ac=edit");
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string _id = Request.QueryString["id"];
        Info user = new Info();
        Dal work = new Dal();
        user.ID=Convert.ToInt32(_id);
        user.Name = nametext.Text;
        user.Pwd = pwdtext.Text;
        user.IsAdmin = admintext.Text;
       int result= work.Update(user);
       if (result!=0)
       {
           string js = "show.aspx?id=" + Request.QueryString["id"];
           Panel1.Visible = true;
           Panel2.Visible = false;
           Jscript.AlertAndRedirect("修改成功!", js);
       }
       else
       {
           Jscript.AlertAndRedirect("修改失败!", Request.RawUrl);
       }
       
        
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        //Response.Write("单击了");
        string _id = Request.QueryString["id"];
        Info deluser = new Info();
        Dal Del= new Dal();
        deluser.ID = Convert.ToInt32(_id);
        int result = Del.Delete(deluser);
        if (result != 0)
        {
            Jscript.AlertAndRedirect("删除成功!,返回列表页面","View.aspx");
        }
        else
        {
            Jscript.AlertAndRedirect("删除失败!,返回", "View.aspx");
        }
    }
}

⌨️ 快捷键说明

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