218 lines
8.9 KiB
C#
218 lines
8.9 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.HJGL.WeldingManage
|
|
{
|
|
public partial class WeldReportOut : PageBase
|
|
{
|
|
#region 定义变量
|
|
/// <summary>
|
|
/// 项目Id
|
|
/// </summary>
|
|
public string ProjectId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["ProjectId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["ProjectId"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 加载页面
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|
this.ProjectId = Request.Params["projectId"];
|
|
// 绑定表格
|
|
this.BindGrid();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 绑定数据
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
if (!string.IsNullOrEmpty(this.ProjectId))
|
|
{
|
|
string strSql = @"select jointInfo.JOT_ID,jointInfo.ProjectId,jointInfo.ISO_ID,jointInfo.DReportID,
|
|
isoInfo.ISO_IsoNo,
|
|
Unit.UnitName,
|
|
jointInfo.JOT_JointNo,
|
|
NDTRate.NDTR_Name,
|
|
Welder.WED_Code AS WED_Code1, --盖面焊工代号
|
|
Welder.WED_Name AS WED_Name1, --盖面焊工名称
|
|
FloorWelder.WED_Code AS WED_Code2, --打底焊工代号
|
|
FloorWelder.WED_Name AS WED_Name2, --打底焊工名称
|
|
jointInfo.WLO_Code,
|
|
jointInfo.JOT_JointAttribute,
|
|
jointInfo.JOT_Location,
|
|
jointInfo.JOT_Size,
|
|
jointInfo.JOT_DoneDin,
|
|
jointInfo.JOT_Dia,
|
|
jointInfo.JOT_Sch,
|
|
WeldMethod.WME_Name AS WME_Name,--焊接方法
|
|
m1.WMT_MatCode AS WeldMat,--焊条
|
|
WeldMaterial.WMT_MatCode AS WeldSilk,--焊丝
|
|
weldReport.JOT_WeldDate,
|
|
weldReport.CHT_Tabler,
|
|
weldReport.JOT_WeldDate,
|
|
weldReport.JOT_DailyReportNo,
|
|
weldReport.JOT_Remark,
|
|
u.UserName as CHT_TablerName,
|
|
(case jointInfo.IS_Proess when 1 then '是' when 0 then '否' else '' end) as IsProess,
|
|
jointInfo.Sort1,jointInfo.Sort2,jointInfo.Sort3,jointInfo.Sort4,jointInfo.Sort5,JointType.JOTY_Group
|
|
from HJGL_PW_JointInfo as jointInfo
|
|
left join HJGL_PW_IsoInfo as isoInfo on isoInfo.ISO_ID= jointInfo.ISO_ID
|
|
left join HJGL_BO_WeldReportMain as weldReport on weldReport.DReportID = jointInfo.DReportID
|
|
LEFT JOIN HJGL_BS_Welder AS Welder ON Welder.WED_ID= jointInfo.JOT_CellWelder
|
|
LEFT JOIN HJGL_BS_Welder AS FloorWelder ON FloorWelder.WED_ID=jointInfo.JOT_FloorWelder
|
|
LEFT JOIN HJGL_BS_NDTRate AS NDTRate ON NDTRate.NDTR_ID =jointInfo.NDTR_ID
|
|
LEFT JOIN Base_Unit AS Unit ON Unit.UnitId=IsoInfo.BSU_ID
|
|
LEFT JOIN HJGL_BS_WeldMethod AS WeldMethod ON WeldMethod .WME_ID=jointInfo.WME_ID
|
|
LEFT JOIN HJGL_BS_WeldMaterial m1 ON m1.WMT_ID=jointInfo.JOT_WeldMat
|
|
LEFT JOIN HJGL_BS_WeldMaterial AS WeldMaterial ON WeldMaterial.WMT_ID=jointInfo.JOT_WeldSilk
|
|
LEFT JOIN HJGL_BS_JointType AS JointType ON JointType.JOTY_ID=jointInfo.JOTY_ID
|
|
left join Sys_User as u on u.UserId = weldReport.CHT_Tabler
|
|
where jointInfo.DReportID is not null and jointInfo.ProjectId=@proId";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@proId", this.ProjectId));
|
|
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
// 2.获取当前分页数据
|
|
//var table = this.GetPagedDataTable(Grid1, tb1);
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
//tb = GetFilteredTable(Grid1.FilteredData, tb);
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 分页排序
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
Grid1.PageIndex = e.NewPageIndex;
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页下拉选择
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
|
{
|
|
Grid1.SortDirection = e.SortDirection;
|
|
Grid1.SortField = e.SortField;
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 导出按钮
|
|
/// 导出按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnOut_Click(object sender, EventArgs e)
|
|
{
|
|
Response.ClearContent();
|
|
string filename = Funs.GetNewFileName();
|
|
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("焊接信息" + filename, System.Text.Encoding.UTF8) + ".xls");
|
|
Response.ContentType = "application/excel";
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
this.Grid1.PageSize = 100000;
|
|
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.HeaderText != "序号")
|
|
{
|
|
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)
|
|
{
|
|
string html = row.Values[column.ColumnIndex].ToString();
|
|
if (column.ColumnID != "tfNumber")
|
|
{
|
|
if (column.ColumnID == "BatchCode")
|
|
{
|
|
sb.AppendFormat("<td style='vnd.ms-excel.numberformat:@;'>{0}</td>", html);
|
|
}
|
|
else
|
|
{
|
|
sb.AppendFormat("<td>{0}</td>", html);
|
|
}
|
|
}
|
|
}
|
|
|
|
sb.Append("</tr>");
|
|
}
|
|
|
|
sb.Append("</table>");
|
|
|
|
return sb.ToString();
|
|
}
|
|
#endregion
|
|
}
|
|
} |