171 lines
6.6 KiB
C#
171 lines
6.6 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Web;
|
|
|
|
namespace FineUIPro.Web.HSSE.Check
|
|
{
|
|
public partial class OfficeCheck : PageBase
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
BindGrid();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定明细
|
|
/// </summary>
|
|
public void BindGrid()
|
|
{
|
|
string strSql = @"SELECT (CASE WHEN Rectify.States=1 THEN '待整改' WHEN Rectify.States=2 THEN '待确认' WHEN Rectify.States=3 THEN '已完成' ELSE '待签发' END) AS StatesName,
|
|
Rectify.RectifyCode,Item.RectifyItemId,Item.RectifyId,Item.WrongContent,Item.Requirement,Item.LimitTime,Item.RectifyResults,Item.IsRectify,Rectify.States,Rectify.ProjectId
|
|
FROM ProjectSupervision_RectifyItem AS Item
|
|
LEFT JOIN ProjectSupervision_Rectify AS Rectify ON Rectify.RectifyId=Item.RectifyId
|
|
WHERE Rectify.States !='0' AND Rectify.States IS NOT NULL ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
strSql += " AND Rectify.ProjectId = @ProjectId";
|
|
strSql += " AND Item.IsRectify = @IsRectify";
|
|
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
|
listStr.Add(new SqlParameter("@IsRectify", this.rbStates.SelectedValue));
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 状态筛选事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void rbStates_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
if (this.rbStates.SelectedValue == "1")
|
|
{
|
|
this.btnSubmit.Hidden = true;
|
|
}
|
|
else
|
|
{
|
|
this.btnSubmit.Hidden = false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Grid行点击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
|
|
{
|
|
string itemId = Grid1.DataKeys[e.RowIndex][0].ToString();
|
|
if (e.CommandName == "AttachUrl")
|
|
{
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/Rectify&menuId={1}&type=0&strParam=1", itemId, BLL.Const.CheckInfoMenuId)));
|
|
}
|
|
if (e.CommandName == "ReAttachUrl")
|
|
{
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/Rectify&menuId={1}&type=0&strParam=2", itemId, BLL.Const.CheckInfoMenuId)));
|
|
var item = BLL.ProjectSupervision_RectifyItemService.GeRectifyItemById(itemId);
|
|
if (item != null)
|
|
{
|
|
item.States = "1";
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
int i = 0;
|
|
var lists = BLL.ProjectSupervision_RectifyItemService.GetRectifyItemByRectifyId(item.RectifyId);
|
|
foreach (var j in lists)
|
|
{
|
|
if (j.States == "1")
|
|
{
|
|
i++;
|
|
}
|
|
}
|
|
if (i == lists.Count)
|
|
{
|
|
var rectify = BLL.ProjectSupervision_RectifyService.GetRectifyById(item.RectifyId);
|
|
if (rectify != null)
|
|
{
|
|
rectify.States = BLL.Const.State_2;
|
|
BLL.ProjectSupervision_RectifyService.UpdateRectify(rectify);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSubmit_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
|
{
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString().Split(',')[0];
|
|
var getV = Funs.DB.ProjectSupervision_RectifyItem.FirstOrDefault(x => x.RectifyItemId == rowID);
|
|
if (getV != null)
|
|
{
|
|
var getR = Funs.DB.ProjectSupervision_Rectify.FirstOrDefault(x => x.RectifyId == getV.RectifyId);
|
|
if (getR != null && getR.States != Const.State_3)
|
|
{
|
|
getR.States = BLL.Const.State_2;
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
}
|
|
}
|
|
|
|
BindGrid();
|
|
ShowNotify("数据已提交成功!");
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取整改前图片(放于Img中)
|
|
/// </summary>
|
|
/// <param name="registrationId"></param>
|
|
/// <returns></returns>
|
|
protected string ConvertImageUrlByImage(object RectifyItemId)
|
|
{
|
|
string url = string.Empty;
|
|
if (RectifyItemId != null)
|
|
{
|
|
var RectifyNoticesItem = BLL.AttachFileService.GetAttachFileByToKeyId(RectifyItemId.ToString() + "#1");
|
|
if (RectifyNoticesItem != null)
|
|
{
|
|
url = HttpUtility.HtmlDecode(BLL.UploadAttachmentService.ShowImage("../../", RectifyNoticesItem.AttachUrl));
|
|
}
|
|
}
|
|
return url;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取整改后图片
|
|
/// </summary>
|
|
/// <param name="registrationId"></param>
|
|
/// <returns></returns>
|
|
protected string ConvertImageUrlByImage2(object RectifyItemId)
|
|
{
|
|
string url = string.Empty;
|
|
if (RectifyItemId != null)
|
|
{
|
|
var RectifyNoticesItem = BLL.AttachFileService.GetAttachFileByToKeyId(RectifyItemId.ToString() + "#2");
|
|
if (RectifyNoticesItem != null)
|
|
{
|
|
url = BLL.UploadAttachmentService.ShowImage("../../", RectifyNoticesItem.AttachUrl);
|
|
}
|
|
}
|
|
return url;
|
|
}
|
|
}
|
|
} |