📄 news_modi.aspx.cs
字号:
using System;
using System.IO;
using System.Text.RegularExpressions;
using System.Data;
using System.Runtime;
using System.Data.SqlClient;
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;
public partial class admin_news_modi : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["shang_admin"] == null)
{
Response.Redirect("get_your_passport.aspx");
}
this.TextBox9.Style.Add("display", "none");
this.eWebEditor1.Attributes.Add("src", "editor/ewebeditor.htm?id=TextBox9&style=gray");
try{
if (!IsPostBack)
{
SqlConnection con = db.CreateConnection();
con.Open();
string strsql = "select * from news where bh='" + Request.QueryString["bh"] + "'";
SqlCommand cmd = new SqlCommand(strsql, con);
SqlDataAdapter ad = new SqlDataAdapter(strsql, con);
DataSet ds = new DataSet();
ad.Fill(ds, "aa");
TextBox9.Text = ds.Tables["aa"].Rows[0]["content"].ToString();
TextBox10.Text = ds.Tables["aa"].Rows[0]["bh"].ToString();
TextBox1.Text = ds.Tables["aa"].Rows[0]["title"].ToString();
TextBox2.Text = ds.Tables["aa"].Rows[0]["url"].ToString();
TextBox3.Text = ds.Tables["aa"].Rows[0]["author"].ToString();
TextBox4.Text = ds.Tables["aa"].Rows[0]["time"].ToString();
TextBox5.Text = ds.Tables["aa"].Rows[0]["tag"].ToString();
TextBox6.Text = ds.Tables["aa"].Rows[0]["xiangguan"].ToString();
TextBox7.Text = ds.Tables["aa"].Rows[0]["infor"].ToString();
TextBox8.Text = ds.Tables["aa"].Rows[0]["smallclassname"].ToString();
TextBox11.Text = ds.Tables["aa"].Rows[0]["bigclassname"].ToString();
DropDownList1.Text = ds.Tables["aa"].Rows[0]["bigclassname"].ToString();
DropDownList2.Text = ds.Tables["aa"].Rows[0]["color"].ToString();
con.Close();
}
}
catch
{
Response.Write("What yuo want to do?Something Error happend,and your IP and PLACE ware written in the System!");
}
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
SqlConnection con = db.CreateConnection();
con.Open();
string strsql = "update news set title='" + TextBox1.Text + "',bigclassname='" + DropDownList1.Text + "',color='" + DropDownList2.Text + "',url='" + TextBox2.Text + "',author='" + TextBox3.Text + "',time='" + Convert.ToDateTime(TextBox4.Text) + "',content='" + TextBox9.Text + "' where bh='" + Convert.ToInt32(TextBox10.Text) + "'";
SqlCommand cmd = new SqlCommand(strsql, con);
cmd.ExecuteNonQuery();
con.Close();
string template;
SqlConnection con1 = db.CreateConnection();
con1.Open();
string strsql1 = "select * from example";
SqlDataAdapter ad1 = new SqlDataAdapter(strsql1, con1);
DataSet ds1 = new DataSet();
ad1.Fill(ds1, "bb");
template = ds1.Tables["bb"].Rows[0]["example"].ToString();
template = Regex.Replace(template, "E_title", TextBox1.Text);
template = Regex.Replace(template, "E_now", TextBox3.Text);
template = Regex.Replace(template, "E_fenlei", DropDownList1.Text);
template = Regex.Replace(template, "E_content", TextBox9.Text);
template = Regex.Replace(template, "E_num", TextBox10.Text);
if (DropDownList1.Text == TextBox11.Text)
{
StreamWriter sw = File.CreateText(Server.MapPath("../articls/" + DropDownList1.Text + "/" + TextBox10.Text + ".aspx"));
sw.Write(template);
sw.Close();
}
else
{
StreamWriter sw = File.CreateText(Server.MapPath("../articls/" + DropDownList1.Text + "/" + TextBox10.Text + ".aspx"));
sw.Write(template);
File.Delete(Server.MapPath("../articls/" + TextBox11.Text + "/" + TextBox10.Text + ".aspx"));
sw.Close();
}
con1.Close();
Response.Redirect("news_manage.aspx?bigclassname="+TextBox11.Text+"");
}
catch
{
Response.Write("Some thing Error happend->NEWS SYSTEM MODI ERROR:you can enter <a href='http://www.shangducms.cn'>shangducms.cn</a> to find more information.");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -