📄 notecontent.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class users_notecontent : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
bind();
}
}
void bind()
{
int t = Convert.ToInt32(Request.QueryString["id"].ToString());
Session["id"] = Request.QueryString["id"].ToString();
SqlConnection con = new SqlConnection("Data source=localhost;uid=sa;pwd=;database=Ebusiness");
con.Open();
SqlCommand comm = new SqlCommand("select asktitle,askcontent,askuser,asktime from service_ask where askid=" + t + "", con);
SqlDataReader reader = comm.ExecuteReader();
if (reader.Read())
{
Label8.Text = reader.GetString(0);
TextBox1.Text = reader.GetString(1);
Label1.Text = reader.GetString(2);
Label2.Text = reader.GetDateTime(3).ToString();
reader.Close();
}
DataSet ds = new DataSet();
SqlDataAdapter sqld = new SqlDataAdapter("select answercontent,answertime,answeruser from service_answer where askid=" + t + "", con);
sqld.Fill(ds, "tab");
GridView1.DataSource =ds.Tables[0].DefaultView;
GridView1.DataBind();
con.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
string str=Session["user"].ToString();
if ( str== "")
{
ShowMassage("你还没有登陆,不能回复本留言");
}
else
{
SqlConnection con = new SqlConnection("Data source=localhost;uid=sa;pwd=;database=Ebusiness");
con.Open();
SqlCommand comm = new SqlCommand("insert into service_answer(answercontent,answeruser,answertime,askid) values(@answercontent,@answeruser,@answertime,@askid)",con);
comm.Parameters.Add("@answercontent", SqlDbType.VarChar, 8000).Value = TextBox2.Text;
comm.Parameters.Add("@answeruser", SqlDbType.Char, 20).Value = str;
comm.Parameters.Add("@answertime", SqlDbType.DateTime).Value = DateTime.Now.ToString();
comm.Parameters.Add("@askid", SqlDbType.Int).Value = Convert.ToInt32(Session["id"].ToString());
comm.ExecuteNonQuery();
con.Close();
ShowMassage("回复成功");
}
bind();
TextBox1.Text = "";
}
protected void Button3_Click(object sender, EventArgs e)
{
TextBox1.Text = "";
}
private void ShowMassage(string msg)
{
Response.Write("<script>window.alert('" + msg + "')</script>");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -