ZHJA_HJGL/HJGL_ZH/FineUIPro.Web/HJGL/CheckManage/CheckResultsSummaryByBatch....

714 lines
30 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using BLL;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using AspNet = System.Web.UI.WebControls;
namespace FineUIPro.Web.HJGL.CheckManage
{
public partial class CheckResultsSummaryByBatch : PageBase
{
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
this.drpProjectId.DataTextField = "ProjectCode";
this.drpProjectId.DataValueField = "ProjectId";
this.drpProjectId.DataSource = BLL.Base_ProjectService.GetOnProjectListByUserId(this.CurrUser.UserId, "1");
this.drpProjectId.DataBind();
Funs.FineUIPleaseSelect(this.drpProjectId);
this.InitTreeMenu();//加载树
}
}
#endregion
#region
/// <summary>
/// 加载树
/// </summary>
private void InitTreeMenu()
{
this.tvControlItem.Nodes.Clear();
TreeNode rootNode = new TreeNode();
rootNode.Text = "施工号-批编号";
rootNode.ToolTip = "项目";
rootNode.NodeID = "0";
rootNode.Expanded = true;
this.tvControlItem.Nodes.Add(rootNode);
List<Model.Base_Project> projects = BLL.Base_ProjectService.GetOnProjectListByUserId(this.CurrUser.UserId, "1");
if (this.drpProjectId.SelectedValue != null && this.drpProjectId.SelectedValue != "null")
{
projects = projects.Where(x => x.ProjectId == this.drpProjectId.SelectedValue).ToList();
}
foreach (var item in projects)
{
TreeNode rootProjectNode = new TreeNode();//定义根节点
rootProjectNode.Text = item.ProjectCode;
rootProjectNode.NodeID = item.ProjectId;
//rootProjectNode.Expanded = false;
rootProjectNode.EnableExpandEvent = true;
rootProjectNode.ToolTip = item.ProjectName;
rootProjectNode.CommandName = "施工号";
rootNode.Nodes.Add(rootProjectNode);
TreeNode tn = new TreeNode();
tn.NodeID = "temp";
tn.Text = "正在加载...";
rootProjectNode.Nodes.Add(tn);
}
}
/// <summary>
/// 节点展开事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void tvControlItem_NodeExpand(object sender, TreeNodeEventArgs e)
{
if (e.Node.Nodes != null)
{
e.Node.Nodes.Clear();
}
string node = e.NodeID;
List<Model.HJGL_BO_Batch> batchLists = (from x in Funs.DB.HJGL_BO_Batch
where x.ProjectId == e.NodeID
select x).ToList();
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ProjectId", e.NodeID));
SqlParameter[] parameter = listStr.ToArray();
DataTable dt = SQLHelper.GetDataTableRunProc("HJGL_spTestingReportPrint", parameter);
this.BindNodes(e.Node, batchLists, dt);
}
/// <summary>
/// 绑定树节点
/// </summary>
/// <param name="node"></param>
private void BindNodes(TreeNode node, List<Model.HJGL_BO_Batch> batchLists, DataTable dt)
{
if (node.CommandName == "施工号")
{
var batchList = (from x in batchLists orderby x.BatchCode descending select x).Distinct();
foreach (var item in batchList)
{
DataRow[] drArr = dt.Select("BatchId='" + item.BatchId + "' and IsPrint=0");//查询
TreeNode newNode = new TreeNode();
if (drArr.Count() > 0)
{
newNode.Text = string.Format("{0:yyyy-MM-dd}", item.BatchStartDate) + " " + item.BatchCode;
}
else
{
newNode.Text = "<font color='#009966'>" + string.Format("{0:yyyy-MM-dd}", item.BatchStartDate) + " " + item.BatchCode + "</font>";
}
newNode.NodeID = item.BatchId;
newNode.ToolTip = "日期-批编号";
newNode.CommandName = "批编号";
newNode.EnableClickEvent = true;
node.Nodes.Add(newNode);
}
}
}
#endregion
#region TreeView
/// <summary>
/// 点击TreeView
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
{
BindPage();
BindGrid();
}
#endregion
#region
/// <summary>
/// 绑定数据
/// </summary>
private void BindGrid()
{
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID) && !string.IsNullOrEmpty(this.tvControlItem.SelectedNode.ParentNode.NodeID))
{
string batchId = this.tvControlItem.SelectedNodeID;
string projectId = this.tvControlItem.SelectedNode.ParentNode.NodeID;//项目ID
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ProjectId", projectId));
listStr.Add(new SqlParameter("@BatchId", batchId));
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunProc("HJGL_sp_CheckResultSummaryByBatch1", parameter);
this.Grid1.RecordCount = tb.Rows.Count;
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataBind();
}
}
private void BindPage()
{
string bathcId = this.tvControlItem.SelectedNodeID;
string projectId = this.tvControlItem.SelectedNode.ParentNode.NodeID;//项目ID
Model.SGGLDB db = Funs.DB;
this.txtSupervisionUnit.Text = string.Empty;
//装置
var installationCode = (from x in db.Project_Installation where x.ProjectId == projectId select x.InstallationCode).FirstOrDefault();
if (!string.IsNullOrEmpty(installationCode))
{
this.txtWorkAreaCode.Text = installationCode;
}
//监理单位
var project = BLL.Base_ProjectService.GetProjectByProjectId(projectId);
if (!string.IsNullOrEmpty(project.WatchUnit))
{
this.txtSupervisionUnit.Text = project.WatchUnit;
}
this.txtConstructionUnit.Text = "镇海石化建安工程有限公司";
this.txtTestingStandard.Text = "NB/T47013-2015";//检测标准
var result = from x in db.HJGL_View_CheckResult
where x.ProjectId == projectId && x.BatchId==bathcId
select x;
#region
//RT对焊接头
var rt1 = from x in result where x.JOTY_Group == "1" && x.States == "2" && x.SysType == "射线检测" select x;
if (rt1.Count() > 0)
{
var q1 = from x in Funs.DB.HJGL_BO_QualityRating where rt1.Select(y => y.CH_TrustItemID).Contains(x.CH_TrustItemID) select x;
var q2 = from x in Funs.DB.HJGL_BO_QualityRatingRepair where rt1.Select(y => y.JOT_ID).Contains(x.JOT_ID) select x;
string rt1Num = rt1.Count().ToString();
string rt1FileNum = (q1.Count() + q2.Count()).ToString();
//string rt1FileNum = rt1.Sum(x => x.RTQueFile).Value.ToString();
this.lblRT1.Text = rt1Num + "/" + rt1FileNum;//RT对焊接头
}
else
{
this.lblRT1.Text = "/";
}
//UT对焊接头
var ut1 = from x in result where x.JOTY_Group == "1" && x.States == "2" && x.SysType == "超声波检测" select x;
if (ut1.Count() > 0)
{
string ut1Num = ut1.Count().ToString();
string ut1FileNum = (Convert.ToDouble(ut1.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000");
this.lblUT1.Text = ut1Num + "/" + ut1FileNum;//UT对焊接头
}
else
{
this.lblUT1.Text = "/";
}
//MT对焊接头
var mt1= from x in result where x.JOTY_Group == "1" && x.States == "2" && x.SysType == "磁粉检测" select x;
if (mt1.Count() > 0)
{
string mt1Num = mt1.Count().ToString();
string mt1FileNum = (Convert.ToDouble(mt1.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000");
this.lblMT1.Text = mt1Num + "/" + mt1FileNum;//MT对焊接头
}
else
{
this.lblMT1.Text = "/";
}
//PT对焊接头
var pt1 = from x in result where x.JOTY_Group == "1" && x.States == "2" && x.SysType == "渗透检测" select x;
if (pt1.Count() > 0)
{
string pt1Num = pt1.Count().ToString();
string pt1FileNum = (Convert.ToDouble(pt1.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000");
this.lblPT1.Text = pt1Num + "/" + pt1FileNum;//PT对焊接头
}
else
{
this.lblPT1.Text = "/";
}
//MT角焊接头
var mt2 = from x in result where x.JOTY_Group == "2" && x.States == "2" && x.SysType == "磁粉检测" select x;
if (mt2.Count() > 0)
{
string mt2Num = mt2.Count().ToString();
string mt2FileNum = (Convert.ToDouble(mt2.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000");
this.lblMT2.Text = mt2Num + "/" + mt2FileNum;//MT角焊接头
}
else
{
this.lblMT2.Text = "/";
}
//PT角焊接头
var pt2 = from x in result where x.JOTY_Group == "2" && x.States == "2" && x.SysType == "渗透检测" select x;
if (pt2.Count() > 0)
{
string pt2Num = pt2.Count().ToString();
string pt2FileNum = (Convert.ToDouble(pt2.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000");
this.lblPT2.Text = pt2Num + "/" + pt2FileNum;//PT角焊接头
}
else
{
this.lblPT2.Text = "/";
}
//RT 支管连接接头
var rt3 = from x in result where x.JOTY_Group == "3" && x.States == "2" && x.SysType == "射线检测" select x;
if (rt3.Count() > 0)
{
var q3 = from x in Funs.DB.HJGL_BO_QualityRating where rt3.Select(y => y.CH_TrustItemID).Contains(x.CH_TrustItemID) select x;
var q4 = from x in Funs.DB.HJGL_BO_QualityRatingRepair where rt3.Select(y => y.JOT_ID).Contains(x.JOT_ID) select x;
string rt3Num = rt3.Count().ToString();
string rt3FileNum = (q3.Count() + q4.Count()).ToString();
this.lblRT3.Text = rt3Num + "/" + rt3FileNum;//RT支管连接接头
}
else
{
this.lblRT3.Text = "/";
}
//UT 支管连接接头
var ut3 = from x in result where x.JOTY_Group == "3" && x.States == "2" && x.SysType == "超声波检测" select x;
if (ut3.Count() > 0)
{
string ut3Num = ut3.Count().ToString();
string ut3FileNum = (Convert.ToDouble(ut3.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000");
this.lblUT3.Text = ut3Num + "/" + ut3FileNum;//UT支管连接接头
}
else
{
this.lblUT3.Text = "/";
}
//MT 支管连接接头
var mt3 = from x in result where x.JOTY_Group == "3" && x.States == "2" && x.SysType == "磁粉检测" select x;
if (mt3.Count() > 0)
{
string mt3Num = mt3.Count().ToString();
string mt3FileNum = (Convert.ToDouble(mt3.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000");
this.lblMT3.Text = mt3Num + "/" + mt3FileNum;//MT支管连接接头
}
else
{
this.lblMT3.Text = "/";
}
//PT 支管连接接头
var pt3 = from x in result where x.JOTY_Group == "3" && x.States == "2" && x.SysType == "渗透检测" select x;
if (pt3.Count() > 0)
{
string pt3Num = pt3.Count().ToString();
string pt3FileNum = (Convert.ToDouble(pt3.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000");
this.lblPT3.Text = pt3Num + "/" + pt3FileNum;//PT支管连接接头
}
else
{
this.lblPT3.Text = "/";
}
#endregion
#region
//RT对焊接头
var unRT1 = from x in result where x.JOTY_Group == "1" && x.States == "4" && x.SysType == "射线检测" select x;
if (unRT1.Count() > 0)
{
var q1 = from x in Funs.DB.HJGL_BO_QualityRating where x.IsPass== "不合格" && unRT1.Select(y => y.CH_TrustItemID).Contains(x.CH_TrustItemID) select x;
string unRT1Num = unRT1.Count().ToString();
string unRT1FileNum = q1.Count().ToString();
//string unRT1FileNum = unRT1.Sum(x => x.RTQueFile).Value.ToString();
this.lblUnRT1.Text = unRT1Num + "/" + unRT1FileNum;//RT对焊接头
}
else
{
this.lblUnRT1.Text = "/";
}
//UT对焊接头
var unUT1 = from x in result where x.JOTY_Group == "1" && x.States == "4" && x.SysType == "超声波检测" select x;
if (unUT1.Count() > 0)
{
string unUT1Num = unUT1.Count().ToString();
string unUT1FileNum = (Convert.ToDouble(unUT1.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000");
this.lblUnUT1.Text = unUT1Num + "/" + unUT1FileNum;//UT对焊接头
}
else
{
this.lblUnUT1.Text = "/";
}
// MT对焊接头
var unMT1 = from x in result where x.JOTY_Group == "1" && x.States == "4" && x.SysType == "磁粉检测" select x;
if (unMT1.Count() > 0)
{
string unMT1Num = unMT1.Count().ToString();
string unMT1FileNum = (Convert.ToDouble(unMT1.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000");
this.lblUnMT1.Text = unMT1Num + "/" + unMT1FileNum;//MT对焊接头
}
else
{
this.lblUnMT1.Text = "/";
}
// PT对焊接头
var unPT1 = from x in result where x.JOTY_Group == "1" && x.States == "4" && x.SysType == "渗透检测" select x;
if (unPT1.Count() > 0)
{
string unPT1Num = unPT1.Count().ToString();
string unPT1FileNum = (Convert.ToDouble(unPT1.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000");
this.lblUnPT1.Text = unPT1Num + "/" + unPT1FileNum;//PT对焊接头
}
else
{
this.lblUnPT1.Text = "/";
}
// MT角焊接头
var unMT2 = from x in result where x.JOTY_Group == "2" && x.States == "4" && x.SysType == "磁粉检测" select x;
if (unMT2.Count() > 0)
{
string unMT2Num = unMT2.Count().ToString();
string unMT2FileNum = (Convert.ToDouble(unMT2.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000");
this.lblUnMT2.Text = unMT2Num + "/" + unMT2FileNum;//MT对焊接头
}
else
{
this.lblUnMT2.Text = "/";
}
// PT角焊接头
var unPT2 = from x in result where x.JOTY_Group == "2" && x.States == "4" && x.SysType == "渗透检测" select x;
if (unPT2.Count() > 0)
{
string unPT2Num = unPT2.Count().ToString();
string unPT2FileNum = (Convert.ToDouble(unPT2.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000");
this.lblUnPT2.Text = unPT2Num + "/" + unPT2FileNum;//PT对焊接头
}
else
{
this.lblUnPT2.Text = "/";
}
// RT支管连接接头
var unRT3 = from x in result where x.JOTY_Group == "3" && x.States == "4" && x.SysType == "射线检测" select x;
if (unRT3.Count() > 0)
{
var q1 = from x in Funs.DB.HJGL_BO_QualityRating where x.IsPass == "不合格" && unRT3.Select(y => y.CH_TrustItemID).Contains(x.CH_TrustItemID) select x;
string unRT3Num = unRT3.Count().ToString();
string unRT3FileNum = q1.Count().ToString(); //unRT3.Sum(x => x.RTQueFile).Value.ToString();
this.lblUnRT3.Text = unRT3Num + "/" + unRT3FileNum;//RT支管连接接头
}
else
{
this.lblUnRT3.Text = "/";
}
// UT支管连接接头
var unUT3 = from x in result where x.JOTY_Group == "3" && x.States == "4" && x.SysType == "超声波检测" select x;
if (unUT3.Count() > 0)
{
string unUT3Num = unUT3.Count().ToString();
string unUT3FileNum = (Convert.ToDouble(unUT3.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000");
this.lblUnUT3.Text = unUT3Num + "/" + unUT3FileNum;//UT支管连接接头
}
else
{
this.lblUnUT3.Text = "/";
}
// MT支管连接接头
var unMT3 = from x in result where x.JOTY_Group == "3" && x.States == "4" && x.SysType == "磁粉检测" select x;
if (unMT3.Count() > 0)
{
string unMT3Num = unMT3.Count().ToString();
string unMT3FileNum = (Convert.ToDouble(unMT3.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000");
this.lblUnMT3.Text = unMT3Num + "/" + unMT3FileNum;//MT支管连接接头
}
else
{
this.lblUnMT3.Text = "/";
}
// PT支管连接接头
var unPT3 = from x in result where x.JOTY_Group == "3" && x.States == "4" && x.SysType == "渗透检测" select x;
if (unPT3.Count() > 0)
{
string unPT3Num = unPT3.Count().ToString();
string unPT3FileNum = (Convert.ToDouble(unPT3.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000");
this.lblUnPT3.Text = unPT3Num + "/" + unPT3FileNum;//PT支管连接接头
}
else
{
this.lblUnPT3.Text = "/";
}
#endregion
}
#endregion
#region
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, GridSortEventArgs e)
{
Grid1.SortDirection = e.SortDirection;
Grid1.SortField = e.SortField;
BindGrid();
}
#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();
}
#endregion
#region
/// <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();
}
#endregion
#region
/// <summary>
/// 项目下拉选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpProjectId_SelectedIndexChanged(object sender, EventArgs e)
{
this.InitTreeMenu();
}
#endregion
#region
///// <summary>
///// 获取RT/UT 合格/不合格
///// </summary>
///// <param name="result"></param>
///// <returns></returns>
//protected string ConvertRTUTResult(object result)
//{
// string rtutResult = string.Empty;
// if (result != null)
// {
// if (result.ToString() == "2")
// {
// rtutResult = "合格";
// }
// else if (result.ToString() == "4")
// {
// rtutResult = "不合格";
// }
// else if (result.ToString() == "2/4")
// {
// rtutResult = "合格/不合格";
// }
// else if (result.ToString() == "4/2")
// {
// rtutResult = "不合格/合格";
// }
// else
// {
// rtutResult = "";
// }
// }
// return rtutResult;
//}
///// <summary>
///// 获取MT/PT合格/不合格
///// </summary>
///// <param name="result"></param>
///// <returns></returns>
//protected string ConvertMTPTResult(object result)
//{
// string mtptResult = string.Empty;
// if (result != null)
// {
// if (result.ToString() == "2")
// {
// mtptResult = "合格";
// }
// else if (result.ToString() == "4")
// {
// mtptResult = "不合格";
// }
// else if (result.ToString() == "2/4")
// {
// mtptResult = "合格/不合格";
// }
// else
// {
// mtptResult = "";
// }
// }
// return mtptResult;
//}
#endregion
#region
/// <summary>
/// 打印
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnPrint_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
{
string bathcId = this.tvControlItem.SelectedNodeID;
if (bathcId != null)
{
string projectId = this.tvControlItem.SelectedNode.ParentNode.NodeID;//项目ID
string reportId = projectId + "|" + bathcId;
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ProjectId", projectId));
listStr.Add(new SqlParameter("@BatchId", bathcId));
listStr.Add(new SqlParameter("@Flag", "0"));
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = BLL.SQLHelper.GetDataTableRunProc("HJGL_sp_CheckResultSummaryByBatch", parameter);
string pageNum = Funs.GetPagesCountByPageSize(5, 14, tb.Rows.Count).ToString();
string projectName = BLL.Base_ProjectService.GetProjectByProjectId(projectId).ProjectName;
string projectCode = BLL.Base_ProjectService.GetProjectByProjectId(projectId).ProjectCode;
string varValue = string.Empty;
string supervisionUnit = this.txtSupervisionUnit.Text.Trim();//监理单位
//V_Name6-V_Name15
string hg = this.lblRT1.Text.Trim() + "|" + this.lblUT1.Text.Trim() + "|" + this.lblMT1.Text.Trim() + "|" + this.lblPT1.Text.Trim() + "|" + this.lblMT2.Text.Trim() + "|" + this.lblPT2.Text.Trim() + "|" + this.lblRT3.Text.Trim() + "|" + this.lblUT3.Text.Trim() + "|" + this.lblMT3.Text.Trim() + "|" + this.lblPT3.Text.Trim();
////V_Name16-V_Name25
string bhg = this.lblUnRT1.Text.Trim() + "|" + this.lblUnUT1.Text.Trim() + "|" + this.lblUnMT1.Text.Trim() + "|" + this.lblUnPT1.Text.Trim() + "|" + this.lblUnMT2.Text.Trim() + "|" + this.lblUnPT2.Text.Trim() + "|" + this.lblUnRT3.Text.Trim() + "|" + this.lblUnUT3.Text.Trim() + "|" + this.lblUnMT3.Text.Trim() + "|" + this.lblUnPT3.Text.Trim();
var installation = (from x in Funs.DB.Project_Installation where x.ProjectId == projectId select x.InstallationCode).FirstOrDefault();
var installationCode = installation;//单位工程 V_Name26
string unitName = "镇海石化建安工程有限公司"; //施工单位 V_Name27
var testingStandard = this.txtTestingStandard.Text.Trim();//检测标准 V_Name28
var workArea = installation;//区号 V_Name29
var reportDate = DateTime.Now.ToShortDateString();//报告日期 V_Name30
varValue = pageNum + "|" + projectName + "|" + supervisionUnit + "|" + "NULL" + "|" + "NULL" + "|" + hg + "|" + bhg + "|" + installationCode + "|" + unitName + "|" + testingStandard + "|" + workArea + "|" + reportDate + "|" + projectCode;
varValue = HttpUtility.UrlEncodeUnicode(varValue);
if (tb.Rows.Count <= 5)
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", BLL.Const.HJGL_NDTSummaryByBatchReportId1, reportId, varValue, "打印 - ")));
}
else
{
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", BLL.Const.HJGL_NDTSummaryByBatchReportId2, reportId, varValue, "打印 - ")));
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", BLL.Const.HJGL_NDTSummaryByBatchReportId1, reportId, varValue, "打印 - ")));
}
}
}
else
{
ShowNotify("请选择要打印的汇总表!", MessageBoxIcon.Warning);
return;
}
}
#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;
Response.Write(GetGridTableHtml(Grid1));
Response.End();
}
/// <summary>
/// 导出方法
/// </summary>
/// <param name="grid"></param>
/// <returns></returns>
private string GetGridTableHtml(Grid grid)
{
StringBuilder sb = new StringBuilder();
grid.PageSize = 100000;
BindGrid();
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)
{
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")
{
html = (row.FindControl("labNumber") as AspNet.Label).Text;
}
sb.AppendFormat("<td>{0}</td>", html);
}
sb.Append("</tr>");
}
sb.Append("</table>");
return sb.ToString();
}
#endregion
}
}