using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace SStiForum
{
/// <summary>
/// Register 的摘要说明。
/// </summary>
public class Register : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.TextBox TextBox3;
protected System.Web.UI.WebControls.TextBox TextBox4;
protected System.Web.UI.WebControls.TextBox TextBox5;
protected System.Web.UI.WebControls.RadioButton RadioButton1;
protected System.Web.UI.WebControls.RadioButton RadioButton2;
public SqlConnection MyConn;
public SqlDataReader dr;
public string PassCheck;
public string UserName;
public string Pass;
public string QQ;
public string mail;
public string face;
public string HeadImg;
public string sex;
public int check=0;
public string Action;
public HttpCookie readcookie;
protected System.Web.UI.WebControls.Button submit;
protected System.Web.UI.WebControls.Button clear;
public string Postuser;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
Action=Request.QueryString["Action"].ToString();
UserName=Request.QueryString["UserName"].ToString();
if (UserName=="")
{
UserName=UserCheck();
if (UserName=="Wrong"&&Action!="reg")
{
Response.Redirect("Exception.aspx?ms=1");
}
}
}
public string UserCheck()
{
if (Request.Cookies["Cookie"]==null)
{
return("Wrong");
}
else
{
readcookie = Request.Cookies["Cookie"];
if (readcookie.Values["UserName"].ToString()!=null)
{
Postuser= readcookie.Values["UserName"].ToString();
Pass= readcookie.Values["Pass"].ToString();
return(Postuser);
}
else
{
return("Wrong");
}
}
}
private void Button2_Click(object sender, System.EventArgs e)
{
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
}
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
private void sumbit_Click(object sender, System.EventArgs e)
{
UserName=TextBox1.Text;
Pass=TextBox2.Text;
PassCheck=TextBox3.Text;
QQ=TextBox4.Text;
mail=TextBox5.Text;
if( RadioButton1.Checked == true )
sex="1";
else
sex="2";
face=Request.Form["HeadImage"];
HeadImg=face;
HeadImg=HeadImg.Replace("'","''");
if (PassCheck!=Pass)
{
Response.Redirect("Exception.aspx?ms=12");
}
if (UserName==""||Pass=="")
{
Response.Redirect("Exception.aspx?ms=11");
}
CMySql SP_ChekUserName = new CMySql();//错误
dr = SP_ChekUserName.CheckUserName(UserName);
while(dr.Read())
{
check=1;
}
dr.Close();
if (check==0)
{
CMySql SP_AddUser = new CMySql();//错误
SP_AddUser.AddUser(UserName,Pass,Int32.Parse(QQ),mail,Int32.Parse(sex), HeadImg);
}
if (check==1)
{
Response.Redirect("exception.aspx?ms=14");
}
else
{
Response.Redirect("Login.aspx");
}
}
}
}