SGGL_JT/SUBQHSE/FineUIPro.Web/Customization/CNCCG/HSSE/Check/SafetyOfficerCheckView.aspx.cs

131 lines
5.3 KiB
C#

using BLL;
using System;
using System.Web;
using System.Linq;
namespace FineUIPro.Web.Customization.CNCCG.HSSE.Check
{
public partial class SafetyOfficerCheckView :PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
public string SafetyOfficerCheckId
{
get
{
return (string)ViewState["SafetyOfficerCheckId"];
}
set
{
ViewState["SafetyOfficerCheckId"] = value;
}
}
public string type
{
get
{
return (string)ViewState["type"];
}
set
{
ViewState["type"] = value;
}
}
#endregion
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
SafetyOfficerCheckId = Request.Params["SafetyOfficerCheckId"];
type = Request.Params["type"];
if (type=="1")
{
this.btnSave.Hidden = false;
}
//接收人
UserService.InitUserDropDownList(this.drpReceiveMan, this.CurrUser.LoginProjectId, false);
if (!string.IsNullOrEmpty(SafetyOfficerCheckId))
{
Model.Check_SafetyOfficerCheck model = Funs.DB.Check_SafetyOfficerCheck.FirstOrDefault(x => x.SafetyOfficerCheckId == SafetyOfficerCheckId);
if (model != null)
{
this.txtHandleIdea.Text = model.HandleIdea;
this.drpReceiveMan.SelectedValue = model.ReceiveMan;
//this.divImageUrl.InnerHtml = BLL.UploadAttachmentService.ShowAttachment("../../", model.ImageUrl);
this.divImageUrl.InnerHtml = ConvertImageUrlByImage(SafetyOfficerCheckId);
}
}
}
}
/// <summary>
/// 获取整改前图片(放于Img中)
/// </summary>
/// <param name="SafetyOfficerCheckId"></param>
/// <returns></returns>
protected string ConvertImageUrlByImage(object SafetyOfficerCheckId)
{
string url = string.Empty;
string httpUrl = string.Empty;
var sysSet6 = (from x in Funs.DB.Sys_Set where x.SetName == "程序访问地址" select x).ToList().FirstOrDefault();
if (sysSet6 != null)
{
httpUrl = sysSet6.SetValue;
}
//httpUrl = "http://localhost:2372/";
if (SafetyOfficerCheckId != null)
{
var model = Funs.DB.Check_SafetyOfficerCheck.FirstOrDefault(x => x.SafetyOfficerCheckId == SafetyOfficerCheckId.ToString());
if (model != null)
{
url = BLL.UploadAttachmentService.ShowImage(httpUrl, model.ImageUrl);
}
}
return url;
}
/// <summary>
/// 提交安全巡检
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
Model.Check_SafetyOfficerCheck model = Funs.DB.Check_SafetyOfficerCheck.FirstOrDefault(x => x.SafetyOfficerCheckId == SafetyOfficerCheckId);
model.State = "2";
BLL.SafetyOfficerCheckService.Update(model);
BLL.LogService.AddSys_Log(this.CurrUser, "", model.SafetyOfficerCheckId, BLL.Const.Check_SafetyOfficerCheckMenuId, BLL.Const.BtnModify);
#region
Model.HSSE_Hazard_HazardRegister register = new Model.HSSE_Hazard_HazardRegister();
register.RegisterDef = model.HandleIdea;//问题描述
register.ProblemTypes = "1"; //安全隐患问题
register.ImageUrl = model.ImageUrl;//整改前照片
register.States = "1"; //待整改
register.CheckManId = model.ReceiveMan;//群安员安检接收人为检查人
register.ProjectId = this.CurrUser.LoginProjectId;//项目id
register.HazardRegisterId = SQLHelper.GetNewID(typeof(Model.HSSE_Hazard_HazardRegister));
#region
//保存附件
Model.AttachFile file = BLL.AttachFileService.GetAttachFile(SafetyOfficerCheckId, Const.Check_SafetyOfficerCheckMenuId);
Model.AttachFile newFile = new Model.AttachFile();
newFile.ToKeyId = register.HazardRegisterId;
newFile.AttachSource = file.AttachSource;
newFile.AttachUrl = file.AttachUrl;
newFile.MenuId = BLL.Const.HiddenRectificationMenuId;
BLL.AttachFileService.AddAttachFile(newFile);
#endregion
BLL.HSSE_Hazard_HazardRegisterService.AddHazardRegister(register);
BLL.LogService.AddSys_Log(this.CurrUser, register.HazardCode, register.HazardRegisterId, BLL.Const.HiddenRectificationMenuId, BLL.Const.BtnAdd);
#endregion
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
}
}
}