using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; using System.Web; 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 HWSB = SuperMap.RealEstate.HighWay.Storage.Business; using Business = SuperMap.RealEstate.HighWay.SellData.Business; namespace SuperMap.RealEstate.HighWay.Modules.EndAccountSeparate { public partial class ENDACCOUNTPage : SuperMap.RealEstate.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; //载入数据 ButtonDelete.Enabled = ENDACCOUNT1.LoadData(); //设置删除提示 SetControlConfirm(ButtonDelete, "您确认删除该记录,删除后将无法恢复数据?"); //设置按钮状态 SetControlClientAction(ButtonDelete, false, true, true); SetControlClientAction(ButtonSave); //注册遮罩式窗口关闭脚本 SetControlClosePopDialog(ButtonClose); } protected void ButtonSave_Click(object sender, EventArgs e) { try { //刷新类型 bool _RefreshType = ButtonDelete.Enabled; string extension = ""; FileUpload mFileUpload = ENDACCOUNT1.FindControl("mFileUpload") as FileUpload; if (mFileUpload.FileName.ToString() == "" && !mFileUpload.HasFile) { Alert("请选择上传图片后保存结账信息!"); return; } else { extension = Path.GetExtension(mFileUpload.PostedFile.FileName).ToLower(); if (extension != ".jpg" && extension != ".gif" && extension != ".png") { Alert("图片格式有误,请上传jpg、png、gif格式的图片!", 3); return; } } //保存数据 ButtonDelete.Enabled = ENDACCOUNT1.Save(); #region 保存图片信息 string ImagePathSrc = string.Empty; string newname = DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss_ffff") + extension; HWSB.IMAGE _IMAGE = new HWSB.IMAGE(this.Transaction); string savePath = ""; Uri URLAddress = HttpContext.Current.Request.Url; ImagePathSrc = "/UploadImageDir/ENDACCOUNT/" + DateTime.Now.ToString("yyyyMM") + "/"; savePath = Server.MapPath("~" + ImagePathSrc); if (!Directory.Exists(savePath)) { Directory.CreateDirectory(savePath); } mFileUpload.PostedFile.SaveAs(savePath + newname); ImagePathSrc += newname; _IMAGE.IMAGE_TYPE = 3000; _IMAGE.IMAGE_PATH = ImagePathSrc; _IMAGE.Table_ID = ENDACCOUNT1.CurrObject.ENDACCOUNT_ID; _IMAGE.Table_Name = "HIGHWAY_SELLDATA.T_ENDACCOUNT"; _IMAGE.IMAGE_DATE = System.DateTime.Now; _IMAGE.IMAGE_TITLE = Path.GetFileName(mFileUpload.PostedFile.FileName); _IMAGE.IMAGE_URL = URLAddress.Scheme + "://" + URLAddress.Authority + _IMAGE.IMAGE_PATH; _IMAGE.ISVALID = 1; _IMAGE.Insert(); #endregion //刷新弹出页列表 RefreshOpenerGridPage(_RefreshType ? RefreshGridPageType.Update : RefreshGridPageType.Insert); //提示信息 Alert("保存成功!", 3); ClosePopDialog(); } catch (Exception ex) { //回滚事务 Transaction.Rollback(); //记录日志 ErrorLogHelper.Write(ex); #if DEBUG Alert("保存失败!可能的原因:\n" + ex.Message); #else Alert("保存失败!"); #endif } } protected void ButtonDelete_Click(object sender, EventArgs e) { try { //删除数据 ButtonDelete.Enabled = !ENDACCOUNT1.Delete(); //刷新弹出页列表 RefreshOpenerGridPage(RefreshGridPageType.Delete); //提示信息 Alert("删除成功!", 3); ClosePopDialog(); } catch (Exception ex) { //回滚事务 Transaction.Rollback(); //记录日志 ErrorLogHelper.Write(ex); #if DEBUG Alert("删除失败!可能的原因:\n" + ex.Message); #else Alert("删除失败!"); #endif } } } }