using BLL; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace FineUIPro.Web.HSSE.SafetyActivities { public partial class ThemeActivitiesEdit : PageBase { #region 定义项 /// /// 主键 /// public string ThemeActivitiesId { get { return (string)ViewState["ThemeActivitiesId"]; } set { ViewState["ThemeActivitiesId"] = value; } } /// /// 项目主键 /// public string ProjectId { get { return (string)ViewState["ProjectId"]; } set { ViewState["ProjectId"] = value; } } /// /// 主键 /// public string UnitId { get { return (string)ViewState["UnitId"]; } set { ViewState["UnitId"] = value; } } #endregion #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.ProjectId = this.CurrUser.LoginProjectId; this.UnitId = Request.Params["UnitId"]; this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.InitDropDownList(); this.ThemeActivitiesId = Request.Params["ThemeActivitiesId"]; if (!string.IsNullOrEmpty(this.ThemeActivitiesId)) { var getData = BLL.ThemeActivitiesService.GetThemeActivitiesById(this.ThemeActivitiesId); if (getData != null) { this.ProjectId = getData.ProjectId; this.UnitId = getData.UnitId; if (this.ProjectId != this.CurrUser.LoginProjectId) { this.InitDropDownList(); } if (!string.IsNullOrEmpty(getData.ActivityTypeId)) { this.drpActivityType.SelectedValue = getData.ActivityTypeId; } this.txtTitle.Text = getData.Title; this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd HH:mm}", getData.CompileDate); this.txtEndTime.Text = string.Format("{0:yyyy-MM-dd HH:mm}", getData.EndTime); if (!string.IsNullOrEmpty(getData.CompileMan)) { this.drpCompileMan.SelectedValue = getData.CompileMan; } this.txtRemark.Text = getData.Remark; this.txtSeeFile.Text = HttpUtility.HtmlDecode(getData.SeeFile); } } else { this.drpCompileMan.SelectedValue = this.CurrUser.UserId; this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd HH:mm}", DateTime.Now); var codeTemplateRule = BLL.ProjectData_CodeTemplateRuleService.GetProjectData_CodeTemplateRuleByMenuIdProjectId(BLL.Const.ProjectThemeActivitiesMenuId, this.ProjectId); if (codeTemplateRule != null) { this.txtSeeFile.Text = HttpUtility.HtmlDecode(codeTemplateRule.Template); } this.txtTitle.Text = this.SimpleForm1.Title; } } } #endregion /// /// 初始化下拉框 /// private void InitDropDownList() { //活动类型 ActivityTypeService.InitActivityTypeDropDownList(this.drpActivityType, true); UserService.InitUserProjectIdUnitIdDropDownList(this.drpCompileMan, this.ProjectId, this.UnitId, true); this.drpCompileMan.SelectedValue = this.CurrUser.UserId; } #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { this.SaveData(BLL.Const.BtnSave); PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference()); } /// /// 保存数据 /// /// private void SaveData(string type) { Model.SafetyActivities_ThemeActivities newThemeActivities = new Model.SafetyActivities_ThemeActivities { ProjectId = this.ProjectId, UnitId = this.UnitId, Title = this.txtTitle.Text.Trim(), CompileDate = Funs.GetNewDateTime(this.txtCompileDate.Text.Trim()), EndTime = Funs.GetNewDateTime(this.txtEndTime.Text.Trim()), }; if (this.drpActivityType.SelectedValue != BLL.Const._Null) { newThemeActivities.ActivityTypeId = this.drpActivityType.SelectedValue; } if (this.drpCompileMan.SelectedValue != BLL.Const._Null) { newThemeActivities.CompileMan = this.drpCompileMan.SelectedValue; } newThemeActivities.Remark = this.txtRemark.Text.Trim(); newThemeActivities.SeeFile = HttpUtility.HtmlEncode(this.txtSeeFile.Text); if (!string.IsNullOrEmpty(this.ThemeActivitiesId)) { newThemeActivities.ThemeActivitiesId = this.ThemeActivitiesId; BLL.ThemeActivitiesService.UpdateThemeActivities(newThemeActivities); BLL.LogService.AddSys_Log(this.CurrUser, newThemeActivities.Title, newThemeActivities.ThemeActivitiesId, BLL.Const.ProjectThemeActivitiesMenuId, BLL.Const.BtnModify); } else { this.ThemeActivitiesId = SQLHelper.GetNewID(typeof(Model.SafetyActivities_ThemeActivities)); newThemeActivities.ThemeActivitiesId = this.ThemeActivitiesId; BLL.ThemeActivitiesService.AddThemeActivities(newThemeActivities); BLL.LogService.AddSys_Log(this.CurrUser, newThemeActivities.Title, newThemeActivities.ThemeActivitiesId, BLL.Const.ProjectThemeActivitiesMenuId, BLL.Const.BtnAdd); } } #endregion #region 附件上传 /// /// 上传附件 /// /// /// protected void btnAttachUrl_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.ThemeActivitiesId)) { SaveData(BLL.Const.BtnSave); } PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/ThemeActivitiesAttachUrl&menuId={1}", ThemeActivitiesId, BLL.Const.ProjectThemeActivitiesMenuId))); } #endregion } }