55944d732a
排除 CreateModel.bat(含明文sa密码与本地服务器名,未入库)
131 lines
4.9 KiB
C#
131 lines
4.9 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
|
||
namespace FineUIPro.Web.HSSE.HazardousMG
|
||
{
|
||
/// <summary>
|
||
/// 编辑安全防护验收页面
|
||
/// </summary>
|
||
public partial class SafetyAcceptanceEdit : PageBase
|
||
{
|
||
#region 定义项
|
||
/// <summary>
|
||
/// 主键
|
||
/// </summary>
|
||
private string AcceptanceId
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["AcceptanceId"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["AcceptanceId"] = value;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 加载
|
||
/// <summary>
|
||
/// 加载页面
|
||
/// </summary>
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
||
this.InitDropDownList();
|
||
this.AcceptanceId = Request.Params["AcceptanceId"];
|
||
if (!string.IsNullOrEmpty(this.AcceptanceId))
|
||
{
|
||
////编辑:回填数据
|
||
Model.HSSE_SafetyAcceptance info = BLL.SafetyAcceptanceService.GetById(this.AcceptanceId);
|
||
if (info != null)
|
||
{
|
||
this.ddlHazardProject.SelectedValue = info.HazardProjectId;
|
||
this.ddlAcceptanceResult.SelectedValue = info.AcceptanceResult;
|
||
this.txtRemark.Text = info.Remark;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 初始化危大、超危清单下拉
|
||
/// </summary>
|
||
private void InitDropDownList()
|
||
{
|
||
if (this.CurrUser == null || string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
|
||
{
|
||
return;
|
||
}
|
||
List<Model.HSSE_HazardProject> projects = BLL.HazardProjectService.GetList(this.CurrUser.LoginProjectId);
|
||
foreach (Model.HSSE_HazardProject p in projects)
|
||
{
|
||
this.ddlHazardProject.Items.Add(new FineUIPro.ListItem(p.ProjectName + "(" + p.ProjectCode + ")", p.HazardProjectId));
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 保存
|
||
/// <summary>
|
||
/// 保存按钮事件
|
||
/// </summary>
|
||
protected void btnSave_Click(object sender, EventArgs e)
|
||
{
|
||
if (this.CurrUser == null || string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
|
||
{
|
||
Alert.ShowInTop("请先选择项目!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
////新增时先生成主键,保证附件能挂到同一记录
|
||
if (string.IsNullOrEmpty(this.AcceptanceId))
|
||
{
|
||
this.AcceptanceId = Guid.NewGuid().ToString();
|
||
}
|
||
////校验附件是否已上传
|
||
Model.AttachFile attach = BLL.Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == this.AcceptanceId);
|
||
if (attach == null || string.IsNullOrEmpty(attach.AttachUrl))
|
||
{
|
||
Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
////根据所选清单回填工程名称
|
||
string hazardProjectName = string.Empty;
|
||
Model.HSSE_HazardProject project = BLL.HazardProjectService.GetById(this.ddlHazardProject.SelectedValue);
|
||
if (project != null)
|
||
{
|
||
hazardProjectName = project.ProjectName;
|
||
}
|
||
Model.HSSE_SafetyAcceptance info = new Model.HSSE_SafetyAcceptance
|
||
{
|
||
AcceptanceId = this.AcceptanceId,
|
||
ProjectId = this.CurrUser.LoginProjectId,
|
||
HazardProjectId = this.ddlHazardProject.SelectedValue,
|
||
HazardProjectName = hazardProjectName,
|
||
AcceptanceResult = this.ddlAcceptanceResult.SelectedValue,
|
||
AcceptanceMan = this.CurrUser.UserName,
|
||
AcceptanceDate = DateTime.Now,
|
||
Remark = this.txtRemark.Text.Trim()
|
||
};
|
||
////存在则更新,不存在则新增(服务层已处理)
|
||
BLL.SafetyAcceptanceService.Update(info);
|
||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||
}
|
||
|
||
/// <summary>
|
||
/// 上传附件
|
||
/// </summary>
|
||
protected void btnAttach_Click(object sender, EventArgs e)
|
||
{
|
||
if (string.IsNullOrEmpty(this.AcceptanceId))
|
||
{
|
||
this.AcceptanceId = Guid.NewGuid().ToString();
|
||
}
|
||
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/SafetyAcceptance&menuId={1}", this.AcceptanceId, BLL.Const.SafetyAcceptanceMenuId)));
|
||
}
|
||
#endregion
|
||
}
|
||
}
|