SGGL_JT/SUBQHSE/FineUIPro.Web/HSSE/SafetyActivities/MonthlyRatingEdit.aspx.cs

185 lines
6.7 KiB
C#

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
/// <summary>
/// 主键
/// </summary>
public string MonthlyRatingId
{
get
{
return (string)ViewState["MonthlyRatingId"];
}
set
{
ViewState["MonthlyRatingId"] = value;
}
}
/// <summary>
/// 项目主键
/// </summary>
public string ProjectId
{
get
{
return (string)ViewState["ProjectId"];
}
set
{
ViewState["ProjectId"] = value;
}
}
/// <summary>
/// 主键
/// </summary>
public string UnitId
{
get
{
return (string)ViewState["UnitId"];
}
set
{
ViewState["UnitId"] = value;
}
}
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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
/// <summary>
/// 初始化下拉框
/// </summary>
private void InitDropDownList()
{
//活动类型
ActivityTypeService.InitActivityTypeDropDownList(this.drpActivityType, true);
}
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
this.SaveData(BLL.Const.BtnSave);
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
}
/// <summary>
/// 保存数据
/// </summary>
/// <param name="type"></param>
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
/// <summary>
/// 上传附件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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
}
}