messagesucess.aspx.cs
资源名称:论坛源码.rar [点击查看]
上传用户:scene123
上传日期:2010-02-19
资源大小:3311k
文件大小:4k
源码类别:
.net编程
开发平台:
C#
- 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.OleDb;
- using System.Text;
- using System.Configuration;
- using System.Web.Security;
- using System.Security.Cryptography;
- namespace kuangren
- {
- /// <summary>
- /// messagesucess 的摘要说明。
- /// </summary>
- public class messagesucess : System.Web.UI.Page
- {
- protected int intRunTime;
- protected DateTime dtStartTime = DateTime.Now;
- public string usercookies;
- public string userjudge;
- public string userjudge1;
- public int userjudge2;
- public int userjudge3;
- public DataSet dsuser;
- private void Page_Load(object sender, System.EventArgs e)
- {
- if (Request.Cookies["jusername"]!=null)
- {
- usercookies=Request.Cookies["jusername"].Value;
- }
- else
- {
- Response.Redirect("logine.aspx");
- }
- OleDbConnection conn;
- string OleDbsql;
- OleDbCommand cmd;
- StringBuilder sb=new StringBuilder();
- ArrayList values=new ArrayList();
- sb.Append("INSERT INTO [forum_5](p_take,p_send,p_title,p_content) values('{0}','{1}','{2}','{3}')");
- if(Request.Form["jtake"]!="")
- values.Add(Request.Form["jtake"]);
- else
- values.Add("Null");
- values.Add(Request.Form["jsend"]);
- values.Add(Request.Form["jtitle"]);
- values.Add(Request.Form["jcontent"]);
- OleDbsql=String.Format(sb.ToString(),values.ToArray());
- conn=new OleDbConnection(ConfigurationSettings.AppSettings["cnFriends.ConnectionString"]);
- cmd=new OleDbCommand("select u_user from userinfo where u_user='"+Request.Form["jtake"]+"'",conn);
- dsuser=new DataSet();
- cmd.Connection.Open();
- OleDbDataReader objDataReader ;
- objDataReader = cmd.ExecuteReader();
- if (objDataReader.Read() == true)
- {
- string str=""+Request.Form["jcontent"]+"";
- string str1=""+Request.Form["jtitle"]+"";
- userjudge2=System.Text.Encoding.Default.GetByteCount(str);
- userjudge3=System.Text.Encoding.Default.GetByteCount(str1);
- if (userjudge2<=1000&&userjudge3<=50&&userjudge2!=0&&userjudge3!=0)
- {
- userjudge="<br><strong>操作成功:<br>您的短消息已经成功发送。</strong>";
- userjudge1="<strong><font color=#FFFFFF>短消息发送成功</font></strong>";
- cmd=new OleDbCommand(OleDbsql,conn);
- }
- else
- {
- userjudge="<br><strong>操作失败:<br>标题或内容超出规定长度。</strong>";
- userjudge1="<strong><font color=#FFFFFF>短消息发送失败</font></strong>";
- }
- }
- else
- {
- userjudge="<br><strong>操作失败:<br>收件人不存在。</strong>";
- userjudge1="<strong><font color=#FFFFFF>短消息发送失败</font></strong>";
- }
- cmd.Connection.Close();
- conn.Open();
- bool doredirect=true;
- try
- {
- cmd.ExecuteNonQuery();
- }
- catch
- {
- doredirect=false;
- }
- finally
- {
- conn.Close();
- }
- if(doredirect)
- {
- }
- else
- {
- Response.Redirect("index.aspx");
- }
- }
- #region Web 窗体设计器生成的代码
- override protected void OnInit(EventArgs e)
- {
- //
- // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
- //
- InitializeComponent();
- base.OnInit(e);
- }
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- this.Load += new System.EventHandler(this.Page_Load);
- }
- #endregion
- }
- }