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

199 lines
7.2 KiB
C#
Raw Normal View History

2024-05-16 09:15:08 +08:00
using BLL;
using System;
using System.Linq;
namespace FineUIPro.Web.HSSE.Hazard
{
public partial class ConstructionRiskControlCheck : PageBase
{
#region
2024-05-16 09:15:08 +08:00
/// <summary>
/// 项目主键
/// </summary>
2024-09-24 11:28:27 +08:00
public string ConstructionRiskCheckId
2024-05-16 09:15:08 +08:00
{
get
{
2024-09-24 11:28:27 +08:00
return (string)ViewState["ConstructionRiskCheckId"];
2024-05-16 09:15:08 +08:00
}
set
{
2024-09-24 11:28:27 +08:00
ViewState["ConstructionRiskCheckId"] = value;
2024-05-16 09:15:08 +08:00
}
}
public string ConstructionRiskId
{
get
{
return (string)ViewState["ConstructionRiskId"];
}
set
{
ViewState["ConstructionRiskId"] = value;
}
}
2024-05-16 09:15:08 +08:00
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
2024-09-24 11:28:27 +08:00
string ConstructionRiskCheckId = Request["ConstructionRiskCheckId"];
if (!string.IsNullOrEmpty(ConstructionRiskCheckId))
2024-05-16 09:15:08 +08:00
{
this.ConstructionRiskCheckId = ConstructionRiskCheckId;
2024-05-16 09:15:08 +08:00
}
2024-09-24 11:28:27 +08:00
this.ConstructionRiskId = Request["ConstructionRiskId"];
var constructionRiskCheck = Funs.DB.HSSE_ConstructionRiskCheck.FirstOrDefault(x => x.ConstructionRiskCheckId == this.ConstructionRiskCheckId);
2024-09-24 11:28:27 +08:00
if (constructionRiskCheck != null)
{
this.ConstructionRiskId = constructionRiskCheck.ConstructionRiskId;
if (constructionRiskCheck.CheckDate != null)
2024-05-16 09:15:08 +08:00
{
2024-09-24 11:28:27 +08:00
this.txtCheckDate.Text = string.Format("{0:yyyy-MM-dd}", constructionRiskCheck.CheckDate);
2024-05-16 09:15:08 +08:00
}
2024-09-24 11:28:27 +08:00
if (!string.IsNullOrEmpty(constructionRiskCheck.CheckResult))
2024-05-16 09:15:08 +08:00
{
2024-09-24 11:28:27 +08:00
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;
2024-05-16 09:15:08 +08:00
}
2024-06-06 15:53:34 +08:00
}
else
{
2024-09-24 11:28:27 +08:00
this.txtCheckDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
2024-06-06 15:53:34 +08:00
}
2024-05-16 09:15:08 +08:00
}
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
2024-11-27 15:21:14 +08:00
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;
}
2024-05-16 09:15:08 +08:00
this.SaveData(BLL.Const.BtnSave);
}
#endregion
/// <summary>
/// 保存数据
/// </summary>
/// <param name="type"></param>
private void SaveData(string type)
{
2024-09-24 11:28:27 +08:00
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;
2024-06-06 15:53:34 +08:00
string str = string.Empty;
2024-09-24 11:28:27 +08:00
if (this.rbCheckResult.SelectedValue == "不符合")
2024-05-16 09:15:08 +08:00
{
2024-11-27 15:21:14 +08:00
if (this.rbRectification.Hidden == false)
{
check.Rectification = rbRectification.SelectedValue;
str = rbRectification.SelectedValue;
}
else
{
check.Rectification = txtRectification.Text.Trim();
}
2024-09-24 11:28:27 +08:00
}
if (!string.IsNullOrEmpty(this.ConstructionRiskCheckId))
{
check.ConstructionRiskCheckId = this.ConstructionRiskCheckId;
BLL.ConstructionRiskCheckService.UpdateConstructionRiskCheck(check);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
else
{
2024-11-27 15:21:14 +08:00
check.ConstructionRiskCheckId = this.hdId.Text;
2024-09-24 11:28:27 +08:00
BLL.ConstructionRiskCheckService.AddConstructionRiskCheck(check);
str += "|" + check.ConstructionRiskCheckId;
PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(str) + ActiveWindow.GetHidePostBackReference());
2024-05-16 09:15:08 +08:00
}
}
protected void rdCheckResult_SelectedIndexChanged(object sender, EventArgs e)
{
}
2024-06-06 15:53:34 +08:00
protected void rbCheckResult_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.rbCheckResult.SelectedValue == "符合")
{
this.rbRectification.Hidden = true;
2024-11-27 15:21:14 +08:00
this.txtRectification.Hidden = true;
2024-06-06 15:53:34 +08:00
}
else
{
var projectUnit = BLL.ProjectUnitService.GetProjectUnitByUnitIdProjectId(this.CurrUser.LoginProjectId, this.CurrUser.UnitId);
2024-11-27 15:21:14 +08:00
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();
2024-06-06 15:53:34 +08:00
}
2024-11-27 15:21:14 +08:00
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)));
2024-06-06 15:53:34 +08:00
}
2024-11-27 15:21:14 +08:00
#endregion
2024-05-16 09:15:08 +08:00
}
}