SGGL_JT/SUBQHSE/FineUIPro.Web/DCGL/ServerCheck/CheckRectifyEdit.aspx.cs

313 lines
12 KiB
C#
Raw Normal View History

2025-04-07 17:43:30 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
2025-12-15 09:26:45 +08:00
using System.Text;
2025-04-07 17:43:30 +08:00
using BLL;
using Newtonsoft.Json.Linq;
2025-12-15 09:26:45 +08:00
using AspNet = System.Web.UI.WebControls;
2025-04-07 17:43:30 +08:00
namespace FineUIPro.Web.DCGL.ServerCheck
{
public partial class CheckRectifyEdit : PageBase
{
2025-12-15 09:26:45 +08:00
private static string proType;
2025-04-07 17:43:30 +08:00
/// <summary>
/// 主键
/// </summary>
public string CheckRectifyId
{
get
{
return (string)ViewState["CheckRectifyId"];
}
set
{
ViewState["CheckRectifyId"] = value;
}
}
2025-09-18 11:31:32 +08:00
/// <summary>
/// 集团服务器路径
/// </summary>
public string CNCECPath = BLL.Funs.CNCECPath;
//public string CNCECPath = "https://qhse.cncecoa.com/QHSE/";
2025-04-07 17:43:30 +08:00
/// <summary>
/// 定义集合
/// </summary>
private static List<Model.View_DCGL_CheckRectifyListFromSUB> CheckRectifyItems = new List<Model.View_DCGL_CheckRectifyListFromSUB>();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.GetButtonPower();
this.CheckRectifyId = Request.Params["CheckRectifyId"];
2025-12-15 09:26:45 +08:00
proType = Request.Params["proType"] ?? string.Empty;
2025-04-07 17:43:30 +08:00
if (!string.IsNullOrEmpty(this.CheckRectifyId))
{
var rectify = Funs.DB.DCGL_Check_CheckRectify.FirstOrDefault(x => x.CheckRectifyId == this.CheckRectifyId);
if (rectify != null)
{
var unit = BLL.UnitService.GetUnitByUnitId(rectify.UnitId);
if (unit != null)
{
this.lbUnitName.Text = unit.UnitName;
}
this.lbProjectName.Text = rectify.ProjectName;
this.lbCheckRectifyCode.Text = rectify.CheckRectifyCode;
if (!string.IsNullOrEmpty(rectify.IssueMan))
{
this.txtIssueMan.Text = rectify.IssueMan;
}
if (rectify.IssueDate.HasValue)
{
this.txtIssueDate.Text = string.Format("{0:yyyy-MM-dd}", rectify.IssueDate);
}
if (rectify.HandleState == BLL.Const.State_3)
{
this.btnSave.Hidden = true;
this.btnSaveUp.Hidden = true;
}
CheckRectifyItems = (from x in Funs.DB.View_DCGL_CheckRectifyListFromSUB where x.CheckRectifyId == this.CheckRectifyId orderby x.SortIndex select x).ToList();
Grid1.DataSource = CheckRectifyItems;
Grid1.DataBind();
//if (CheckRectifyItems.FirstOrDefault(x => x.DangerPoint.Length > 1) == null)
//{
2025-12-15 09:26:45 +08:00
//this.Grid1.Columns[1].Hidden = true;
//this.Grid1.Columns[2].Hidden = true;
2025-04-07 17:43:30 +08:00
//}
}
}
}
}
2025-09-18 11:31:32 +08:00
/// <summary>
/// 获取整改前图片(放于Img中)
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
protected string ConvertImageUrlByImage(object id)
{
string url = string.Empty;
if (id != null)
{
var attachFile = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == id.ToString());
if (attachFile != null)
{
2025-12-15 09:26:45 +08:00
CNCECPath = !string.IsNullOrWhiteSpace(CNCECPath) ? CNCECPath : "https://qhse.cncecoa.com/QHSE/";
2025-09-18 11:31:32 +08:00
url = BLL.UploadAttachmentService.ShowImage(CNCECPath, attachFile.AttachUrl);
}
}
return url;
}
2025-04-07 17:43:30 +08:00
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
this.SavaData(BLL.Const.BtnSave);
}
/// <summary>
/// 保存并提交
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSaveUp_Click(object sender, EventArgs e)
{
this.SavaData(BLL.Const.BtnSaveUp);
}
/// <summary>
/// 保存数据方法
/// </summary>
/// <param name="type"></param>
private void SavaData(string type)
{
jerqueSaveList();
foreach (var item in CheckRectifyItems)
{
var newCheckNoticeItem = BLL.DCGLCheckNoticeItemService.GetCheckNoticeItemByCheckNoticeItemId(item.NoticeItemId);
if (newCheckNoticeItem != null)
{
newCheckNoticeItem.Situation = item.Situation;
BLL.DCGLCheckNoticeItemService.UpdateCheckNoticeItem(newCheckNoticeItem);
}
var newCheckRectifyItem = BLL.DCGLCheckRectifyItemService.GetCheckRectifyItemByCheckRectifyItemId(item.CheckRectifyItemId);
if (newCheckRectifyItem != null)
{
newCheckRectifyItem.RealEndDate = item.RealEndDate;
newCheckRectifyItem.OrderEndPerson = item.OrderEndPerson;
//newCheckRectifyItem.Verification = item.Verification;
BLL.DCGLCheckRectifyItemService.UpdateCheckRectifyItem(newCheckRectifyItem);
}
}
var newCheckRectify = BLL.DCGLCheckRectifyService.GetCheckRectifyByCheckRectifyId(this.CheckRectifyId);
if (newCheckRectify != null && newCheckRectify.HandleState != BLL.Const.State_3)
{
newCheckRectify.HandleState = BLL.Const.State_2; //待上报
BLL.DCGLCheckRectifyService.UpdateCheckRectify(newCheckRectify);
}
if (type == BLL.Const.BtnSaveUp)
{
2025-09-18 11:31:32 +08:00
//string code = CNCECHSSEGetWebService.UpReportDCGlCheck_CheckRectify(newCheckRectify.CheckRectifyId, this.CurrUser);
2025-04-07 17:43:30 +08:00
string code = CNCECHSSEGetWebService.UpDCGlCheck_CheckRectify(newCheckRectify.CheckRectifyId, this.CurrUser);
if (code == "1")
{
ShowNotify("同步成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
return;
}
else
{
Alert.ShowInParent("同步异常,请退出后重试!", MessageBoxIcon.Error);
}
}
BLL.LogService.AddSys_Log(this.CurrUser, string.Empty, string.Empty, BLL.Const.DCGLCheckRectifyMenuId, BLL.Const.BtnModify);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
/// <summary>
/// 保存集合
/// </summary>
private void jerqueSaveList()
{
JArray mergedData = Grid1.GetMergedData();
foreach (JObject mergedRow in mergedData)
{
string status = mergedRow.Value<string>("status");
JObject values = mergedRow.Value<JObject>("values");
string checkRectifyItemId = values.Value<string>("CheckRectifyItemId").ToString();
var item = CheckRectifyItems.FirstOrDefault(e => e.CheckRectifyItemId == checkRectifyItemId);
if (item != null)
{
item.OrderEndPerson = values.Value<string>("OrderEndPerson").ToString();
item.RealEndDate = Funs.GetNewDateTime(values.Value<string>("RealEndDate").ToString());
//item.Verification = values.Value<string>("Verification").ToString();
item.Situation = values.Value<string>("Situation").ToString();
}
}
}
#region
/// <summary>
/// 权限按钮设置
/// </summary>
private void GetButtonPower()
{
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.DCGLCheckRectifyMenuId);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(BLL.Const.BtnSave))
{
this.btnSave.Hidden = false;
2025-12-15 09:26:45 +08:00
if (proType == "1")
{
this.btnSaveUp.Hidden = true;
}
else
{
this.btnSaveUp.Hidden = false;
}
2025-04-07 17:43:30 +08:00
}
}
}
#endregion
#region
/// <summary>
/// 关闭按钮事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnClose_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
#endregion
2025-12-15 09:26:45 +08:00
#region
/// <summary>
/// 导出按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnOutExcel_Click(object sender, EventArgs e)
{
Response.ClearContent();
var unitProjectName = $"{this.lbUnitName.Text}{this.lbProjectName.Text}";
string filename = Funs.GetNewFileName();
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(unitProjectName + "隐患问题表" + filename, System.Text.Encoding.UTF8) + ".xls");
Response.ContentType = "application/excel";
Response.ContentEncoding = System.Text.Encoding.UTF8;
this.Grid1.PageSize = this.Grid1.RecordCount;
//this.BindGrid();
Response.Write(GetGridTableHtml(Grid1));
Response.End();
}
/// <summary>
/// 导出方法
/// </summary>
/// <param name="grid"></param>
/// <returns></returns>
private string GetGridTableHtml(Grid grid)
{
StringBuilder sb = new StringBuilder();
sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>");
sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">");
sb.Append("<tr>");
foreach (GridColumn column in grid.Columns)
{
if (column.ColumnID != "ckbIsSelected" && column.ColumnID != "Punish" && column.ColumnID != "Del" && column.ColumnID != "CheckRectifyItemId")
{
sb.AppendFormat("<td>{0}</td>", column.HeaderText);
}
}
sb.Append("</tr>");
foreach (GridRow row in grid.Rows)
{
sb.Append("<tr>");
foreach (GridColumn column in grid.Columns)
{
if (column.ColumnID != "ckbIsSelected" && column.ColumnID != "Punish" && column.ColumnID != "Del" && column.ColumnID != "CheckRectifyItemId")
{
string html = row.Values[column.ColumnIndex].ToString();
if (column.ColumnID == "tfPageIndex")
{
html = (row.FindControl("lblPageIndex") as AspNet.Label).Text;
}
if (column.ColumnID == "tfRiskExists")
{
html = (row.FindControl("lbRiskExists") as AspNet.Label).Text;
}
if (column.ColumnID == "tfImageUrl1")
{
html = (row.FindControl("lbImageUrl1") as AspNet.Label).Text;
}
sb.AppendFormat("<td>{0}</td>", html);
}
}
sb.Append("</tr>");
}
sb.Append("</table>");
return sb.ToString();
}
#endregion
2025-04-07 17:43:30 +08:00
}
}