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

📄 register.aspx.cs

📁 ASP.net网站开发四“酷”全书:新闻、论坛、电子商城、博客_源码
💻 CS
📖 第 1 页 / 共 2 页
字号:
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 SampleForum.SetData;
using System.Data.SqlClient;
using BusObjectForum;
using System.Data.OleDb;
namespace SampleForum.Forum
{
	/// <summary>
	/// WebForm1 的摘要说明。
	/// </summary>
	public class TopicList : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label labLoginName;
		protected System.Web.UI.WebControls.Label labLoginPWD;
		protected System.Web.UI.WebControls.Label labConfirmPWD;
		protected System.Web.UI.WebControls.Label labRealName;
		protected System.Web.UI.WebControls.Label labDistrict;
		protected System.Web.UI.WebControls.Label labPhone;
		protected System.Web.UI.WebControls.Label labMobile;
		protected System.Web.UI.WebControls.Label labMSN;
		protected System.Web.UI.WebControls.Label labOICQ;
		protected System.Web.UI.WebControls.Label labPostCode;
		protected System.Web.UI.WebControls.Label labCardNo;
		protected System.Web.UI.WebControls.TextBox txtLoginName;
		protected System.Web.UI.WebControls.TextBox txtLoginPWD;
		protected System.Web.UI.WebControls.TextBox txtConfirmPWD;
		protected System.Web.UI.WebControls.TextBox txtRealName;
		protected System.Web.UI.WebControls.TextBox txtPhoneNO;
		protected System.Web.UI.WebControls.TextBox txtMobile;
		protected System.Web.UI.WebControls.TextBox txtMSN;
		protected System.Web.UI.WebControls.TextBox txtICQ;
		protected System.Web.UI.WebControls.TextBox txtQQ;
		protected System.Web.UI.WebControls.TextBox txtPostCode;
		protected System.Web.UI.WebControls.TextBox txtCardNo;
		protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
		protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
		protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator3;
		protected System.Web.UI.WebControls.Label labGender;
		protected System.Web.UI.WebControls.Label LabAge;
		protected System.Web.UI.WebControls.TextBox txtAge;
		protected System.Web.UI.WebControls.Button btnOK;
		protected System.Web.UI.WebControls.Button btnCandel;
		protected System.Web.UI.WebControls.DropDownList selDistrict;
		protected System.Web.UI.WebControls.DropDownList selGender;
		protected System.Web.UI.WebControls.Button btnUpdate;
		protected System.Web.UI.WebControls.Label labICQ;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			string strState = Request.QueryString["state"];
			//修改状态需要重新初始化表单
			string strUID="";
			string ErrDesc = "";
			if(strState=="edit")
			{
				this.btnOK.Visible = false;
				try
				{
					strUID = Session["UserID"].ToString();
				}
				catch(NullReferenceException exp)
				{
					strUID = "";
				}	
				if(strUID=="")
				{
					Response.Write ("没有登陆,取不到注册信息!");
					Response.Write ("<A href='../InitList.aspx'>返回</A>");
					Response.End();
				}
				else
				{
					Initform(OLEDBCONNSTRING,strUID,out ErrDesc);
					if(ErrDesc=="")
					{
					}
					else
					{
						Response.Write ("发生错误:"+ErrDesc);
					}
				}
			}
			else
			{
				this.btnUpdate.Visible=false;
			}
		}
		private void Initform(string strConn,string UID,out string ErrDesc)
		{
			LoginC oLogin = new LoginC();
			DataSet oDataSet = oLogin.getUserInfoByID(UID,strConn,out ErrDesc);
			if(!Page.IsPostBack)
			if(ErrDesc=="")
			{
				txtLoginName.Text = oDataSet.Tables[0].Rows[0].ItemArray[4].ToString();
				this.txtLoginPWD.Text = oDataSet.Tables[0].Rows[0].ItemArray[5].ToString();
				this.txtConfirmPWD.Text = oDataSet.Tables[0].Rows[0].ItemArray[5].ToString();
				this.txtRealName.Text = oDataSet.Tables[0].Rows[0].ItemArray[8].ToString();
				this.selGender.SelectedValue = oDataSet.Tables[0].Rows[0].ItemArray[27].ToString()=="1"?"true":"false";
				this.txtAge.Text =oDataSet.Tables[0].Rows[0].ItemArray[26].ToString();
				this.selDistrict.SelectedValue = oDataSet.Tables[0].Rows[0].ItemArray[14].ToString();
				this.txtPhoneNO.Text=oDataSet.Tables[0].Rows[0].ItemArray[9].ToString();
				this.txtMobile .Text = oDataSet.Tables[0].Rows[0].ItemArray[10].ToString();
				this.txtMSN.Text = oDataSet.Tables[0].Rows[0].ItemArray[11].ToString();
				this.txtICQ.Text =oDataSet.Tables[0].Rows[0].ItemArray[13].ToString();
				this.txtQQ.Text=oDataSet.Tables[0].Rows[0].ItemArray[12].ToString();
				this.txtPostCode.Text =oDataSet.Tables[0].Rows[0].ItemArray[15].ToString();
				this.txtCardNo.Text=oDataSet.Tables[0].Rows[0].ItemArray[20].ToString();
			}
			else
			{
			}
		}
		public static string CONNSTRING
		{
			get
			{
				connect_strings oConn = new connect_strings();
				return oConn.SqlConnectionString;
			}
		}
		public static string OLEDBCONNSTRING
		{
			get
			{
				connect_strings oConn = new connect_strings();
				return oConn.OLEDBConnectionString;
			}
		}
		//检查用户唯一性
		public bool CheckOnlyUser(string strConn,out string ErrDesc)
		{
			ErrDesc = "";
			string sql = "select count(*) as fintLoginCount from T_Operator where fbitNoUsed=0 and  fchrLoginName = '" + this.txtLoginName.Text + "'";
			OleDbConnection oConn = new OleDbConnection(strConn);
			oConn.Open();
			OleDbCommand oCommand = new OleDbCommand(sql,oConn);
			OleDbDataReader oReader = oCommand.ExecuteReader();
			while (oReader.Read())
			{
				if(oReader.GetInt32(0)==0)
				{
					return true;
				}
			}
			oReader.Close();
			oConn.Close();
			return false;
		}
		//注册新用户
		private bool RegisterUser(string conn,out string ErrDesc)
		{
			ErrDesc = "";
			string sql = "insert into T_Operator (fchrOperatorID,fchrOperatorName,fchrMarkID,flotMark," +
				"fchrLoginName,fchrPassWord,fchrIcon,fdtmDate,fchrRealName,fchrPhoneNo," +
				"fchrMobile,fchrMSN,fchrQQ,fchrICQ,fchrDistrict,fchrPostCode,fbitIsAdmin,fbitIsPower," +
				"flotTopicCount,flotForumCount,fchrCardNo,fchrIP,fbitNoUsed,fbitKickOff,fchrKickOff," +
				"flotAge,fbitGender)" +
				"values(@fchrOperatorID,@fchrOperatorName,@fchrMarkID,@flotMark," +
				"@fchrLoginName,@fchrPassWord,@fchrIcon,@fdtmDate,@fchrRealName,@fchrPhoneNo," +
				"@fchrMobile,@fchrMSN,@fchrQQ,@fchrICQ,@fchrDistrict,@fchrPostCode,@fbitIsAdmin,@fbitIsPower," +
				"@flotTopicCount,@flotForumCount,@fchrCardNo,@fchrIP,@fbitNoUsed,@fbitKickOff,@fchrKickOff," +
				"@flotAge,@fbitGender)";
			SqlConnection oConn = new SqlConnection(CONNSTRING);
			
			SqlCommand oCommand = new SqlCommand(sql,oConn);
			oCommand.Parameters.Add(new SqlParameter("@fchrOperatorID",SqlDbType.UniqueIdentifier,16));
			oCommand.Parameters.Add(new SqlParameter("@fchrOperatorName",SqlDbType.VarChar,50));
			oCommand.Parameters.Add(new SqlParameter("@fchrMarkID",SqlDbType.VarChar,50));
			oCommand.Parameters.Add(new SqlParameter("@flotMark",SqlDbType.Float,8));
			oCommand.Parameters.Add(new SqlParameter("@fchrLoginName",SqlDbType.VarChar,50));
			oCommand.Parameters.Add(new SqlParameter("@fchrPassWord",SqlDbType.VarChar,50));
			oCommand.Parameters.Add(new SqlParameter("@fchrIcon",SqlDbType.VarChar,50));
			oCommand.Parameters.Add(new SqlParameter("@fdtmDate",SqlDbType.DateTime ,8));
			oCommand.Parameters.Add(new SqlParameter("@fchrRealName",SqlDbType.VarChar,50));
			oCommand.Parameters.Add(new SqlParameter("@fchrPhoneNo",SqlDbType.VarChar,50));
			oCommand.Parameters.Add(new SqlParameter("@fchrMobile",SqlDbType.VarChar,50));
			oCommand.Parameters.Add(new SqlParameter("@fchrMSN",SqlDbType.VarChar,50));
			oCommand.Parameters.Add(new SqlParameter("@fchrQQ",SqlDbType.VarChar,50));
			oCommand.Parameters.Add(new SqlParameter("@fchrICQ",SqlDbType.VarChar,50));
			oCommand.Parameters.Add(new SqlParameter("@fchrDistrict",SqlDbType.VarChar,50));

⌨️ 快捷键说明

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