📄 xinxifasong.aspx.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.Data.SqlTypes;
using System.Data.Common;
namespace free.bbs
{
/// <summary>
/// Summary description for xinxifasong.
/// </summary>
public partial class xinxifasong : System.Web.UI.Page
{
string UserName;
SqlConnection myconn;
SqlCommand mycomm;
void GetName(string LogName)
{
UserName= LogName;
}
protected void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
myconn=new SqlConnection(Session["str_connection"].ToString());
try
{
string ss=Request.Cookies["free_huiyuan"].Value.ToString();
}
catch
{
Response.Redirect("error.aspx");
}
if(!Page.IsPostBack)
{
try
{
jieshouzhe.Text=Request.Params["jieshouren"].ToString();
}
catch
{
jieshouzhe.Text="";
}
}
}
#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 quxiao_Click(object sender, System.EventArgs e)
{
Response.Write("<script>window.close()</script>");
}
protected void fasong_Click(object sender, System.EventArgs e)
{
try
{
if(jieshouzhe.Text=="")
Response.Write("<script>alert('您必须指定一个接收人!')</script>");
else if(zhuti.Text=="")
Response.Write("<script>alert('发送主题不能为空!')</script>");
else if(TextBox1.Text=="")
Response.Write("<script>alert('发送内容不能为空!')</script>");
else
{
DateTime DeT = DateTime.Now;
myconn.Open();
//string sqlins="INSERT INTO duanxiaoxi(neirong,faqiren,jieshoufang,shijian,zhuti) VALUES( '"+TextBox1.Text+"','"+Request.Cookies["free_huiyuan"].Value+"','"+SelName+"','"+DeT.ToString()+"', '"+zhuti.Text+"')";
string sqlins="INSERT INTO duanxiaoxi(neirong,faqiren,jieshoufang,shijian,zhuti) VALUES(@neirong,@faqiren,@jieshoufang,@time,@zhuti)";
mycomm= new SqlCommand(sqlins,myconn);
mycomm.Parameters.Add(new SqlParameter("@neirong",SqlDbType.NText,16));
mycomm.Parameters["@neirong"].Value=TextBox1.Text;
mycomm.Parameters.Add(new SqlParameter("@faqiren",SqlDbType.Char,12));
mycomm.Parameters["@faqiren"].Value=Request.Cookies["free_huiyuan"].Value;
mycomm.Parameters.Add(new SqlParameter("@jieshoufang",SqlDbType.Char,12));
mycomm.Parameters["@jieshoufang"].Value=jieshouzhe.Text.Trim();
mycomm.Parameters.Add(new SqlParameter("@time",SqlDbType.DateTime));
mycomm.Parameters["@time"].Value=DeT;
mycomm.Parameters.Add(new SqlParameter("@zhuti",SqlDbType.Char,100));
mycomm.Parameters["@zhuti"].Value=zhuti.Text;
try
{
mycomm.ExecuteNonQuery();
myconn.Close();
Response.Write("<script>alert('短消息发送成功!')</script>");
Response.Write("<script>window.close()</script>");
}
catch
{
myconn.Close();
Response.Write("<script>alert('短消息发送失败!')</script>");
Response.Write("<script>window.close()</script>");
}
}
}
catch
{}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -