📄 registerpress.aspx.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.SqlClient;
public partial class Regist : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//Response.Cache.SetCacheability(HttpCacheability.NoCache);
Hashtable user=new Hashtable();
user.Add("userName", Request.Params["userName"].Trim());
user.Add("userPassWorld", Request.Params["userPassWorld"].Trim());
user.Add("validate", Request.Params["validate"].Trim());
user.Add("quiz", Request.Params["quiz"].Trim());
user.Add("solution", Request.Params["solution"].Trim());
user.Add("email", Request.Params["email"].Trim());
user.Add("validateCode", Request.Params["validateCode"].Trim());
string updateStr = null;
string selectStr = null;
string str = null;
string key = null;
string passWorld = null;
//str = user["userPassWorld"].ToString ();
//passWorld = XOR(str, key);
selectStr = "select userName from UserTab where userName='" + user["userName"] + "'";
if (SelectTable(selectStr) >= 1)
{
Label1.Text = "用户已存在,注册失败";
return;
}
updateStr = "insert into UserTab (userId,userName,userPassWorld,quiz,solution,email ) values('" + Guid.NewGuid().ToString() + "','" + user["userName"] + "','" + user["userPassWorld"] + "','" + user["quiz"] + "','" + user["solution"] + "','" + user["email"] + "')";
if (UpDataTable(updateStr) == 1)
{
Label1.Text = "注册成功";
}
else
Label1.Text = "注册失败";
}
//private string XOR(string strV,string strPass )
//{
// int intPassLength = strPass.Length ;
// //int intstrV = strV.Length;
// string re = "";
// char[] strvArr = strV.ToCharArray();
// char[] strPassArr = strPass.ToCharArray();
// for (int i = 0; i < strV.Length; i++)
// {
// char a ,b,c;
// a = strvArr[i];
// // re += String.fromCharCode(strV.charCodeAt(i) ^ strPass.charCodeAt(i % intPassLength));
// re +=(char )( (byte)( strvArr[i]) ^ (byte )(strPassArr[i % intPassLength]));
// }
// return re;
//}
public static DataTable
FillDataTable(string sqlQuery)
{
string strConn = "Initial Catalog = shopping; Data Source=127.0.0.1; Integrated Security=true";
SqlConnection conn = new SqlConnection(strConn);
SqlDataAdapter cmd1 = new SqlDataAdapter();
cmd1.SelectCommand = new SqlCommand(sqlQuery, conn);
DataSet dataSet1 = new DataSet();
cmd1.Fill(dataSet1);
cmd1.Dispose();
conn.Close();
return dataSet1.Tables[0];
}
public static int
UpDataTable(string sqlQuery)
{
int i = 0;
string strConn = "Initial Catalog = shopping; Data Source=127.0.0.1; Integrated Security=true";
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
SqlCommand cmd = new SqlCommand(sqlQuery ,conn);
i= cmd.ExecuteNonQuery();
conn.Close();
return i;
}
public static int
SelectTable(string sqlQuery)
{
SqlDataReader readset=null ;
int i = 0;
string strConn = "Initial Catalog = shopping; Data Source=127.0.0.1; Integrated Security=true";
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
SqlCommand cmd = new SqlCommand(sqlQuery ,conn);
readset = cmd.ExecuteReader();
if (readset.HasRows == true )
i = 1;
conn.Close();
return i;
}
#region
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
/// <summary>
///
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -