62,268
社区成员
发帖
与我相关
我的任务
分享 protected void PostNew_Click(object sender, EventArgs e)
{
string sql = "INSERT INTO News (News_Title, News_Poster, News_content, Type) VALUES ('{0}', {1}, '{2}', {3})";
sql = string.Format(sql, TextBox1.Text, Page.Session["UserId"].ToString(), TextBox2.Text, Page.Request["type"]);
Connection conn = new Connection();
if (conn.SQLExecuteNonQuery(sql) == 1)
{
WebPublic.MsgOKBox("成功", "成功发表了新的文章", Page);
sql = @"
SELECT News.ID AS 新闻ID,News.News_Title AS 新闻标题, News.News_PostTime AS 发表时间,
[User].NiceName AS 发表人
FROM ((News INNER JOIN
News_Type ON News.Type = News_Type.ID) INNER JOIN
[User] ON News.News_Poster = [User].UserID)
WHERE (News.Type = " + Page.Request["type"] + ")";
GridView1.DataSource = conn.SqlDataSet(sql);
GridView1.DataBind();
}
else
{
WebPublic.MsgErrBox("失败", "发表文章失败了...", Page);
}
} protected void PostNew_Click(object sender, EventArgs e)
{
string sql = "INSERT INTO News (News_Title, News_Poster, News_content, Type) VALUES ('{0}', {1}, '{2}', {3})";
sql = string.Format(sql, TextBox1.Text, Page.Session["UserId"].ToString(), TextBox2.Text, Page.Request["type"]);
Connection conn = new Connection();
if (conn.SQLExecuteNonQuery(sql) == 1)
{
WebPublic.MsgOKBox("成功", "成功发表了新的文章", Page);
grdatabind()
}
else
{
WebPublic.MsgErrBox("失败", "发表文章失败了...", Page);
}
}
private void grdatabind()
{
string sql = @"
SELECT News.ID AS 新闻ID,News.News_Title AS 新闻标题, News.News_PostTime AS 发表时间,
[User].NiceName AS 发表人
FROM ((News INNER JOIN
News_Type ON News.Type = News_Type.ID) INNER JOIN
[User] ON News.News_Poster = [User].UserID)
WHERE (News.Type = " + Page.Request["type"] + ")";
Connection conn = new Connection();
GridView1.DataSource = conn.SqlDataSet(sql);
GridView1.DataBind();
}
static public void MsgOKBox(string title, string mes, System.Web.UI.Page page)
{
string str = @"
<script type='text/javascript'>
Ext.onReady(function(){
top.Ext.MessageBox.show(
{
title: '" + title + @"',
msg: '" + mes + @"',
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.INFO
}) });
</script>";
page.ClientScript.RegisterStartupScript(page.GetType(), "MesOKBox", str);
}private void grdatabind(Connection conn)
{
string sql = @"
SELECT News.ID AS 新闻ID,News.News_Title AS 新闻标题, News.News_PostTime AS 发表时间,
[User].NiceName AS 发表人
FROM ((News INNER JOIN
News_Type ON News.Type = News_Type.ID) INNER JOIN
[User] ON News.News_Poster = [User].UserID)
WHERE (News.Type = " + Page.Request["type"] + ")";
GridView1.DataSource = conn.SqlDataSet(sql);
GridView1.DataBind();
}
protected void PostNew_Click(object sender, EventArgs e)
{
string sql = "INSERT INTO News (News_Title, News_Poster, News_content, Type) VALUES ('{0}', {1}, '{2}', {3})";
sql = string.Format(sql, TextBox1.Text, Page.Session["UserId"].ToString(), TextBox2.Text, Page.Request["type"]);
Connection conn = new Connection();
if (conn.SQLExecuteNonQuery(sql) == 1)
{
grdatabind() ;
WebPublic.MsgOKBox("成功", "成功发表了新的文章", Page);
}
else
{
WebPublic.MsgErrBox("失败", "发表文章失败了...", Page);
}
}
private void grdatabind()
{
string sql = @"
SELECT News.ID AS 新闻ID,News.News_Title AS 新闻标题, News.News_PostTime AS 发表时间,
[User].NiceName AS 发表人
FROM ((News INNER JOIN
News_Type ON News.Type = News_Type.ID) INNER JOIN
[User] ON News.News_Poster = [User].UserID)
WHERE (News.Type = " + Page.Request["type"] + ")";
Connection conn = new Connection();
GridView1.DataSource = conn.SqlDataSet(sql);
GridView1.DataBind();
}