145 lines
5.5 KiB
C#
145 lines
5.5 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_menu_add : Mtxfw.Utility.AdminPage
|
|
{
|
|
public Mtxfw.DAL.Article daoArt = new Mtxfw.DAL.Article();
|
|
public Mtxfw.Utility.Config config = new Mtxfw.Utility.Config();
|
|
public String TitName, strBody = "", strimg="";
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
base.OnLoad(e);
|
|
|
|
if (!IsPostBack)
|
|
{
|
|
Hidd_Url.Value = Request.UrlReferrer.ToString();
|
|
Select_Bind();
|
|
}
|
|
if (Request.QueryString["action"] == "add")
|
|
{
|
|
TitName = "添加栏目";
|
|
if (!IsPostBack)
|
|
{
|
|
Btn_Update.Visible = false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
TitName = "更新栏目";
|
|
if (!IsPostBack)
|
|
{
|
|
Btn_Insert.Visible = false;
|
|
}
|
|
Mtxfw.Model.Article model = daoArt.GetModel(int.Parse(Request.QueryString["ID"]));
|
|
|
|
strBody = model.Content;
|
|
if (!IsPostBack)
|
|
{
|
|
Text_Title.Text = model.Title;
|
|
Hidd_C.Value = model.CategoryId;
|
|
Drop_MenuClass.SelectedValue = model.ParentID.ToString();
|
|
hiddenphoto.Value = model.Author;
|
|
}
|
|
if (hiddenphoto.Value != "")
|
|
{
|
|
strimg = "<li id='picli0'><img src='/GetFiles.ashx?image=" + hiddenphoto.Value + "&itsize=100x100&itmode=cut' width='100' class='pic'/><a href=javascript:DeletePic('" + hiddenphoto.Value + "',0)>删除</a></li>";
|
|
}
|
|
}
|
|
|
|
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(Drop_MenuClass.SelectedItem.Value);
|
|
model.CategoryId = "0";
|
|
model.AddTime = DateTime.Now;
|
|
model.Author = hiddenphoto.Value;
|
|
|
|
model.Paths = "";
|
|
model.Seef = 1;
|
|
model.wtype = 0;
|
|
model.LinkID = 0;
|
|
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");
|
|
new admin_Product_list().Createtopproduct();
|
|
Mtxfw.Utility.Tools.Message("添加栏目成功!", 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(Drop_MenuClass.SelectedItem.Value);
|
|
model.CategoryId = Hidd_C.Value;
|
|
model.AddTime = DateTime.Now;
|
|
model.Author = hiddenphoto.Value;
|
|
model.Content = Hidd_myEditor.Value;
|
|
model.Paths = "";
|
|
model.Seef = 1;
|
|
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");
|
|
new admin_Product_list().Createtopproduct();
|
|
Mtxfw.Utility.Tools.Message("更新栏目成功!", Hidd_Url.Value);
|
|
};
|
|
}
|
|
|
|
protected void Select_Bind()
|
|
{
|
|
foreach (KeyValuePair<int, string> kv in Mtxfw.Utility.Common.GetMenuClass())
|
|
{
|
|
Drop_MenuClass.Items.Add(new ListItem(kv.Value, kv.Key.ToString()));
|
|
}
|
|
}
|
|
}
|
|
} |