migrate to new git
This commit is contained in:
108
web/admin/news/reg.aspx.cs
Normal file
108
web/admin/news/reg.aspx.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Globalization;
|
||||
using static TreeView;
|
||||
|
||||
public partial class admin_news__reg : MyWeb.config
|
||||
{
|
||||
private Model.ezEntities _db = new Model.ezEntities();
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
|
||||
if (isStrNull(Request["num"]))
|
||||
{
|
||||
Response.Redirect("list.aspx" + rtnQueryString("num"));
|
||||
}
|
||||
else
|
||||
{
|
||||
int _num = Val(Request["num"]);
|
||||
var qry = _db.news.AsEnumerable();
|
||||
var prod = qry.Where(q => q.num == _num).FirstOrDefault();
|
||||
|
||||
if (prod != null)
|
||||
{
|
||||
if (prod.author.HasValue)
|
||||
author.Text = prod.admin.u_name;
|
||||
if (prod.uptime.HasValue)
|
||||
uptime.Text = prod.uptime.Value.ToString("yyyy-MM-dd");
|
||||
if (prod.kind.HasValue)
|
||||
{
|
||||
kind.Text = prod.news_kind.kind;
|
||||
kind.Text = new TreeView().kindText(_db.news_kind.Select(o => new TreeItem()
|
||||
{
|
||||
kind = o.kind,
|
||||
num = o.num,
|
||||
root = o.root,
|
||||
}).ToList(), prod.kind);
|
||||
|
||||
}
|
||||
|
||||
subject.Text = prod.subject;
|
||||
word.Text = prod.word;
|
||||
|
||||
|
||||
//檔案
|
||||
var qry2 = _db.news_files.AsEnumerable();
|
||||
var prod2 = qry2.Where(q => q.news_id == _num).ToList();
|
||||
Repeater1.DataSource = prod2;
|
||||
Repeater1.DataBind();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Response.Redirect("list.aspx");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected void goback_Click(object sender, EventArgs e)
|
||||
{
|
||||
Response.Redirect("list.aspx?page=" + Convert.ToString(Request["page"]));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#region 檔案下載
|
||||
protected void file_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
FileInfo FileInfo = new FileInfo(HttpContext.Current.Server.MapPath(Model. news.Dir + "/" + ((LinkButton)sender).CommandName));
|
||||
if (FileInfo.Exists)
|
||||
{
|
||||
|
||||
Response.ContentType = "application/octet-stream";
|
||||
//指定輸出類型
|
||||
Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}", ((LinkButton)sender).CommandArgument));
|
||||
Response.HeaderEncoding = System.Text.Encoding.GetEncoding("big5");
|
||||
// 若要支援中文檔名,要加這個。
|
||||
Response.WriteFile(FileInfo.FullName);
|
||||
// 輸出檔案內容
|
||||
Response.End();
|
||||
}
|
||||
else
|
||||
{
|
||||
Response.ContentType = "text/plain";
|
||||
//Response.Write("資料不存在");
|
||||
ScriptMsg("資料不存在", "", msgIcon.error);
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user