FastReport报表使用代码C#

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

using System;

using System.Data;

using ponentModel;

using FastReport;

namespace cx

{

///

/// Summary description for FrxDataSet.

///

public class FrxDataTable : DataTable

{

private int nItem;

TfrxUserDataSetClass m_ds;

private DataTable m_ChildTable;

public new string TableName

{

get { return m_; }

}

public IfrxDataSet FrxTable

{

get { return m_ds as IfrxDataSet; }

}

private void constructor(string name)

{

m_ChildTable = null;

m_ds = new TfrxUserDataSetClass();

m_ds.OnCheckEOF += new

IfrxUserDataSetEvents_OnCheckEOFEventHandler(OnCheckEOFEventHandler); m_ds.OnGetValue += new

IfrxUserDataSetEvents_OnGetValueEventHandler(OnGetValueHandler);

m_ds.OnFirst += new

IfrxUserDataSetEvents_OnFirstEventHandler(OnFirstEventHandler);

m_ds.OnNext += new

IfrxUserDataSetEvents_OnNextEventHandler(OnNextEventHandler);

m_ds.OnPrior += new

IfrxUserDataSetEvents_OnPriorEventHandler(OnPriorEventHandler);

m_ = name;

DataColumnCollection cols = Columns;

cols.CollectionChanged += new CollectionChangeEventHandler(ColumnsCollection_Changed);

}

public FrxDataTable(string name)

{

constructor(name);

}

public FrxDataTable(DataTable t)

{

constructor(t.TableName);

string FieldNames = null;

foreach (DataColumn col in t.Columns) FieldNames += col.Caption + "\n"; m_ds.Fields = FieldNames;

m_ChildTable = t;

}

///

/// Assigns table to report

///

public void AssignToDataBand(string BandName, TfrxReportClass report)

{

IfrxComponent frx_component;

((IfrxComponent)report).FindObject(BandName, out frx_component);

((IfrxDataBand)frx_component).DataSet = (IfrxDataSet)m_ds;

}

///

/// Assigns table to report

///

public void AssignToReport(bool Enable, TfrxReportClass report)

{

report.SelectDataset(Enable, m_ds);

}

///

/// On First event handler

///

private void OnFirstEventHandler()

{

nItem = 0;

}

///

/// On Next event handler

///

private void OnNextEventHandler()

{

nItem++;

}

///

/// On Prior evene handler

///

private void OnPriorEventHandler()

{

nItem--;

}

///

/// On check EndOfFile event handler

///

private void OnCheckEOFEventHandler(out bool eof)

{

if (m_ChildTable == null)

{

eof = (nItem >= Rows.Count);

}

else

{

eof = (nItem >= m_ChildTable.Rows.Count);

}

}

///

/// On get value handler

///

private void OnGetValueHandler(object VarName, out object Val) {

if (m_ChildTable == null)

{

Val = Rows[nItem][VarName.ToString()];

}

else

{

Val = m_ChildTable.Rows[nItem][VarName.ToString()];

}

// FastReport does not know about System.Decimal object type

// so convert it to Integer

if (Val is Decimal)

{

Val = Decimal.ToInt32((Decimal)Val);

}

}

相关文档
最新文档