SGGL_JT/SUBQHSE/FineUIPro.Web/HSSE/Manager/DisasterRiskListItem.aspx.cs

163 lines
6.6 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.HSSE.Manager
{
public partial class DisasterRiskListItem : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
public string DisasterRiskListId
{
get
{
return (string)ViewState["DisasterRiskListId"];
}
set
{
ViewState["DisasterRiskListId"] = value;
}
}
/// <summary>
/// 项目主键
/// </summary>
public string ProjectId
{
get
{
return (string)ViewState["ProjectId"];
}
set
{
ViewState["ProjectId"] = value;
}
}
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.DisasterRiskListId = Request.Params["DisasterRiskListId"];
this.ProjectId = this.CurrUser.LoginProjectId;
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
DisasterRiskService.InitDisasterRiskDropDownList(this.drpDisasterRisk, false);
UserService.InitUserDropDownList(this.drpFillMan, this.ProjectId, true);
if (!string.IsNullOrEmpty(this.DisasterRiskListId))
{
var getD = DisasterRiskListService.GetDisasterRiskListById(this.DisasterRiskListId);
if (getD != null)
{
this.ProjectId = getD.ProjectId;
UserService.InitUserDropDownList(this.drpFillMan, this.ProjectId, true);
this.txtMonths.Text = string.Format("{0:yyyy-MM}", getD.Months);
this.txtProjectName.Text = ProjectService.GetProjectNameByProjectId(this.ProjectId);
this.txtAddress.Text = getD.Address;
this.drpDisasterRisk.SelectedValue = getD.DisasterRiskId;
this.txtContactInfo.Text = getD.ContactInfo;
this.txtEmergencyPlan.Text = getD.EmergencyPlan;
this.txtEmergencyDrill.Text = getD.EmergencyDrill;
this.txtRiskStatus.Text = getD.RiskStatus;
this.drpFillMan.SelectedValue = getD.FillManId;
this.txtFillingTime.Text = string.Format("{0:yyyy-MM-dd}", getD.FillingTime);
this.txtFillManContact.Text = getD.FillManContact;
}
}
else
{
this.drpFillMan.SelectedValue = this.CurrUser.UserId;
this.txtFillingTime.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
this.txtFillManContact.Text = this.CurrUser.Telephone;
var getP = ProjectService.GetProjectByProjectId(this.ProjectId);
if (getP != null)
{
this.txtProjectName.Text = getP.ProjectName;
this.txtContactInfo.Text = getP.Telephone;
}
}
}
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
this.SaveData();
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
}
/// <summary>
/// 保存数据
/// </summary>
/// <param name="type"></param>
private void SaveData()
{
Model.Manager_DisasterRiskList newDisasterRiskList = new Model.Manager_DisasterRiskList
{
ProjectId = this.ProjectId,
Months = Funs.GetNewDateTimeOrNow(this.txtMonths.Text),
Address = this.txtAddress.Text.Trim(),
ContactInfo = this.txtContactInfo.Text.Trim(),
EmergencyPlan = this.txtEmergencyPlan.Text.Trim(),
EmergencyDrill = this.txtEmergencyDrill.Text.Trim(),
RiskStatus = this.txtRiskStatus.Text.Trim(),
FillingTime=Funs.GetNewDateTimeOrNow(this.txtFillingTime.Text),
FillManContact=this.txtFillManContact.Text.Trim(),
};
if (!string.IsNullOrEmpty(this.drpDisasterRisk.SelectedValue))
{
newDisasterRiskList.DisasterRiskId = this.drpDisasterRisk.SelectedValue;
}
if (!string.IsNullOrEmpty(this.drpFillMan.SelectedValue) && this.drpFillMan.SelectedValue != Const._Null)
{
newDisasterRiskList.FillManId = this.drpFillMan.SelectedValue;
}
if (!string.IsNullOrEmpty(this.DisasterRiskListId))
{
newDisasterRiskList.DisasterRiskListId = this.DisasterRiskListId;
BLL.DisasterRiskListService.UpdateDisasterRiskList(newDisasterRiskList);
BLL.LogService.AddSys_Log(this.CurrUser, this.txtMonths.Text, newDisasterRiskList.DisasterRiskListId, BLL.Const.ProjectDisasterRiskListMenuId, BLL.Const.BtnModify);
}
else
{
this.DisasterRiskListId = BLL.DisasterRiskListService.AddDisasterRiskList(newDisasterRiskList);
BLL.LogService.AddSys_Log(this.CurrUser, this.txtMonths.Text, newDisasterRiskList.DisasterRiskListId, BLL.Const.ProjectDisasterRiskListMenuId, 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.DisasterRiskListId))
{
this.SaveData();
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/DisasterRiskListAttachUrl&menuId={1}", DisasterRiskListId, BLL.Const.ProjectDisasterRiskListMenuId)));
}
#endregion
}
}