328 lines
12 KiB
C#
328 lines
12 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.Runtime.InteropServices;
|
||
|
||
namespace FineUIPro.Web.DataShow
|
||
{
|
||
public partial class LargeEngineering : PageBase
|
||
{
|
||
#region 项目主键
|
||
/// <summary>
|
||
/// 项目主键
|
||
/// </summary>
|
||
public string ProjectId
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["ProjectId"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["ProjectId"] = value;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#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);
|
||
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
||
//BLL.ProjectService.InitProjectDropDownList(this.drpProject, true);
|
||
LargerHazard = (from x in Funs.DB.Solution_LargerHazard
|
||
join y in Funs.DB.Base_Project on x.ProjectId equals y.ProjectId
|
||
where y.ProjectState == Const.ProjectState_1 && x.RecordTime > Funs.minSysDate
|
||
select x).ToList();
|
||
// 绑定表格t
|
||
BindGrid();
|
||
// 合计
|
||
OutputSummaryData();
|
||
this.Panel1.Title = "危大工程数据(" + BLL.UnitService.GetUnitNameByUnitId(BLL.CommonService.GetThisUnitId()) + ")";
|
||
}
|
||
}
|
||
private List<Model.LargeEngineeringOutput> model = new List<Model.LargeEngineeringOutput>();
|
||
public static List<Model.Solution_LargerHazard> LargerHazard = new List<Model.Solution_LargerHazard>();
|
||
protected void changeTree(object sender, EventArgs e)
|
||
{
|
||
|
||
this.ProjectId = this.ucTree.ProjectId;
|
||
this.BindGrid();
|
||
}
|
||
/// <summary>
|
||
/// 绑定数据
|
||
/// </summary>
|
||
private void BindGrid()
|
||
{
|
||
model = HSSEData_HSSEService.GetLargeEngineeringOutputs();
|
||
|
||
//if (this.drpProject.SelectedValue != Const._Null)
|
||
//{
|
||
// model = model.Where(x => x.ProjectId == this.drpProject.SelectedValue).ToList();
|
||
//}
|
||
if (!string.IsNullOrEmpty(this.ucTree.SelectedNodeID))
|
||
{
|
||
if (!string.IsNullOrEmpty(this.ucTree.ProjectId))
|
||
{
|
||
model = model.Where(x => x.ProjectId == this.ucTree.ProjectId).ToList();
|
||
}
|
||
else
|
||
{
|
||
var BeUnderConstructionList = ProjectService.GetProjectWorkList().Where(x => (x.ProjectAttribute == "GONGCHENG" || x.ProjectAttribute == null) && x.UnitId == this.ucTree.UnitId).Select(x => x.ProjectId).ToList();
|
||
model = model.Where(x => BeUnderConstructionList.Contains(x.ProjectId)).ToList();
|
||
|
||
}
|
||
}
|
||
Grid1.RecordCount = model.Count;
|
||
Grid1.DataSource = this.GetPagedDataTable(Grid1, Funs.LINQToDataTable(model.OrderBy(x => x.ProjectId).ThenBy(x => x.UnitName)));
|
||
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)
|
||
{
|
||
BindGrid();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 排序
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Grid1_Sort(object sender, GridSortEventArgs 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 Window1_Close(object sender, WindowCloseEventArgs e)
|
||
{
|
||
BindGrid();
|
||
}
|
||
#endregion
|
||
|
||
#region Grid双击事件 编辑
|
||
/// <summary>
|
||
/// Grid行双击事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
||
{
|
||
EditData();
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
private void EditData()
|
||
{
|
||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||
{
|
||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
|
||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("LargeEngineeringItem.aspx?projectId={0}", Grid1.SelectedRowID, "查看 - ")));
|
||
}
|
||
#endregion
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnView_Click(object sender, EventArgs e)
|
||
{
|
||
EditData();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取危大工程数
|
||
/// </summary>
|
||
/// <param name="state"></param>
|
||
/// <returns></returns>
|
||
protected int Count1(object projectId)
|
||
{
|
||
int cout1 = 0;
|
||
if (projectId != null)
|
||
{
|
||
cout1 = LargerHazard.Where(x => x.ProjectId == projectId.ToString() && x.IsSuperLargerHazard == false ).Count();
|
||
}
|
||
return cout1;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取超危大工程数
|
||
/// </summary>
|
||
/// <param name="state"></param>
|
||
/// <returns></returns>
|
||
protected int Count2(object projectId)
|
||
{
|
||
int cout1 = 0;
|
||
if (projectId != null)
|
||
{
|
||
cout1 = LargerHazard.Where(x => x.ProjectId == projectId.ToString() && x.IsSuperLargerHazard == true).Count();
|
||
}
|
||
return cout1;
|
||
}
|
||
/// <summary>
|
||
/// 在施危大工程数量
|
||
/// </summary>
|
||
/// <param name="state"></param>
|
||
/// <returns></returns>
|
||
protected int Count3(object projectId)
|
||
{
|
||
int cout1 = 0;
|
||
if (projectId != null)
|
||
{
|
||
cout1 = LargerHazard.Where(x => x.ProjectId == projectId.ToString() && x.States == Const.State_2).Count();
|
||
}
|
||
return cout1;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 审批完成数量
|
||
/// </summary>
|
||
/// <param name="state"></param>
|
||
/// <returns></returns>
|
||
protected int Count4(object projectId)
|
||
{
|
||
int cout1 = 0;
|
||
if (projectId != null)
|
||
{
|
||
cout1 = LargerHazard.Where(x => x.ProjectId == projectId.ToString() && x.States == Const.State_1).Count();
|
||
}
|
||
return cout1;
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 培训人次数
|
||
/// </summary>
|
||
/// <param name="state"></param>
|
||
/// <returns></returns>
|
||
protected int Count5(object projectId)
|
||
{
|
||
int cout1 = 0;
|
||
if (projectId != null)
|
||
{
|
||
cout1 = LargerHazard.Where(x => x.ProjectId == projectId.ToString()).Sum(x => x.TrainPersonNum ?? 0);
|
||
}
|
||
return cout1;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 完工个数
|
||
/// </summary>
|
||
/// <param name="state"></param>
|
||
/// <returns></returns>
|
||
protected int Count6(object projectId)
|
||
{
|
||
int cout1 = 0;
|
||
if (projectId != null)
|
||
{
|
||
cout1 = LargerHazard.Where(x => x.ProjectId == projectId.ToString() && x.States == Const.State_3).Count();
|
||
}
|
||
return cout1;
|
||
}
|
||
|
||
#region 合计
|
||
private void OutputSummaryData2()
|
||
{
|
||
string strSql = @"select P.ProjectId,P.ProjectCode, P.ProjectName,
|
||
isnull((select count(*) from Solution_LargerHazard as a where a.ProjectId=P.ProjectId and a.IsSuperLargerHazard=0 ),0) as Count1,
|
||
isnull((select count(*) from Solution_LargerHazard as b where b.ProjectId=P.ProjectId and b.IsSuperLargerHazard=1 ),0) as Count2,
|
||
isnull((select count(*) from Solution_LargerHazard as c where c.ProjectId=P.ProjectId and c.States='2' ),0) as Count3,
|
||
isnull((select count(*) from Solution_LargerHazard as d where d.ProjectId=P.ProjectId and d.States='1' ),0) as Count4,
|
||
isnull((select sum(TrainPersonNum) from Solution_LargerHazard as e where e.ProjectId=P.ProjectId ),0) as Count5,
|
||
isnull((select count(*) from Solution_LargerHazard as f where f.ProjectId=P.ProjectId and f.States='3' ),0) as Count6
|
||
from Base_Project AS P
|
||
where ProjectState =1 and (isDelete IS NULL OR isDelete =0) ";
|
||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||
SqlParameter[] parameter = listStr.ToArray();
|
||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||
int Count1 = 0, Count2 = 0, Count3 = 0, Count4 = 0, Count5 = 0, Count6 = 0;
|
||
foreach (DataRow row in tb.Rows)
|
||
{
|
||
Count1 += Convert.ToInt32(row["Count1"]);
|
||
Count2 += Convert.ToInt32(row["Count2"]);
|
||
Count3 += Convert.ToInt32(row["Count3"]);
|
||
Count4 += Convert.ToInt32(row["Count4"]);
|
||
Count5 += Convert.ToInt32(row["Count5"]);
|
||
Count6 += Convert.ToInt32(row["Count6"]);
|
||
}
|
||
JObject summary = new JObject();
|
||
summary.Add("ProjectName", "合计:");
|
||
summary.Add("Count1", Count1.ToString());
|
||
summary.Add("Count2", Count2.ToString());
|
||
summary.Add("Count3", Count3.ToString());
|
||
summary.Add("Count4", Count4.ToString());
|
||
summary.Add("Count5", Count5.ToString());
|
||
summary.Add("Count6", Count6.ToString());
|
||
Grid1.SummaryData = summary;
|
||
}
|
||
private void OutputSummaryData()
|
||
{
|
||
|
||
JObject summary = new JObject();
|
||
summary.Add("ProjectName", "合计:");
|
||
summary.Add("CompletedNum",model.Sum(x=>x.CompletedNum));
|
||
summary.Add("SuperCompletedNum", model.Sum(x => x.SuperCompletedNum));
|
||
summary.Add("ConstructionNum", model.Sum(x => x.ConstructionNum));
|
||
summary.Add("SuperConstructionNum", model.Sum(x => x.SuperConstructionNum));
|
||
summary.Add("FinishedNum", model.Sum(x => x.FinishedNum));
|
||
summary.Add("SuperFinishedNum", model.Sum(x => x.SuperFinishedNum));
|
||
summary.Add("TrainPersonNum", model.Sum(x => x.TrainPersonNum));
|
||
summary.Add("SuperTrainPersonNum", model.Sum(x => x.SuperTrainPersonNum));
|
||
Grid1.SummaryData = summary;
|
||
}
|
||
|
||
#endregion
|
||
}
|
||
} |