465 lines
19 KiB
C#
465 lines
19 KiB
C#
using BLL;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using AspNet = System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.HJGL.WeldingReport
|
|
{
|
|
public partial class UnitWorkAreaQuality :PageBase
|
|
{
|
|
#region 加载
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
Funs.DropDownPageSize(this.ddlPageSize);
|
|
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
|
|
List<Model.Base_Unit> units = new List<Model.Base_Unit>();
|
|
var pUnit = BLL.ProjectUnitService.GetProjectUnitByUnitIdProjectId(this.CurrUser.LoginProjectId, this.CurrUser.UnitId);
|
|
if (pUnit == null || pUnit.UnitType == Const.ProjectUnitType_1)
|
|
{
|
|
units = BLL.UnitService.GetUnitByProjectIdUnitTypeList(this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2);
|
|
//this.drpUnit.Enabled = false;
|
|
this.drpUnit.DataTextField = "UnitName";
|
|
this.drpUnit.DataValueField = "UnitId";
|
|
this.drpUnit.DataSource = units;
|
|
this.drpUnit.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpUnit);
|
|
Funs.FineUIPleaseSelect(this.drpInstallation);
|
|
}
|
|
else
|
|
{
|
|
units = BLL.UnitService.GetSubUnitsListBySupervisorUnitId(this.CurrUser.ProjectId, this.CurrUser.UnitId);
|
|
this.drpUnit.Enabled = false;
|
|
this.drpUnit.DataTextField = "UnitName";
|
|
this.drpUnit.DataValueField = "UnitId";
|
|
this.drpUnit.DataSource = units;
|
|
this.drpUnit.DataBind();
|
|
this.drpUnit.SelectedValue = CurrUser.UnitId;
|
|
Project_InstallationService.InitInstallationDropDownList(this.drpInstallation, this.CurrUser.LoginProjectId, true);
|
|
this.drpInstallation.SelectedValue = BLL.Const._Null;
|
|
}
|
|
///单位
|
|
Funs.FineUIPleaseSelect(this.drpWorkArea);
|
|
////钢材类型
|
|
this.drpSteType.DataTextField = "Text";
|
|
this.drpSteType.DataValueField = "Value";
|
|
this.drpSteType.DataSource = BLL.DropListService.HJGL_GetSteTypeList();
|
|
this.drpSteType.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpSteType);
|
|
|
|
//显示列
|
|
Model.Sys_UserShowColumns c = BLL.UserShowColumnsService.GetColumnsByUserId(this.CurrUser.UserId, Const.UnitAreaQualityMenuId);
|
|
if (c != null)
|
|
{
|
|
this.GetShowColumn(c.Columns);
|
|
}
|
|
BindGrid();
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 绑定BindGrid
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
private DataTable tb = null;
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
List<SqlParameter> listStr = new List<SqlParameter>
|
|
{
|
|
new SqlParameter("@projectId", this.CurrUser.LoginProjectId)
|
|
};
|
|
if (this.drpUnit.SelectedValue != BLL.Const._Null)
|
|
{
|
|
listStr.Add(new SqlParameter("@UnitNo", this.drpUnit.SelectedValue));
|
|
}
|
|
else
|
|
{
|
|
listStr.Add(new SqlParameter("@UnitNo", null));
|
|
}
|
|
if (this.drpWorkArea.SelectedValue != BLL.Const._Null)
|
|
{
|
|
listStr.Add(new SqlParameter("@areaNo", this.drpWorkArea.SelectedValue));
|
|
}
|
|
else
|
|
{
|
|
listStr.Add(new SqlParameter("@areaNo", null));
|
|
}
|
|
if (this.drpInstallation.SelectedValue != BLL.Const._Null)
|
|
{
|
|
listStr.Add(new SqlParameter("@installationId", this.drpInstallation.SelectedValue));
|
|
}
|
|
else
|
|
{
|
|
listStr.Add(new SqlParameter("@installationId", null));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtStarTime.Text))
|
|
{
|
|
listStr.Add(new SqlParameter("@date1", this.txtStarTime.Text.Trim()));
|
|
}
|
|
else
|
|
{
|
|
listStr.Add(new SqlParameter("@date1", null));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtEndTime.Text))
|
|
{
|
|
listStr.Add(new SqlParameter("@date2", this.txtEndTime.Text.Trim()));
|
|
}
|
|
else
|
|
{
|
|
listStr.Add(new SqlParameter("@date2", null));
|
|
}
|
|
if (this.drpSteType.SelectedValue!=BLL.Const._Null&&!string.IsNullOrEmpty(this.drpSteType.SelectedValue))
|
|
{
|
|
listStr.Add(new SqlParameter("@ste_steeltype", this.drpSteType.SelectedValue));
|
|
}
|
|
else
|
|
{
|
|
listStr.Add(new SqlParameter("@ste_steeltype", null));
|
|
}
|
|
if (BLL.WorkAreaService.IsSupervisor(this.CurrUser.UnitId, this.CurrUser.LoginProjectId))
|
|
{
|
|
listStr.Add(new SqlParameter("@supervisorUnitId", this.CurrUser.UnitId));
|
|
}
|
|
else
|
|
{
|
|
listStr.Add(new SqlParameter("@supervisorUnitId", null));
|
|
}
|
|
if (this.cb_IsStandard.SelectedIndexArray != null && this.cb_IsStandard.SelectedIndexArray.Length == 1)
|
|
{
|
|
listStr.Add(new SqlParameter("@IsStandard", this.cb_IsStandard.SelectedValueArray[0]));
|
|
}
|
|
else
|
|
{
|
|
listStr.Add(new SqlParameter("@IsStandard", null));
|
|
}
|
|
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
tb = SQLHelper.GetDataTableRunProc("sp_rpt_UnitWorkAreaQuality", parameter);
|
|
this.Grid1.RecordCount = tb.Rows.Count;
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
OutputSummaryData();
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 改变索引事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
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)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 计算合计
|
|
/// <summary>
|
|
/// 计算合计
|
|
/// </summary>
|
|
protected void OutputSummaryData()
|
|
{
|
|
if (tb != null)
|
|
{
|
|
int total_jotSum = 0;//总焊口数
|
|
int total_sjotSum = 0;
|
|
int total_fjotSum = 0;
|
|
int finished_total_jotSum = 0;
|
|
int finished_total_sjotSum = 0;
|
|
int finished_total_fjotSum = 0;
|
|
int current_total_filmSum = 0;
|
|
int current_pass_filmSum = 0;
|
|
int current_point_total_filmSum = 0;
|
|
int current_point_pass_filmSum = 0;
|
|
int current_ext_total_filmSum = 0;
|
|
int current_ext_pass_filmSum = 0;
|
|
int current_trust_count_totalSum = 0;
|
|
int current_check_count_totalSum = 0;
|
|
int total_filmSum = 0;
|
|
int pass_filmSum = 0;
|
|
int point_total_filmSum = 0;
|
|
int point_pass_filmSum = 0;
|
|
int ext_total_filmSum = 0;
|
|
int ext_pass_filmSum = 0;
|
|
int trust_count_totalSum = 0;
|
|
int point_count_totalSum = 0;
|
|
int extend_count_totalSum = 0;
|
|
int repair_count_totalSum = 0;
|
|
int trust_check_totalSum = 0;
|
|
foreach (DataRow row in tb.Rows)
|
|
{
|
|
total_jotSum += Funs.GetNewIntOrZero(row["total_jot"].ToString());
|
|
total_sjotSum += Funs.GetNewIntOrZero(row["total_sjot"].ToString());
|
|
total_fjotSum += Funs.GetNewIntOrZero(row["total_fjot"].ToString());
|
|
finished_total_jotSum += Funs.GetNewIntOrZero(row["finished_total_jot"].ToString());
|
|
finished_total_sjotSum += Funs.GetNewIntOrZero(row["finished_total_sjot"].ToString());
|
|
finished_total_fjotSum += Funs.GetNewIntOrZero(row["finished_total_fjot"].ToString());
|
|
current_total_filmSum += Funs.GetNewIntOrZero(row["current_total_film"].ToString());
|
|
current_pass_filmSum += Funs.GetNewIntOrZero(row["current_pass_film"].ToString());
|
|
current_point_total_filmSum += Funs.GetNewIntOrZero(row["current_point_total_film"].ToString());
|
|
current_point_pass_filmSum += Funs.GetNewIntOrZero(row["current_point_pass_film"].ToString());
|
|
current_ext_total_filmSum += Funs.GetNewIntOrZero(row["current_ext_total_film"].ToString());
|
|
current_ext_pass_filmSum += Funs.GetNewIntOrZero(row["current_ext_pass_film"].ToString());
|
|
current_trust_count_totalSum += Funs.GetNewIntOrZero(row["current_trust_count_total"].ToString());
|
|
current_check_count_totalSum += Funs.GetNewIntOrZero(row["current_check_count_total"].ToString());
|
|
total_filmSum += Funs.GetNewIntOrZero(row["total_film"].ToString());
|
|
pass_filmSum += Funs.GetNewIntOrZero(row["pass_film"].ToString());
|
|
point_total_filmSum += Funs.GetNewIntOrZero(row["point_total_film"].ToString());
|
|
point_pass_filmSum += Funs.GetNewIntOrZero(row["point_pass_film"].ToString());
|
|
ext_total_filmSum += Funs.GetNewIntOrZero(row["ext_total_film"].ToString());
|
|
ext_pass_filmSum += Funs.GetNewIntOrZero(row["ext_pass_film"].ToString());
|
|
trust_count_totalSum += Funs.GetNewIntOrZero(row["trust_count_total"].ToString());
|
|
point_count_totalSum += Funs.GetNewIntOrZero(row["point_count_total"].ToString());
|
|
extend_count_totalSum += Funs.GetNewIntOrZero(row["extend_count_total"].ToString());
|
|
repair_count_totalSum += Funs.GetNewIntOrZero(row["repair_count_total"].ToString());
|
|
trust_check_totalSum += Funs.GetNewIntOrZero(row["trust_check_total"].ToString());
|
|
}
|
|
|
|
JObject summary = new JObject
|
|
{
|
|
{ "tfNumber", "合计:" },
|
|
{ "total_jot", total_jotSum },
|
|
{ "total_sjot", total_sjotSum },
|
|
{ "total_fjot", total_fjotSum },
|
|
{ "finished_total_jot", finished_total_jotSum },
|
|
{ "finished_total_sjot", finished_total_sjotSum },
|
|
{ "finished_total_fjot", finished_total_fjotSum },
|
|
{ "current_total_film", current_total_filmSum },
|
|
{ "current_pass_film", current_pass_filmSum },
|
|
{ "current_point_total_film", current_point_total_filmSum },
|
|
{ "current_ext_total_film", current_ext_total_filmSum },
|
|
{ "current_ext_pass_film", current_ext_pass_filmSum },
|
|
{ "current_trust_count_total", current_trust_count_totalSum },
|
|
{ "current_check_count_total", current_check_count_totalSum },
|
|
{ "total_film", total_filmSum },
|
|
{ "pass_film", pass_filmSum },
|
|
{ "point_total_film", point_total_filmSum },
|
|
{ "point_pass_film", point_pass_filmSum },
|
|
{ "point_passreate", point_total_filmSum >0? (100.0*point_pass_filmSum/point_total_filmSum).ToString("###.#")+"%":""},
|
|
{ "ext_total_film", ext_total_filmSum },
|
|
{ "ext_pass_film", ext_pass_filmSum },
|
|
{ "trust_count_total", trust_count_totalSum },
|
|
{ "point_count_total", point_count_totalSum },
|
|
{ "extend_count_total", extend_count_totalSum },
|
|
{ "repair_count_total", repair_count_totalSum },
|
|
{ "trust_check_total", trust_check_totalSum }
|
|
};
|
|
Grid1.SummaryData = summary;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 选择要显示列
|
|
/// <summary>
|
|
/// 选择显示列
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSelectColumn_Click(object sender, EventArgs e)
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ShowColumn.aspx?menuId={0}", BLL.Const.UnitAreaQualityMenuId, "显示列 - ")));
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
// 显示列
|
|
var c = UserShowColumnsService.GetColumnsByUserId(this.CurrUser.UserId, Const.UnitAreaQualityMenuId);
|
|
if (c != null)
|
|
{
|
|
this.GetShowColumn(c.Columns);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 显示的列
|
|
/// </summary>
|
|
/// <param name="column"></param>
|
|
private void GetShowColumn(string column)
|
|
{
|
|
if (!string.IsNullOrEmpty(column))
|
|
{
|
|
for (int i = 0; i < Grid1.Columns.Count; i++)
|
|
{
|
|
this.Grid1.Columns[i].Hidden = true;
|
|
}
|
|
|
|
List<string> columns = column.Split(',').ToList();
|
|
foreach (var item in columns)
|
|
{
|
|
this.Grid1.Columns[Convert.ToInt32(item)].Hidden = false;
|
|
}
|
|
}
|
|
}
|
|
#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();
|
|
grid.PageSize = this.Grid1.RecordCount;
|
|
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 style=\"vnd.ms-excel.numberformat:@\" >{0}</td>", html);
|
|
}
|
|
|
|
sb.Append("</tr>");
|
|
}
|
|
var sumary = grid.SummaryData;
|
|
if (sumary != null)
|
|
{
|
|
foreach (GridColumn column in grid.Columns)
|
|
{
|
|
try
|
|
{
|
|
if (sumary.ContainsKey(column.ColumnID))
|
|
{
|
|
sb.AppendFormat("<td style=\"vnd.ms-excel.numberformat:@\" >{0}</td>", sumary.GetValue(column.ColumnID).ToString());
|
|
}
|
|
else
|
|
{
|
|
sb.AppendFormat("<td style=\"vnd.ms-excel.numberformat:@\" >{0}</td>", "");
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
sb.AppendFormat("<td style=\"vnd.ms-excel.numberformat:@\" >{0}</td>", "");
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
sb.Append("</table>");
|
|
|
|
return sb.ToString();
|
|
}
|
|
#endregion
|
|
|
|
#region 下拉选择事件
|
|
/// <summary>
|
|
/// 单位下拉选择事件
|
|
/// </summary>
|
|
/// <param name = "sender" ></ param >
|
|
/// < param name="e"></param>
|
|
protected void drpUnit_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.drpInstallation.Items.Clear(); ///装置
|
|
this.drpWorkArea.Items.Clear(); ///区域
|
|
|
|
Project_InstallationService.InitInstallationDropDownList(this.drpInstallation, this.CurrUser.LoginProjectId, true);
|
|
this.drpInstallation.SelectedValue = BLL.Const._Null;
|
|
|
|
Funs.FineUIPleaseSelect(this.drpWorkArea);
|
|
this.drpWorkArea.SelectedValue = BLL.Const._Null;
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void drpInstallation_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.drpWorkArea.Items.Clear();
|
|
WorkAreaService.InitWorkAreaProjectInstallUnitDropDownList(this.drpWorkArea, this.CurrUser.LoginProjectId, this.drpInstallation.SelectedValue, this.drpUnit.SelectedValue, true);
|
|
this.drpWorkArea.SelectedValue = BLL.Const._Null;
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
}
|
|
} |