2021-04-30 10:28:37 +08:00
using BLL ;
using System ;
using System.Collections.Generic ;
using System.Data ;
using System.Data.SqlClient ;
using System.Linq ;
namespace FineUIPro.Web.JDGL.CostAnalysis
{
public partial class EarnedValueCurve : PageBase
{
#region 加 载
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load ( object sender , EventArgs e )
{
if ( ! IsPostBack )
{
BindChart ( ) ;
InitTreeMenu ( ) ;
}
}
#endregion
#region 加 载
/// <summary>
2021-08-13 11:15:59 +08:00
/// 树加载
2021-04-30 10:28:37 +08:00
/// </summary>
private void InitTreeMenu ( )
{
this . trWBS . Nodes . Clear ( ) ;
this . trWBS . ShowBorder = false ;
this . trWBS . ShowHeader = false ;
this . trWBS . EnableIcons = true ;
this . trWBS . AutoScroll = true ;
2021-08-13 11:15:59 +08:00
this . trWBS . EnableSingleClickExpand = true ;
2021-10-22 10:10:15 +08:00
//var project = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId);
//if (project != null)
//{
// TreeNode rootNode = new TreeNode();
// rootNode.Text = project.ProjectName;
// rootNode.NodeID = project.ProjectId;
// rootNode.CommandName = "project";
// rootNode.EnableExpandEvent = true;
// this.trWBS.Nodes.Add(rootNode);
// if (BLL.Project_InstallationService.IsExitProjectInstallation(project.ProjectId))
// {
// TreeNode emptyNode = new TreeNode();
// emptyNode.Text = "";
// emptyNode.NodeID = "";
// rootNode.Nodes.Add(emptyNode);
// }
//}
Model . Project_Installation installation = BLL . Project_InstallationService . GetProjectInstallationByProjectId ( this . CurrUser . LoginProjectId ) ;
if ( installation ! = null )
2021-04-30 10:28:37 +08:00
{
2021-10-22 10:10:15 +08:00
TreeNode newNode = new TreeNode ( ) ;
newNode . Text = "[" + installation . InstallationCode + "]" + installation . InstallationName ;
newNode . NodeID = installation . InstallationId ;
newNode . CommandName = "installation" ;
newNode . EnableExpandEvent = true ;
newNode . EnableClickEvent = true ;
newNode . EnableCheckBox = false ;
this . trWBS . Nodes . Add ( newNode ) ;
TreeNode emptyNode = new TreeNode ( ) ;
emptyNode . Text = "" ;
emptyNode . NodeID = "" ;
newNode . Nodes . Add ( emptyNode ) ;
2021-04-30 10:28:37 +08:00
}
}
#endregion
2021-08-13 11:15:59 +08:00
#region 树 节 点 展 开
2021-04-30 10:28:37 +08:00
/// <summary>
2021-08-13 11:15:59 +08:00
/// 树节点展开
2021-04-30 10:28:37 +08:00
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void trWBS_NodeExpand ( object sender , TreeNodeEventArgs e )
{
e . Node . Nodes . Clear ( ) ;
2021-08-13 11:15:59 +08:00
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 ( ) ;
2021-10-22 10:10:15 +08:00
newNode . Text = "[" + installation . InstallationCode + "]" + installation . InstallationName ;
2021-08-13 11:15:59 +08:00
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" ) //展开装置/单元节点
2021-04-30 10:28:37 +08:00
{
var installations = from x in Funs . DB . Project_Installation
where x . SuperInstallationId = = e . Node . NodeID
orderby x . InstallationCode
select x ;
if ( installations . Count ( ) > 0 )
{
foreach ( var installation in installations )
{
TreeNode newNode = new TreeNode ( ) ;
2021-10-22 10:10:15 +08:00
newNode . Text = "[" + installation . InstallationCode + "]" + installation . InstallationName ;
2021-04-30 10:28:37 +08:00
newNode . NodeID = installation . InstallationId ;
newNode . CommandName = "installation" ;
newNode . EnableExpandEvent = true ;
newNode . EnableClickEvent = true ;
e . Node . Nodes . Add ( newNode ) ;
2021-08-13 11:15:59 +08:00
2021-04-30 10:28:37 +08:00
TreeNode emptyNode = new TreeNode ( ) ;
emptyNode . Text = "" ;
emptyNode . NodeID = "" ;
newNode . Nodes . Add ( emptyNode ) ;
}
}
else
{
2021-08-13 11:15:59 +08:00
var cnProfessions = from x in Funs . DB . WBS_CnProfession where x . InstallationId = = e . Node . NodeID & & x . IsApprove = = true orderby x . OldId select x ;
2021-04-30 10:28:37 +08:00
if ( cnProfessions . Count ( ) > 0 ) //普通装置主项
{
foreach ( var cnProfession in cnProfessions )
{
2021-08-13 11:15:59 +08:00
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 ) ;
2021-04-30 10:28:37 +08:00
}
}
else //总图
{
2021-08-13 11:15:59 +08:00
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 ;
2021-04-30 10:28:37 +08:00
foreach ( var unitProject in unitProjects )
{
2021-08-13 11:15:59 +08:00
TreeNode newNode = new TreeNode ( ) ;
newNode . Text = unitProject . UnitProjectName ;
newNode . NodeID = unitProject . UnitProjectId ;
newNode . CommandName = "unitProject" ;
newNode . EnableExpandEvent = true ;
if ( unitProject . IsApprove = = true )
2021-04-30 10:28:37 +08:00
{
2021-08-13 11:15:59 +08:00
newNode . Checked = true ;
2021-04-30 10:28:37 +08:00
}
2021-08-13 11:15:59 +08:00
else
{
newNode . Checked = false ;
}
newNode . EnableClickEvent = true ;
e . Node . Nodes . Add ( newNode ) ;
TreeNode emptyNode = new TreeNode ( ) ;
emptyNode . Text = "" ;
emptyNode . NodeID = "" ;
newNode . Nodes . Add ( emptyNode ) ;
2021-04-30 10:28:37 +08:00
}
}
}
}
else if ( e . Node . CommandName = = "cnProfession" ) //展开专业节点
{
var unitProjects = from x in Funs . DB . Wbs_UnitProject where x . CnProfessionId = = e . Node . NodeID & & x . SuperUnitProjectId = = null & & x . IsApprove = = true orderby x . SortIndex , x . UnitProjectCode select x ;
foreach ( var unitProject in unitProjects )
{
TreeNode newNode = new TreeNode ( ) ;
newNode . Text = unitProject . UnitProjectName ;
newNode . NodeID = unitProject . UnitProjectId ;
newNode . CommandName = "unitProject" ;
newNode . EnableExpandEvent = true ;
2021-08-13 11:15:59 +08:00
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 ;
}
2021-04-30 10:28:37 +08:00
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 = = "unitProject" ) //展开单位工程节点
{
2021-08-13 11:15:59 +08:00
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 )
2021-04-30 10:28:37 +08:00
{
2021-08-13 11:15:59 +08:00
foreach ( var wbsSet1 in wbsSet1s )
2021-04-30 10:28:37 +08:00
{
TreeNode newNode = new TreeNode ( ) ;
2021-08-13 11:15:59 +08:00
newNode . Text = wbsSet1 . WbsSetName ;
newNode . NodeID = wbsSet1 . WbsSetId ;
newNode . CommandName = "wbsSet" ;
2021-04-30 10:28:37 +08:00
newNode . EnableExpandEvent = true ;
2021-08-13 11:15:59 +08:00
newNode . EnableCheckBox = true ;
newNode . EnableCheckEvent = true ;
2021-04-30 10:28:37 +08:00
newNode . EnableClickEvent = true ;
e . Node . Nodes . Add ( newNode ) ;
2021-08-13 11:15:59 +08:00
var wbsSets = BLL . WbsSetService . GetWbsSetsBySuperWbsSetId ( wbsSet1 . WbsSetId ) ;
if ( wbsSets . Count > 0 )
2021-04-30 10:28:37 +08:00
{
2021-08-13 11:15:59 +08:00
TreeNode emptyNode = new TreeNode ( ) ;
emptyNode . Text = "" ;
emptyNode . NodeID = "" ;
newNode . Nodes . Add ( emptyNode ) ;
2021-04-30 10:28:37 +08:00
}
2021-08-13 11:15:59 +08:00
//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);
//}
2021-04-30 10:28:37 +08:00
}
}
}
else if ( e . Node . CommandName = = "wbsSet" ) //展开分部/子分部/分项/子分项工程节点
{
var childWbsSets = BLL . WbsSetService . GetApproveWbsSetsBySuperWbsSetId ( e . Node . NodeID ) ;
foreach ( var wbsSet in childWbsSets )
{
TreeNode newNode = new TreeNode ( ) ;
newNode . Text = wbsSet . WbsSetName ;
newNode . NodeID = wbsSet . WbsSetId ;
newNode . CommandName = "wbsSet" ;
newNode . EnableExpandEvent = true ;
newNode . EnableClickEvent = true ;
e . Node . Nodes . Add ( newNode ) ;
2021-08-13 11:15:59 +08:00
var wbsSets = BLL . WbsSetService . GetApproveWbsSetsBySuperWbsSetId ( wbsSet . WbsSetId ) ;
if ( wbsSets . Count > 0 )
2021-04-30 10:28:37 +08:00
{
TreeNode emptyNode = new TreeNode ( ) ;
emptyNode . Text = "" ;
emptyNode . NodeID = "" ;
newNode . Nodes . Add ( emptyNode ) ;
}
2021-08-13 11:15:59 +08:00
//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);
//}
2021-04-30 10:28:37 +08:00
}
}
BindChart ( ) ;
}
#endregion
#region Tree点击事件
/// <summary>
/// Tree点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void trWBS_NodeCommand ( object sender , TreeCommandEventArgs e )
{
BindChart ( ) ;
}
#endregion
#region 数 据 绑 定
/// <summary>
/// 数据绑定
/// </summary>
private void BindChart ( )
{
2021-08-13 11:15:59 +08:00
string id = this . trWBS . SelectedNodeID ;
Model . WBS_CostControl costControl = BLL . CostControlService . GetCostControlByCostControlId ( id ) ;
if ( costControl ! = null )
2021-04-30 10:28:37 +08:00
{
2021-08-13 11:15:59 +08:00
string strSql = "select distinct (cast(YEAR(Months) as varchar(4))+'.'+cast(MONTH(Months) as varchar(2))) as 月份,t.Months," +
2021-09-23 14:45:21 +08:00
"ThisRealCost as '本月已完工作实际费用-ACWP',ThisPlanCost as '本月已完工作预算费用-BCWP',ThisPlanValue as '本月计划工作预算费用-BCWS',TotalPlanValue as '累计计划工作预算费用-BCWS',TotalRealCost as '累计已完工作实际费用-ACWP',TotalPlanCost as '累计已完工作预算费用-BCWP' " +
2021-08-13 11:15:59 +08:00
"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 ( ) ;
2022-04-14 11:15:34 +08:00
decimal lastbcws = 0 , bcws = 0 , lastacwp = 0 , acwp = 0 , lastbcwp = 0 , bcwp = 0 ;
for ( int i = 0 ; i < dt . Rows . Count ; i + + )
{
dt . Rows [ i ] [ "本月已完工作实际费用-ACWP" ] = Funs . GetNewDecimalOrZero ( dt . Rows [ i ] [ "本月已完工作实际费用-ACWP" ] . ToString ( ) ) / 10000 ;
dt . Rows [ i ] [ "本月已完工作预算费用-BCWP" ] = Funs . GetNewDecimalOrZero ( dt . Rows [ i ] [ "本月已完工作预算费用-BCWP" ] . ToString ( ) ) / 10000 ;
dt . Rows [ i ] [ "本月计划工作预算费用-BCWS" ] = Funs . GetNewDecimalOrZero ( dt . Rows [ i ] [ "本月计划工作预算费用-BCWS" ] . ToString ( ) ) / 10000 ;
bcws = Funs . GetNewDecimalOrZero ( dt . Rows [ i ] [ "累计计划工作预算费用-BCWS" ] . ToString ( ) ) ;
acwp = Funs . GetNewDecimalOrZero ( dt . Rows [ i ] [ "累计已完工作实际费用-ACWP" ] . ToString ( ) ) ;
bcwp = Funs . GetNewDecimalOrZero ( dt . Rows [ i ] [ "累计已完工作预算费用-BCWP" ] . ToString ( ) ) ;
if ( bcws = = lastbcws )
{
2022-06-27 15:36:01 +08:00
if ( Funs . GetNewDateTimeOrNow ( dt . Rows [ i ] [ "Months" ] . ToString ( ) ) > DateTime . Now )
{
dt . Rows [ i ] [ "累计计划工作预算费用-BCWS" ] = DBNull . Value ;
}
else
{
dt . Rows [ i ] [ "累计计划工作预算费用-BCWS" ] = bcws / 10000 ;
}
2022-04-14 11:15:34 +08:00
}
else
{
dt . Rows [ i ] [ "累计计划工作预算费用-BCWS" ] = bcws / 10000 ;
}
if ( acwp = = lastacwp )
{
2022-06-27 15:36:01 +08:00
if ( Funs . GetNewDateTimeOrNow ( dt . Rows [ i ] [ "Months" ] . ToString ( ) ) > DateTime . Now )
{
dt . Rows [ i ] [ "累计已完工作实际费用-ACWP" ] = DBNull . Value ;
}
else
{
dt . Rows [ i ] [ "累计已完工作实际费用-ACWP" ] = acwp / 10000 ;
}
2022-04-14 11:15:34 +08:00
}
else
{
dt . Rows [ i ] [ "累计已完工作实际费用-ACWP" ] = acwp / 10000 ;
}
if ( bcwp = = lastbcwp )
{
2022-06-27 15:36:01 +08:00
if ( Funs . GetNewDateTimeOrNow ( dt . Rows [ i ] [ "Months" ] . ToString ( ) ) > DateTime . Now )
{
dt . Rows [ i ] [ "累计已完工作预算费用-BCWP" ] = DBNull . Value ;
}
else
{
dt . Rows [ i ] [ "累计已完工作预算费用-BCWP" ] = bcwp / 10000 ;
}
2022-04-14 11:15:34 +08:00
}
else
{
dt . Rows [ i ] [ "累计已完工作预算费用-BCWP" ] = bcwp / 10000 ;
}
lastbcws = bcws ;
lastacwp = acwp ;
lastbcwp = bcwp ;
}
this . ChartEV . CreateMaryChart ( dt , 1020 , 420 , null ) ;
2021-08-13 11:15:59 +08:00
}
else
{
string strSql = "select distinct (cast(YEAR(Months) as varchar(4))+'.'+cast(MONTH(Months) as varchar(2))) as 月份,t.Months," +
2021-09-23 14:45:21 +08:00
"ThisRealCost as '本月已完工作实际费用-ACWP',ThisPlanCost as '本月已完工作预算费用-BCWP',ThisPlanValue as '本月计划工作预算费用-BCWS',TotalPlanValue as '累计计划工作预算费用-BCWS',TotalRealCost as '累计已完工作实际费用-ACWP',TotalPlanCost as '累计已完工作预算费用-BCWP' " +
2021-08-13 11:15:59 +08:00
"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 ( ) ;
2022-04-14 11:15:34 +08:00
decimal lastbcws = 0 , bcws = 0 , lastacwp = 0 , acwp = 0 , lastbcwp = 0 , bcwp = 0 ;
for ( int i = 0 ; i < dt . Rows . Count ; i + + )
{
dt . Rows [ i ] [ "本月已完工作实际费用-ACWP" ] = Funs . GetNewDecimalOrZero ( dt . Rows [ i ] [ "本月已完工作实际费用-ACWP" ] . ToString ( ) ) / 10000 ;
dt . Rows [ i ] [ "本月已完工作预算费用-BCWP" ] = Funs . GetNewDecimalOrZero ( dt . Rows [ i ] [ "本月已完工作预算费用-BCWP" ] . ToString ( ) ) / 10000 ;
dt . Rows [ i ] [ "本月计划工作预算费用-BCWS" ] = Funs . GetNewDecimalOrZero ( dt . Rows [ i ] [ "本月计划工作预算费用-BCWS" ] . ToString ( ) ) / 10000 ;
bcws = Funs . GetNewDecimalOrZero ( dt . Rows [ i ] [ "累计计划工作预算费用-BCWS" ] . ToString ( ) ) ;
acwp = Funs . GetNewDecimalOrZero ( dt . Rows [ i ] [ "累计已完工作实际费用-ACWP" ] . ToString ( ) ) ;
bcwp = Funs . GetNewDecimalOrZero ( dt . Rows [ i ] [ "累计已完工作预算费用-BCWP" ] . ToString ( ) ) ;
if ( bcws = = lastbcws )
{
2022-06-27 15:36:01 +08:00
if ( Funs . GetNewDateTimeOrNow ( dt . Rows [ i ] [ "Months" ] . ToString ( ) ) > DateTime . Now )
{
dt . Rows [ i ] [ "累计计划工作预算费用-BCWS" ] = DBNull . Value ;
}
else
{
dt . Rows [ i ] [ "累计计划工作预算费用-BCWS" ] = bcws / 10000 ;
}
2022-04-14 11:15:34 +08:00
}
else
{
dt . Rows [ i ] [ "累计计划工作预算费用-BCWS" ] = bcws / 10000 ;
}
if ( acwp = = lastacwp )
{
2022-06-27 15:36:01 +08:00
if ( Funs . GetNewDateTimeOrNow ( dt . Rows [ i ] [ "Months" ] . ToString ( ) ) > DateTime . Now )
{
dt . Rows [ i ] [ "累计已完工作实际费用-ACWP" ] = DBNull . Value ;
}
else
{
dt . Rows [ i ] [ "累计已完工作实际费用-ACWP" ] = acwp / 10000 ;
}
2022-04-14 11:15:34 +08:00
}
else
{
dt . Rows [ i ] [ "累计已完工作实际费用-ACWP" ] = acwp / 10000 ;
}
if ( bcwp = = lastbcwp )
{
2022-06-27 15:36:01 +08:00
if ( Funs . GetNewDateTimeOrNow ( dt . Rows [ i ] [ "Months" ] . ToString ( ) ) > DateTime . Now )
{
dt . Rows [ i ] [ "累计已完工作预算费用-BCWP" ] = DBNull . Value ;
}
else
{
dt . Rows [ i ] [ "累计已完工作预算费用-BCWP" ] = bcwp / 10000 ;
}
2022-04-14 11:15:34 +08:00
}
else
{
dt . Rows [ i ] [ "累计已完工作预算费用-BCWP" ] = bcwp / 10000 ;
}
lastbcws = bcws ;
lastacwp = acwp ;
lastbcwp = bcwp ;
}
this . ChartEV . CreateMaryChart ( dt , 1020 , 420 , null ) ;
2021-04-30 10:28:37 +08:00
}
}
#endregion
#region 将 DataTable行列转换
/// <summary>
/// 将DataTable行列转换
/// </summary>
/// <param name="src">要转换的DataTable</param>
/// <param name="columnHead">要作为Column的哪列</param>
/// <returns></returns>
private DataTable Col2Row ( DataTable src , int columnHead )
{
DataTable result = new DataTable ( ) ;
DataColumn myHead = src . Columns [ columnHead ] ;
result . Columns . Add ( myHead . ColumnName ) ;
FineUIPro . RenderField bf ;
bf = new FineUIPro . RenderField ( ) ;
bf . ColumnID = myHead . ColumnName ;
bf . DataField = myHead . ColumnName ;
bf . HeaderText = myHead . ColumnName ;
Grid1 . Columns . Add ( bf ) ;
for ( int i = 0 ; i < src . Rows . Count ; i + + )
{
result . Columns . Add ( src . Rows [ i ] [ myHead ] . ToString ( ) ) ;
bf = new FineUIPro . RenderField ( ) ;
bf . ColumnID = src . Rows [ i ] [ myHead ] . ToString ( ) ;
bf . DataField = src . Rows [ i ] [ myHead ] . ToString ( ) ;
bf . HeaderText = src . Rows [ i ] [ myHead ] . ToString ( ) ;
Grid1 . Columns . Add ( bf ) ;
}
Grid1 . DataKeyNames = new string [ ] { "月份" } ;
foreach ( DataColumn col in src . Columns )
{
if ( col = = myHead )
continue ;
object [ ] newRow = new object [ src . Rows . Count + 1 ] ;
newRow [ 0 ] = col . ColumnName ;
for ( int i = 0 ; i < src . Rows . Count ; i + + )
{
newRow [ i + 1 ] = src . Rows [ i ] [ col ] ;
}
result . Rows . Add ( newRow ) ;
}
return result ;
}
private DataTable Col2Row ( DataTable src , string columnHead )
{
for ( int i = 0 ; i < src . Columns . Count ; i + + )
{
if ( src . Columns [ i ] . ColumnName . ToUpper ( ) = = columnHead . ToUpper ( ) )
return Col2Row ( src , i ) ;
}
return new DataTable ( ) ;
}
#endregion
}
}