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

📄 default.aspx.cs

📁 固定资产管理系统 登陆
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
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 System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
// 在此处放置用户代码以初始化页面
			if(Session["UserId"]==null)
			{
				//如果用户未登录
				Panel3.Visible=false;
				Panel2.Visible=false;
			}
			else
			{
				//如果登录
				Panel3.Visible=true;
                btn_new_rec.Attributes.Add("onclick", "javasrcipt:window.open('Enter_Record.aspx');");
                btn_select_update.Attributes.Add("onclick", "javasrcipt:window.open('Query_Update.aspx');");
                btn_export.Attributes.Add("onclick", "javasrcipt:window.open('TablesView.aspx');");
			}

    }
    protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {

    }
    protected void ChangePassword1_ChangedPassword(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string sql = "select id from UserLogin where UserId= '" + TextBox1.Text + "' and Password='" + TextBox2.Text + "'";
        SqlConnection scon = new SqlConnection("server=42.1.47.11;database=AssetsDB;uid=yy;pwd=123456;");
        scon.Open();
        SqlCommand scmd = new SqlCommand(sql, scon);
        int count = Convert.ToInt32(scmd.ExecuteScalar());
        if (count > 0)
        {

            Session["UserId"] = TextBox1.Text;  //新建一个Session
            Session["Password"] = TextBox2.Text;
            msg.Text = "管理员登录成功,欢迎您!";
            TextBox2.Visible = false;
            Panel3.Visible = true;
         }
        else
            msg.Text = "用户名或密码错误。";
            TextBox1.Text = "";
            TextBox2.Text = "";


    }
    
    

    protected void Button3_Click1(object sender, EventArgs e)
    {
        if (msg.Text == "管理员登录成功,欢迎您!")
        {    
           Panel2.Visible = !Panel2.Visible;
           Panel3.Visible = !Panel2.Visible;
           if (Panel2.Visible == false)
           {
               Button3.Text = "密码修改";
           }
           else
           {
               Button3.Text = "功能选择";
           }
        }
        else
        {
            msg.Text = "您还没有登录!";
        }
    }
    protected void Button2_Click1(object sender, EventArgs e)
    {

        try
        {
            if (TextBox4.Text == TextBox5.Text)
            {
                SqlConnection scon = new SqlConnection("server=42.1.47.11;database=AssetsDB;uid=yy;pwd=123456;");
                scon.Open();
                string strsql = "update UserLogin set Password='" + TextBox5.Text + "' where UserId='" + TextBox3.Text + "'";
                SqlCommand cmd = new SqlCommand(strsql, scon);
                cmd.ExecuteNonQuery();
                scon.Close();
                msg2.Text = "修改成功";
                Response.Write("<script language=javascript>alert('修改密码成功!')</script>");
                Panel3.Visible = true;
                Panel2.Visible = false;

            }
            else
            {
                msg2.Text = "确认新密码与新密码不同!";
            }

        }
        catch
        {
            msg2.Text = "修改不成功";
        }

    }

}

⌨️ 快捷键说明

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