📄 addpy.aspx.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;
using System.Xml;
public partial class manger_addpy : System.Web.UI.Page
{
private XmlDocument xmld;
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (Session["admin"].ToString() != "true")
{
//Response.Write("<script>parent.window.location.href='login.aspx';</script>");
Response.Write("<script>parent.window.location.href='../login.aspx';</script>");
Response.End();
}
}
catch
{
Response.Write("<script>parent.window.location.href='../login.aspx';</script>");
Response.End();
}
try
{
xmld = new XmlDocument();
xmld.Load(Server.MapPath(@"../config/PeiYangFangAn.xml"));
}
catch//(Exception exp)
{
Response.Write("数据打开失败,请与管理员联系");
Response.End();
}
int i = -1;
XmlNodeList xnl = xmld.SelectSingleNode("data").ChildNodes;
foreach (XmlNode xn in xnl)
{
XmlElement xe = (XmlElement)xn;
if (xe.GetAttribute("name") == "peiyang")
{
HyperLink1.NavigateUrl = HyperLink1.NavigateUrl + xe.GetAttribute("value");
i = 1;
break;
}
}
if (i == 1)
{
xmld.Save(Server.MapPath(@"../config/PeiYangFangAn.xml"));
//Response.Write("<script>alert('上传成功成功');</script>");
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string kk = "";
if (FileUpload1.HasFile)
{
String str = Server.MapPath("");
str = str.Substring(0, str.Length - 6);
str = str + "upload\\";
string myDateTime = DateTime.UtcNow.ToString("yyyy_MM_dd_HH_mm_ss_fffffff");
kk = myDateTime + FileUpload1.FileName;
str = str + myDateTime + FileUpload1.FileName;
try
{
FileUpload1.SaveAs(str);
}
catch
{
Response.Write("<script>alert('上传文件超过1M,上传遇到技术问题,请与技术人员联系');</script>");
}
try
{
xmld = new XmlDocument();
xmld.Load(Server.MapPath(@"../config/PeiYangFangAn.xml"));
}
catch//(Exception exp)
{
Response.Write("数据打开失败,请与管理员联系");
Response.End();
}
int i = -1;
XmlNodeList xnl = xmld.SelectSingleNode("data").ChildNodes;
foreach (XmlNode xn in xnl)
{
XmlElement xe = (XmlElement)xn;
if (xe.GetAttribute("name") =="peiyang")
{
xe.SetAttribute("value", kk);
i = 1;
break;
}
}
if (i == 1)
{
xmld.Save(Server.MapPath(@"../config/PeiYangFangAn.xml"));
Response.Write("<script>alert('上传成功成功');</script>");
}
HyperLink1.NavigateUrl = "../upload/" + kk;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -