Files
xinjiang/SGGL/FineUIPro.Web/Check/HSE/CheckProblemEdit.aspx.cs
T

387 lines
16 KiB
C#
Raw Normal View History

2026-06-04 10:14:15 +08:00
using BLL;
using Model;
using System;
namespace FineUIPro.Web.Check.HSE
{
public partial class CheckProblemEdit : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
public string CheckId
{
get
{
return (string)ViewState["CheckId"];
}
set
{
ViewState["CheckId"] = value;
}
}
#endregion
/// <summary>
/// 图片是否可以编辑 -1查看 0编辑
/// </summary>
public int QuestionImg
{
get
{
return Convert.ToInt32(ViewState["QuestionImg"]);
}
set
{
ViewState["QuestionImg"] = value;
}
}
/// <summary>
/// 页面初始化加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
CheckId = Request.Params["CheckId"];
this.InitDropDownList();
var model = CheckProblemSafetyService.GetCheckProblemById(this.CheckId);
if (model != null)
{
this.drpUnit.SelectedValue = model.UnitId;
BLL.ProjectService.InitProjectDropDownList(this.drpProject, model.UnitId, true);
if (!string.IsNullOrWhiteSpace(model.ProjectId))
{
this.drpProject.SelectedValue = model.ProjectId;
}
else if (!string.IsNullOrWhiteSpace(model.ProjectName))
{
this.drpProject.Text = model.ProjectName;
}
this.drpClassify.SelectedValue = model.ClassifyId;
BLL.SafetyProblemClassifyItemService.InitClassifyItemDownList(this.drpClassifyItem, model.ClassifyId, true);
if (!string.IsNullOrWhiteSpace(model.ClassifyItemId))
{
this.drpClassifyItem.SelectedValue = model.ClassifyItemId;
}
this.drpNature.SelectedValue = model.NatureId;
BLL.SafetyProblemNatureItemService.InitNatureItemDownList(this.drpNatureItem, model.NatureId, true);
if (!string.IsNullOrWhiteSpace(model.NatureItemId))
{
this.drpNatureItem.SelectedValue = model.NatureItemId;
}
this.txtAddress.Text = model.Address;
this.rblUnitType.SelectedValue = model.UnitType;
this.txtAssemblyName.Text = model.AssemblyName;
this.txtDescription.Text = model.Description;
this.txtRemark.Text = model.Remark;
this.txtCheckTeamUser.Text = model.CheckTeamUser;
//if (!string.IsNullOrWhiteSpace(model.CheckUserId))
//{
// this.drpCheckUser.SelectedValue = model.CheckUserId;
//}
if (!string.IsNullOrWhiteSpace(model.RectificationUserId))
{
this.drpRectificationUser.SelectedValue = model.RectificationUserId;
}
if (!string.IsNullOrWhiteSpace(model.PMUserId))
{
this.drpPMUser.SelectedValue = model.PMUserId;
}
this.txtCompileManName.Text = model.CompileManName;
if (model.CheckDate != null)
{
this.txtCheckDate.Text = string.Format("{0:yyyy-MM-dd}", model.CheckDate);
}
if (model.LimitDate != null)
{
this.txtLimitDate.Text = string.Format("{0:yyyy-MM-dd}", model.LimitDate);
}
if (model.CloseTime != null)
{
this.txtCloseTime.Text = string.Format("{0:yyyy-MM-dd}", model.CloseTime);
}
if (model.CompileDate != null)
{
this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", model.CompileDate);
}
}
else
{
this.txtCompileManName.Text = this.CurrUser.UserName;
this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
}
}
}
#region
/// <summary>
/// 初始化下拉框
/// </summary>
private void InitDropDownList()
{
//受检单位
UnitService.InitBranchUnitDropDownList(this.drpUnit, false);
//受检项目
ProjectService.InitProjectDropDownList(this.drpProject, true);
//问题分类
SafetyProblemClassifyService.InitClassifyDropDownList(this.drpClassify, false);
//问题性质
SafetyProblemNatureService.InitNatureDropDownList(this.drpNature, false);
}
/// <summary>
/// 受检单位下拉触发事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpUnit_SelectedIndexChanged(object sender, EventArgs e)
{
//this.drpProject.Items.Clear();
////受检项目
//BLL.ProjectService.InitProjectDropDownList(this.drpProject, this.drpUnit.SelectedValue, true);
this.drpRectificationUser.Items.Clear();
BLL.UserService.InitUserUnitIdDropDownList(this.drpRectificationUser, this.drpUnit.SelectedValue, true);
this.drpPMUser.Items.Clear();
BLL.UserService.InitUserUnitIdDropDownList(this.drpPMUser, this.drpUnit.SelectedValue, true);
}
/// <summary>
/// 受检项目下拉触发事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpProject_SelectedIndexChanged(object sender, EventArgs e)
{
string proId = this.drpProject.SelectedValue;
if (!string.IsNullOrWhiteSpace(proId) && proId != Const._Null)
{
var pro = BLL.ProjectService.GetProjectByProjectId(proId);
if (pro != null)
{
this.txtAddress.Text = pro.ProjectAddress;
this.drpPMUser.Items.Clear();
BLL.UserService.InitUserDropDownList(this.drpPMUser, proId, true);
}
}
}
/// <summary>
/// 问题分类下拉触发事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpClassify_SelectedIndexChanged(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(this.drpClassify.SelectedValue))
{
this.drpClassifyItem.Items.Clear();
BLL.SafetyProblemClassifyItemService.InitClassifyItemDownList(this.drpClassifyItem, this.drpClassify.SelectedValue, true);
}
}
/// <summary>
/// 问题性质下拉触发事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpNature_SelectedIndexChanged(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(this.drpNature.SelectedValue))
{
this.drpNatureItem.Items.Clear();
BLL.SafetyProblemNatureItemService.InitNatureItemDownList(this.drpNatureItem, this.drpNature.SelectedValue, true);
}
}
#endregion
#region
/// <summary>
/// 上传附件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAttach_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/CheckProblemSafety&menuId={1}", this.CheckId, BLL.Const.SafetyCheckProblemMenuId)));
}
#endregion
//protected void imgBtnFile_Click(object sender, EventArgs e)
//{
// PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type={0}&toKeyId={1}&path=FileUpload/CheckProblemSafety&menuId={2}", QuestionImg, this.hdCheckControlCode.Text, BLL.Const.SafetyCheckProblemMenuId)));
//}
/// <summary>
/// 保存
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
//if (this.drpUnit.SelectedValue == BLL.Const._Null)
//{
// Alert.ShowInTop("请选择受检单位!", MessageBoxIcon.Warning);
// return;
//}
//if (string.IsNullOrWhiteSpace(this.drpClassify.SelectedValue) || this.drpClassify.SelectedValue == BLL.Const._Null)
//{
// Alert.ShowInTop("请选择问题分类!", MessageBoxIcon.Warning);
// return;
//}
//if (string.IsNullOrWhiteSpace(this.drpNature.SelectedValue) || this.drpNature.SelectedValue == BLL.Const._Null)
//{
// Alert.ShowInTop("请选择问题性质!", MessageBoxIcon.Warning);
// return;
//}
//if (string.IsNullOrWhiteSpace(this.txtDescription.Text.Trim()))
//{
// Alert.ShowInTop("请填写问题描述!", MessageBoxIcon.Warning);
// return;
//}
//if (string.IsNullOrWhiteSpace(this.txtCheckTeamUser.Text.Trim()))
//{
// Alert.ShowInTop("请填写检查组/检查人!", MessageBoxIcon.Warning);
// return;
//}
//if (string.IsNullOrWhiteSpace(this.drpRectificationUser.SelectedValue) || this.drpRectificationUser.SelectedValue == BLL.Const._Null)
//{
// Alert.ShowInTop("请选择整改人!", MessageBoxIcon.Warning);
// return;
//}
//if (string.IsNullOrWhiteSpace(this.drpPMUser.SelectedValue) || this.drpPMUser.SelectedValue == BLL.Const._Null)
//{
// Alert.ShowInTop("请选择项目经理!", MessageBoxIcon.Warning);
// return;
//}
//if (string.IsNullOrWhiteSpace(this.txtCheckDate.Text.Trim()))
//{
// Alert.ShowInTop("请选择检查日期!", MessageBoxIcon.Warning);
// return;
//}
//if (string.IsNullOrWhiteSpace(this.txtLimitDate.Text.Trim()))
//{
// Alert.ShowInTop("请选择整改期限!", MessageBoxIcon.Warning);
// return;
//}
SaveData();
ShowNotify("保存成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
///// <summary>
///// 提交
///// </summary>
///// <param name="sender"></param>
///// <param name="e"></param>
//protected void btnSubmit_Click(object sender, EventArgs e)
//{
// if (BLL.CommonService.GetAllButtonPowerList(CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.SafetyCheckProblemMenuId, BLL.Const.BtnSubmit))
// {
// if (string.IsNullOrEmpty(Request.Params["Main"]))
// {
// PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
// }
// else
// {
// PageContext.RegisterStartupScript(String.Format("window.close();"));
// }
// }
// else
// {
// Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
// }
//}
/// <summary>
/// 保存数据
/// </summary>
protected void SaveData()
{
CheckProblem_Safety model = new CheckProblem_Safety();
model.UnitId = this.drpUnit.SelectedValue;
model.UnitName = this.drpUnit.SelectedText;
string proId = this.drpProject.SelectedValue;
if (!string.IsNullOrWhiteSpace(proId) && proId != Const._Null)
{
model.ProjectId = this.drpProject.SelectedValue;
model.ProjectName = this.drpProject.SelectedText;
}
//else
//{
// model.ProjectName = this.drpUnit.SelectedText;
//}
model.Address = this.txtAddress.Text.Trim();
model.Description = this.txtDescription.Text.Trim();
model.UnitType = this.rblUnitType.SelectedValue;
model.AssemblyName = this.txtAssemblyName.Text.Trim();
model.CheckTeamUser = this.txtCheckTeamUser.Text.Trim();
model.CheckDate = Funs.GetNewDateTimeOrNow(this.txtCheckDate.Text.Trim());
model.LimitDate = Funs.GetNewDateTime(this.txtLimitDate.Text.Trim());
if (!string.IsNullOrWhiteSpace(this.txtCloseTime.Text.Trim()))
{
model.CloseTime = Funs.GetNewDateTime(this.txtCloseTime.Text.Trim());
model.State = (int)CheckProblemSafetyService.StateInt.;
}
else
{
model.State = (int)CheckProblemSafetyService.StateInt.;
}
model.RectificationUserId = this.drpRectificationUser.SelectedValue;
model.RectificationUserName = this.drpRectificationUser.SelectedText;
model.PMUserId = this.drpPMUser.SelectedValue;
model.PMUserName = this.drpPMUser.SelectedText;
model.ClassifyId = this.drpClassify.SelectedValue;
string classifyItemId = this.drpClassifyItem.SelectedValue;
if (!string.IsNullOrWhiteSpace(classifyItemId) && classifyItemId != Const._Null)
{
model.ClassifyItemId = classifyItemId;
}
model.NatureId = this.drpNature.SelectedValue;
string natureItemId = this.drpNatureItem.SelectedValue;
if (!string.IsNullOrWhiteSpace(natureItemId) && natureItemId != Const._Null)
{
model.NatureItemId = natureItemId;
}
model.Remark = this.txtRemark.Text.Trim();
if (string.IsNullOrWhiteSpace(this.CheckId))
{
//新增
model.CheckId = SQLHelper.GetNewID(typeof(CheckProblem_Safety));
this.CheckId = model.CheckId;
model.CompileMan = this.CurrUser.UserId;
model.CompileManName = this.CurrUser.UserName;
model.CompileDate = DateTime.Now;
BLL.CheckProblemSafetyService.AddCheckProblem(model);
////增加一条编码记录
//BLL.CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(BLL.Const.SafetyCheckProblemMenuId, model.ProjectId, null, model.CheckId, model.CheckDate);
}
else
{
//更新
model.CheckId = this.CheckId;
BLL.CheckProblemSafetyService.UpdateCheckProblem(model);
}
}
protected void WindowAtt_Close(object sender, WindowCloseEventArgs e)
{
}
}
}