191 lines
7.0 KiB
C#
191 lines
7.0 KiB
C#
using System;
|
||
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 Business = SuperMap.RealEstate.HighWay.Storage.Business;
|
||
using System.IO;
|
||
|
||
namespace SuperMap.RealEstate.HighWay.Modules.ProblemDeal
|
||
{
|
||
/// <summary>
|
||
/// T_IMAGE_图片表 的WebUserControl
|
||
/// <summary>
|
||
public partial class IMAGE : UserControl<Business.IMAGE>
|
||
{
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
}
|
||
|
||
//在此加入界面的数据初始化(Page_Load之前),如DropDownList的数据源绑定等
|
||
public override void InitializeWebControl()
|
||
{
|
||
//是否有效
|
||
ISVALID.Clear();
|
||
DictionaryHelper.BindingDropDownList("ISVALID", ISVALID.Items, this.Transaction);
|
||
}
|
||
|
||
//载入数据
|
||
public override bool LoadData()
|
||
{
|
||
//初始化并加载列表
|
||
GridViewEx1.SelectingWithInit<Business.IMAGE>(ObjectDataSource1, GridPageEx1,
|
||
DictionaryHelper.GetDictionary(Transaction, "ISVALID"));
|
||
//设置回车焦点按钮
|
||
Page.SetControlClientAction(ButtonSearch);
|
||
//如果是工作流组件请自行修改载入的逻辑,以下是功能模块的默认代码
|
||
if (!String.IsNullOrEmpty(Request["ID"]))
|
||
{
|
||
CurrObject.IMAGE_ID_Encrypt = Request["ID"];
|
||
return this.Select();
|
||
}
|
||
//默认返回值,工作流组件返回True,功能模块返回False。
|
||
return (WorkFlowPage != null);
|
||
}
|
||
|
||
//OnDataAction_XXXXX 有一个系列可用,在此加入界面的逻辑处理
|
||
//e.CancelDataAction 来处理是否取消该动作;
|
||
//失败的原因可以用Page.Alert()传递到页面
|
||
public override void OnDataAction_BeforeSave(DataActionEventArgs<Business.IMAGE> e)
|
||
{
|
||
if (mFileUpload.FileName.ToString() == "")
|
||
{
|
||
e.Success = DataActionResult.False;
|
||
return;
|
||
}
|
||
string ImagePathSrc = string.Empty;
|
||
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/ENDACCOUNT/";
|
||
string savePath = Server.MapPath("~/UploadImageDir/ENDACCOUNT/");
|
||
if (!Directory.Exists(savePath))
|
||
{
|
||
Directory.CreateDirectory(savePath);
|
||
}
|
||
mFileUpload.PostedFile.SaveAs(savePath + newname);
|
||
ImagePathSrc += newname;
|
||
}
|
||
}
|
||
|
||
CurrObject.IMAGE_PATH = ImagePathSrc;
|
||
|
||
CurrObject.TABLE_ID = int.Parse(Request["ENDACCOUNT_ID"].ToDecrypt());
|
||
CurrObject.TABLE_NAME = "T_ENDACCOUNT";
|
||
CurrObject.IMAGE_DATE = System.DateTime.Now;
|
||
|
||
base.OnDataAction_BeforeSave(e);
|
||
}
|
||
|
||
public override void OnDataAction_AfterSave(DataActionEventArgs<Business.IMAGE> e)
|
||
{
|
||
//绑定列表
|
||
base.OnDataAction_AfterSave(e);
|
||
}
|
||
|
||
public override bool Save(bool AutoBindData = true)
|
||
{
|
||
bool FLAG = base.Save(AutoBindData);
|
||
|
||
//初始化并加载列表
|
||
GridViewEx1.SelectingWithInit<Business.IMAGE>(ObjectDataSource1, GridPageEx1,
|
||
DictionaryHelper.GetDictionary(Transaction, "ISVALID"));
|
||
//设置回车焦点按钮
|
||
Page.SetControlClientAction(ButtonSearch);
|
||
|
||
Image_ID.Text = "";
|
||
IMAGE_DESC.Text = "";
|
||
|
||
return FLAG;
|
||
}
|
||
|
||
public override bool SaveEx(ClientSetEventArgs ClientSet)
|
||
{
|
||
return base.SaveEx(ClientSet);
|
||
}
|
||
|
||
#region 方法 -> 绑定列表
|
||
protected void ButtonSearch_CallBackClick(object sender, ClientSetEventArgs e)
|
||
{
|
||
GridViewEx1.Selecting<Business.IMAGE>(ObjectDataSource1, GridPageEx1);
|
||
//设置UI变化
|
||
e.SetValue(GridViewEx1);
|
||
e.SetValue(GridPageEx1);
|
||
}
|
||
|
||
//翻页事件
|
||
protected void GridPageEx1_CallBackPageChanged(object src, ClientSetEventArgs e)
|
||
{
|
||
GridViewEx1.Pagging<Business.IMAGE>(ObjectDataSource1, GridPageEx1);
|
||
//设置UI变化
|
||
e.SetValue(GridViewEx1);
|
||
}
|
||
|
||
//查询SQL设置
|
||
protected void GridViewEx1_SelectMethodParameters(object sender, SelectMethodParametersArgs e)
|
||
{
|
||
//搜索选项的搜索条件过滤
|
||
if (!string.IsNullOrEmpty(TextBox_Search.Text))
|
||
e.AddOrParams(GridViewSearch1, TextBox_Search.Text);
|
||
//且搜索条件
|
||
//e.AddAndParams(字段名, 值);
|
||
e.AddAndParams("TABLE_NAME", "T_ENDACCOUNT");
|
||
e.AddAndParams("TABLE_ID", Request["ENDACCOUNT_ID"].ToDecrypt());
|
||
//或搜索条件
|
||
//e.AddOrParams(字段名, 值);
|
||
//排序
|
||
e.AddOrderByParams(GridViewOrderBy1);
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 选择
|
||
protected void SelectButton_CallBackClick(object sender, ClientSetEventArgs e)
|
||
{
|
||
CallBackButton _button = (CallBackButton)sender;
|
||
GridViewRow _Row = (GridViewRow)_button.NamingContainer;
|
||
string _Image_ID = GridViewEx1.DataKeys[_Row.RowIndex][0].ToString();
|
||
|
||
Business.IMAGE _IMAGE = new Business.IMAGE(this.Transaction);
|
||
_IMAGE.IMAGE_ID = int.Parse(_Image_ID);
|
||
if (_IMAGE.Select())
|
||
{
|
||
e.SetValue(Image_ID, _IMAGE.IMAGE_ID.Value.ToString());
|
||
e.SetValue(IMAGE_PATH, _IMAGE.IMAGE_PATH);
|
||
e.SetValue(IMAGE_DESC, _IMAGE.IMAGE_DESC);
|
||
e.ExcuteClientScript("BindImg()");
|
||
}
|
||
//
|
||
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 删除
|
||
protected void DeleteButton_CallBackClick(object sender, ClientSetEventArgs e)
|
||
{
|
||
CallBackButton _button = (CallBackButton)sender;
|
||
GridViewRow _Row = (GridViewRow)_button.NamingContainer;
|
||
string _Image_ID = GridViewEx1.DataKeys[_Row.RowIndex][0].ToString();
|
||
|
||
Business.IMAGE _IMAGE = new Business.IMAGE(this.Transaction);
|
||
_IMAGE.Delete(int.Parse(_Image_ID));
|
||
|
||
e.SetValue(Image_ID, "");
|
||
e.SetValue(IMAGE_DESC, "");
|
||
e.SetValue(Table_Name, "T_ENDACCOUNT");
|
||
e.SetValue(Table_ID, Request["ENDACCOUNT_ID"].ToDecrypt());
|
||
//
|
||
ButtonSearch_CallBackClick(null, e);
|
||
}
|
||
#endregion
|
||
}
|
||
}
|