PBCAnalyzer:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using DataAccess.PO;

namespace BusinessFacade


{
public class PBCAnalyzer

{
public static DataTable GetIndicatorMonthBase(List<Import_MonthBase> monthbaseList,List<Indicator> indicatorList)

{
if (monthbaseList == null) return null;

DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("UID"));
dt.Columns.Add(new DataColumn("指标ID"));
dt.Columns.Add(new DataColumn("指标名称"));
dt.Columns.Add(new DataColumn("年份"));
dt.Columns.Add(new DataColumn("月份"));
dt.Columns.Add(new DataColumn("指标值"));

//2,赋值
DataRow dr;
foreach (Import_MonthBase monthbase in monthbaseList)

{
dr = dt.NewRow();
dr["UID"] = monthbase.UID;
dr["指标ID"] = monthbase.IndicatorID;
dr["指标名称"] = GetIndiCnNameByID(monthbase.IndicatorID, indicatorList);
dr["年份"] = monthbase.YearNo;
dr["月份"] = monthbase.MonthNo;
dr["指标值"] = monthbase.IndicatorValue;

dt.Rows.Add(dr);
}

//3,添加到表
return dt;
}

private static string GetIndiCnNameByID(string indiID, List<Indicator> indicatorList)

{
foreach (Indicator indi in indicatorList)

{
if (indi.IndicatorCode.Equals(indiID, StringComparison.OrdinalIgnoreCase))
return indi.DisplayName;
}
return string.Empty;

}

public static DataTable GetCnnameList(List<PBCIndicatorCode> cnnameList)

{
if (cnnameList == null) return null;

DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("PBC库指标ID"));
dt.Columns.Add(new DataColumn("PBC库指标名称"));

//2,赋值
DataRow dr;
foreach (PBCIndicatorCode cnname in cnnameList)

{
dr = dt.NewRow();
dr["PBC库指标ID"] = cnname.IndicatorID;
dr["PBC库指标名称"] = cnname.IndicatorName;
dt.Rows.Add(dr);
}

//3,添加到表
return dt;
}
}
}

DataManagement_IndicatorConfiguration.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using System.ComponentModel;
using System.Xml;
using System.Data.SqlClient;
using System.IO;
using System.Xml.Serialization;
using System.Diagnostics;
using System.Text;
using DataAccess.PO;
using BusinessFacade;

public partial class DataManagement_IndicatorConfiguration : System.Web.UI.Page


{

private void Bind(int pageIndex)

{
StringBuilder indiCodes = new StringBuilder();
if (IndicatorMultiSelectControl1.SelectedIndicatorList != null)

{
foreach (Indicator indi in IndicatorMultiSelectControl1.SelectedIndicatorList)

{
indiCodes.Append("'" + indi.IndicatorCode + "',");//加逗号是因为参数里有逗号分隔符
}
}

if (indiCodes == null || indiCodes.Length == 0)
return;
indiCodes.Remove(indiCodes.Length - 1, 1);//去掉加上的逗号
string filter = "IndicatorID in ( " + indiCodes.ToString() + " )";



/**////从PBC库中取出数据
PBCIntegrationManager manager = new PBCIntegrationManager();
List<Import_MonthBase> monthbase = new List<Import_MonthBase>();
monthbase = manager.GetEntityList(filter);
Session["PBCmonthbase"] = monthbase;

DataTable dt = PBCAnalyzer.GetIndicatorMonthBase(monthbase, IndicatorMultiSelectControl1.SelectedIndicatorList);

ImportGridView.DataSource = dt;
ImportGridView.PageIndex = pageIndex;
ImportGridView.DataBind();
}
protected void ShowButton_Click(object sender, EventArgs e)

{

/**////从EWS库取指标
Bind(0);

}

protected void ImportGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)

{
Bind(e.NewPageIndex);
}

protected void SelectBoxCheckedChanged(object sender, EventArgs e)

{
CheckBox box = (CheckBox)sender;
int rowIndex = ((GridViewRow)box.NamingContainer).RowIndex;
string key = ImportGridView.DataKeys[rowIndex].Value.ToString();
Response.Write("<script>alert('"+key+"')</script>");
}
protected void Import_Click(object sender, EventArgs e)

{

/**////从EWS库取指标
List<Import_MonthBase> mbs = Session["PBCmonthbase"] as List<Import_MonthBase>;
string file = "D:\\PBCmonth.xml";
TextWriter writer = new StreamWriter(file);
XmlSerializer sr = new XmlSerializer(typeof(List<Import_MonthBase>));
sr.Serialize(writer, mbs);
writer.Close();


}
protected void ImportGridView_SelectedIndexChanged(object sender, EventArgs e)

