📄 template_manage.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_template_manage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["shang_admin"] == null)
{
Response.Redirect("get_your_passport.aspx");
}
try
{
if (!IsPostBack)
{
SqlConnection con = db.CreateConnection();
con.Open();
string strsql = "select * from example";
SqlCommand cmd = new SqlCommand(strsql, con);
SqlDataAdapter ad = new SqlDataAdapter(strsql, con);
DataSet ds = new DataSet();
ad.Fill(ds, "aa");
TextArea1.Value = ds.Tables["aa"].Rows[0]["example"].ToString();
Textarea2.Value = ds.Tables["aa"].Rows[1]["example"].ToString();
Textarea3.Value = ds.Tables["aa"].Rows[2]["example"].ToString();
con.Close();
}
}
catch
{
Response.Write("Template Error:0972!you can enter http://www.shangducms.cn to get more information");
}
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = db.CreateConnection();
con.Open();
string strsql = "update example set example='" + TextArea1.Value + "' where bh=1";
SqlCommand cmd = new SqlCommand(strsql, con);
cmd.ExecuteNonQuery();
con.Close();
}
protected void Button2_Click(object sender, EventArgs e)
{
SqlConnection con = db.CreateConnection();
con.Open();
string strsql = "update example set example='" + Textarea2.Value + "' where bh=2";
SqlCommand cmd = new SqlCommand(strsql, con);
cmd.ExecuteNonQuery();
con.Close();
}
protected void Button3_Click(object sender, EventArgs e)
{
SqlConnection con = db.CreateConnection();
con.Open();
string strsql = "update example set example='" + Textarea3.Value + "' where bh=3";
SqlCommand cmd = new SqlCommand(strsql, con);
cmd.ExecuteNonQuery();
con.Close();
}
protected void Button4_Click(object sender, EventArgs e)
{
//开始读取内容
SqlConnection con3 = db.CreateConnection();
con3.Open();
string strsql3 = "select * from bigclass";
SqlDataAdapter ad3 = new SqlDataAdapter(strsql3, con3);
DataSet ds3 = new DataSet();
ad3.Fill(ds3, "cc");
for (int i = 0; i < ad3.Fill(ds3, "cc"); i++)
{
if (!Directory.Exists(Server.MapPath("../articls/" + ds3.Tables["cc"].Rows[i]["bigclassname"].ToString())))
{
Directory.CreateDirectory(Server.MapPath("../articls/" + ds3.Tables["cc"].Rows[i]["bigclassname"].ToString()));
}
}
con3.Close();
Response.Redirect("template_manage.aspx?action=操作已成功");
}
protected void Button5_Click(object sender, EventArgs e)
{
//开始读取模板
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");
//开始刷新新闻
SqlConnection con3 = db.CreateConnection();
con3.Open();
string strsql3 = "select * from news";
SqlDataAdapter ad3 = new SqlDataAdapter(strsql3, con3);
DataSet ds3 = new DataSet();
ad3.Fill(ds3, "cc");
for (int i = 0; i < ad3.Fill(ds3, "cc"); i++)
{
template = ds1.Tables["bb"].Rows[0]["example"].ToString();
template = Regex.Replace(template, "E_title", ds3.Tables["cc"].Rows[i]["title"].ToString());
template = Regex.Replace(template, "E_now", ds3.Tables["cc"].Rows[i]["time"].ToString());
template = Regex.Replace(template, "E_fenlei", ds3.Tables["cc"].Rows[i]["bigclassname"].ToString());
template = Regex.Replace(template, "E_content", ds3.Tables["cc"].Rows[i]["content"].ToString());
template = Regex.Replace(template, "E_num", ds3.Tables["cc"].Rows[i]["bh"].ToString());
StreamWriter sw = File.CreateText(Server.MapPath("../articls/" + ds3.Tables["cc"].Rows[i]["bigclassname"].ToString() + "/" + ds3.Tables["cc"].Rows[i]["bh"].ToString() + ".aspx"));
sw.Write(template);
}
con1.Close();
con3.Close();
Response.Redirect("template_manage.aspx?action=操作已成功");
}
protected void Button6_Click(object sender, EventArgs e)
{
//开始读取内容
SqlConnection con3 = db.CreateConnection();
con3.Open();
string strsql3 = "select * from download_class";
SqlDataAdapter ad3 = new SqlDataAdapter(strsql3, con3);
DataSet ds3 = new DataSet();
ad3.Fill(ds3, "cc");
for (int i = 0; i < ad3.Fill(ds3, "cc"); i++)
{
if (!Directory.Exists(Server.MapPath("../downloads/" + ds3.Tables["cc"].Rows[i]["classname"].ToString())))
{
Directory.CreateDirectory(Server.MapPath("../downloads/" + ds3.Tables["cc"].Rows[i]["classname"].ToString()));
}
}
con3.Close();
Response.Redirect("template_manage.aspx?action=操作已成功");
}
protected void Button7_Click(object sender, EventArgs e)
{
//开始读取模板
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");
//开始刷新下载
SqlConnection con3 = db.CreateConnection();
con3.Open();
string strsql3 = "select * from downloads";
SqlDataAdapter ad3 = new SqlDataAdapter(strsql3, con3);
DataSet ds3 = new DataSet();
ad3.Fill(ds3, "cc");
for (int i = 0; i < ad3.Fill(ds3, "cc"); i++)
{
template = ds1.Tables["bb"].Rows[1]["example"].ToString();
template = Regex.Replace(template, "E_name", ds3.Tables["cc"].Rows[i]["name"].ToString());
template = Regex.Replace(template, "E_pic", ds3.Tables["cc"].Rows[i]["pic"].ToString());
template = Regex.Replace(template, "E_infor", ds3.Tables["cc"].Rows[i]["infor"].ToString());
template = Regex.Replace(template, "E_bigclassname", ds3.Tables["cc"].Rows[i]["bigclassname"].ToString());
template = Regex.Replace(template, "E_place", ds3.Tables["cc"].Rows[i]["place"].ToString());
template = Regex.Replace(template, "E_now", ds3.Tables["cc"].Rows[i]["time"].ToString());
template = Regex.Replace(template, "E_num", ds3.Tables["cc"].Rows[i]["bh"].ToString());
StreamWriter sw = File.CreateText(Server.MapPath("../downloads/" + ds3.Tables["cc"].Rows[i]["bigclassname"].ToString() + "/" + ds3.Tables["cc"].Rows[i]["bh"].ToString() + ".aspx"));
sw.Write(template);
}
con1.Close();
con3.Close();
Response.Redirect("template_manage.aspx?action=操作已成功");
}
protected void Button8_Click(object sender, EventArgs e)
{
//开始读取内容
SqlConnection con3 = db.CreateConnection();
con3.Open();
string strsql3 = "select * from shop_class";
SqlDataAdapter ad3 = new SqlDataAdapter(strsql3, con3);
DataSet ds3 = new DataSet();
ad3.Fill(ds3, "cc");
for (int i = 0; i < ad3.Fill(ds3, "cc"); i++)
{
if (!Directory.Exists(Server.MapPath("../shops/" + ds3.Tables["cc"].Rows[i]["classname"].ToString())))
{
Directory.CreateDirectory(Server.MapPath("../shops/" + ds3.Tables["cc"].Rows[i]["classname"].ToString()));
}
}
con3.Close();
Response.Redirect("template_manage.aspx?action=操作已成功");
}
protected void Button9_Click(object sender, EventArgs e)
{
//开始读取模板
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");
//开始刷新商城
SqlConnection con3 = db.CreateConnection();
con3.Open();
string strsql3 = "select * from shops";
SqlDataAdapter ad3 = new SqlDataAdapter(strsql3, con3);
DataSet ds3 = new DataSet();
ad3.Fill(ds3, "cc");
for (int i = 0; i < ad3.Fill(ds3, "cc"); i++)
{
template = ds1.Tables["bb"].Rows[2]["example"].ToString();
template = Regex.Replace(template, "E_name", ds3.Tables["cc"].Rows[i]["shop_name"].ToString());
template = Regex.Replace(template, "E_infor", ds3.Tables["cc"].Rows[i]["shop_infor"].ToString());
template = Regex.Replace(template, "E_pic", ds3.Tables["cc"].Rows[i]["shop_pic"].ToString());
template = Regex.Replace(template, "E_money", ds3.Tables["cc"].Rows[i]["shop_money"].ToString());
template = Regex.Replace(template, "E_place", ds3.Tables["cc"].Rows[i]["shop_place"].ToString());
template = Regex.Replace(template, "E_sell_time", ds3.Tables["cc"].Rows[i]["sell_time"].ToString());
template = Regex.Replace(template, "E_sell_end_time", ds3.Tables["cc"].Rows[i]["sell_end_time"].ToString());
template = Regex.Replace(template, "E_seller_name", ds3.Tables["cc"].Rows[i]["seller_name"].ToString());
template = Regex.Replace(template, "E_seller_qq", ds3.Tables["cc"].Rows[i]["seller_qq"].ToString());
template = Regex.Replace(template, "E_seller_phone", ds3.Tables["cc"].Rows[i]["seller_phone"].ToString());
template = Regex.Replace(template, "E_seller_email", ds3.Tables["cc"].Rows[i]["seller_email"].ToString());
template = Regex.Replace(template, "E_fenlei", ds3.Tables["cc"].Rows[i]["bigclassname"].ToString());
template = Regex.Replace(template, "E_num", ds3.Tables["cc"].Rows[i]["bh"].ToString());
StreamWriter sw = File.CreateText(Server.MapPath("../shops/" + ds3.Tables["cc"].Rows[i]["bigclassname"].ToString() + "/" + ds3.Tables["cc"].Rows[i]["bh"].ToString() + ".aspx"));
sw.Write(template);
}
con1.Close();
con3.Close();
Response.Redirect("template_manage.aspx?action=操作已成功");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -