116 lines
4.6 KiB
C#
116 lines
4.6 KiB
C#
using System;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Web;
|
|
using System.Web.UI.WebControls;
|
|
using Business = SuperMap.RealEstate.SendRec.Storage.Business;
|
|
using HCC = HZQR.Common.Common;
|
|
using HZQR.Common;
|
|
|
|
namespace SuperMap.RealEstate.SendRec.Common
|
|
{
|
|
public partial class AttachmentUpload : Web.UI.Page
|
|
{
|
|
protected string postUrl = ConfigurationManager.AppSettings["postUrl"];
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (IsPostBack) return;
|
|
|
|
if (Request["readonly"] == "true")
|
|
{
|
|
uploadComponents.Visible = false;
|
|
}
|
|
//载入数据
|
|
TABLE_ID.Text = Request["TABLE_ID"].ToDecrypt();
|
|
TABLE_NAME.Text = Request["TABLE_NAME"].ToDecrypt();
|
|
//绑定附件列表
|
|
BindRepick();
|
|
}
|
|
|
|
private void BindRepick()
|
|
{
|
|
//未保存备案合同数据,隐藏正式文件及上传按钮
|
|
RepeaterFile.DataSource = new Business.ATTACHMENT(Transaction).FillDataTable(
|
|
"WHERE TABLE_ID = " + TABLE_ID.Text + " AND TABLE_NAME = '" + TABLE_NAME.Text + "'");
|
|
RepeaterFile.DataBind();
|
|
}
|
|
|
|
#region 方法 -> 附件行绑定事件
|
|
protected void RepeaterFile_ItemDataBound(object sender, RepeaterItemEventArgs e)
|
|
{
|
|
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem ||
|
|
e.Item.ItemType == ListItemType.SelectedItem)
|
|
{
|
|
DataRowView rowv = (DataRowView)e.Item.DataItem;
|
|
//附件链接
|
|
LinkButton LinkButton = e.Item.FindControl("LinkButton") as LinkButton;
|
|
LinkButton.ToolTip = rowv["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"] = rowv["ATTACHMENT_ID"].ToEncrypt();
|
|
//删除按钮
|
|
LinkButton DelButton = e.Item.FindControl("DelButton") as LinkButton;
|
|
if (Request["readonly"] == "true")
|
|
{
|
|
DelButton.Visible = false;
|
|
}
|
|
else
|
|
{
|
|
DelButton.Text = "<span><img src='/HighWay/Resources/v1_0/Images/delete.png' /></span>";
|
|
DelButton.Attributes["base-code"] = rowv["ATTACHMENT_ID"].ToEncrypt();
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 方法 -> 附件下载事件
|
|
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())
|
|
{
|
|
Open(_ATTACHMENT.ATTACHMENT_URL, "AttachmentPage", 2000, 2000, 0, 0, true, true, false, false, false, false, true);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 方法 -> 附件删除事件
|
|
protected void DelButton_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
LinkButton LinkButton = sender as LinkButton;
|
|
Business.ATTACHMENT _ATTACHMENT = new Business.ATTACHMENT(Transaction);
|
|
_ATTACHMENT.ATTACHMENT_ID_Encrypt = LinkButton.Attributes["base-code"].ToString();
|
|
if (_ATTACHMENT.Select())
|
|
{
|
|
_ATTACHMENT.STAFF_ID = PassportInfo.ID;
|
|
_ATTACHMENT.STAFF_NAME = PassportInfo.Name;
|
|
_ATTACHMENT.OPERATE_DATE = long.Parse(DateTime.Now.ToString("yyyyMMddHHmmss"));
|
|
_ATTACHMENT.Update();
|
|
|
|
if (Request["DelFile"].TryParseToBool())
|
|
{
|
|
//删除指定服务器上的文件
|
|
HCC.CommonHelper.DelFileFromServer(_ATTACHMENT.ATTACHMENT_PATH,
|
|
_ATTACHMENT.ATTACHMENT_NAME, postUrl + "FileUpload.ashx");
|
|
}
|
|
//从数据库删除记录
|
|
_ATTACHMENT.Delete();
|
|
}
|
|
BindRepick();
|
|
Alert("删除成功!");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Alert(ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
} |