Index.aspx.cs
上传用户:shjujing
上传日期:2022-07-28
资源大小:11244k
文件大小:4k
源码类别:

Email客户端

开发平台:

Visual C++

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using System.Data.SqlClient;  ///引入命名空间
  12. public partial class IndexFrame_Main : System.Web.UI.Page
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.     }
  17.     protected void btnOK_Click(object sender, EventArgs e)
  18.     {
  19.         if (Request.Cookies["CheckCode"] == null)
  20.         {
  21.             Response.Write("<script language=javascript>alert('您的浏览器设置已被禁用 Cookies,您必须设置浏览器允许使用 Cookies 选项后才能使用本系统。')</script>");
  22.             return;
  23.         }
  24.         if (this.CheckBox1.Checked)
  25.         {
  26.             if (String.Compare(Request.Cookies["CheckCode"].Value, txtCheckCode.Text.ToUpper(), true) != 0)
  27.             {
  28.                 Response.Write("<script language=javascript>alert('验证码错误,请重新输入!')</script>");
  29.                 return;
  30.             }
  31.             else
  32.             {
  33.                 SqlConnection Con = new SqlConnection(ConfigurationManager.AppSettings["ConSQL"]);
  34.                 Con.Open();
  35.                 SqlCommand Com = new SqlCommand("select * from tb_User where UserName='" + this.txtName.Text + "' and PassWord='" + this.txtPwd.Text + "' and Popedom='0'", Con);
  36.                 SqlDataReader dr = Com.ExecuteReader();
  37.                 dr.Read();
  38.                 if (dr.HasRows)
  39.                 {
  40.                     Session["UserName"] = dr["UserName"].ToString();
  41.                     Session["Name"] = dr["Name"].ToString();
  42.                     Session["PassWord"] = dr["PassWord"].ToString();
  43.                     Session["Popedom"] = dr["Popedom"].ToString();
  44.                     Session.Timeout = 100;
  45.                     string cmdtxt = "INSERT INTO tb_LoginLog(UserName,LoginTime,LoginIP)";
  46.                     cmdtxt += " VALUES('" + dr["UserName"].ToString() + "','" + DateTime.Now + "','" + Request.UserHostAddress + "')";
  47.                     SqlData da = new SqlData();
  48.                     da.ExceSQL(cmdtxt);
  49.                     Response.Redirect("Module/Index.aspx");
  50.                 }
  51.                 else
  52.                 {
  53.                     Response.Write("<script language=javascript>alert('用户名或密码不正确!');</script>");
  54.                 }
  55.                 dr.Close();
  56.             }
  57.         }
  58.         else
  59.         {
  60.             if (String.Compare(Request.Cookies["CheckCode"].Value, txtCheckCode.Text.ToUpper(), true) != 0)
  61.             {
  62.                 Response.Write("<script language=javascript>alert('验证码错误,请重新输入!')</script>");
  63.                 return;
  64.             }
  65.             else
  66.             {
  67.                 SqlConnection Con = new SqlConnection(ConfigurationManager.AppSettings["ConSQL"]);
  68.                 Con.Open();
  69.                 SqlCommand Com = new SqlCommand("select * from tb_User where UserName='" + this.txtName.Text + "' and PassWord='" + this.txtPwd.Text + "' and Popedom='1'", Con);
  70.                 SqlDataReader dr = Com.ExecuteReader();
  71.                 dr.Read();
  72.                 if (dr.HasRows)
  73.                 {
  74.                     Session["UserName"] = dr["UserName"].ToString();
  75.                     Session["Name"] = dr["Name"].ToString();
  76.                     Session["PassWord"] = dr["PassWord"].ToString();
  77.                     Session["Popedom"] = dr["Popedom"].ToString();
  78.                     string cmdtxt = "INSERT INTO tb_LoginLog(UserName,LoginTime,LoginIP)";
  79.                     cmdtxt += " VALUES('" + dr["UserName"].ToString() + "','" + DateTime.Now + "','" + Request.UserHostAddress + "')";
  80.                     SqlData da = new SqlData();
  81.                     da.ExceSQL(cmdtxt);
  82.                     Response.Redirect("Module/Index.aspx");
  83.                 }
  84.                 else
  85.                 {
  86.                     Response.Write("<script language=javascript>alert('用户名或密码不正确!');</script>");
  87.                 }
  88.                 dr.Close();
  89.             }
  90.         }
  91.     }
  92. }