122 lines
		
	
	
		
			5.0 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			122 lines
		
	
	
		
			5.0 KiB
		
	
	
	
		
			C#
		
	
	
	
|  | using System; | |||
|  | using System.Collections.Generic; | |||
|  | using System.Linq; | |||
|  | using System.Web; | |||
|  | using System.Web.UI; | |||
|  | using System.Web.UI.WebControls; | |||
|  | using BLL; | |||
|  | 
 | |||
|  | namespace FineUIPro.Web.Party | |||
|  | { | |||
|  |     public partial class PartyHistoryStudyEdit : PageBase | |||
|  |     { | |||
|  |         #region 加载 | |||
|  |         /// <summary> | |||
|  |         /// 页面加载 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void Page_Load(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (!IsPostBack) | |||
|  |             { | |||
|  |                 string id = Request.Params["partyHistoryStudyId"]; | |||
|  |                 string year = DateTime.Now.Year.ToString(); | |||
|  |                 if (!string.IsNullOrEmpty(Request.Params["Year"])) | |||
|  |                 { | |||
|  |                     year = Request.Params["Year"]; | |||
|  |                 } | |||
|  |                 if (!string.IsNullOrEmpty(Request.Params["type"])) | |||
|  |                 { | |||
|  |                     this.btnSave.Hidden = true; | |||
|  |                 } | |||
|  |                 if (!string.IsNullOrEmpty(id)) | |||
|  |                 { | |||
|  |                     Model.Party_PartyHistoryStudy partyHistoryStudy = BLL.PartyHistoryStudyService.GetPartyHistoryStudyById(id); | |||
|  |                     if (partyHistoryStudy != null) | |||
|  |                     { | |||
|  |                         this.hdId.Text = id; | |||
|  |                         if (partyHistoryStudy.Year != null) | |||
|  |                         { | |||
|  |                             this.txtYear.Text = partyHistoryStudy.Year.ToString(); | |||
|  |                         } | |||
|  |                         if (partyHistoryStudy.StudyDate != null) | |||
|  |                         { | |||
|  |                             this.txtStudyDate.Text = string.Format("{0:yyyy-MM-dd}", partyHistoryStudy.StudyDate); | |||
|  |                         } | |||
|  |                         this.txtSpeaker.Text = partyHistoryStudy.Speaker; | |||
|  |                         this.txtTheme.Text = partyHistoryStudy.Theme; | |||
|  |                     } | |||
|  |                 } | |||
|  |                 else | |||
|  |                 { | |||
|  |                     this.txtYear.Text = year; | |||
|  |                     this.txtStudyDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); | |||
|  |                 } | |||
|  |             } | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #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.Party_PartyHistoryStudy)); | |||
|  |             } | |||
|  |             if (!string.IsNullOrEmpty(Request.Params["type"])) | |||
|  |             { | |||
|  |                 PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/Party/PartyHistoryStudy&menuId={1}", this.hdId.Text, BLL.Const.PartyHistoryStudyMenuId))); | |||
|  |             } | |||
|  |             else | |||
|  |             { | |||
|  |                 PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/Party/PartyHistoryStudy&menuId={1}", this.hdId.Text, BLL.Const.PartyHistoryStudyMenuId))); | |||
|  |             } | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 保存 | |||
|  |         /// <summary> | |||
|  |         /// 保存按钮 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void btnSave_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             string id = Request.Params["partyHistoryStudyId"]; | |||
|  |             Model.Party_PartyHistoryStudy newPartyHistoryStudy = new Model.Party_PartyHistoryStudy(); | |||
|  |             newPartyHistoryStudy.Year = Funs.GetNewIntOrZero(this.txtYear.Text.Trim()); | |||
|  |             newPartyHistoryStudy.StudyDate = Funs.GetNewDateTimeOrNow(this.txtStudyDate.Text.Trim()); | |||
|  |             newPartyHistoryStudy.Speaker = this.txtSpeaker.Text.Trim(); | |||
|  |             newPartyHistoryStudy.Theme = this.txtTheme.Text.Trim(); | |||
|  |             if (!string.IsNullOrEmpty(id)) | |||
|  |             { | |||
|  |                 newPartyHistoryStudy.PartyHistoryStudyId = id; | |||
|  |                 BLL.PartyHistoryStudyService.UpdatePartyHistoryStudy(newPartyHistoryStudy); | |||
|  |             } | |||
|  |             else | |||
|  |             { | |||
|  |                 if (!string.IsNullOrEmpty(this.hdId.Text)) | |||
|  |                 { | |||
|  |                     newPartyHistoryStudy.PartyHistoryStudyId = this.hdId.Text.Trim(); | |||
|  |                 } | |||
|  |                 else | |||
|  |                 { | |||
|  |                     newPartyHistoryStudy.PartyHistoryStudyId = SQLHelper.GetNewID(typeof(Model.Party_PartyHistoryStudy)); | |||
|  |                     this.hdId.Text = newPartyHistoryStudy.PartyHistoryStudyId; | |||
|  |                 } | |||
|  |                 newPartyHistoryStudy.CompileMan = this.CurrUser.UserId; | |||
|  |                 newPartyHistoryStudy.CompileDate = DateTime.Now; | |||
|  |                 BLL.PartyHistoryStudyService.AddPartyHistoryStudy(newPartyHistoryStudy); | |||
|  |             } | |||
|  |             ShowNotify("保存成功!", MessageBoxIcon.Success); | |||
|  |             PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); | |||
|  |         } | |||
|  |         #endregion | |||
|  |     } | |||
|  | } |