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

📄 zhuce2.aspx.cs

📁 简易BBS源码,包括系统管理、论坛管理、用户可以看懂源码
💻 CS
字号:
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;
using System.Web.Mail;

namespace free.bbs
{
	/// <summary>
	/// Summary description for zhuece2.
	/// </summary>
	public partial class zhuce2 : System.Web.UI.Page
	{

		protected System.Data.SqlClient.SqlConnection myconn_1;
		protected System.Data.SqlClient.SqlCommand mycomm_1;
	
		protected void Page_Load(object sender, System.EventArgs e)
		{
			// Put user code to initialize the page here
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    

		}
		#endregion

		protected void Button1_Click(object sender, System.EventArgs e)
		{
			myconn_1=new SqlConnection(Session["str_connection"].ToString());
			myconn_1.Open();
			SqlDataReader mydr;
			string sqlstr="select * from huiyuan where yonghuming=@yonghuming";
			mycomm_1=new SqlCommand(sqlstr,myconn_1);
			mycomm_1.Parameters.Add(new SqlParameter("@yonghuming",SqlDbType.Char,15));
			mycomm_1.Parameters["@yonghuming"].Value=t_yonghuming.Text.Trim();
			mydr=mycomm_1.ExecuteReader();
			if (mydr.Read())
			{
				//Label1.Text="该用户已经存在,请重新输入!";
				Response.Redirect("zhucewrong.aspx?id=1");
				//Response.Write("<script>alert('该用户已经存在,请重试!')</scritp>");
				myconn_1.Close();
				mydr.Close();
				return ;
			}
			
			else if (t_mima.Text!=t_rimima.Text)
			{
				Response.Redirect("zhucewrong.aspx?id=2");
				//Label1.Text="两次输入密码不一致,请重新输入!";
				
				return ;
			}
			else if(Page.IsValid)
			{
				mydr.Close();
				DateTime time=DateTime.Now;
				sqlstr="Insert into huiyuan(yonghuming,mima,email,face,zhuceshijian,mimatishi,mimadaan) values(@yonghuming,@mima,@email,'face/000.GIF',@time,@wenti,@daan)";
				mycomm_1=new SqlCommand(sqlstr,myconn_1);
				mycomm_1.Parameters.Add(new SqlParameter("@yonghuming",SqlDbType.Char,15));
				mycomm_1.Parameters["@yonghuming"].Value=t_yonghuming.Text.Trim();
				mycomm_1.Parameters.Add(new SqlParameter("@mima",SqlDbType.Char,12));
				mycomm_1.Parameters["@mima"].Value=t_mima.Text.Trim();
				mycomm_1.Parameters.Add(new SqlParameter("@email",SqlDbType.Char,100));
				mycomm_1.Parameters["@email"].Value=t_email.Text.Trim();
				mycomm_1.Parameters.Add(new SqlParameter("@wenti",SqlDbType.Char,100));
				mycomm_1.Parameters["@wenti"].Value=TextBox1.Text.Trim();
				mycomm_1.Parameters.Add(new SqlParameter("@daan",SqlDbType.Char,100));
				mycomm_1.Parameters["@daan"].Value=TextBox2.Text.Trim();
				mycomm_1.Parameters.Add(new SqlParameter("@time",SqlDbType.DateTime));
				mycomm_1.Parameters["@time"].Value=time;
				if(mycomm_1.ExecuteNonQuery()>0)	
				{
					MailMessage mail=new MailMessage();
					mail.To=t_email.Text;
					mail.From="yongsong_liu@163.com";
					mail.Subject="海纳会员注册成功";
					mail.Body="   欢迎您成为海纳的一分子,请您记住您的资料:用户名:"+mycomm_1.Parameters["@yonghuming"].Value+",密码:"+mycomm_1.Parameters["@mima"].Value+".希望您能多提宝贵的意见!";
					//SmtpMail.Send(mail);
					

					string sqlins="INSERT INTO duanxiaoxi(neirong,faqiren,jieshoufang,shijian,zhuti) VALUES('   海纳百川建站资讯网于2005年2月9日发布,海纳百川全体管理员欢迎您的加盟,海纳百川的每一步成长都离不开您的参与和支持。我们相信因您的加入,海纳百川的成长会更快。我们将尽可能的提供更多的资料与信息,让我们一起共建海纳百川吧!','free911','"+t_yonghuming.Text.Trim()+"','"+time+"','海纳百川全体管理员欢迎您的加入')";
					mycomm_1= new SqlCommand(sqlins,myconn_1);
					try
					{
						mycomm_1.ExecuteNonQuery();
					}
					catch{}

					Response.Redirect("zhuce_success.aspx");

					myconn_1.Close();
				}
				else
				{
					Response.Redirect("zhucewrong.aspx?id=3");
					
				}
			}
		
		}

		protected void Button2_Click(object sender, System.EventArgs e)
		{
			myconn_1=new SqlConnection(Session["str_connection"].ToString());
			myconn_1.Open();
			SqlDataReader mydr;
			string sqlstr="select * from huiyuan where yonghuming=@yonghuming";
			mycomm_1=new SqlCommand(sqlstr,myconn_1);
			mycomm_1.Parameters.Add(new SqlParameter("@yonghuming",SqlDbType.Char,15));
			mycomm_1.Parameters["@yonghuming"].Value=t_yonghuming.Text.Trim();
			mydr=mycomm_1.ExecuteReader();
			if (mydr.Read())
			{
				//Label1.Text="该用户已经存在,请重新输入!";
				Response.Redirect("zhucewrong.aspx?id=1");
				//Response.Write("<script>alert('该用户已经存在,请重试!')</scritp>");
				myconn_1.Close();
				mydr.Close();
				return ;
			}
		
		}
	}
}

⌨️ 快捷键说明

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