250 lines
9.1 KiB
C#
250 lines
9.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Text;
|
|
using BLL;
|
|
using System.Linq;
|
|
using Newtonsoft.Json.Linq;
|
|
using AspNet = System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.HJGL.HotProessManage
|
|
{
|
|
public partial class HotProessHardSelect : PageBase
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
|
|
///项目
|
|
this.drpProject.DataTextField = "ProjectCode";
|
|
this.drpProject.DataValueField = "ProjectId";
|
|
this.drpProject.DataSource = BLL.Base_ProjectService.GetOnProjectListByUserId(this.CurrUser.UserId, "1");
|
|
this.drpProject.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpProject);
|
|
this.drpProject.SelectedValue = this.CurrUser.LoginProjectId;
|
|
|
|
|
|
drpProessTypes.DataTextField = "Name";
|
|
drpProessTypes.DataValueField = "Id";
|
|
drpProessTypes.DataSource = BLL.HJGL_PW_JointInfoService.GetProessTypes();
|
|
drpProessTypes.DataBind();
|
|
Funs.FineUIPleaseSelect(drpProessTypes);
|
|
}
|
|
}
|
|
|
|
#region 绑定数据
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
string strSql = string.Empty;
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
if (this.drpProject.SelectedValue != BLL.Const._Null)
|
|
{
|
|
strSql = @"SELECT * "
|
|
+ @" FROM dbo.HJGL_View_CH_HotProessResult AS Result"
|
|
+ @" WHERE Result.ProjectId= @ProjectId ";
|
|
listStr.Add(new SqlParameter("@ProjectId", this.drpProject.SelectedValue));
|
|
}
|
|
else
|
|
{
|
|
strSql = @"SELECT * "
|
|
+ @" FROM dbo.HJGL_View_CH_HotProessResult AS Result WHERE 1=1 ";
|
|
}
|
|
if (this.drpProessTypes.SelectedValue != BLL.Const._Null)
|
|
{
|
|
strSql += " and Result.ProessTypes=@ProessTypes ";
|
|
listStr.Add(new SqlParameter("@ProessTypes", this.drpProessTypes.SelectedValue));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtSearchNo.Text.Trim()))
|
|
{
|
|
strSql += @" AND RecordChartNo like @RecordChartNo";
|
|
listStr.Add(new SqlParameter("@RecordChartNo", "%" + this.txtSearchNo.Text.Trim() + "%"));
|
|
}
|
|
|
|
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 TextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 分页
|
|
/// <summary>
|
|
/// 分页
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页显示条数下拉框
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.Grid1.PageSize = Convert.ToInt32(this.ddlPageSize.SelectedValue);
|
|
this.BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 统计按钮事件
|
|
/// <summary>
|
|
/// 统计
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void BtnAnalyse_Click(object sender, EventArgs e)
|
|
{
|
|
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;
|
|
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\"/><html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">");
|
|
sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">");
|
|
sb.Append("<tr>");
|
|
this.Grid1.PageSize = 20000;
|
|
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();
|
|
if (column.ColumnID == "ProessTypes")
|
|
{
|
|
html = (row.FindControl("lbProessTypes") as AspNet.Label).Text;
|
|
}
|
|
if (column.ColumnID == "HardResultDate")
|
|
{
|
|
html = (row.FindControl("lbHardResultDate") as AspNet.Label).Text;
|
|
}
|
|
if (column.ColumnID == "ISO_IsoNo")
|
|
{
|
|
sb.AppendFormat("<td x:str>{0}</td>", html);
|
|
}
|
|
else
|
|
{
|
|
sb.AppendFormat("<td>{0}</td>", html);
|
|
}
|
|
}
|
|
sb.Append("</tr>");
|
|
}
|
|
|
|
sb.Append("</table>");
|
|
|
|
return sb.ToString();
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 得到热处理类型
|
|
/// </summary>
|
|
/// <param name="bigType"></param>
|
|
/// <returns></returns>
|
|
protected string ConvertProessTypes(object ProessTypes)
|
|
{
|
|
string proessTypes = string.Empty;
|
|
if (ProessTypes != null)
|
|
{
|
|
proessTypes = BLL.HJGL_PW_JointInfoService.ConvertProessTypes(ProessTypes.ToString());
|
|
}
|
|
|
|
return proessTypes;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 得到硬度检测结果
|
|
/// </summary>
|
|
/// <param name="bigType"></param>
|
|
/// <returns></returns>
|
|
protected string ConvertHardResultDate(object HotProessResultId)
|
|
{
|
|
string result = string.Empty;
|
|
if (HotProessResultId != null)
|
|
{
|
|
Model.HJGL_CH_HotProessResult hotProessResult = BLL.HJGL_CH_HotProessResultService.GetHotProessResultByID(HotProessResultId.ToString());
|
|
if (hotProessResult != null && hotProessResult.ProessTypes.Contains("4"))
|
|
{
|
|
Model.HJGL_CH_HardTestReportItem hardTestReportItem = Funs.DB.HJGL_CH_HardTestReportItem.FirstOrDefault(x => x.HotProessTrustId == hotProessResult.HotProessTrustId && x.JOT_ID == hotProessResult.JOT_ID);
|
|
if (hardTestReportItem != null)
|
|
{
|
|
Model.HJGL_CH_HardTestResult hardTestResult = Funs.DB.HJGL_CH_HardTestResult.FirstOrDefault(x => x.HardTestReportId == hardTestReportItem.HardTestReportId && x.JOT_ID == hardTestReportItem.JOT_ID);
|
|
if (hardTestResult != null)
|
|
{
|
|
result = hardTestResult.ResultDate != null ? hardTestResult.ResultDate.Value.ToString() : "";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
} |