92 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			92 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			C#
		
	
	
	
|  | using BLL; | |||
|  | using System; | |||
|  | 
 | |||
|  | namespace FineUIPro.Web.CQMS.DataBase | |||
|  | { | |||
|  |     public partial class PhotoEdit : PageBase | |||
|  |     { | |||
|  |         protected void Page_Load(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (!IsPostBack) | |||
|  |             { | |||
|  |                 //string dataTypeProjectId = Request.Params["dataTypeProjectId"]; | |||
|  |                 string photoId = Request.Params["photoId"]; | |||
|  |                 if (!string.IsNullOrEmpty(photoId)) | |||
|  |                 { | |||
|  |                     Model.DataBase_Photo photo = BLL.PhotoService.GetPhotoById(photoId); | |||
|  |                     if (photo!=null) | |||
|  |                     { | |||
|  |                         this.txtDate.Text = photo.Date.HasValue ? string.Format("{0:yyyy-MM-dd}", photo.Date) : ""; | |||
|  |                         this.txtPlace.Text = photo.Place; | |||
|  |                         this.txtPerson.Text = photo.Person; | |||
|  |                         this.txtSubject.Text = photo.Subject; | |||
|  |                         this.txtBackground.Text = photo.Background; | |||
|  |                         this.txtPhotographer.Text = photo.Photographer; | |||
|  |                     } | |||
|  |                 } | |||
|  |                 else | |||
|  |                 { | |||
|  |                     this.txtDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);   | |||
|  |                 } | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         #region 附件上传 | |||
|  |         /// <summary> | |||
|  |         /// 附件上传 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void btnAttach_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (string.IsNullOrEmpty(this.hdId.Text))   //新增记录 | |||
|  |             { | |||
|  |                 this.hdId.Text = SQLHelper.GetNewID(typeof(Model.DataBase_Photo)); | |||
|  |             } | |||
|  |             PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/CommonUpLoadFile&menuId={1}", this.hdId.Text, BLL.Const.DataBaseProjectMenuId))); | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 保存 | |||
|  |         /// <summary> | |||
|  |         /// 保存按钮 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void btnSave_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             string dataTypeProjectId = Request.Params["dataTypeProjectId"]; | |||
|  |             string photoId = Request.Params["photoId"]; | |||
|  |             Model.DataBase_Photo newPhoto = new Model.DataBase_Photo(); | |||
|  |             newPhoto.Date = Funs.GetNewDateTime(this.txtDate.Text.Trim()); | |||
|  |             newPhoto.Place = this.txtPlace.Text.Trim(); | |||
|  |             newPhoto.Person = this.txtPerson.Text.Trim(); | |||
|  |             newPhoto.Subject = this.txtSubject.Text.Trim(); | |||
|  |             newPhoto.Background = this.txtBackground.Text.Trim(); | |||
|  |             newPhoto.Photographer = this.txtPhotographer.Text.Trim(); | |||
|  |             if (!string.IsNullOrEmpty(photoId)) | |||
|  |             { | |||
|  |                 newPhoto.PhotoId = photoId; | |||
|  |                 BLL.PhotoService.UpdatePhoto(newPhoto); | |||
|  |             } | |||
|  |             else | |||
|  |             { | |||
|  |                 newPhoto.ProjectId = this.CurrUser.LoginProjectId; | |||
|  |                 newPhoto.PhotoType = dataTypeProjectId; | |||
|  |                 if (!string.IsNullOrEmpty(this.hdId.Text.Trim())) | |||
|  |                 { | |||
|  |                     newPhoto.PhotoId = this.hdId.Text.Trim(); | |||
|  |                 } | |||
|  |                 else | |||
|  |                 { | |||
|  |                     newPhoto.PhotoId = SQLHelper.GetNewID(typeof(Model.DataBase_Photo)); | |||
|  |                     this.hdId.Text = newPhoto.PhotoId; | |||
|  |                 } | |||
|  |                 BLL.PhotoService.AddPhoto(newPhoto); | |||
|  |             } | |||
|  |             ShowNotify("保存成功!", MessageBoxIcon.Success); | |||
|  |             PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); | |||
|  |         } | |||
|  |         #endregion | |||
|  |     } | |||
|  | } |