using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace Mtxfw._admin { public partial class admin_link_add : Mtxfw.Utility.AdminPage { public Mtxfw.DAL.Link dao = new Mtxfw.DAL.Link(); public Mtxfw.Utility.Config config = new Mtxfw.Utility.Config(); public String TitName; protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!IsPostBack) { if (Request.QueryString["action"] == "add") { Btn_Update.Visible = false; Img_Img.Visible = false; TitName = "添加链接"; } else { TitName = "更新链接"; Btn_Insert.Visible = false; Mtxfw.Model.Link model = dao.GetModel(Int32.Parse((Request.QueryString["ID"]))); Text_LinkName.Text = model.LinkName; Text_LinkUrl.Text = model.LinkUrl; if (!String.IsNullOrEmpty(model.LinkImg)) { Img_Img.Visible = true; Img_Img.Src = Mtxfw.Utility.Common.GetCoverPic(model.LinkImg, "100x40", config.webImgMode); Hidd_Img.Value = model.LinkImg; } else { Img_Img.Visible = false; Hidd_Img.Value = String.Empty; } } } //添加管理员 Btn_Insert.Click += delegate(object s, EventArgs ex) { if (!String.IsNullOrEmpty(Text_LinkName.Text) && !String.IsNullOrEmpty(Text_LinkUrl.Text)) { Mtxfw.Model.Link model = new Mtxfw.Model.Link(); model.LinkName = Text_LinkName.Text; model.LinkUrl = Text_LinkUrl.Text; Mtxfw.Utility.UploadFile upload = new Utility.UploadFile(File_LinkImg.PostedFile, config.webUpPath, config.webUpType, int.Parse(config.webUpSize)); if (File_LinkImg.FileName.Length > 0) { upload.StatrUpFile(); model.LinkImg = upload.UploadPath; } else model.LinkImg = String.Empty; dao.Add(model); Response.Redirect("admin_link_list.aspx"); } else Mtxfw.Utility.Tools.Message("请不要提交空值!"); }; //更改密码 Btn_Update.Click += delegate(object s, EventArgs ex) { if (!String.IsNullOrEmpty(Text_LinkName.Text) && !String.IsNullOrEmpty(Text_LinkUrl.Text)) { Mtxfw.Model.Link model = dao.GetModel(Int32.Parse((Request.QueryString["ID"]))); model.LinkName = Text_LinkName.Text; model.LinkUrl = Text_LinkUrl.Text; Mtxfw.Utility.UploadFile upload = new Utility.UploadFile(File_LinkImg.PostedFile, config.webUpPath, config.webUpType, int.Parse(config.webUpSize)); if (File_LinkImg.FileName.Length > 0) { upload.StatrUpFile(); model.LinkImg = upload.UploadPath; } else model.LinkImg = Hidd_Img.Value; dao.Update(model); Response.Redirect("admin_link_list.aspx"); } else Mtxfw.Utility.Tools.Message("请不要提交空值!"); }; } } }