2025-03-27 15:05:14 +08:00

118 lines
4.2 KiB
C#

using System;
using System.IO;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web.UI;
using System.Web.UI.WebControls;
using SuperMap.RealEstate.CoreFrameWork;
using SuperMap.RealEstate.ServiceModel;
using SuperMap.RealEstate.Utility;
using SuperMap.RealEstate.Web.UI;
using SuperMap.RealEstate.Web.UI.WebControls;
using SuperMap.RealEstate.Web.Utility;
using Storage=SuperMap.RealEstate.HighWay.Storage;
namespace SuperMap.RealEstate.ExchangeData
{
public partial class IMAGEPage : SuperMap.RealEstate.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack) return;
//载入数据
//ButtonDelete.Enabled = IMAGE1.LoadData();
//设置删除提示
SetControlConfirm(ButtonDelete, "您确认删除该记录,删除后将无法恢复数据?");
//设置按钮状态
SetControlClientAction(ButtonDelete, false, true, true);
SetControlClientAction(ButtonSave);
//注册遮罩式窗口关闭脚本
SetControlClosePopDialog(ButtonClose);
if (Request["ReadOnly"] != null && (Request["ReadOnly"].ToString() == "true" ||
Request["ReadOnly"].ToString() == ModifyTypeEnum.ReadOnlyVisible.ToString()))
{
ButtonSave.Visible = false;
ButtonDelete.Visible = false;
}
}
protected void ButtonSave_Click(object sender, EventArgs e)
{
if (mFileUpload.FileName.ToString() == "")
{
Alert("请选择图片");
return;
}
string ImagePathSrc = string.Empty;
Storage.Business.IMAGE _IMAGE = new Storage.Business.IMAGE(this.Transaction);
if (mFileUpload.HasFile)
{
string extension = Path.GetExtension(mFileUpload.PostedFile.FileName).ToLower();
string newname = DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss_ffff") + extension;
if (extension == ".jpg" || extension == ".gif" || extension == ".png")
{
ImagePathSrc += "/UploadImageDir/CASHIERCONTROL/";
string savePath = Server.MapPath("~/UploadImageDir/CASHIERCONTROL/");
if (!Directory.Exists(savePath))
{
Directory.CreateDirectory(savePath);
}
mFileUpload.PostedFile.SaveAs(savePath + newname);
ImagePathSrc += newname;
}
}
_IMAGE.IMAGE_PATH = ImagePathSrc;
_IMAGE.Table_ID = int.Parse(Request["CASHIERCONTROL_ID"].ToDecrypt());
_IMAGE.Table_Name = "T_CASHIERCONTROL";
_IMAGE.IMAGE_DATE = System.DateTime.Now;
_IMAGE.IMAGE_TITLE = IMAGE_TITLE.Text;
_IMAGE.Insert();
//清空旧值
IMAGE_TITLE.Text = "";
Alert("保存成功!", 3);
IMAGE1.BindTreeView();
}
protected void ButtonDelete_Click(object sender, EventArgs e)
{
try
{
//删除数据
//ButtonDelete.Enabled = !IMAGE1.Delete();
if ((IMAGE1.FindControl("IMAGE_ID") as TextBoxEx).Text != "")
{
IMAGE1.Delete();
//刷新弹出页列表
RefreshOpenerGridPage(RefreshGridPageType.Delete);
//提示信息
Alert("删除成功!", 3);
}
//ClosePopDialog();
}
catch (Exception ex)
{
//回滚事务
Transaction.Rollback();
//记录日志
ErrorLogHelper.Write(ex);
#if DEBUG
Alert("删除失败!可能的原因:\n" + ex.Message);
#else
Alert("删除失败!");
#endif
}
}
protected void BtnAdd_Click(object sender, EventArgs e)
{
IMAGE1.CurrObject.ResetProperty();
IMAGE1.LoadData();
}
}
}