173 lines
5.9 KiB
C#
173 lines
5.9 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Text;
|
|
using AspNet = System.Web.UI.WebControls;
|
|
using BLL;
|
|
using System.Diagnostics;
|
|
|
|
namespace FineUIPro.Web.Welder
|
|
{
|
|
public partial class FilmInfoQuery : PageBase
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|
|
|
var unit = (from x in Funs.DB.HJGL_BO_QualityRating
|
|
join y in Funs.DB.HJGL_PW_JointInfo on x.JOT_ID equals y.JOT_ID
|
|
join z in Funs.DB.HJGL_PW_IsoInfo on y.ISO_ID equals z.ISO_ID
|
|
join u in Funs.DB.Base_Unit on z.BSU_ID equals u.UnitId
|
|
select new { u.UnitId, u.UnitName }).ToList().Distinct();
|
|
///单位
|
|
this.drpUnit.DataTextField = "UnitName";
|
|
this.drpUnit.DataValueField = "UnitId";
|
|
this.drpUnit.DataSource = unit;
|
|
this.drpUnit.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpUnit);
|
|
|
|
txtStartDate.SelectedDate = DateTime.Now.AddDays(-30).Date;
|
|
txtEndDate.SelectedDate = DateTime.Now.Date;
|
|
// 绑定表格
|
|
BindGrid();
|
|
}
|
|
}
|
|
|
|
private void BindGrid()
|
|
{
|
|
List<SqlParameter> listStr = new List<SqlParameter>
|
|
{
|
|
/* new SqlParameter("@pageIndex", Grid1.PageIndex+1),
|
|
new SqlParameter("@pageSize", Grid1.PageSize)*/
|
|
};
|
|
if (this.drpUnit.SelectedValue != BLL.Const._Null)
|
|
{
|
|
listStr.Add(new SqlParameter("@unitId", this.drpUnit.SelectedValue));
|
|
}
|
|
else
|
|
{
|
|
listStr.Add(new SqlParameter("@unitId", null));
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrEmpty(this.txtStartDate.Text.Trim()))
|
|
{
|
|
listStr.Add(new SqlParameter("@date1", this.txtStartDate.Text.Trim()));
|
|
}
|
|
else
|
|
{
|
|
listStr.Add(new SqlParameter("@date1", null));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtEndDate.Text.Trim()))
|
|
{
|
|
listStr.Add(new SqlParameter("@date2", this.txtEndDate.Text.Trim()));
|
|
}
|
|
else
|
|
{
|
|
listStr.Add(new SqlParameter("@date2", null));
|
|
}
|
|
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
Stopwatch sw = new Stopwatch();
|
|
|
|
sw.Start();
|
|
|
|
|
|
DataTable tb = SQLHelper.GetDataTableRunProc("HJGL_sp_FilmInfo", parameter);
|
|
this.Grid1.RecordCount = tb.Rows.Count;
|
|
tb = GetFilteredTable(Grid1.FilteredData, tb);
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
sw.Stop();
|
|
TimeSpan dt = sw.Elapsed;
|
|
}
|
|
|
|
#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
|
|
|
|
protected void BtnQuery_Click(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
|
|
#region 导出按钮
|
|
/// 导出按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnExport_Click(object sender, EventArgs e)
|
|
{
|
|
Response.ClearContent();
|
|
string filename = Funs.GetNewFileName();
|
|
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("RT拍片信息" + 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();
|
|
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>");
|
|
this.Grid1.PageSize = 100000;
|
|
BindGrid();
|
|
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();
|
|
sb.AppendFormat("<td>{0}</td>", html);
|
|
}
|
|
|
|
sb.Append("</tr>");
|
|
}
|
|
|
|
sb.Append("</table>");
|
|
|
|
return sb.ToString();
|
|
}
|
|
#endregion
|
|
}
|
|
} |