SGGL_SHJ/SGGL/FineUIPro.Web/HSSE/Hazard/ConstructionRiskControlChec...

202 lines
7.3 KiB
C#

using BLL;
using Org.BouncyCastle.Crypto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace FineUIPro.Web.HSSE.Hazard
{
public partial class ConstructionRiskControlCheck : PageBase
{
#region
/// <summary>
/// 项目主键
/// </summary>
public string ConstructionRiskCheckId
{
get
{
return (string)ViewState["ConstructionRiskCheckId"];
}
set
{
ViewState["ConstructionRiskCheckId"] = value;
}
}
public string ConstructionRiskId
{
get
{
return (string)ViewState["ConstructionRiskId"];
}
set
{
ViewState["ConstructionRiskId"] = value;
}
}
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string ConstructionRiskCheckId = Request["ConstructionRiskCheckId"];
if (!string.IsNullOrEmpty(ConstructionRiskCheckId))
{
this.ConstructionRiskCheckId = ConstructionRiskCheckId;
}
this.ConstructionRiskId = Request["ConstructionRiskId"];
var constructionRiskCheck = Funs.DB.HSSE_ConstructionRiskCheck.FirstOrDefault(x=>x.ConstructionRiskCheckId == this.ConstructionRiskCheckId);
if (constructionRiskCheck != null)
{
this.ConstructionRiskId = constructionRiskCheck.ConstructionRiskId;
if (constructionRiskCheck.CheckDate != null)
{
this.txtCheckDate.Text = string.Format("{0:yyyy-MM-dd}", constructionRiskCheck.CheckDate);
}
if (!string.IsNullOrEmpty(constructionRiskCheck.CheckResult))
{
rbCheckResult.SelectedValue = constructionRiskCheck.CheckResult;
}
if (this.rbCheckResult.SelectedValue == "符合")
{
this.rbRectification.Hidden = true;
}
else
{
this.rbRectification.Hidden = false;
}
if (!string.IsNullOrEmpty(constructionRiskCheck.Rectification))
{
rbRectification.SelectedValue = constructionRiskCheck.Rectification;
}
}
else
{
this.txtCheckDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
}
}
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.hdId.Text))
{
Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning);
return;
}
if (this.rbRectification.Hidden == false && string.IsNullOrEmpty(this.rbRectification.SelectedValue))
{
Alert.ShowInTop("请选择整改情况!", MessageBoxIcon.Warning);
return;
}
if (this.txtRectification.Hidden == false && string.IsNullOrEmpty(this.txtRectification.Text.Trim()))
{
Alert.ShowInTop("请输入整改情况!", MessageBoxIcon.Warning);
return;
}
this.SaveData(BLL.Const.BtnSave);
}
#endregion
/// <summary>
/// 保存数据
/// </summary>
/// <param name="type"></param>
private void SaveData(string type)
{
Model.HSSE_ConstructionRiskCheck check = new Model.HSSE_ConstructionRiskCheck();
check.ConstructionRiskId = this.ConstructionRiskId;
check.CheckDate = Funs.GetNewDateTimeOrNow(this.txtCheckDate.Text.Trim());
check.CheckResult = rbCheckResult.SelectedValue;
check.CheckMan = this.CurrUser.PersonId;
string str = string.Empty;
if (this.rbCheckResult.SelectedValue == "不符合")
{
if (this.rbRectification.Hidden == false)
{
check.Rectification = rbRectification.SelectedValue;
str = rbRectification.SelectedValue;
}
else
{
check.Rectification = txtRectification.Text.Trim();
}
}
if (!string.IsNullOrEmpty(this.ConstructionRiskCheckId))
{
check.ConstructionRiskCheckId = this.ConstructionRiskCheckId;
BLL.ConstructionRiskCheckService.UpdateConstructionRiskCheck(check);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
else
{
check.ConstructionRiskCheckId = this.hdId.Text;
BLL.ConstructionRiskCheckService.AddConstructionRiskCheck(check);
str += "|" + check.ConstructionRiskCheckId;
PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(str) + ActiveWindow.GetHidePostBackReference());
}
}
protected void rdCheckResult_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void rbCheckResult_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.rbCheckResult.SelectedValue == "符合")
{
this.rbRectification.Hidden = true;
this.txtRectification.Hidden = true;
}
else
{
var projectUnit = BLL.ProjectUnitService.GetProjectUnitByUnitIdProjectId(this.CurrUser.LoginProjectId,this.CurrUser.UnitId);
if (projectUnit != null && projectUnit.UnitType == BLL.Const.ProjectUnitType_2)
{
this.txtRectification.Hidden = false;
}
else
{
this.rbRectification.Hidden = false;
}
}
}
#region
/// <summary>
/// 上传附件资源
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAttachUrl_Click(object sender, EventArgs e)
{
string edit = "0";
if (string.IsNullOrEmpty(this.hdId.Text))
{
this.hdId.Text = SQLHelper.GetNewID();
}
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/ConstructionRiskControlCheck&menuId={1}&edit={2}", this.hdId.Text, BLL.Const.ConstructionRiskMenuId, edit)));
}
#endregion
}
}