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 MonthlyRatingEdit : PageBase { #region 定义项 /// /// 主键 /// public string MonthlyRatingId { get { return (string)ViewState["MonthlyRatingId"]; } set { ViewState["MonthlyRatingId"] = 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.MonthlyRatingId = Request.Params["MonthlyRatingId"]; if (!string.IsNullOrEmpty(this.MonthlyRatingId)) { var getData = BLL.MonthlyRatingService.GetMonthlyRatingById(this.MonthlyRatingId); if (getData != null) { this.ProjectId = getData.ProjectId; this.UnitId = getData.UnitId; this.txtTitle.Text = getData.Title; if (!string.IsNullOrEmpty(getData.ActivityTypeId)) { this.drpActivityType.SelectedValue = getData.ActivityTypeId; } this.txtActivitiesDate.Text = string.Format("{0:yyyy-MM-dd HH:mm}", getData.ActivitiesDate); this.txtEndTime.Text = string.Format("{0:yyyy-MM-dd HH:mm}", getData.EndTime); this.txtPersonCount.Text = getData.PersonCount.ToString(); //this.txtRemark.Text = getData.Remark; this.txtSeeFile.Text = HttpUtility.HtmlDecode(getData.SeeFile); } } else { this.txtActivitiesDate.Text = string.Format("{0:yyyy-MM-dd HH:mm}", DateTime.Now); var codeTemplateRule = BLL.ProjectData_CodeTemplateRuleService.GetProjectData_CodeTemplateRuleByMenuIdProjectId(BLL.Const.ProjectMonthlyRatingMenuId, 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); } #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_MonthlyRating newMonthlyRating = new Model.SafetyActivities_MonthlyRating { ProjectId = this.ProjectId, UnitId = this.UnitId, Title = this.txtTitle.Text.Trim(), CompileDate = DateTime.Now, ActivitiesDate = Funs.GetNewDateTime(this.txtActivitiesDate.Text), EndTime = Funs.GetNewDateTime(this.txtEndTime.Text), PersonCount = Funs.GetNewInt(this.txtPersonCount.Text), }; if (this.drpActivityType.SelectedValue != BLL.Const._Null) { newMonthlyRating.ActivityTypeId = this.drpActivityType.SelectedValue; } //newMonthlyRating.Remark = this.txtRemark.Text.Trim(); newMonthlyRating.SeeFile = HttpUtility.HtmlEncode(this.txtSeeFile.Text); if (!string.IsNullOrEmpty(this.MonthlyRatingId)) { newMonthlyRating.MonthlyRatingId = this.MonthlyRatingId; BLL.MonthlyRatingService.UpdateMonthlyRating(newMonthlyRating); BLL.LogService.AddSys_Log(this.CurrUser, newMonthlyRating.Title, newMonthlyRating.MonthlyRatingId, BLL.Const.ProjectMonthlyRatingMenuId, BLL.Const.BtnModify); } else { this.MonthlyRatingId = SQLHelper.GetNewID(); newMonthlyRating.MonthlyRatingId = this.MonthlyRatingId; BLL.MonthlyRatingService.AddMonthlyRating(newMonthlyRating); BLL.LogService.AddSys_Log(this.CurrUser, newMonthlyRating.Title, newMonthlyRating.MonthlyRatingId, BLL.Const.ProjectMonthlyRatingMenuId, BLL.Const.BtnAdd); } } #endregion #region 附件上传 /// /// 上传附件 /// /// /// protected void btnAttachUrl_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.MonthlyRatingId)) { SaveData(BLL.Const.BtnSave); } PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/MonthlyRatingAttachUrl&menuId={1}", MonthlyRatingId, BLL.Const.ProjectMonthlyRatingMenuId))); } #endregion } }