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

📄 modify.aspx.cs

📁 这是我制作的一个小论坛源码··能够简单实现发表帖子··管理帖子·后台管理等功能
💻 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;

namespace bbs
{
	/// <summary>
	/// modify 的摘要说明。
	/// </summary>
	public class modify : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.TextBox TextBox4;
		protected System.Web.UI.WebControls.Panel Panel1;
		protected System.Web.UI.WebControls.TextBox TextBox_UserName;
		protected System.Web.UI.WebControls.TextBox TextBox_sBbsQuestion;
		protected System.Web.UI.WebControls.TextBox TextBox_sBbsAnswer;
		protected System.Web.UI.WebControls.TextBox TextBox_UN;
		protected System.Web.UI.WebControls.TextBox TextBox_newpwd;
		protected System.Web.UI.WebControls.TextBox TextBox_pwd;
		protected System.Web.UI.WebControls.Button Buttom_Commit;
		protected System.Web.UI.WebControls.Button Button_send;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			this.Panel1.Visible=false;
			// 在此处放置用户代码以初始化页面
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.Button_send.Click += new System.EventHandler(this.Button_send_Click);
			this.Buttom_Commit.Click += new System.EventHandler(this.Buttom_Commit_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void Button_send_Click(object sender, System.EventArgs e)
		{
			string ConnectionString=System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
			string sql="select count(*) from users where username='"+this.TextBox_UserName.Text+"'and sBbSquestion='"+this.TextBox_sBbsQuestion.Text+"' and sBbsAnswer='"+this.TextBox_sBbsAnswer.Text+"' and semail='"+this.TextBox4.Text+"'";
			SqlConnection conn = new SqlConnection(ConnectionString);
			SqlCommand cmd=new SqlCommand(sql,conn);
		
			if(this.TextBox_sBbsAnswer.Text==null || this.TextBox_sBbsAnswer.Text=="")
			{
				Response.Write("请输入安全提问和密码");
			}
			else
			{
				try
				{
				
					if(conn.State!=ConnectionState.Open)
					{
						conn.Open();
					}
					int count=Convert.ToInt32(cmd.ExecuteScalar());
					if(count>0)
					{
						this.Panel1.Visible=true;					
					}
					else
					{
						Response.Write("用户名不存在或条件错误");
					}

			
				}
		
				catch(Exception ex)
				{	
					Response.Write(ex.Message);
					conn.Close();
				}
				finally
				{		
					conn.Close();
					conn.Dispose();
					conn=null;
				}

			}
		
		}

		private void Buttom_Commit_Click(object sender, System.EventArgs e)
		{
			
			string sqlstr="update users set pwd='"+this.TextBox_newpwd.Text+"' where username='"+this.TextBox_UN.Text+"'";
			da.da d=new da.da();
			d.command(sqlstr);
			Response.Redirect("index.aspx");
		}


	}
}

⌨️ 快捷键说明

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