⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 managesystem.aspx.cs

📁 ASP.NET 2.0动态网站设计实例源代码,本书介绍了ASP.NET2.0的基础知识
💻 CS
字号:
using System;
using System.Data;
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_ManageSystem : System.Web.UI.Page
{

 protected void Page_Load(object sender, EventArgs e)
 {
  if (!IsPostBack)
   BindData();
 }

 private void BindData()
 {
  tbxCopyRight.Text = Application["CopyRight"].ToString();
  if (Application["Logo"].ToString() == "")
   hlnkLogo.Text = @"暂时没有上传Logo";
  else
   hlnkLogo.NavigateUrl = @"~/image/" + (string)Application["Logo"];
 }
 protected void btnConfirm_Click(object sender, EventArgs e)
 {
  eSystemSetting esys = new eSystemSetting();
  esys.SettingKey = @"CopyRight";
  esys.SettingValue = tbxCopyRight.Text;
  if (esys.GetValueByKey() == "")
   esys.AddSetting();
  else
   esys.SetValueByKey();
  Application["CopyRight"] = tbxCopyRight.Text;
  if (fuldLogo.HasFile)
  {
   esys.SettingKey = @"Logo";
   esys.SettingValue = uploadFile(esys.GetValueByKey());
   if (esys.GetValueByKey() == "")
    esys.AddSetting();
   else
    esys.SetValueByKey();   
   Application["Logo"] = esys.SettingValue;
  }
  Server.Transfer("ManageSystem.aspx");
 }
 /// <summary>
 /// 上传图标文件
 /// </summary>
 /// <returns>图标的URL</returns>
 private string uploadFile(string strOldValue)
 {
  string physicalPath = Application["PhysicalPath"].ToString();
  if (strOldValue != "")
  {
   string oldFile = physicalPath + @"\image\" + strOldValue;
   if (System.IO.File.Exists(oldFile))
    System.IO.File.Delete(oldFile);
  }
  string returnFile = DateTime.Now.ToString("yyyyMMddhhmmss") + 
   DateTime.Now.Millisecond.ToString() +
   System.IO.Path.GetExtension(fuldLogo.FileName);
  string newFile = physicalPath+ @"\image\"+returnFile;
  fuldLogo.SaveAs(newFile);
  return returnFile;
 }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -