?? admindown.aspx.cs
字號:
using System;
using System.IO;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace _211
{
/// <summary>
/// AdminDown 的摘要說明。
/// </summary>
public partial class AdminDown : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
if(Session["name"]==null)
{
Response.Write("<script>top.location='AdminLogin.aspx'</script>");
return;
}
if(!Page.IsPostBack)
{
BindDown();
BindDownType();
DownList2Text();
}
Button3.Attributes["onclick"]="return confirm('確定要刪除么?')";
}
private void BindDown()
{
d.DataSource=TableQuery.DownQuery();
d.DataTextField="DownName";
d.DataValueField="DownId";
d.DataBind();
}
private void BindDownType()
{
DataTable dt=TableQuery.DownTypeQuery();
ty.Text="";
for(int i=0;i<dt.Rows.Count;i++)
{
ty.Text+=dt.Rows[i][1].ToString()+" ";
}
}
private void DownList2Text()
{
if(d.SelectedItem!=null)
{
ename.Text=d.SelectedItem.Text;
intro.Text="<a href=\""+TableQuery.DownUrlQuery(d.SelectedValue)+"\">下載地址</a> <font color=red>下載文件如不需要修改文件瀏覽框請留空</font>";
}
}
private void CreateStaticWeb()
{
using(CreateDown cd=new CreateDown())
{
cd.Add();
}
}
#region Web 窗體設計器生成的代碼
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 該調用是 ASP.NET Web 窗體設計器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內容。
/// </summary>
private void InitializeComponent()
{
}
#endregion
protected void Button2_Click(object sender, System.EventArgs e)
{
if(name.Text==""||upfile.Value=="")
{
Response.Write("<script>alert('添加未成功');</script>");
return;
}
using(Down dw=new Down())
{
try
{
dw.setDownName(name.Text);
dw.setDownUrl(FileOperate.UpLoadFile(upfile));
dw.Add();
//upfile.Value="";
name.Text="";
Response.Write("<script>alert('添加成功');</script>");
}
catch(Exception ex)
{
Response.Write("<script>alert('"+ex.Message.ToString()+"');</script>");
}
}
CreateStaticWeb();
BindDown();
DownList2Text();
}
protected void Button1_Click(object sender, System.EventArgs e)
{
if(ename.Text==""||d.SelectedItem==null)
{
return;
}
using(Down dw=new Down(Convert.ToUInt32(d.SelectedValue)))
{
try
{
dw.setDownName(ename.Text);
if(up.Value!="")
{
FileOperate.DelFile(dw.getDownUrl());
dw.setDownUrl(FileOperate.UpLoadFile(up));
}
dw.Update();
//up.Value="";
Response.Write("<script>alert('修改成功');</script>");
}
catch(Exception ex)
{
Response.Write("<script>alert('"+ex.Message.ToString()+"');</script>");
}
}
CreateStaticWeb();
BindDown();
DownList2Text();
}
protected void Button3_Click(object sender, System.EventArgs e)
{
if(d.SelectedItem==null)
{
return;
}
using(Down dw=new Down(Convert.ToUInt32(d.SelectedValue)))
{
try
{
FileOperate.DelFile(dw.getDownUrl());
dw.Del();
Response.Write("<script>alert('刪除成功');</script>");
}
catch(Exception ex)
{
Response.Write("<script>alert('"+ex.Message.ToString()+"');</script>");
}
}
CreateStaticWeb();
BindDown();
DownList2Text();
int temp=(int)DBQuery.ExecuteScalar("select count(*) from down");
if(temp%10==0)
{
FileInfo fi=new FileInfo(Request.ServerVariables["APPL_PHYSICAL_PATH"].ToString()+"Down_"+(temp/10)+".htm");
if(fi.Exists)fi.Delete();
}
}
protected void d_SelectedIndexChanged(object sender, System.EventArgs e)
{
DownList2Text();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -