SGGL_HBAZ/SGGL/FineUIPro.Web/OfficeCheck/Inspect/ProjectSafetyInspectionRect...

234 lines
8.4 KiB
C#
Raw Normal View History

2025-03-21 14:33:56 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using BLL.OfficeCheck.Inspect;
namespace FineUIPro.Web.OfficeCheck.Inspect
{
public partial class ProjectSafetyInspectionRectify : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
private string InspectionItemId
{
get
{
return (string)ViewState["InspectionItemId"];
}
set
{
ViewState["InspectionItemId"] = value;
}
}
/// <summary>
/// 责任人
/// </summary>
public string PersonResponsible
{
get
{
return (string)ViewState["PersonResponsible"];
}
set
{
ViewState["PersonResponsible"] = value;
}
}
/// <summary>
/// 类型
/// </summary>
public string type
{
get
{
return (string)ViewState["type"];
}
set
{
ViewState["type"] = value;
}
}
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
this.InspectionItemId = Request.QueryString["InspectionItemId"];
this.type = Request.QueryString["type"];
if (this.type == "1")
{
this.btnSave.Hidden = true;
}
if (!string.IsNullOrEmpty(this.InspectionItemId))
{
var registration = (from x in Funs.DB.Inspect_InspectionItem
join y in Funs.DB.Inspect_Inspection on x.InspectionId equals y.InspectionId into inspection
from inspectionJoin in inspection.DefaultIfEmpty()
where x.InspectionItemId == this.InspectionItemId
select new
{
x.InspectionItemId,
x.InspectionDescribe,
x.PhotoUrl,
x.VideoUrl,
inspectionJoin.PersonResponsible,
x.EvaluateResults,
inspectionJoin.InspectMan,
x.TimeLimited,
x.RectificationDescription
}).FirstOrDefault();
if (registration != null)
{
this.txtInspectionDescribe.Text = registration.InspectionDescribe;
// this.UploadPhoto.Text = registration.PhotoUrl;
// this.UploadVideo.Text = registration.VideoUrl;
if (registration.InspectMan != null)
{
//查询用户名
var user = (from x in Funs.DB.Sys_User
where x.UserId == registration.InspectMan
select new { x.UserName }).FirstOrDefault();
if (user != null)
{
this.txtCheckManName.Text = user.UserName;
}
}
this.txtEvaluateResults.Text = registration.EvaluateResults;
if (registration.PersonResponsible != null)
{
//查询用户名
var user = (from x in Funs.DB.Sys_User
where x.UserId == registration.PersonResponsible
select new { x.UserName }).FirstOrDefault();
if (user != null)
{
this.txtResponsibleManName.Text = user.UserName;
}
}
if (registration.TimeLimited != null)
{
this.txtTimeLimited.Text = string.Format("{0:yyyy-MM-dd HH:mm:ss}", registration.TimeLimited);
}
this.txtRectificationDescription.Text = registration.RectificationDescription;
this.PersonResponsible = registration.PersonResponsible;
}
}
}
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(this.PersonResponsible) && this.PersonResponsible == this.CurrUser.UserId)
{
SaveData(true);
}
else
{
Alert.ShowInTop("您不是当前责任人,无法整改!", MessageBoxIcon.Warning);
return;
}
}
/// <summary>
/// 保存数据
/// </summary>
/// <param name="p"></param>
private void SaveData(bool isClosed)
{
var register = Inspect_InspectionService.GetInspectItemsById(this.InspectionItemId);
if (register != null)
{
var file = AttachFileService.GetAttachFile(register.InspectionItemId + "_3", BLL.Const.ProjectSafetyInspectionMenuId);
if (file != null && file.AttachUrl != "")
{
register.States = "3"; //已整改待复查
register.RectificationPhotoUrl = file.AttachUrl.Trim();
}
else
{
ShowNotify("请先上传整改后照片!", MessageBoxIcon.Warning);
return;
}
Inspect_InspectionService.UpdateInspectionItem(register);
if (isClosed)
{
if (string.IsNullOrEmpty(Request.Params["Main"]))
{
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
else
{
PageContext.RegisterStartupScript(String.Format("window.close();"));
}
}
}
}
#endregion
#region
/// <summary>
/// 附件查看
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnPhotoUrl_Click(object sender, EventArgs e)
{
var itemId = this.InspectionItemId + "_1";
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format(
"../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/InspectionItem&menuId={1}", itemId,
BLL.Const.ProjectSafetyInspectionMenuId)));
}
protected void btnVideoUrl_Click(object sender, EventArgs e)
{
var itemId = this.InspectionItemId + "_2";
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format(
"../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/InspectionItem&menuId={1}", itemId,
BLL.Const.ProjectSafetyInspectionMenuId)));
}
#endregion
#region
/// <summary>
/// 附件上传
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAttachUrlR_Click(object sender, EventArgs e)
{
var itemId = this.InspectionItemId + "_3";
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format(
"../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/InspectionItem&menuId={1}", itemId,
BLL.Const.ProjectSafetyInspectionMenuId)));
}
#endregion
}
}