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.PublicInfo.ProcessControl { public partial class WeldNoHandle : PageBase { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindGrid2(); } } #region 选项卡改变事件 /// /// 选项卡改变事件 /// /// /// protected void TabStrip1_TabIndexChanged(object sender, EventArgs e) { if (this.TabStrip1.ActiveTabIndex == 0) { BindGrid2(); } else if (this.TabStrip1.ActiveTabIndex == 1) { BindGrid1(); } else if (this.TabStrip1.ActiveTabIndex == 2) { BindGrid3(); } } #endregion #region 数据绑定 /// /// Grid2数据绑定 /// /// private void BindGrid1() { string strSql = @"SELECT pro.ProjectCode,pipe.PipelineCode,jot.WeldJointCode, CONVERT(VARCHAR(100) ,batchItem.PointDate,23)AS PointDate,'' AS Remark FROM dbo.Batch_PointBatchItem batchItem LEFT JOIN dbo.Pipeline_WeldJoint jot ON jot.WeldJointId = batchItem.WeldJointId LEFT JOIN dbo.Batch_BatchTrustItem trustItem ON trustItem.PointBatchItemId = batchItem.PointBatchItemId LEFT JOIN dbo.Pipeline_Pipeline pipe ON pipe.PipelineId = jot.PipelineId LEFT JOIN dbo.Base_Project pro on pro.ProjectId = jot.ProjectId WHERE batchItem.PointState IS NOT NULL AND trustItem.TrustBatchItemId IS NULL "; List listStr = new List(); if (!string.IsNullOrEmpty(txtProjectCode1.Text)) { strSql += " AND pro.ProjectCode LIKE @ProjectCode"; listStr.Add(new SqlParameter("@ProjectCode", "%" + txtProjectCode1.Text.Trim() + "%")); } if (!string.IsNullOrEmpty(txtIsoNo.Text)) { strSql += " AND pipe.PipelineCode LIKE @PipelineCode"; listStr.Add(new SqlParameter("@PipelineCode", "%" + txtIsoNo.Text.Trim() + "%")); } strSql += " ORDER BY pro.ProjectCode,batchItem.PointDate,pipe.PipelineCode DESC"; SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); Grid1.RecordCount = tb.Rows.Count; var table = this.GetPagedDataTable(Grid1, tb); Grid1.DataSource = table; Grid1.DataBind(); } private void BindGrid2() { string strSql = @"SELECT p.PointBatchId,p.PointBatchCode,p.ProjectId,pro.ProjectCode, CONVERT(VARCHAR(100) ,p.StartDate,23)AS StartDate,'' AS Remark FROM dbo.Batch_PointBatch p LEFT JOIN dbo.Base_Project pro ON pro.ProjectId = p.ProjectId WHERE (SELECT COUNT(*) FROM dbo.Batch_PointBatchItem item WHERE item.PointBatchId=p.PointBatchId AND item.PointDate IS NOT NULL )=0 "; List listStr = new List(); if (!string.IsNullOrEmpty(txtProjectCode.Text)) { strSql += " AND pro.ProjectCode LIKE @ProjectCode"; listStr.Add(new SqlParameter("@ProjectCode", "%" + txtProjectCode.Text.Trim() + "%")); } strSql += " ORDER BY pro.ProjectCode, p.StartDate DESC"; SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); Grid2.RecordCount = tb.Rows.Count; var table = this.GetPagedDataTable(Grid2, tb); Grid2.DataSource = table; Grid2.DataBind(); } private void BindGrid3() { string strSql = @"SELECT pro.ProjectCode, trust.TrustBatchCode, ''AS Remark, pipe.PipelineCode,jot.WeldJointCode,CONVERT(VARCHAR(100) ,trust.TrustDate,23)AS TrustDate FROM Batch_BatchTrustItem trustItem LEFT JOIN dbo.Batch_BatchTrust trust ON trust.TrustBatchId = trustItem.TrustBatchId LEFT JOIN dbo.Pipeline_WeldJoint jot ON jot.WeldJointId = trustItem.WeldJointId LEFT JOIN dbo.Batch_NDEItem ndtItem ON ndtItem.TrustBatchItemId = trustItem.TrustBatchItemId LEFT JOIN dbo.Pipeline_Pipeline pipe ON pipe.PipelineId = jot.PipelineId LEFT JOIN dbo.Base_Project pro ON pro.ProjectId = jot.ProjectId WHERE (ndtItem.NDEItemID IS NULL OR (ndtItem.NDEItemID IS NOT NULL AND ndtItem.NDEReportNo IS NULL)) AND (trustItem.IsCancelTrust IS NULL OR trustItem.IsCancelTrust=0)"; List listStr = new List(); if (!string.IsNullOrEmpty(txtProjectCode3.Text)) { strSql += " AND pro.ProjectCode LIKE @ProjectCode"; listStr.Add(new SqlParameter("@ProjectCode", "%" + txtProjectCode3.Text.Trim() + "%")); } if (!string.IsNullOrEmpty(txtIsoNo3.Text)) { strSql += " AND pipe.PipelineCode LIKE @PipelineCode"; listStr.Add(new SqlParameter("@PipelineCode", "%" + txtIsoNo3.Text.Trim() + "%")); } strSql += " ORDER BY pro.ProjectCode, pipe.PipelineCode,trust.TrustDate DESC"; SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); Grid3.RecordCount = tb.Rows.Count; var table = this.GetPagedDataTable(Grid3, tb); Grid3.DataSource = table; Grid3.DataBind(); } #endregion protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { Grid1.PageIndex = e.NewPageIndex; BindGrid1(); } protected void drpPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(drpPageSize.SelectedValue); BindGrid1(); } protected void Grid2_PageIndexChange(object sender, GridPageEventArgs e) { Grid2.PageIndex = e.NewPageIndex; BindGrid2(); } protected void Grid3_PageIndexChange(object sender, GridPageEventArgs e) { Grid3.PageIndex = e.NewPageIndex; BindGrid3(); } protected void drpPageSize2_SelectedIndexChanged(object sender, EventArgs e) { Grid2.PageSize = Convert.ToInt32(drpPageSize.SelectedValue); BindGrid2(); } protected void drpPageSize3_SelectedIndexChanged(object sender, EventArgs e) { Grid3.PageSize = Convert.ToInt32(drpPageSize.SelectedValue); BindGrid3(); } #region 查询 ///查询 protected void btnSearch_Click(object sender, EventArgs e) { BindGrid1(); } protected void btnSearch2_Click(object sender, EventArgs e) { BindGrid2(); } protected void btnSearch3_Click(object sender, EventArgs e) { BindGrid3(); } #endregion #region 导出按钮 /// 导出按钮 /// /// /// protected void btnOut1_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,"1")); Response.End(); } protected void btnOut2_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(Grid2, "2")); Response.End(); } protected void btnOut3_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(Grid3, "3")); Response.End(); } /// /// 导出方法 /// /// /// private string GetGridTableHtml(Grid grid, string no) { StringBuilder sb = new StringBuilder(); grid.PageSize = 10000; if (no == "1") { BindGrid1(); } if (no == "2") { BindGrid2(); } if (no == "3") { BindGrid3(); } sb.Append(""); sb.Append(""); sb.Append(""); foreach (GridColumn column in grid.Columns) { sb.AppendFormat("", column.HeaderText); } sb.Append(""); foreach (GridRow row in grid.Rows) { sb.Append(""); foreach (GridColumn column in grid.Columns) { string html = row.Values[column.ColumnIndex].ToString(); sb.AppendFormat("", html); } sb.Append(""); } sb.Append("
{0}
{0}
"); return sb.ToString(); } #endregion } }