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

📄 browers.aspx.cs

📁 ASP.NET简洁论坛源代码 这是一个简单的论坛
💻 CS
📖 第 1 页 / 共 2 页
字号:
					lnkNext.Enabled = false;
					lnkNext2.Enabled = false;
				}
				else
				{
					lnkNext.NavigateUrl=Request.CurrentExecutionFilePath+"?QID="+QS+"&Page=" + Convert.ToString(CurrentPage+1);
					lnkNext2.NavigateUrl=Request.CurrentExecutionFilePath+"?QID="+QS+"&Page=" + Convert.ToString(CurrentPage+1);
				}
				if(CurrentPage==1)
				{
					lnkPrev.Enabled = false;
					lnkPrev2.Enabled = false;
				}
				else
				{
					lnkPrev.NavigateUrl=Request.CurrentExecutionFilePath+"?QID="+QS+"&Page=" + Convert.ToString(CurrentPage-1);
					lnkPrev2.NavigateUrl=Request.CurrentExecutionFilePath+"?QID="+QS+"&Page=" + Convert.ToString(CurrentPage-1);
				}
				lblCurrentPage.Text = CurrentPage.ToString();
				lblCurrentPage2.Text = CurrentPage.ToString(); 

				//右侧帖子列表
				this.DList1.DataSource= DBOperate.SelectFormForum("SELECT Q_ID, Q_Note, pith, BigClass_ID, HiteCounter, SmallClass_ID, kind FROM Questions WHERE (pith=1)and(Q_ID<"+QS+") AND(BigClass_ID = "+BID+") AND (SmallClass_ID ="+SID+") AND(kind > 0) ORDER BY Q_ID DESC",0,10,"Questions");
				this.DList1.DataBind();

				this.DList2.DataSource= DBOperate.SelectFormForum("SELECT Q_ID, Q_Note, pith, BigClass_ID, HiteCounter, SmallClass_ID, kind FROM Questions WHERE (pith=1) AND(kind > 0) ORDER BY Q_ID DESC",0,10,"Questions");
				this.DList2.DataBind();
			}
			catch (Exception) 
			{
				this.Response.Redirect("Logon.aspx?url="+Server.UrlEncode(this.Request.Url.ToString()));
			}
		}

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

		}
		#endregion

		public string ImgShow(string Imgname)
		{
            string s = System.Configuration.ConfigurationSettings.AppSettings["followUpImagePath"];
            if ((Imgname == null) || (Imgname == "default.gif"))
                return "";
            else
                return "<a href='ImageView.aspx?IMG=" + s + Imgname + "' target='_blank'><img src='" + s + Imgname + "'onload='javascript:if(this.width>540)this.width=540' border=0 alt='点击图片放大看原图'></a><br>点击图片放大看原图<br>";
		}
		
		private void LinkButton1_Click(object sender, System.EventArgs e)
		{
			//转向登录页面
			this.Response.Redirect("Logon.aspx?url="+Server.UrlEncode(this.Request.Url.ToString()));
		}

		protected void BtnPut_Click(object sender, System.EventArgs e)
		{
			string ext;
			string fn="";
			int id;
			//string  imgpath="followUpImage/";
            string imgpath = System.Configuration.ConfigurationSettings.AppSettings["followUpImagePath"];

			//提交输入的内容
			if (TB_Content.Text=="") 
			{
				Span1.Text="评论内容不能为空。";
				return;  
			}
			if (User.Identity.Name=="") 
			{
				Span1.Text="用户未登录。";
				return;  
			}

			ext=Path.GetExtension(Files1.PostedFile.FileName);
			if (Files1.PostedFile.ContentLength>1107200) 
			{ 
				Span1.Text="上传的文件不能超过1M"; 
				return;  
			} 
			else 
			{
				if(Files1.PostedFile != null)
				{
                    try
                    {
                        id = CommonFuntion.getNewTableID("followUpImage");
                        if (Files1.PostedFile.FileName.ToString() == "")
                        {
                            fn = "default.gif";
                        }
                        else
                        {
                            if (!((ext.ToLower() == ".gif") || (ext.ToLower() == ".bmp") || (ext.ToLower() == ".png") || (ext.ToLower() == ".ico") || (ext.ToLower() == ".jpg") || (ext.ToLower() == ".wmf")))
                            {
                                Span1.Text = "上传图片格式错误!(JPG/GIF/ICO/BMP/WMF/PNG)";
                                return;
                            }
                            fn = Path.GetFileName(Files1.PostedFile.FileName);
                            if (fn.Length > 20)
                                fn = fn.Substring(fn.Length - 20, 20);
                            fn = id.ToString() + "_" + fn;
                            if (File.Exists(Server.MapPath(imgpath + fn)))
                            {
                                Span1.Text = "上传文件重名,请改名后再上传!";
                                return;
                            }
                            Files1.PostedFile.SaveAs(Server.MapPath(imgpath + fn));
                        }
                        
                        string DBtype = ConfigurationManager.AppSettings["DBtype"];
                        if (DBtype == "Accsee")
                        {
                            DBsql exsql = new DBsql();
                            try
                            {
                                string sac = ("INSERT INTO Answers (Question_ID,Ans_Man,Ans_Content, Ans_Time, Ans_IPAddress, ImageName) VALUES (" + Request.QueryString["QID"]
                                    + ",'" + User.Identity.Name.ToString() + "',@Ans_Content, '" + System.DateTime.Now.ToString() + "','" + this.Request.UserHostAddress + "',@ImageName)");
                                exsql.Open();
                                OleDbCommand comcol = new OleDbCommand(sac, exsql.con);
                                comcol.Parameters.Add("@Ans_Content", SqlDbType.VarChar);
                                comcol.Parameters.Add("@ImageName", SqlDbType.VarChar);
                                comcol.Parameters["@Ans_Content"].Value = TB_Content.Text;
                                comcol.Parameters["@ImageName"].Value = fn;
                                comcol.ExecuteNonQuery();
                                exsql.Close();
                            }
                            catch (Exception ex)
                            {
                                throw (ex);
                            }
                            finally
                            {
                                exsql.Close();
                            }
                        }
                        else
                        {
                            SqlConnection sqlConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["DBConnection"]);
                            try
                            {
                                string s = ("INSERT INTO Answers (Question_ID,Ans_Man,Ans_Content, Ans_Time, Ans_IPAddress, ImageName) VALUES (" + Request.QueryString["QID"]
                                    + ",'" + User.Identity.Name.ToString() + "',@Ans_Content, '" + System.DateTime.Now.ToString() + "','" + this.Request.UserHostAddress + "',@ImageName)");

                                SqlCommand sqlCmd = new SqlCommand(s, sqlConnection);
                                sqlCmd.Parameters.Add("@Ans_Content", System.Data.SqlDbType.Text);
                                sqlCmd.Parameters.Add("@ImageName", System.Data.SqlDbType.Text);
                                sqlCmd.Parameters["@Ans_Content"].Value = TB_Content.Text;
                                sqlCmd.Parameters["@ImageName"].Value = fn;
                                sqlConnection.Open();
                                sqlCmd.ExecuteNonQuery();
                            }
                            finally
                            {
                                sqlConnection.Close();
                            }
                        }

                        DBOperate.ExcSQL("UPDATE Questions SET AnsCounter = AnsCounter + 1, ReleaseTime =  '" + System.DateTime.Now.ToString() + "' WHERE (Q_ID = " + Request.QueryString["QID"] + ")");
                        DBOperate.ExcSQL("update users set jifen=jifen+1 where User_name='" + User.Identity.Name.ToString() + "'");

                        this.Response.Redirect(this.Request.Url.ToString());
                    }
                    catch (Exception exception)
                    {
                        Span1.Text = exception.ToString();
                    }
				}
			}
		}

		private void gotonext(int x)
		{
			string QID;
			if (Request.QueryString["QID"]==null)
			{
				QID="1";
			}
			else
			{
				QID=Request.QueryString["QID"];
			}
			string s=Request.CurrentExecutionFilePath+"?QID="+QID+"&Page="+Convert.ToString(x);
			this.Response.Redirect(s);
		}

		protected void Button5_Click(object sender, System.EventArgs e)
		{
			try
			{
				int x = System.Convert.ToInt32(TextBox1.Text.ToString());
				gotonext(x);
			}
			catch(Exception) 
			{
			}
		}

		protected void Button1_Click(object sender, System.EventArgs e)
		{
			try
			{
				int x = System.Convert.ToInt32(TextBox2.Text.ToString());
				gotonext(x);		
			}
			catch(Exception) 
			{
			}
		}
	}
}

⌨️ 快捷键说明

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