log.aspx.cs
上传用户:vtryaojia
上传日期:2020-04-18
资源大小:1214k
文件大小:2k
源码类别:

SCSI/ASPI

开发平台:

Others

  1. 
  2. using System;
  3. using System.Data;
  4. using System.Configuration;
  5. using System.Collections;
  6. using System.Web;
  7. using System.Web.Security;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.WebControls.WebParts;
  11. using System.Web.UI.HtmlControls;
  12. using System.Data.OleDb;
  13. using System.Text;
  14. using System.Security.Cryptography;
  15. public partial class log : System.Web.UI.Page
  16. {
  17.     protected void Page_Load(object sender, EventArgs e)
  18.     {
  19.     }
  20.     
  21.     protected void logButton_Click1(object sender, EventArgs e)
  22.     {
  23.         if (UserName.Text == "")
  24.         {
  25.             if (Password.Text == "")
  26.             {
  27.                 Response.Write("<script>alert('用户名和密码不能为空')</script>");
  28.             }
  29.             else
  30.             {
  31.                 Response.Write("<script>alert('用户名和密码不能为空')</script>");
  32.             }
  33.         }
  34.         string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~/App_Data/zzu.mdb") + ";";
  35.         OleDbConnection conn = new OleDbConnection(strConnection);
  36.         conn.Open();
  37.         OleDbCommand cmd1 = new OleDbCommand("select*from [Member] where name='" + UserName.Text.ToString() + "'and password='" + Password.Text.ToString() + "'");
  38.         cmd1.Connection = conn;
  39.         OleDbDataReader dr = cmd1.ExecuteReader();
  40.         if (dr.Read())
  41.         {
  42.             Session["name"] = dr["name"].ToString();
  43.             Session.Add("password", Password.Text);
  44.             
  45.             Response.Redirect("GoodsList.aspx");
  46.         }
  47.         else
  48.         {
  49.             Response.Write("<script>alert('用户名或密码错误')</script>");
  50.             UserName.Text = "";
  51.             Password.Text = "";
  52.         }
  53.        
  54.         conn.Close();
  55.     }
  56.   
  57.     
  58.     protected void regButton_Click(object sender, EventArgs e)
  59.     {
  60.         Response.Redirect("reg.aspx");
  61.     }
  62.     protected void Button1_Click(object sender, EventArgs e)
  63.     {
  64.         Response.Redirect("zhaohuimima.aspx");
  65.     }
  66.     protected void back_Click(object sender, EventArgs e)
  67.     {
  68.         Response.Write("<script language=javascript>history.go(-2);</script>"); 
  69.     }
  70. }