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

📄 login.aspx.cs

📁 asp.net 的某物流管理系统 MIS 系统
💻 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;
using System.Text;
using System.Data.OleDb;

public partial class admin_login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    	
 //   	Response.Write(Myencode("51aspx"));
 //   	Response.End();
        try
        {
            if (Session["Leaveword"].ToString() == "pass")
            {
                Response.Redirect("Loginsuccess.aspx");
            }
        }
        catch
        {
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //验证码
        if (txtCheck.Text.ToString() != Session["Checkcode"].ToString())
        {
            lblNote.Text = "验证码错误!";
            txtCheck.Text = "";
            return;      
        }
        //用户名和密码是否为空
        if (txtUsername.Text.Trim().Length < 1 || txtPassword.Text.Trim().Length < 1)
        {
            lblNote.Text = "用户名和密码不能空!";
            return;
        }
        string myname = txtUsername.Text.ToString().Trim();
        string mypass = Myencode(txtPassword.Text.ToString().Trim());

        OleDbDataReader dr = Loginusername(myname);
        string strtemp = "";
        //登陆
        if (dr.Read())
        {
            strtemp = dr["Mypassword"].ToString();
        }
        //设置登陆标志
        if (strtemp==mypass.Trim())
        {
            Session["Leaveword"] = "pass";
            dr.Close();
            Response.Redirect("Loginsuccess.aspx");
        }
        else
        {
            lblNote.Text = "用户名和密码错误";
        }
    }

    protected void Button3_Click(object sender, EventArgs e)
    {
        txtCheck.Text = "";
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Write("<script>parent.location.replace('../Reginster.aspx');</script>");
    }
    public OleDbDataReader Loginusername(string sName)
    {
        string myConnectionString = ConfigurationManager.ConnectionStrings["OLEDBCONNECTIONSTRING1"].ConnectionString + Server.MapPath("~") + ConfigurationManager.ConnectionStrings["OLEDBCONNECTIONSTRING3"].ConnectionString;
        OleDbConnection myConnection = new OleDbConnection(myConnectionString);
        string cmdText = "SELECT * FROM Myuser WHERE Myusername='" + sName + "'";
        OleDbCommand myCommand = new OleDbCommand(cmdText, myConnection);
        OleDbDataReader dr = null;
        try
        {
            myConnection.Open();
            dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
        }
        catch (OleDbException ex)
        {
            throw new Exception(ex.Message, ex);
        }
        return dr;
    }
    public string Myencode(string spass)
    {
        Encoding utfstr = Encoding.UTF7;
        byte[] utfstrByte = utfstr.GetBytes(spass.Trim());
        string mima = BitConverter.ToString(utfstrByte);
        return mima;
    }
   
}

⌨️ 快捷键说明

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