This commit is contained in:
gaofei
2021-08-13 11:15:59 +08:00
parent 43acc57060
commit d8dff88c39
320 changed files with 37219 additions and 4678 deletions
@@ -19,7 +19,6 @@ namespace FineUIPro.Web.JDGL.CostAnalysis
{
if (!IsPostBack)
{
BLL.UnitService.InitUnitDropDownList(this.drpUnit, this.CurrUser.LoginProjectId, true);
BindChart();
InitTreeMenu();
}
@@ -28,7 +27,7 @@ namespace FineUIPro.Web.JDGL.CostAnalysis
#region
/// <summary>
/// 加载
/// 加载
/// </summary>
private void InitTreeMenu()
{
@@ -37,82 +36,17 @@ namespace FineUIPro.Web.JDGL.CostAnalysis
this.trWBS.ShowHeader = false;
this.trWBS.EnableIcons = true;
this.trWBS.AutoScroll = true;
var installations = from x in Funs.DB.Project_Installation where x.ProjectId == this.CurrUser.LoginProjectId && x.SuperInstallationId == "0" orderby x.InstallationCode select x;
foreach (var installation in installations)
this.trWBS.EnableSingleClickExpand = true;
var project = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId);
if (project != null)
{
TreeNode rootNode = new TreeNode();
rootNode.Text = installation.InstallationName;
rootNode.NodeID = installation.InstallationId;
rootNode.CommandName = "installation";
rootNode.CommandArgument = installation.UnitId;
rootNode.ToolTip = installation.InstallationCode;
rootNode.EnableClickEvent = true;
if (installation.InstallationName != "总图")
{
rootNode.Expanded = true;
}
else
{
rootNode.EnableExpandEvent = true;
}
rootNode.Text = project.ProjectName;
rootNode.NodeID = project.ProjectId;
rootNode.CommandName = "project";
rootNode.EnableExpandEvent = true;
this.trWBS.Nodes.Add(rootNode);
var installation1s = from x in Funs.DB.Project_Installation
where x.SuperInstallationId == installation.InstallationId
orderby x.InstallationCode
select x;
if (installation1s.Count() > 0)
{
foreach (var installation1 in installation1s)
{
TreeNode newNode = new TreeNode();
newNode.Text = installation1.InstallationName;
newNode.NodeID = installation1.InstallationId;
newNode.CommandName = "installation";
newNode.CommandArgument = installation1.Weights == null ? null : installation1.Weights.ToString();
newNode.ToolTip = installation1.InstallationCode;
newNode.EnableClickEvent = true;
newNode.Expanded = true;
rootNode.Nodes.Add(newNode);
var installation2s = from x in Funs.DB.Project_Installation
where x.SuperInstallationId == installation1.InstallationId
orderby x.InstallationCode
select x;
foreach (var installation2 in installation2s)
{
TreeNode newNode2 = new TreeNode();
newNode2.Text = installation2.InstallationName;
newNode2.NodeID = installation2.InstallationId;
newNode2.CommandName = "installation";
newNode2.CommandArgument = installation2.Weights == null ? null : installation2.Weights.ToString();
newNode2.ToolTip = installation2.InstallationCode;
newNode2.EnableClickEvent = true;
newNode2.Expanded = true;
newNode.Nodes.Add(newNode2);
var cnProfessions = from x in Funs.DB.WBS_CnProfession where x.InstallationId == installation2.InstallationId orderby x.OldId select x;
foreach (var cnProfession in cnProfessions)
{
var unitProjects = from x in Funs.DB.Wbs_UnitProject where x.CnProfessionId == cnProfession.CnProfessionId && x.IsApprove == true select x;
if (unitProjects.Count() > 0)
{
TreeNode newNode3 = new TreeNode();
newNode3.Text = cnProfession.CnProfessionName;
newNode3.NodeID = cnProfession.CnProfessionId;
newNode3.CommandName = "cnProfession";
newNode3.CommandArgument = cnProfession.UnitId;
newNode3.ToolTip = cnProfession.CnProfessionCode;
newNode3.EnableExpandEvent = true;
newNode3.EnableClickEvent = true;
newNode2.Nodes.Add(newNode3);
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode3.Nodes.Add(emptyNode);
}
}
}
}
}
else
if (BLL.Project_InstallationService.IsExitProjectInstallation(project.ProjectId))
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
@@ -123,17 +57,38 @@ namespace FineUIPro.Web.JDGL.CostAnalysis
}
#endregion
#region Tree展开事件
#region
/// <summary>
/// 树展开事件
/// 树节点展开
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void trWBS_NodeExpand(object sender, TreeNodeEventArgs e)
{
BindChart();
e.Node.Nodes.Clear();
if (e.Node.CommandName == "installation") //展开装置/单元节点
if (e.Node.CommandName == "project") //展开项目节点
{
var installations = from x in Funs.DB.Project_Installation
where x.ProjectId == e.Node.NodeID && x.SuperInstallationId == "0"
orderby x.InstallationCode
select x;
foreach (var installation in installations)
{
TreeNode newNode = new TreeNode();
newNode.Text = installation.InstallationName;
newNode.NodeID = installation.InstallationId;
newNode.CommandName = "installation";
newNode.EnableExpandEvent = true;
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode.Nodes.Add(emptyNode);
}
}
else if (e.Node.CommandName == "installation") //展开装置/单元节点
{
var installations = from x in Funs.DB.Project_Installation
where x.SuperInstallationId == e.Node.NodeID
@@ -147,11 +102,10 @@ namespace FineUIPro.Web.JDGL.CostAnalysis
newNode.Text = installation.InstallationName;
newNode.NodeID = installation.InstallationId;
newNode.CommandName = "installation";
newNode.CommandArgument = installation.Weights == null ? null : installation.Weights.ToString();
newNode.ToolTip = installation.InstallationCode;
newNode.EnableExpandEvent = true;
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
@@ -160,52 +114,48 @@ namespace FineUIPro.Web.JDGL.CostAnalysis
}
else
{
var cnProfessions = from x in Funs.DB.WBS_CnProfession where x.InstallationId == e.Node.NodeID orderby x.OldId select x;
var cnProfessions = from x in Funs.DB.WBS_CnProfession where x.InstallationId == e.Node.NodeID && x.IsApprove == true orderby x.OldId select x;
if (cnProfessions.Count() > 0) //普通装置主项
{
foreach (var cnProfession in cnProfessions)
{
var unitProjects = from x in Funs.DB.Wbs_UnitProject where x.CnProfessionId == cnProfession.CnProfessionId && x.IsApprove == true select x;
if (unitProjects.Count() > 0)
{
TreeNode newNode = new TreeNode();
newNode.Text = cnProfession.CnProfessionName;
newNode.NodeID = cnProfession.CnProfessionId;
newNode.CommandName = "cnProfession";
newNode.CommandArgument = cnProfession.Weights == null ? null : cnProfession.Weights.ToString();
newNode.ToolTip = cnProfession.CnProfessionCode;
newNode.EnableExpandEvent = true;
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode.Nodes.Add(emptyNode);
}
TreeNode newNode = new TreeNode();
newNode.Text = cnProfession.CnProfessionName;
newNode.NodeID = cnProfession.CnProfessionId;
newNode.CommandName = "cnProfession";
newNode.EnableExpandEvent = true;
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode.Nodes.Add(emptyNode);
}
}
else //总图
{
var unitProjects = from x in Funs.DB.Wbs_UnitProject where x.InstallationId == e.Node.NodeID && x.SuperUnitProjectId == null orderby x.SortIndex, x.UnitProjectCode select x;
var unitProjects = from x in Funs.DB.Wbs_UnitProject where x.InstallationId == e.Node.NodeID && x.SuperUnitProjectId == null && x.IsApprove == true orderby x.SortIndex, x.UnitProjectCode select x;
foreach (var unitProject in unitProjects)
{
var wbsSets = from x in Funs.DB.Wbs_WbsSet where x.UnitProjectId == unitProject.UnitProjectId && x.IsApprove == true select x;
if (wbsSets.Count() > 0)
TreeNode newNode = new TreeNode();
newNode.Text = unitProject.UnitProjectName;
newNode.NodeID = unitProject.UnitProjectId;
newNode.CommandName = "unitProject";
newNode.EnableExpandEvent = true;
if (unitProject.IsApprove == true)
{
TreeNode newNode = new TreeNode();
newNode.Text = unitProject.UnitProjectName;
newNode.NodeID = unitProject.UnitProjectId;
newNode.CommandName = "unitProject";
newNode.CommandArgument = unitProject.Weights == null ? null : unitProject.Weights.ToString();
newNode.ToolTip = unitProject.UnitProjectCode;
newNode.EnableExpandEvent = true;
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode.Nodes.Add(emptyNode);
newNode.Checked = true;
}
else
{
newNode.Checked = false;
}
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode.Nodes.Add(emptyNode);
}
}
}
@@ -219,9 +169,22 @@ namespace FineUIPro.Web.JDGL.CostAnalysis
newNode.Text = unitProject.UnitProjectName;
newNode.NodeID = unitProject.UnitProjectId;
newNode.CommandName = "unitProject";
newNode.CommandArgument = unitProject.Weights == null ? null : unitProject.Weights.ToString();
newNode.ToolTip = unitProject.UnitProjectCode;
newNode.EnableExpandEvent = true;
newNode.EnableCheckBox = true;
newNode.EnableCheckEvent = true;
if (unitProject.IsSelected == true && unitProject.IsApprove == null)
{
unitProject.IsApprove = true;
BLL.UnitProjectService.UpdateUnitProject(unitProject);
}
if (unitProject.IsApprove == true)
{
newNode.Checked = true;
}
else
{
newNode.Checked = false;
}
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
TreeNode emptyNode = new TreeNode();
@@ -232,102 +195,46 @@ namespace FineUIPro.Web.JDGL.CostAnalysis
}
else if (e.Node.CommandName == "unitProject") //展开单位工程节点
{
var childUnitProjects = from x in Funs.DB.Wbs_UnitProject where x.SuperUnitProjectId == e.Node.NodeID && x.IsApprove == true orderby x.SortIndex, x.UnitProjectCode select x;
if (childUnitProjects.Count() > 0) //存在子单位工程
var wbsSet1s = from x in Funs.DB.Wbs_WbsSet where x.UnitProjectId == e.Node.NodeID && x.SuperWbsSetId == null && x.IsApprove == true orderby x.WbsSetCode select x;
if (wbsSet1s.Count() > 0)
{
foreach (var childUnitProject in childUnitProjects)
foreach (var wbsSet1 in wbsSet1s)
{
TreeNode newNode = new TreeNode();
newNode.Text = childUnitProject.UnitProjectName;
newNode.NodeID = childUnitProject.UnitProjectId;
newNode.CommandName = "childUnitProject";
newNode.CommandArgument = childUnitProject.Weights == null ? null : childUnitProject.Weights.ToString();
newNode.ToolTip = childUnitProject.UnitProjectCode;
newNode.Text = wbsSet1.WbsSetName;
newNode.NodeID = wbsSet1.WbsSetId;
newNode.CommandName = "wbsSet";
newNode.EnableExpandEvent = true;
newNode.EnableCheckBox = true;
newNode.EnableCheckEvent = true;
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode.Nodes.Add(emptyNode);
}
}
else //不存在子单位工程,加载分部工程
{
var wbsSet1s = from x in Funs.DB.Wbs_WbsSet where x.Flag == 1 && x.UnitProjectId == e.Node.NodeID && x.IsApprove == true && x.NoShow == null orderby x.SortIndex, x.WbsSetCode select x;
if (wbsSet1s.Count() > 0)
{
foreach (var wbsSet1 in wbsSet1s)
var wbsSets = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(wbsSet1.WbsSetId);
if (wbsSets.Count > 0)
{
TreeNode newNode = new TreeNode();
newNode.Text = wbsSet1.WbsSetName;
newNode.NodeID = wbsSet1.WbsSetId;
newNode.CommandName = "wbsSet";
newNode.CommandArgument = wbsSet1.Weights == null ? null : wbsSet1.Weights.ToString();
newNode.ToolTip = wbsSet1.WbsSetCode;
newNode.EnableExpandEvent = true;
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
var childWbsSets2 = BLL.WbsSetService.GetApproveWbsSetsBySuperWbsSetId(newNode.NodeID);
if (childWbsSets2.Count() > 0)
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode.Nodes.Add(emptyNode);
}
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode.Nodes.Add(emptyNode);
}
}
else //单位工程下直接是分项内容,如质量行为
{
var wbsSet3s = from x in Funs.DB.Wbs_WbsSet where x.Flag == 3 && x.UnitProjectId == e.Node.NodeID && x.IsApprove == true && x.NoShow == null orderby x.SortIndex, x.WbsSetCode select x;
if (wbsSet3s.Count() > 0)
{
foreach (var wbsSet3 in wbsSet3s)
{
TreeNode newNode = new TreeNode();
newNode.Text = wbsSet3.WbsSetName;
newNode.NodeID = wbsSet3.WbsSetId;
newNode.CommandName = "wbsSet";
newNode.CommandArgument = wbsSet3.Weights == null ? null : wbsSet3.Weights.ToString();
newNode.ToolTip = wbsSet3.WbsSetCode;
newNode.EnableExpandEvent = true;
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
var childWbsSets2 = BLL.WbsSetService.GetApproveWbsSetsBySuperWbsSetId(newNode.NodeID);
if (childWbsSets2.Count() > 0)
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode.Nodes.Add(emptyNode);
}
}
}
}
}
}
else if (e.Node.CommandName == "childUnitProject") //展开子单位工程节点
{
var wbsSet1s = from x in Funs.DB.Wbs_WbsSet where x.Flag == 1 && x.UnitProjectId == e.Node.NodeID && x.IsApprove == true && x.NoShow == null orderby x.SortIndex, x.WbsSetCode select x;
foreach (var wbsSet1 in wbsSet1s)
{
TreeNode newNode = new TreeNode();
newNode.Text = wbsSet1.WbsSetName;
newNode.NodeID = wbsSet1.WbsSetId;
newNode.CommandName = "wbsSet";
newNode.CommandArgument = wbsSet1.Weights == null ? null : wbsSet1.Weights.ToString();
newNode.ToolTip = wbsSet1.WbsSetCode;
newNode.EnableExpandEvent = true;
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
var childWbsSets2 = BLL.WbsSetService.GetApproveWbsSetsBySuperWbsSetId(newNode.NodeID);
if (childWbsSets2.Count() > 0)
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode.Nodes.Add(emptyNode);
//needAddTempNode = false;
//var wbsSets = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(wbsSet1.WbsSetId);
//foreach (var wbsSet in wbsSets)
//{
// var childWbsSets = from x in Funs.DB.Wbs_WbsSet where x.SuperWbsSetId == wbsSet.WbsSetId select x;
// if (childWbsSets.Count() > 0)
// {
// needAddTempNode = true;
// break;
// }
//}
//if (needAddTempNode)
//{
// TreeNode emptyNode = new TreeNode();
// emptyNode.Text = "";
// emptyNode.NodeID = "";
// newNode.Nodes.Add(emptyNode);
//}
}
}
}
@@ -340,57 +247,37 @@ namespace FineUIPro.Web.JDGL.CostAnalysis
newNode.Text = wbsSet.WbsSetName;
newNode.NodeID = wbsSet.WbsSetId;
newNode.CommandName = "wbsSet";
newNode.CommandArgument = wbsSet.Weights == null ? null : wbsSet.Weights.ToString();
newNode.ToolTip = wbsSet.WbsSetCode;
newNode.EnableExpandEvent = true;
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
var childWbsSets2 = BLL.WbsSetService.GetApproveWbsSetsBySuperWbsSetId(newNode.NodeID);
if (childWbsSets2.Count() > 0)
var wbsSets = BLL.WbsSetService.GetApproveWbsSetsBySuperWbsSetId(wbsSet.WbsSetId);
if (wbsSets.Count > 0)
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode.Nodes.Add(emptyNode);
}
//needAddTempNode = false;
//var wbsSets = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(wbsSet.WbsSetId);
//foreach (var wbsSetc in wbsSets)
//{
// var childWbsSets1 = from x in Funs.DB.Wbs_WbsSet where x.SuperWbsSetId == wbsSetc.WbsSetId select x;
// if (childWbsSets1.Count() > 0)
// {
// needAddTempNode = true;
// break;
// }
//}
//if (needAddTempNode)
//{
// TreeNode emptyNode = new TreeNode();
// emptyNode.Text = "";
// emptyNode.NodeID = "";
// newNode.Nodes.Add(emptyNode);
//}
}
}
}
#endregion
#region
/// <summary>
/// 单位下拉选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpUnit_SelectedIndexChanged(object sender, EventArgs e)
{
List<string> nodeIds = new List<string>();
if (this.drpUnit.SelectedValue != BLL.Const._Null)
{
foreach (var item in this.trWBS.Nodes)
{
if (item.CommandArgument == this.drpUnit.SelectedValue)
{
nodeIds.Add(item.NodeID);
}
foreach (var item1 in item.Nodes)
{
foreach (var item2 in item1.Nodes)
{
foreach (var item3 in item2.Nodes)
{
if (item3.CommandArgument == this.drpUnit.SelectedValue)
{
nodeIds.Add(item3.NodeID);
}
}
}
}
}
}
this.trWBS.SelectedNodeIDArray = nodeIds.ToArray();
BindChart();
}
#endregion
@@ -413,29 +300,40 @@ namespace FineUIPro.Web.JDGL.CostAnalysis
/// </summary>
private void BindChart()
{
string[] nodeIds = this.trWBS.SelectedNodeIDArray;
string toWbs = string.Empty;
foreach (var nodeId in nodeIds)
string id = this.trWBS.SelectedNodeID;
Model.WBS_CostControl costControl = BLL.CostControlService.GetCostControlByCostControlId(id);
if (costControl != null)
{
toWbs += nodeId + ",";
string strSql = "select distinct (cast(YEAR(Months) as varchar(4))+'.'+cast(MONTH(Months) as varchar(2))) as 月份,t.Months," +
"ThisRealCost as 本月实际成本,ThisPlanCost as 本月完成预算,ThisPlanValue as 本月计划完成预算,TotalPlanValue as 累计计划完成预算,TotalRealCost as 累计完成成本,TotalPlanCost as 累计完成预算 " +
"from dbo.View_WBS_CostControlDetail as t where CostControlId=@Id order by t.Months";
//string date = DateTime.Now.Year + "-" + DateTime.Now.Month + "-01";
SqlParameter[] parameter = new SqlParameter[]
{
new SqlParameter("@Id",id),
//new SqlParameter("@Months",date),
};
DataTable dt = SQLHelper.GetDataTableRunText(strSql, parameter);
this.Grid1.DataSource = dt;
this.Grid1.DataBind();
this.ChartEV.CreateMaryChart(dt, 820, 320, null);
}
else
{
string strSql = "select distinct (cast(YEAR(Months) as varchar(4))+'.'+cast(MONTH(Months) as varchar(2))) as 月份,t.Months," +
"ThisRealCost as 本月实际成本,ThisPlanCost as 本月完成预算,ThisPlanValue as 本月计划完成预算,TotalPlanValue as 累计计划完成预算,TotalRealCost as 累计完成成本,TotalPlanCost as 累计完成预算 " +
"from dbo.View_WBS_CostControlParentDetail as t where ParentId=@Id order by t.Months";
//string date = DateTime.Now.Year + "-" + DateTime.Now.Month + "-01";
SqlParameter[] parameter = new SqlParameter[]
{
new SqlParameter("@Id",id),
//new SqlParameter("@Months",date),
};
DataTable dt = SQLHelper.GetDataTableRunText(strSql, parameter);
this.Grid1.DataSource = dt;
this.Grid1.DataBind();
this.ChartEV.CreateMaryChart(dt, 820, 320, null);
}
string strSql = "select distinct (cast(YEAR(Months) as varchar(4))+'.'+cast(MONTH(Months) as varchar(2))) as 月份,t.Months, (select SUM(PlanValue) from dbo.WbsDetail where Months=t.Months and CHARINDEX(ToWbs,@ToWbs)>0) as 计划值," +
"(select SUM(PlanValue) from dbo.WbsDetail where Months<=t.Months and CHARINDEX(ToWbs,@ToWbs)>0) as 计划累积值 ," +
"(select SUM(CompleteValue) from dbo.WbsDetail where Months=t.Months and CHARINDEX(ToWbs,@ToWbs)>0) as 完成值," +
"(select SUM(CompleteValue) from dbo.WbsDetail where Months<=t.Months and CHARINDEX(ToWbs,@ToWbs)>0) as 完成累积值," +
"(select SUM(RealValue) from dbo.WbsDetail where Months=t.Months and CHARINDEX(ToWbs,@ToWbs)>0) as 实耗值," +
"(select SUM(RealValue) from dbo.WbsDetail where Months<=t.Months and CHARINDEX(ToWbs,@ToWbs)>0) as 实耗累积值 " +
"from dbo.WbsDetail as t where CHARINDEX(t.ToWbs,@ToWbs)>0 order by t.Months";
string date = DateTime.Now.Year + "-" + DateTime.Now.Month + "-01";
SqlParameter[] parameter = new SqlParameter[]
{
new SqlParameter("@ToWbs",toWbs),
new SqlParameter("@Months",date),
};
DataTable dt = SQLHelper.GetDataTableRunText(strSql, parameter);
this.Grid1.DataSource = dt;
this.Grid1.DataBind();
this.ChartEV.CreateMaryChart(dt, 820, 320, null);
}
#endregion