146 lines
5.2 KiB
C#
146 lines
5.2 KiB
C#
using System;
|
|
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 System.IO;
|
|
|
|
namespace SuperMap.RealEstate.HighWay.Compents.ExpenseBill
|
|
{
|
|
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() == ModifyTypeEnum.ReadOnlyVisible.ToString())
|
|
{
|
|
ButtonSave.Visible = false;
|
|
ButtonDelete.Visible = false;
|
|
}
|
|
}
|
|
|
|
protected void ButtonSave_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
|
|
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/EXPENSEBILL/";
|
|
string savePath = Server.MapPath("~/UploadImageDir/EXPENSEBILL/");
|
|
if (!Directory.Exists(savePath))
|
|
{
|
|
Directory.CreateDirectory(savePath);
|
|
}
|
|
mFileUpload.PostedFile.SaveAs(savePath + newname);
|
|
ImagePathSrc += newname;
|
|
if (!string.IsNullOrEmpty(Request["EXPENSEBILL_ID"]))
|
|
{
|
|
_IMAGE.Table_ID = int.Parse(Request["EXPENSEBILL_ID"].ToDecrypt());
|
|
_IMAGE.Table_Name = "T_EXPENSEBILL";
|
|
}
|
|
else if (!string.IsNullOrEmpty(Request["FUNDAPPLY_ID"]))
|
|
{
|
|
_IMAGE.Table_ID = int.Parse(Request["FUNDAPPLY_ID"].ToDecrypt());
|
|
_IMAGE.Table_Name = "T_FUNDAPPLY";
|
|
}
|
|
_IMAGE.IMAGE_PATH = ImagePathSrc;
|
|
_IMAGE.IMAGE_DATE = System.DateTime.Now;
|
|
_IMAGE.IMAGE_TITLE = IMAGE_TITLE.Text;
|
|
_IMAGE.Insert();
|
|
|
|
Alert("保存票据成功!", 3);
|
|
IMAGE1.BindTreeView();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert("图片格式有误!", 3);
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
Alert("图片格式有误!", 3);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 将B转换为MB
|
|
/// </summary>
|
|
/// <param name="b"></param>
|
|
/// <returns></returns>
|
|
private double GetMB(long b)
|
|
{
|
|
for (int i = 0; i < 2; i++)
|
|
{
|
|
b /= 1024;
|
|
}
|
|
return b;
|
|
}
|
|
protected void ButtonDelete_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
//if (IMAGE1.CurrObject.Image_ID == 0 || IMAGE1.CurrObject.Image_ID == null)
|
|
//{
|
|
// Alert("请选择要删除的图片!");
|
|
// return;
|
|
//}
|
|
//删除数据
|
|
//ButtonDelete.Enabled = !IMAGE1.Delete();
|
|
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() ;
|
|
}
|
|
}
|
|
}
|