20250908 焊接统计分析表
This commit is contained in:
@@ -0,0 +1,401 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Data;
|
||||
using BLL;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using AspNet = System.Web.UI.WebControls;
|
||||
|
||||
namespace FineUIPro.Web.HJGL.WeldingReport
|
||||
{
|
||||
public partial class WeldingStatistical : 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.DataTextField = "UnitName";
|
||||
// this.drpUnit.DataValueField = "UnitId";
|
||||
// this.drpUnit.DataSource = units;
|
||||
// this.drpUnit.DataBind();
|
||||
// this.drpUnit.SelectedValue = CurrUser.UnitId;
|
||||
// Funs.FineUIPleaseSelect(this.drpUnit);
|
||||
// Funs.FineUIPleaseSelect(this.drpInstallation);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// units = BLL.UnitService.GetSubUnitsListBySupervisorUnitId(this.CurrUser.LoginProjectId, 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.WeldingStatisticalMenuId);
|
||||
//if (c != null)
|
||||
//{
|
||||
// this.GetShowColumn(c.Columns);
|
||||
//}
|
||||
//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.drpInstallation.SelectedValue != BLL.Const._Null)
|
||||
{
|
||||
listStr.Add(new SqlParameter("@installationId", this.drpInstallation.SelectedValue));
|
||||
}
|
||||
else
|
||||
{
|
||||
listStr.Add(new SqlParameter("@installationId", null));
|
||||
}
|
||||
if (this.drpWorkArea.SelectedValue != BLL.Const._Null)
|
||||
{
|
||||
listStr.Add(new SqlParameter("@AreaNo", this.drpWorkArea.SelectedValue));
|
||||
}
|
||||
else
|
||||
{
|
||||
listStr.Add(new SqlParameter("@AreaNo", null));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(this.txtStarTime.Text))
|
||||
{
|
||||
listStr.Add(new SqlParameter("@startTime", this.txtStarTime.Text.Trim()));
|
||||
}
|
||||
else
|
||||
{
|
||||
listStr.Add(new SqlParameter("@startTime", null));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(this.txtEndTime.Text))
|
||||
{
|
||||
listStr.Add(new SqlParameter("@endTime", this.txtEndTime.Text.Trim()));
|
||||
}
|
||||
else
|
||||
{
|
||||
listStr.Add(new SqlParameter("@endTime", 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.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 (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_WeldingStatistical", parameter);
|
||||
this.Grid1.RecordCount = tb.Rows.Count;
|
||||
var table = this.GetPagedDataTable(Grid1, tb);
|
||||
Grid1.DataSource = table;
|
||||
Grid1.DataBind();
|
||||
}
|
||||
|
||||
/// <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
|
||||
|
||||
/// <summary>
|
||||
/// 全部行合计
|
||||
/// </summary>
|
||||
private void OutputSummaryData()
|
||||
{
|
||||
if (tb != null)
|
||||
{
|
||||
int total_jot = 0;
|
||||
double total_din = 0.0f;
|
||||
double finished_total_din_bq = 0.0f;
|
||||
double RemainingDain = 0.0f;
|
||||
double AvgDayCompletedDin = 0.0f;
|
||||
foreach (DataRow row in tb.Rows)
|
||||
{
|
||||
total_jot += Convert.ToInt32(row["total_jot"]);
|
||||
total_din += Convert.ToDouble(row["total_din"]);
|
||||
finished_total_din_bq += Convert.ToDouble(row["finished_total_din_bq"]);
|
||||
RemainingDain += Convert.ToDouble(row["RemainingDain"]);
|
||||
AvgDayCompletedDin += Convert.ToDouble(row["AvgDayCompletedDin"]);
|
||||
}
|
||||
|
||||
JObject summary = new JObject
|
||||
{
|
||||
{ "tfNumber", "合计" },
|
||||
{ "total_jot", total_jot.ToString() },
|
||||
{ "total_din", total_din.ToString("F2") },
|
||||
{ "finished_total_din_bq", finished_total_din_bq.ToString("F2") },
|
||||
{ "RemainingDain",RemainingDain.ToString("F2") },
|
||||
{ "AvgDayCompletedDin", AvgDayCompletedDin.ToString("F2") },
|
||||
};
|
||||
|
||||
Grid1.SummaryData = summary;
|
||||
}
|
||||
}
|
||||
|
||||
#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.WeldingStatisticalMenuId, "显示列 - ")));
|
||||
//}
|
||||
|
||||
//protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
||||
//{
|
||||
// this.BindGrid();
|
||||
// // 显示列
|
||||
// Model.Sys_UserShowColumns c = BLL.UserShowColumnsService.GetColumnsByUserId(this.CurrUser.UserId, BLL.Const.WeldingStatisticalMenuId);
|
||||
// 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();
|
||||
OutputSummaryData();
|
||||
}
|
||||
#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;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void drpInstallation_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.drpWorkArea.Items.Clear();
|
||||
if (this.drpInstallation.SelectedValue != BLL.Const._Null)
|
||||
{
|
||||
WorkAreaService.InitWorkAreaByProjectIdAndInstallationId(this.drpWorkArea, this.CurrUser.LoginProjectId, this.drpInstallation.SelectedValue, true);
|
||||
}else
|
||||
{
|
||||
Funs.FineUIPleaseSelect(this.drpWorkArea);
|
||||
}
|
||||
this.drpWorkArea.SelectedValue = BLL.Const._Null;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user