85 lines
3.7 KiB
C#
85 lines
3.7 KiB
C#
using System;
|
||
using System.Data;
|
||
using System.IO;
|
||
using System.Web;
|
||
using System.Web.UI;
|
||
using System.Web.UI.WebControls;
|
||
using SuperMap.RealEstate.Web.UI;
|
||
using Business = SuperMap.RealEstate.Contract.Storage.Business;
|
||
|
||
namespace SuperMap.RealEstate.Contract.Modules.ContractProinst
|
||
{
|
||
public partial class ATTACHMENT1 : UserControl<Business.ATTACHMENT>
|
||
{
|
||
protected override void OnInit(EventArgs e)
|
||
{
|
||
base.OnInit(e);
|
||
}
|
||
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (IsPostBack) return;
|
||
//绑定对应的控件
|
||
BindRepick();
|
||
}
|
||
|
||
//载入数据
|
||
public override bool LoadData()
|
||
{
|
||
PROINST_ID.Text = Request["CONTRACTPROINST_ID"].ToDecrypt();
|
||
//默认返回值,工作流组件返回True,功能模块返回False。
|
||
return (WorkFlowPage != null);
|
||
}
|
||
|
||
private void BindRepick()
|
||
{
|
||
//绑定对应的控件
|
||
Repeater1.DataSource = new Business.ATTACHMENT(Transaction).FillDataTable(
|
||
"WHERE TABLE_NAME = 'T_CONTRACTPROINST' AND TABLE_ID = " + PROINST_ID.Text);
|
||
Repeater1.DataBind();
|
||
}
|
||
|
||
protected void LinkButton_Click(object sender, EventArgs e)
|
||
{
|
||
LinkButton LinkButton = sender as LinkButton;
|
||
//下载内容
|
||
Business.ATTACHMENT _ATTACHMENT = new Business.ATTACHMENT(Transaction);
|
||
_ATTACHMENT.ATTACHMENT_ID_Encrypt = LinkButton.Attributes["base-code"];
|
||
if (_ATTACHMENT.Select())
|
||
{
|
||
string uploadPath = HttpContext.Current.Server.MapPath("~" + _ATTACHMENT.ATTACHMENT_PATH);
|
||
string FileName = System.Web.HttpUtility.UrlEncode(_ATTACHMENT.ATTACHMENT_NAME, System.Text.Encoding.UTF8);
|
||
|
||
System.IO.MemoryStream ms = new System.IO.MemoryStream();
|
||
HttpContext.Current.Response.Clear();
|
||
HttpContext.Current.Response.Buffer = true;
|
||
HttpContext.Current.Response.Charset = "utf-8";
|
||
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");//设置输出流为简体中文
|
||
HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format(
|
||
"attachment; filename=" + FileName, DateTime.Now.ToString("yyyyMMddHHmmssfff")));
|
||
HttpContext.Current.Response.BinaryWrite(System.IO.File.ReadAllBytes(uploadPath));
|
||
HttpContext.Current.Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。
|
||
HttpContext.Current.Response.End();
|
||
ms.Close();
|
||
ms.Dispose();
|
||
}
|
||
|
||
}
|
||
|
||
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
|
||
{
|
||
if (e.Item.ItemType == System.Web.UI.WebControls.ListItemType.Item ||
|
||
e.Item.ItemType == System.Web.UI.WebControls.ListItemType.AlternatingItem ||
|
||
e.Item.ItemType == System.Web.UI.WebControls.ListItemType.SelectedItem)
|
||
{
|
||
DataRowView _DataRowView = (DataRowView)e.Item.DataItem;
|
||
|
||
LinkButton LinkButton = e.Item.FindControl("LinkButton") as LinkButton;
|
||
LinkButton.ToolTip = _DataRowView["ATTACHMENT_NAME"].ToString();
|
||
LinkButton.Text = "<span><img src='/HighWay/Resources/v1_0/Images/4950_old-versions.png' />" +
|
||
(LinkButton.ToolTip.Length > 30 ? LinkButton.ToolTip.Substring(0, 25) + "..." : LinkButton.ToolTip) + "</span>";
|
||
LinkButton.Attributes["base-code"] = _DataRowView["ATTACHMENT_ID"].ToEncrypt();
|
||
}
|
||
}
|
||
}
|
||
} |