289 lines
11 KiB
C#
289 lines
11 KiB
C#
using BLL;
|
|
using Model;
|
|
using System;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using AspNet = System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.ZHGL.Supervise
|
|
{
|
|
public partial class UnitHazardRegisterRecord : PageBase
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
Funs.DropDownPageSize(this.ddlPageSize);
|
|
|
|
//if (this.CurrUser != null && this.CurrUser.PageSize.HasValue)
|
|
//{
|
|
// Grid1.PageSize = this.CurrUser.PageSize.Value;
|
|
//}
|
|
this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|
|
|
// 绑定表格
|
|
this.BindGrid();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
// 获取 Type 参数 (0=安全, 1=质量)
|
|
string type = Request["type"] ?? "0";
|
|
|
|
// 解析时间参数
|
|
DateTime? startTime = null;
|
|
DateTime? endTime = null;
|
|
if (!string.IsNullOrEmpty(txtStartTime.Text.Trim()))
|
|
{
|
|
startTime = Funs.GetNewDateTime(txtStartTime.Text.Trim());
|
|
}
|
|
if (!string.IsNullOrEmpty(txtEndTime.Text.Trim()))
|
|
{
|
|
endTime = Funs.GetNewDateTime(txtEndTime.Text.Trim());
|
|
}
|
|
|
|
// 解析状态参数
|
|
int? problemStates = null;
|
|
if (!string.IsNullOrEmpty(this.drpProblemStates.SelectedValue))
|
|
{
|
|
problemStates = Convert.ToInt32(this.drpProblemStates.SelectedValue);
|
|
}
|
|
|
|
// 构建查询条件
|
|
var input = new UnitHazardRegisterItemInput
|
|
{
|
|
CheckMainType = type,
|
|
CheckTeam = this.txtCheckTeam.Text.Trim(),
|
|
CheckType = this.txtCheckType.Text.Trim(),
|
|
Problem = this.txtProblem.Text.Trim(),
|
|
StartTime = startTime,
|
|
EndTime = endTime,
|
|
RiskLevel = this.drpRiskLevel.SelectedValue,
|
|
ProblemStates = problemStates,
|
|
UnitId = this.CurrUser.UnitId
|
|
};
|
|
if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
|
|
{
|
|
input.ProjectId = this.CurrUser.LoginProjectId;
|
|
}
|
|
int totalCount;
|
|
|
|
// 使用新方法获取数据
|
|
var list = BLL.UnitHazardRegisterItemService.GetUnitHazardRegisterItems(
|
|
input,
|
|
Grid1.PageIndex,
|
|
Grid1.PageSize,
|
|
false,
|
|
out totalCount);
|
|
|
|
Grid1.RecordCount = totalCount;
|
|
Grid1.DataSource = list;
|
|
Grid1.DataBind();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页
|
|
/// </summary>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
Grid1.PageIndex = e.NewPageIndex;
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
protected void Grid1_Sort(object sender,GridSortEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页显示条数下拉框
|
|
/// </summary>
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
if (!string.IsNullOrEmpty(this.txtStartTime.Text.Trim()) && !string.IsNullOrEmpty(this.txtEndTime.Text.Trim()))
|
|
{
|
|
if (Funs.GetNewDateTime(this.txtStartTime.Text.Trim()) > Funs.GetNewDateTime(this.txtEndTime.Text.Trim()))
|
|
{
|
|
Alert.ShowInTop("开始时间不能大于结束时间!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
this.BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 关闭弹出窗
|
|
/// </summary>
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Grid行双击事件
|
|
/// </summary>
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
string itemId = Grid1.SelectedRowID;
|
|
// 打开单个问题记录整改编辑界面
|
|
var item = BLL.UnitHazardRegisterItemService.GetUnitHazardRegisterItemById(itemId);
|
|
if (item != null)
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(
|
|
String.Format("UnitHazardRegisterRecordEdit.aspx?ItemId={0}&RegisterId={1}&type={2}",
|
|
itemId, item.UnitHazardRegisterId, Request["type"])));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Grid行命令事件
|
|
/// </summary>
|
|
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
|
|
{
|
|
string itemId = Grid1.DataKeys[e.RowIndex][0].ToString();
|
|
|
|
if (e.CommandName == "attchUrl")
|
|
{
|
|
// 查看问题图片
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(
|
|
String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/UnitHazardRegister&menuId={1}&edit=1&type=-1",
|
|
itemId, Request["type"] == "0" ? BLL.Const.UnitHazardRegisterMenu_Safety : BLL.Const.UnitHazardRegisterMenu_Quality)));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 导出按钮
|
|
/// </summary>
|
|
protected void btnOut_Click(object sender, EventArgs e)
|
|
{
|
|
string type = Request["type"] ?? "0";
|
|
string typeText = type == "0" ? "安全" : "质量";
|
|
|
|
Response.ClearContent();
|
|
Response.ContentType = "application/octet-stream";
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("企业" + typeText + "检查记录.xls", System.Text.Encoding.UTF8));
|
|
Response.Charset = "UTF-8";
|
|
|
|
Grid1.PageSize = 100000;
|
|
BindGrid();
|
|
|
|
Response.Write(GetGridTableHtml(Grid1));
|
|
Response.End();
|
|
}
|
|
|
|
#pragma warning disable CS0108 // “HiddenRectificationList.GetGridTableHtml(Grid)”隐藏继承的成员“PageBase.GetGridTableHtml(Grid)”。如果是有意隐藏,请使用关键字 new。
|
|
/// <summary>
|
|
/// 导出方法
|
|
/// </summary>
|
|
/// <param name="grid"></param>
|
|
/// <returns></returns>
|
|
private string GetGridTableHtml(Grid grid)
|
|
#pragma warning restore CS0108 // “HiddenRectificationList.GetGridTableHtml(Grid)”隐藏继承的成员“PageBase.GetGridTableHtml(Grid)”。如果是有意隐藏,请使用关键字 new。
|
|
{
|
|
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")
|
|
{
|
|
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")
|
|
{
|
|
string html = row.Values[column.ColumnIndex].ToString();
|
|
if (column.ColumnID == "tfPageIndex")
|
|
{
|
|
html = (row.FindControl("lblPageIndex") as AspNet.Label).Text;
|
|
}
|
|
if (column.ColumnID == "tfImageUrl")
|
|
{
|
|
html = (row.FindControl("lbtnImageUrl") as AspNet.LinkButton).Text;
|
|
}
|
|
if (column.ColumnID == "tfRectificationImageUrl")
|
|
{
|
|
html = (row.FindControl("lbtnRectificationImageUrl") as AspNet.LinkButton).Text;
|
|
}
|
|
if (column.ColumnID == "ProblemTypes")
|
|
{
|
|
html = (row.FindControl("lbProblemTypes") as AspNet.Label).Text;
|
|
}
|
|
if (column.ColumnID == "tfImageUrl1")
|
|
{
|
|
html = (row.FindControl("lbImageUrl1") as AspNet.Label).Text;
|
|
|
|
}
|
|
if (column.ColumnID == "tfImageUrl2")
|
|
{
|
|
html = (row.FindControl("lbImageUrl2") as AspNet.Label).Text;
|
|
|
|
}
|
|
if (column.ColumnID == "CheckCycle")
|
|
{
|
|
html = (row.FindControl("Label2") as AspNet.Label).Text;
|
|
}
|
|
//if (column.ColumnID == "tfCutPayment")
|
|
//{
|
|
// html = (row.FindControl("lbtnCutPayment") as AspNet.LinkButton).Text;
|
|
//}
|
|
sb.AppendFormat("<td>{0}</td>", html);
|
|
}
|
|
}
|
|
sb.Append("</tr>");
|
|
}
|
|
sb.Append("</table>");
|
|
|
|
return sb.ToString();
|
|
}
|
|
|
|
protected void btnEdit_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
string itemId = Grid1.SelectedRowID;
|
|
// 打开单个问题记录整改编辑界面
|
|
var item = BLL.UnitHazardRegisterItemService.GetUnitHazardRegisterItemById(itemId);
|
|
if (item != null)
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(
|
|
String.Format("UnitHazardRegisterRecordEdit.aspx?ItemId={0}&RegisterId={1}&type={2}",
|
|
itemId, item.UnitHazardRegisterId, Request["type"])));
|
|
}
|
|
}
|
|
}
|
|
}
|