using System; using System.Collections.Generic; using System.Text; using gregn6Lib; using System.Data; using System.Data.SqlClient; using System.Collections; using System.Runtime.Serialization; namespace BLL { /// /// Ë«Íø¸ñ´òÓ¡ /// [Serializable()] public class ReportBase : IReport { private GridppReport GRReport = new GridppReport(); private IDataReader Dr; private DataTable Dt; private Hashtable t = new Hashtable(); private IList array = null; private subRpt _subRpt = null; private int subRptIndex = 0; public class subRpt { public subRpt(GridppReport Report, IDataReader Dr, Hashtable t) { this.Report = Report; this.Dr = Dr; this.t = t; } private GridppReport report; public GridppReport Report { get { return Report; } set { Report = value; } } private IDataReader dr; public IDataReader Dr { get { return dr; } set { dr = value; } } private Hashtable t1; public Hashtable t { get { return t1; } set { t1 = value; } } } #region IReport ³ÉÔ± public void MainReport(GridppReport Report, string FileName) { this.array = new List(); this.GRReport = Report; this.GRReport.LoadFromFile(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "report\\" + FileName + ".grf"); } public void SubReport(String Name, IDataReader Dr, Hashtable t) { GridppReport rptSub = this.GRReport.ControlByName(Name).AsSubReport.Report; array.Add(new subRpt(rptSub, Dr, t)); rptSub.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(rpt_BeforePostRecord); rptSub.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(rpt_FetchRecord); } public void rpt_BeforePostRecord() { if (_subRpt.t != null) { foreach (DictionaryEntry obj in _subRpt.t) { _subRpt.Report.FieldByName(obj.Key.ToString()).AsString = obj.Value.ToString(); } } } public void rpt_FetchRecord() { this._subRpt = array[subRptIndex]; Utility.FillRecordToReport(this._subRpt.Report, this._subRpt.Dr); subRptIndex++; } //³õʼ»¯±¨±í public object InitReport(GridppReport Report, IDataReader Dr, string FileName, Hashtable t) { try { this.GRReport = Report; this.Dr = Dr; this.t = t; this.GRReport.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(BeforePostRecord); this.GRReport.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(FetchRecord); this.GRReport.LoadFromFile(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "report\\" + FileName + ".grf"); return this.GRReport; } catch { return null; } } #region IReport ³ÉÔ± public object InitReport(GridppReport Report, DataTable Dt, string FileName, Hashtable t) { try { this.GRReport = Report; this.Dt = Dt; this.t = t; this.GRReport.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(BeforePostRecord); this.GRReport.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(FetchRecordDataTable); this.GRReport.LoadFromFile(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "report\\" + FileName + ".grf"); return this.GRReport; } catch { return null; } } #endregion public void BeforePostRecord() { if (t != null) { foreach (DictionaryEntry obj in t) { this.GRReport.FieldByName(obj.Key.ToString()).AsString = obj.Value.ToString(); } } } public void FetchRecord() { Utility.FillRecordToReport(this.GRReport, this.Dr); } public void FetchRecordDataTable() { Utility.FillRecordToReport(this.GRReport, this.Dt); } public void Print(bool ShowPrintDialg) { this.GRReport.Print(ShowPrintDialg); } public void PrintPreview(bool ShowModal) { this.GRReport.PrintPreview(ShowModal); } public void Export(GRExportType type, bool ShowOptionDlg, bool DoneOpen) { this.GRReport.ExportDirect(type, this.GRReport.Title, ShowOptionDlg, DoneOpen); } public string GetPath() { return System.Environment.CurrentDirectory + "\\" + this.GRReport.Title + ".xls"; } public object GetReport() { return this.GRReport; } #endregion } }