173 lines
7.1 KiB
C#
173 lines
7.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace Mtxfw.shop._Admin
|
|
{
|
|
public partial class admin_gong_eadd : Mtxfw.Utility.AdminPage
|
|
{
|
|
public Mtxfw.DAL.Article daoArt = new Mtxfw.DAL.Article();
|
|
public String TitName, strtitle, strBody = "";
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
base.OnLoad(e);
|
|
|
|
if (!IsPostBack)
|
|
{
|
|
Data_Bindlb();
|
|
Hidd_Url.Value = Request.UrlReferrer.ToString();
|
|
if (Request.QueryString["ParentID"] != null)
|
|
{
|
|
|
|
if (Request.QueryString["action"] == "add")
|
|
{
|
|
if (Request.QueryString["CategoryId"] != null)
|
|
{
|
|
for (int i = 0; i < Drop_parentid.Items.Count; i++)
|
|
{
|
|
if (Drop_parentid.Items[i].Value == Request.QueryString["CategoryId"].ToString())
|
|
{
|
|
Drop_parentid.Items[i].Selected = true;
|
|
}
|
|
else
|
|
{
|
|
Drop_parentid.Items[i].Selected = false;
|
|
}
|
|
}
|
|
}
|
|
TitName = "添加";
|
|
Btn_Update.Visible = false;
|
|
}
|
|
else
|
|
{
|
|
TitName = "更新";
|
|
Btn_Insert.Visible = false;
|
|
|
|
Mtxfw.Model.Article model = daoArt.GetModel(int.Parse(Request.QueryString["ID"]));
|
|
Text_Title.Text = model.Title;
|
|
Text_Paths.Text = model.Paths;
|
|
strBody = model.Content;
|
|
Hidd_C.Value = model.CategoryId;
|
|
Text_LinkID.Text = model.LinkID.ToString();
|
|
for (int i = 0; i < Drop_parentid.Items.Count; i++)
|
|
{
|
|
if (Drop_parentid.Items[i].Value == model.CategoryId.ToString())
|
|
{
|
|
Drop_parentid.Items[i].Selected = true;
|
|
}
|
|
else
|
|
{
|
|
Drop_parentid.Items[i].Selected = false;
|
|
}
|
|
}
|
|
}
|
|
if (Request.QueryString["ParentID"].ToString() == "12")
|
|
{
|
|
strtitle = "英文版栏目";
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
Btn_Insert.Click += delegate(object s, EventArgs ex)
|
|
{
|
|
Mtxfw.Model.Article model = new Mtxfw.Model.Article();
|
|
model.senderid = 0;
|
|
model.receiverid = 0;
|
|
model.Title = Text_Title.Text;
|
|
model.ParentID = int.Parse(Request.QueryString["ParentID"].ToString());
|
|
model.CategoryId = Drop_parentid.SelectedItem.Value;
|
|
model.AddTime = DateTime.Now;
|
|
model.Author = IdentityName;
|
|
model.Content = Hidd_myEditor.Value;
|
|
model.Paths = Text_Paths.Text;
|
|
model.Seef = (model.CategoryId == "0" ? 1 : 2);
|
|
model.wtype = 0;
|
|
model.LinkID = Convert.ToInt32(Text_LinkID.Text);
|
|
model.Content2 = "";
|
|
model.KeyWords = "";
|
|
model.Paths2 = "";
|
|
model.media_id = "";
|
|
model.thumb_media_id = "";
|
|
daoArt.Add(model);
|
|
if (Session["UploadFileIng"] != null)
|
|
{
|
|
string[] stra = Session["UploadFileIng"].ToString().Split(',');
|
|
foreach (string str in stra)
|
|
{
|
|
if (str.Trim() != "")
|
|
{
|
|
if ( model.Content.IndexOf(str.Trim()) == -1)
|
|
{
|
|
if (System.IO.File.Exists(Server.MapPath(str.Trim())))
|
|
{
|
|
System.IO.File.Delete(Server.MapPath(str.Trim()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Session.Remove("UploadFileIng");
|
|
System.Collections.IDictionaryEnumerator CacheEnum = Cache.GetEnumerator();
|
|
while (CacheEnum.MoveNext())
|
|
{
|
|
Cache.Remove(CacheEnum.Key.ToString());
|
|
}
|
|
Response.Redirect(Hidd_Url.Value);
|
|
};
|
|
|
|
Btn_Update.Click += delegate(object s, EventArgs ex)
|
|
{
|
|
Int32 ID = int.Parse(Request.QueryString["ID"]);
|
|
Mtxfw.Model.Article model = daoArt.GetModel(ID);
|
|
model.senderid = 0;
|
|
model.receiverid = 0;
|
|
model.Title = Text_Title.Text;
|
|
model.ParentID = int.Parse(Request.QueryString["ParentID"].ToString());
|
|
model.CategoryId = Drop_parentid.SelectedItem.Value;
|
|
model.AddTime = DateTime.Now;
|
|
model.Author = IdentityName;
|
|
model.Content = Hidd_myEditor.Value;
|
|
model.Paths = Text_Paths.Text;
|
|
model.Seef = (model.CategoryId == "0" ? 1 : 2);
|
|
model.LinkID = Convert.ToInt32(Text_LinkID.Text);
|
|
model.id = ID;
|
|
daoArt.Update(model);
|
|
if (Session["UploadFileIng"] != null)
|
|
{
|
|
string[] stra = Session["UploadFileIng"].ToString().Split(',');
|
|
foreach (string str in stra)
|
|
{
|
|
if (str.Trim() != "")
|
|
{
|
|
if ( model.Content.IndexOf(str.Trim()) == -1)
|
|
{
|
|
if (System.IO.File.Exists(Server.MapPath(str.Trim())))
|
|
{
|
|
System.IO.File.Delete(Server.MapPath(str.Trim()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Session.Remove("UploadFileIng");
|
|
System.Collections.IDictionaryEnumerator CacheEnum = Cache.GetEnumerator();
|
|
while (CacheEnum.MoveNext())
|
|
{
|
|
Cache.Remove(CacheEnum.Key.ToString());
|
|
}
|
|
Response.Redirect(Hidd_Url.Value);
|
|
};
|
|
}
|
|
protected void Data_Bindlb()
|
|
{
|
|
Drop_parentid.DataSource = daoArt.GetList1("id,Title", "ParentID=" + Request.QueryString["ParentID"].ToString() + " and categoryid=0 Order by LinkID desc");
|
|
Drop_parentid.DataBind();
|
|
Drop_parentid.Items.Insert(0, new ListItem("==请选择==", "0"));
|
|
}
|
|
}
|
|
} |