{

}
protected void PBCButton_Click(object sender, EventArgs e)

{
//文本框 关键字匹配
string keyWord = KeyWordTextBox.Text;


}
}


DataManagement_IndicatorConfiguration.aspx
<%@ Page Language="C#" MasterPageFile="~/Common/MainFramePage.master" AutoEventWireup="true" CodeFile="IndicatorConfiguration.aspx.cs" Inherits="DataManagement_IndicatorConfiguration" Title="Untitled Page" %>

<%@ Register Src="../Common/UserControl/IndicatorMultiSelectControl.ascx" TagName="IndicatorMultiSelectControl"
TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolderMainFramePage" Runat="Server">
<asp:Label ID="LbTitle" runat="server" Text="IndicatorConfiguration" Height="16px" Width="117px"></asp:Label> <br />
<table frame="void" border="0" cellpadding="5" cellspacing="0" width ="100%" align="center" id="TABLE2">
<tr>
<td style="width: 116px; height: 124px;" valign="top">
<asp:Label ID="ImportLabel" runat="server" Text="请选择EWS库指标:" Width="122px" Height="108px"></asp:Label></td>
<td>
<uc1:IndicatorMultiSelectControl ID="IndicatorMultiSelectControl1" runat="server" />
</td>
</tr>
</table>
<table style="width: 547px">
<tr>
<td>
<asp:Button ID="ShowButton" runat="server" Height="32px" Text="显示数据" Width="156px" OnClick="ShowButton_Click" /></td>
<td style="width: 297px">
<asp:Label ID="nodataLabel" runat="server" Text=" " Width="186px" Height="31px"></asp:Label></td>
</tr>
</table>
<asp:GridView ID="ImportGridView" runat="server" Height="186px" Width="635px" BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" CellPadding="2" ForeColor="Black" GridLines="None" OnPageIndexChanging="ImportGridView_PageIndexChanging" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="UID" >
<FooterStyle BackColor="Tan" />
<SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
<PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
<HeaderStyle BackColor="Tan" Font-Bold="True" />
<AlternatingRowStyle BackColor="PaleGoldenrod" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="CheckBox2" runat="server" AutoPostBack="true" OnCheckedChanged="SelectBoxCheckedChanged" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="指标ID" HeaderText="指标ID" />
<asp:BoundField DataField="指标名称" HeaderText="指标名称" />
<asp:BoundField DataField="年份" HeaderText="年份" />
<asp:BoundField DataField="月份" HeaderText="月份" />
<asp:BoundField DataField="指标值" HeaderText="指标值" />
</Columns>
</asp:GridView>
<br />
<table style="width: 635px">
<tr>
<td style="width: 154px; height: 36px">
<asp:Label ID="KeyWordLabel" runat="server" Height="32px" Text="请输入PBC库指标关键字:" Width="154px"></asp:Label></td>
<td style="width: 253px; height: 36px">
<asp:TextBox ID="KeyWordTextBox" runat="server" Height="26px" Width="243px"></asp:TextBox></td>
<td style="width: 217px; height: 36px">
<asp:Button ID="PBCButton" runat="server" Height="29px" Text="显示PBC库指标" Width="106px" OnClick="PBCButton_Click" /></td>
</tr>
</table>
<asp:GridView ID="PBCGridView" runat="server" BackColor="LightGoldenrodYellow" BorderColor="Tan"
BorderWidth="1px" CellPadding="2" ForeColor="Black" GridLines="None" Height="153px"
Width="639px">
<FooterStyle BackColor="Tan" />
<SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
<PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
<HeaderStyle BackColor="Tan" Font-Bold="True" />
<AlternatingRowStyle BackColor="PaleGoldenrod" />
<Columns>
<asp:TemplateField HeaderText="全选">
<HeaderTemplate>
<input id="chkAll" onclick="javascript:SelectAllCheckboxes(this);" type="checkbox" />全选
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</ItemTemplate>
<FooterTemplate>
<input id="chkAll" onclick="javascript:SelectAllCheckboxes(this);" type="checkbox" />全选
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<br />
<asp:Button ID="Import" runat="server" Height="32px" Text="导出数据" Width="156px" OnClick="Import_Click" /><br />
<br />
<hr style="width: 658px; height: 1px" />
<asp:Button ID="Export" runat="server" Height="32px" Text="导入数据" Width="156px" />
</asp:Content>

