Browse Source

Update Examples Reports using StoredProcedures with Parameters (SQl Server + Northwind) added

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1714 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Peter Forstmeier 19 years ago
parent
commit
4b2f438095
  1. 1
      samples/SharpReport/PullData/MSDE/CustOrdersOrders.srd
  2. 1
      samples/SharpReport/PullData/MSDE/NorthWindSalesByYear.srd
  3. 81
      samples/SharpReport/ReportSamples/BaseSample.cs
  4. 70
      samples/SharpReport/ReportSamples/ContributersList.cs
  5. 82
      samples/SharpReport/ReportSamples/CustOrdersOrdersDetail.cs
  6. 45
      samples/SharpReport/ReportSamples/EventLogger.cs
  7. 58
      samples/SharpReport/ReportSamples/MainForm.Designer.cs
  8. 63
      samples/SharpReport/ReportSamples/MainForm.cs
  9. 48
      samples/SharpReport/ReportSamples/MissingConnection.cs
  10. 13
      samples/SharpReport/ReportSamples/MultipageUnboundPullModel.cs
  11. 49
      samples/SharpReport/ReportSamples/NorthWindSalesByYear.cs
  12. 142
      samples/SharpReport/ReportSamples/ParameterDialog.cs
  13. 10
      samples/SharpReport/ReportSamples/ReportSamples.csproj
  14. 36
      samples/SharpReport/ReportSamples/SimplePullModel.cs
  15. 43
      samples/SharpReport/ReportSamples/SimplePushModel.cs
  16. 2
      samples/SharpReport/ReportSamples/SimpleUnboundPullModel.cs
  17. 30
      samples/SharpReport/ReportSamples/UnboundFormSheet.cs
  18. 7
      samples/SharpReport/ReportSamples/UnboundPushModel.cs
  19. 2
      samples/SharpReport/ReportsFromList/ContributersList.srd
  20. 2
      samples/SharpReport/ReportsFromList/EventLogReport.srd

1
samples/SharpReport/PullData/MSDE/CustOrdersOrders.srd

File diff suppressed because one or more lines are too long

1
samples/SharpReport/PullData/MSDE/NorthWindSalesByYear.srd

File diff suppressed because one or more lines are too long

81
samples/SharpReport/ReportSamples/BaseSample.cs

@ -0,0 +1,81 @@ @@ -0,0 +1,81 @@
/*
* Created by SharpDevelop.
* User: Forstmeier Helmut
* Date: 14.08.2006
* Time: 22:28
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Data;
using System.Windows.Forms;
using SharpReportCore;
namespace ReportSamples
{
/// <summary>
/// Description of BaseSample.
/// </summary>
public class BaseSample{
string msdeConnection = @"Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Northwind";
SharpReportEngine engine = new SharpReportCore.SharpReportEngine();
string reportName;
public BaseSample(){
engine = new SharpReportCore.SharpReportEngine();
}
public virtual void Run() {
try
{
OpenFileDialog dg = new OpenFileDialog();
dg.Filter = "SharpReport files|*.srd";
dg.Title = "Select a report file: ";
if (dg.ShowDialog() == DialogResult.OK){
this.reportName = dg.FileName;
}
}
catch(Exception er)
{
MessageBox.Show(er.ToString(),"MainForm");
}
}
protected DataTable SelectData()
{
OpenFileDialog dg = new OpenFileDialog();
dg.Filter = "SharpReport files|*.xsd";
dg.Title = "Select a '.xsdfile: ";
if (dg.ShowDialog() == DialogResult.OK){
DataSet ds = new DataSet();
ds.ReadXml(dg.FileName);
return ds.Tables[0];
}
return null;
}
protected SharpReportEngine Engine {
get {
return engine;
}
}
protected string ReportName {
get {
return reportName;
}
}
protected string MSDEConnection {
get {
return msdeConnection;
}
}
}
}

70
samples/SharpReport/ReportSamples/ContributersList.cs

@ -8,59 +8,59 @@ @@ -8,59 +8,59 @@
*/
using System;
using System.Windows.Forms;
using System.ComponentModel;
using System.Collections.Generic;
using System.Windows.Forms;
using SharpReportCore;
namespace ReportSamples{
/// <summary>
/// Description of ReportFromCollection.
/// </summary>
public class ContributersList
public class ContributersList:BaseSample
{
public ContributersList(){
}
public void Run () {
string reportFileName;
public override void Run () {
try
{
OpenFileDialog dg = new OpenFileDialog();
dg.Filter = "SharpReport files|*.srd";
dg.Title = "Select a report file: ";
if (dg.ShowDialog() == DialogResult.OK){
SharpReportCore.SharpReportEngine engine = new SharpReportCore.SharpReportEngine();
reportFileName = dg.FileName.ToString();
TestList list = new TestList();
list.Add(new LastFirst("Bernhard","Spuida","Core"));
list.Add(new LastFirst("Daniel","Grunwald","Core"));
list.Add(new LastFirst("Christoph","Wille","Core"));
list.Add(new LastFirst("Markus","Palme","Prg."));
list.Add(new LastFirst("Georg","Brandl","Prg."));
list.Add(new LastFirst("David","Srbecky","Debugger"));
list.Add(new LastFirst("Dickon","Field","DBTools"));
list.Add(new LastFirst("Matt","Ward","NUnit"));
list.Add(new LastFirst("Troy","Simpson","Prg."));
list.Add(new LastFirst("Peter","Forstmeier","SharpReport"));
list.Add(new LastFirst("David","Alpert","Prg."));
// list.Add(new LastFirst("Sylvana","Schmid"));
// engine.SectionRendering += new EventHandler<SectionRenderEventArgs>(PushPrinting);
// engine.SectionRendered += new EventHandler<SectionRenderEventArgs>(PushPrinted);
engine.PreviewPushDataReport(reportFileName,list);
// }
base.Run();
if (!String.IsNullOrEmpty(base.ReportName)) {
TestList list = CreateTestList();
base.Engine.PreviewPushDataReport(base.ReportName,list);
}
}
catch (Exception){
catch (Exception e){
MessageBox.Show(e.Message,this.ToString());
}
}
private TestList CreateTestList () {
TestList list = new TestList();
list.Add(new LastFirst("Bernhard","Spuida","Core"));
list.Add(new LastFirst("Daniel","Grunwald","Core"));
list.Add(new LastFirst("Christoph","Wille","Core"));
list.Add(new LastFirst("Markus","Palme","Prg."));
list.Add(new LastFirst("Georg","Brandl","Prg."));
list.Add(new LastFirst("David","Srbecky","Debugger"));
list.Add(new LastFirst("Dickon","Field","DBTools"));
list.Add(new LastFirst("Matt","Ward","NUnit"));
list.Add(new LastFirst("Troy","Simpson","Prg."));
list.Add(new LastFirst("Peter","Forstmeier","SharpReport"));
list.Add(new LastFirst("David","Alpert","Prg."));
return list;
}
}
public class LastFirst {
string last;
string first;

82
samples/SharpReport/ReportSamples/CustOrdersOrdersDetail.cs

@ -0,0 +1,82 @@ @@ -0,0 +1,82 @@
/*
* Created by SharpDevelop.
* User: Forstmeier Helmut
* Date: 23.08.2006
* Time: 22:24
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Windows.Forms;
using SharpReportCore;
namespace ReportSamples
{
/// <summary>
/// Description of CustOrdersDetail.
/// </summary>
public class CustOrdersOrdersDetail:BaseSample
{
string paramName;
public CustOrdersOrdersDetail()
{
}
public override void Run()
{
try {
base.Run();
if (!String.IsNullOrEmpty(base.ReportName)) {
ConnectionObject con = new ConnectionObject(base.MSDEConnection);
ReportParameters par = base.Engine.LoadParameters(base.ReportName);
par.ConnectionObject = con;
using (ParameterDialog dialog = new ParameterDialog(par.SqlParameters)){
dialog.ShowDialog();
if (dialog.DialogResult == DialogResult.OK) {
SqlParameter p = par.SqlParameters.Find("@CustomerID");
this.paramName = (string)p.ParameterValue;
base.Engine.SectionRendering += new EventHandler<SectionRenderEventArgs>(CustOrdersOrdersPrinting);
base.Engine.PreviewStandartReport(base.ReportName,par);
}
}
}
} catch (Exception e) {
MessageBox.Show(e.Message,this.ToString());
}
}
private void CustOrdersOrdersPrinting (object sender,SectionRenderEventArgs e) {
switch (e.CurrentSection) {
case GlobalEnums.enmSection.ReportHeader:
break;
case GlobalEnums.enmSection.ReportPageHeader:
BaseDataItem bdi = e.Section.Items.Find("CustomerID") as BaseDataItem;
bdi.DbValue = "[" + this.paramName + "]";
break;
case GlobalEnums.enmSection.ReportDetail:
break;
case GlobalEnums.enmSection.ReportPageFooter:
break;
case GlobalEnums.enmSection.ReportFooter:
break;
default:
break;
}
}
}
}

45
samples/SharpReport/ReportSamples/EventLogger.cs

@ -15,7 +15,7 @@ using System.Resources; @@ -15,7 +15,7 @@ using System.Resources;
using System.Windows.Forms;
using SharpReportCore;
using System.Reflection;
//using System.Collections.Generic;
namespace ReportSamples
@ -27,62 +27,53 @@ namespace ReportSamples @@ -27,62 +27,53 @@ namespace ReportSamples
/// <summary>
/// Description of EventLogger.
/// </summary>
public class EventLogger
public class EventLogger:BaseSample
{
ImageList imageList ;
public EventLogger()
public EventLogger():base()
{
}
public void Run() {
public override void Run() {
EventLog ev = new EventLog();
ev.Log = "System";
ev.MachineName = "."; // Lokale Maschine
FillImageList();
string reportFileName;
try
{
OpenFileDialog dg = new OpenFileDialog();
dg.Filter = "SharpReport files|*.srd";
dg.Title = "Select a report file: ";
if (dg.ShowDialog() == DialogResult.OK){
SharpReportCore.SharpReportEngine engine = new SharpReportCore.SharpReportEngine();
reportFileName = dg.FileName.ToString();
// EventLog dosn#t implement IList, so we have to convert it to the 'cheapest'
// IList implementaion
base.Run();
if (!String.IsNullOrEmpty(base.ReportName)) {
// EventLog dosn't implement IList, so we have to convert it to the 'cheapest'
// IList implementaion
ArrayList ar = new ArrayList();
ar.AddRange(ev.Entries);
SharpReportCore.SharpReportEngine engine = new SharpReportCore.SharpReportEngine();
engine.SectionRendering += new EventHandler<SectionRenderEventArgs>(PushPrinting);
engine.SectionRendered += new EventHandler<SectionRenderEventArgs>(PushPrinted);
engine.PreviewPushDataReport(reportFileName,ar);
engine.PreviewPushDataReport(base.ReportName,ar);
}
}
catch (Exception){
}
catch (Exception e){
MessageBox.Show(e.Message,this.ToString());
}
}
private void PushPrinting (object sender,SectionRenderEventArgs e) {
// System.Console.WriteLine("SimpleUnboundPullPrinting");
// CheckItems(e.Section.Items);
switch (e.CurrentSection) {
case GlobalEnums.enmSection.ReportHeader:
// System.Console.WriteLine("\tI found the ReportHeader");
break;
case GlobalEnums.enmSection.ReportPageHeader:
// System.Console.WriteLine("\tI found the Pageheader");
break;
case GlobalEnums.enmSection.ReportDetail:
// System.Console.WriteLine("\tI found the ReportDetail");
// this.rowNr ++;
RowItem ri = e.Section.Items[0] as RowItem;
if (ri != null) {
BaseDataItem r = (BaseDataItem)ri.Items.Find("reportDbTextItem1");
@ -105,11 +96,9 @@ namespace ReportSamples @@ -105,11 +96,9 @@ namespace ReportSamples
break;
case GlobalEnums.enmSection.ReportPageFooter:
// System.Console.WriteLine("\tI found the PageFooter");
break;
case GlobalEnums.enmSection.ReportFooter:
// System.Console.WriteLine("\tI found the ReportFooter");
break;
default:

58
samples/SharpReport/ReportSamples/MainForm.Designer.cs generated

@ -44,10 +44,12 @@ namespace ReportSamples @@ -44,10 +44,12 @@ namespace ReportSamples
this.pullMpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.employeeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.missingConnectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.northWindSalesByYearToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.custOrdersDetailToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.pushModelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.emlpoyeesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.unboundToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.unboundToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.unboundPullModelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.multipageUnboundPullModelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.unboundPuskModelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -86,21 +88,22 @@ namespace ReportSamples @@ -86,21 +88,22 @@ namespace ReportSamples
//
this.simpleFormsSheetToolStripMenuItem.Name = "simpleFormsSheetToolStripMenuItem";
this.simpleFormsSheetToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.simpleFormsSheetToolStripMenuItem.Text = "SimpleFormsSheet";
this.simpleFormsSheetToolStripMenuItem.Click += new System.EventHandler(this.SimpleFormsSheetClick);
this.simpleFormsSheetToolStripMenuItem.Text = "SimpleFormSheet";
this.simpleFormsSheetToolStripMenuItem.Click += new System.EventHandler(this.SimpleFormsSheet);
//
// unboundFormSheetToolStripMenuItem
//
this.unboundFormSheetToolStripMenuItem.Name = "unboundFormSheetToolStripMenuItem";
this.unboundFormSheetToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.unboundFormSheetToolStripMenuItem.Text = "UnboundFormSheet";
this.unboundFormSheetToolStripMenuItem.Click += new System.EventHandler(this.UnboundFormSheetToolStripMenuItemClick);
this.unboundFormSheetToolStripMenuItem.Click += new System.EventHandler(this.UnboundFormSheet);
//
// pullMpToolStripMenuItem
//
this.pullMpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.employeeToolStripMenuItem,
this.missingConnectionToolStripMenuItem});
this.missingConnectionToolStripMenuItem,
this.toolStripMenuItem1});
this.pullMpToolStripMenuItem.Name = "pullMpToolStripMenuItem";
this.pullMpToolStripMenuItem.Size = new System.Drawing.Size(65, 20);
this.pullMpToolStripMenuItem.Text = "PullModell";
@ -119,6 +122,29 @@ namespace ReportSamples @@ -119,6 +122,29 @@ namespace ReportSamples
this.missingConnectionToolStripMenuItem.Text = "MissingConnection";
this.missingConnectionToolStripMenuItem.Click += new System.EventHandler(this.MissingConnectionClick);
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.northWindSalesByYearToolStripMenuItem,
this.custOrdersDetailToolStripMenuItem});
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(173, 22);
this.toolStripMenuItem1.Text = "From MSDE";
//
// northWindSalesByYearToolStripMenuItem
//
this.northWindSalesByYearToolStripMenuItem.Name = "northWindSalesByYearToolStripMenuItem";
this.northWindSalesByYearToolStripMenuItem.Size = new System.Drawing.Size(195, 22);
this.northWindSalesByYearToolStripMenuItem.Text = "NorthWindSalesByYear";
this.northWindSalesByYearToolStripMenuItem.Click += new System.EventHandler(this.NorthWindSalesByYearClick);
//
// custOrdersDetailToolStripMenuItem
//
this.custOrdersDetailToolStripMenuItem.Name = "custOrdersDetailToolStripMenuItem";
this.custOrdersDetailToolStripMenuItem.Size = new System.Drawing.Size(195, 22);
this.custOrdersDetailToolStripMenuItem.Text = "CustOrdersOrders";
this.custOrdersDetailToolStripMenuItem.Click += new System.EventHandler(this.CustOrdersDetailClick);
//
// pushModelToolStripMenuItem
//
this.pushModelToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -137,7 +163,6 @@ namespace ReportSamples @@ -137,7 +163,6 @@ namespace ReportSamples
// unboundToolStripMenuItem
//
this.unboundToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.unboundToolStripMenuItem1,
this.unboundPullModelToolStripMenuItem,
this.multipageUnboundPullModelToolStripMenuItem,
this.unboundPuskModelToolStripMenuItem});
@ -145,33 +170,26 @@ namespace ReportSamples @@ -145,33 +170,26 @@ namespace ReportSamples
this.unboundToolStripMenuItem.Size = new System.Drawing.Size(62, 20);
this.unboundToolStripMenuItem.Text = "Unbound";
//
// unboundToolStripMenuItem1
//
this.unboundToolStripMenuItem1.Name = "unboundToolStripMenuItem1";
this.unboundToolStripMenuItem1.Size = new System.Drawing.Size(218, 22);
this.unboundToolStripMenuItem1.Text = "SimpleUnbound";
this.unboundToolStripMenuItem1.Click += new System.EventHandler(this.UnboundToolStripMenuItem1Click);
//
// unboundPullModelToolStripMenuItem
//
this.unboundPullModelToolStripMenuItem.Name = "unboundPullModelToolStripMenuItem";
this.unboundPullModelToolStripMenuItem.Size = new System.Drawing.Size(218, 22);
this.unboundPullModelToolStripMenuItem.Text = "UnboundPullModel";
this.unboundPullModelToolStripMenuItem.Click += new System.EventHandler(this.UnboundPullModelToolStripMenuItemClick);
this.unboundPullModelToolStripMenuItem.Click += new System.EventHandler(this.UnboundPullModelClick);
//
// multipageUnboundPullModelToolStripMenuItem
//
this.multipageUnboundPullModelToolStripMenuItem.Name = "multipageUnboundPullModelToolStripMenuItem";
this.multipageUnboundPullModelToolStripMenuItem.Size = new System.Drawing.Size(218, 22);
this.multipageUnboundPullModelToolStripMenuItem.Text = "MultipageUnboundPullModel";
this.multipageUnboundPullModelToolStripMenuItem.Click += new System.EventHandler(this.MultipageUnboundPullModelToolStripMenuItemClick);
this.multipageUnboundPullModelToolStripMenuItem.Click += new System.EventHandler(this.MultiPageUnboundPullModelClick);
//
// unboundPuskModelToolStripMenuItem
//
this.unboundPuskModelToolStripMenuItem.Name = "unboundPuskModelToolStripMenuItem";
this.unboundPuskModelToolStripMenuItem.Size = new System.Drawing.Size(218, 22);
this.unboundPuskModelToolStripMenuItem.Text = "UnboundPushModel";
this.unboundPuskModelToolStripMenuItem.Click += new System.EventHandler(this.UnboundPushModelToolStripMenuItemClick);
this.unboundPuskModelToolStripMenuItem.Click += new System.EventHandler(this.UnboundPushModelClick);
//
// listDatasourceToolStripMenuItem
//
@ -187,14 +205,14 @@ namespace ReportSamples @@ -187,14 +205,14 @@ namespace ReportSamples
this.simpleListToolStripMenuItem.Name = "simpleListToolStripMenuItem";
this.simpleListToolStripMenuItem.Size = new System.Drawing.Size(161, 22);
this.simpleListToolStripMenuItem.Text = "ContributersList";
this.simpleListToolStripMenuItem.Click += new System.EventHandler(this.ListDatasourceToolStripMenuItemClick);
this.simpleListToolStripMenuItem.Click += new System.EventHandler(this.ContributersListClick);
//
// eventLoggerToolStripMenuItem
//
this.eventLoggerToolStripMenuItem.Name = "eventLoggerToolStripMenuItem";
this.eventLoggerToolStripMenuItem.Size = new System.Drawing.Size(161, 22);
this.eventLoggerToolStripMenuItem.Text = "EventLogger";
this.eventLoggerToolStripMenuItem.Click += new System.EventHandler(this.EventLoggerToolStripMenuItemClick);
this.eventLoggerToolStripMenuItem.Click += new System.EventHandler(this.EventLoggerClick);
//
// errorProvider1
//
@ -215,6 +233,9 @@ namespace ReportSamples @@ -215,6 +233,9 @@ namespace ReportSamples
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Windows.Forms.ToolStripMenuItem custOrdersDetailToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem northWindSalesByYearToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem eventLoggerToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem simpleListToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem listDatasourceToolStripMenuItem;
@ -222,7 +243,6 @@ namespace ReportSamples @@ -222,7 +243,6 @@ namespace ReportSamples
private System.Windows.Forms.ToolStripMenuItem unboundPuskModelToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem multipageUnboundPullModelToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem unboundPullModelToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem unboundToolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem unboundToolStripMenuItem;
private System.Windows.Forms.ErrorProvider errorProvider1;
private System.Windows.Forms.ToolStripMenuItem emlpoyeesToolStripMenuItem;

63
samples/SharpReport/ReportSamples/MainForm.cs

@ -39,18 +39,25 @@ namespace ReportSamples @@ -39,18 +39,25 @@ namespace ReportSamples
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
void SimpleFormsSheetClick(object sender, System.EventArgs e)
#region FormsSheet
void SimpleFormsSheet(object sender, System.EventArgs e)
{
SimplePullModel simplePull = new SimplePullModel();
simplePull.Run();
}
void UnboundFormSheet(object sender, System.EventArgs e){
UnboundFormSheet unboundFormSheet = new UnboundFormSheet();
unboundFormSheet.Run();
}
#endregion
#region PullModel
void PullModelClick(object sender, System.EventArgs e)
{
@ -65,50 +72,70 @@ namespace ReportSamples @@ -65,50 +72,70 @@ namespace ReportSamples
missingConnection.Run();
}
#endregion
#region PushModel
void SimplePushClick(object sender, System.EventArgs e)
{
SimplePushModel simplePush = new SimplePushModel();
simplePush.Run();
}
void UnboundToolStripMenuItem1Click(object sender, System.EventArgs e)
{
SimpleUnbound simpleUnbound = new SimpleUnbound();
simpleUnbound.Run();
}
#endregion
#region Unbound
void UnboundPullModelToolStripMenuItemClick(object sender, System.EventArgs e){
void UnboundPullModelClick(object sender, System.EventArgs e){
SimpleUnboundPullModel sm = new SimpleUnboundPullModel();
sm.Run();
}
void MultipageUnboundPullModelToolStripMenuItemClick(object sender, System.EventArgs e)
void MultiPageUnboundPullModelClick(object sender, System.EventArgs e)
{
MultiPageUnboundPullModel mp = new MultiPageUnboundPullModel();
mp.Run();
}
void UnboundPushModelToolStripMenuItemClick(object sender, System.EventArgs e)
void UnboundPushModelClick(object sender, System.EventArgs e)
{
UnboundPushModel u = new UnboundPushModel();
u.Run();
}
void UnboundFormSheetToolStripMenuItemClick(object sender, System.EventArgs e){
UnboundFormSheet unboundFormSheet = new UnboundFormSheet();
unboundFormSheet.Run();
}
#endregion
void ListDatasourceToolStripMenuItemClick(object sender, System.EventArgs e)
#region List as DataSource
void ContributersListClick(object sender, System.EventArgs e)
{
ContributersList r = new ContributersList();
r.Run();
}
void EventLoggerToolStripMenuItemClick(object sender, System.EventArgs e)
void EventLoggerClick(object sender, System.EventArgs e)
{
EventLogger el = new EventLogger();
el.Run();
}
#endregion
#region MSDE
void NorthWindSalesByYearClick(object sender, System.EventArgs e)
{
NorthWindSalesByYear northWindSalesByYear = new NorthWindSalesByYear();
northWindSalesByYear.Run();
}
void CustOrdersDetailClick(object sender, System.EventArgs e)
{
CustOrdersOrdersDetail custOrderDetail = new CustOrdersOrdersDetail();
custOrderDetail.Run();
}
#endregion
}
}

48
samples/SharpReport/ReportSamples/MissingConnection.cs

@ -0,0 +1,48 @@ @@ -0,0 +1,48 @@
/*
* Created by SharpDevelop.
* User: Forstmeier Helmut
* Date: 14.08.2006
* Time: 22:37
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Data;
using System.Data.OleDb;
using System.Windows.Forms;
using SharpReportCore;
namespace ReportSamples
{
/// <summary>
/// Description of MissingConnection.
/// </summary>
public class MissingConnection:BaseSample
{
string conString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\CSharp\samples\Nwind.mdb;Persist Security Info=False";
public MissingConnection(){
}
public override void Run(){
base.Run();
ReportParameters p = base.Engine.LoadParameters(base.ReportName);
/* this snippet shows a different method to get a valid ConnectionObject
ConnectionObject con = new ConnectionObject(this.conString);
p.ConnectionObject = con;
*/
try {
System.Data.OleDb.OleDbConnectionStringBuilder b = new OleDbConnectionStringBuilder(this.conString); p.ConnectionObject = new ConnectionObject(b);
base.Engine.PreviewStandartReport(base.ReportName,p);
} catch (Exception e) {
MessageBox.Show(e.Message,this.ToString());
}
}
}
}

13
samples/SharpReport/ReportSamples/MultipageUnboundPullModel.cs

@ -30,7 +30,6 @@ namespace ReportSamples{ @@ -30,7 +30,6 @@ namespace ReportSamples{
try{
base.Run();
if (!String.IsNullOrEmpty(base.ReportName)) {
MessageBox.Show("got it");
SharpReportCore.SharpReportEngine mn = new SharpReportCore.SharpReportEngine();
base.Engine.SectionRendering += new EventHandler<SectionRenderEventArgs>(MultipagePrinting);
base.Engine.SectionRendered += new EventHandler<SectionRenderEventArgs>(MultipagePrinted);
@ -39,23 +38,19 @@ namespace ReportSamples{ @@ -39,23 +38,19 @@ namespace ReportSamples{
}
}
catch(Exception er){
MessageBox.Show(er.ToString(),"MainForm");
MessageBox.Show(er.ToString(),this.ToString());
}
}
private void MultipagePrinting (object sender,SectionRenderEventArgs e) {
// System.Console.WriteLine("UnboundPullPrinting");
CheckItems(e.Section.Items);
switch (e.CurrentSection) {
case GlobalEnums.enmSection.ReportHeader:
// System.Console.WriteLine("\tReportHeader");
break;
case GlobalEnums.enmSection.ReportPageHeader:
// System.Console.WriteLine("\tPageheader");
System.Console.WriteLine("");
System.Console.WriteLine("");
this.rowsPerPage = 0;
break;
@ -63,7 +58,7 @@ namespace ReportSamples{ @@ -63,7 +58,7 @@ namespace ReportSamples{
this.rowNr ++;
this.rowsPerPage ++;
// System.Console.WriteLine("\tReportDetail");
RowItem ri = e.Section.Items[0] as RowItem;
if (ri != null) {
if (this.rowNr %2 == 0) {
@ -75,7 +70,6 @@ namespace ReportSamples{ @@ -75,7 +70,6 @@ namespace ReportSamples{
break;
case GlobalEnums.enmSection.ReportPageFooter:
// System.Console.WriteLine("\tPageFooter");
BaseDataItem bdi = e.Section.Items.Find("ItemsPerPage") as BaseDataItem;
if (bdi != null) {
bdi.DbValue = this.rowsPerPage.ToString();
@ -83,7 +77,6 @@ namespace ReportSamples{ @@ -83,7 +77,6 @@ namespace ReportSamples{
break;
case GlobalEnums.enmSection.ReportFooter:
// System.Console.WriteLine("\tReportFooter");
this.endTime = System.DateTime.Now;
BaseDataItem b = e.Section.Items.Find("reportDbTextItem1")as BaseDataItem;

49
samples/SharpReport/ReportSamples/NorthWindSalesByYear.cs

@ -0,0 +1,49 @@ @@ -0,0 +1,49 @@
/*
* Created by SharpDevelop.
* User: Forstmeier Helmut
* Date: 16.08.2006
* Time: 11:10
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Windows.Forms;
using SharpReportCore;
namespace ReportSamples
{
/// <summary>
/// Description of StoredProcedure.
/// </summary>
public class NorthWindSalesByYear:BaseSample
{
// string conString = @"Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Northwind";
public NorthWindSalesByYear():base()
{
}
public override void Run(){
try {
base.Run();
if (!String.IsNullOrEmpty(base.ReportName)) {
ConnectionObject con = new ConnectionObject(base.MSDEConnection);
ReportParameters par = base.Engine.LoadParameters(base.ReportName);
par.ConnectionObject = con;
par.SqlParameters.Clear();
par.SqlParameters.Add(new SqlParameter("@Beginning_Date",
System.Data.DbType.DateTime,
"01/01/1997"));
par.SqlParameters.Add(new SqlParameter("@Ending_Date",
System.Data.DbType.DateTime,
"31.01.1997"));
base.Engine.PreviewStandartReport(base.ReportName,par);
}
} catch (Exception e) {
MessageBox.Show(e.Message,this.ToString());
}
}
}
}

142
samples/SharpReport/ReportSamples/ParameterDialog.cs

@ -0,0 +1,142 @@ @@ -0,0 +1,142 @@
/*
* Created by SharpDevelop.
* User: Forstmeier Helmut
* Date: 09.08.2006
* Time: 13:55
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using SharpReportCore;
namespace ReportSamples{
/// <summary>
/// Description of ParameterDialog.
/// </summary>
public class ParameterDialog : System.Windows.Forms.Form
{
private SqlParametersCollection collection;
public ParameterDialog(SqlParametersCollection collection):this(){
this.collection = collection;
this.dataGrid1.DataSource = this.collection;
}
public ParameterDialog()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
}
#region Designer generated
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.cancelButton = new System.Windows.Forms.Button();
this.okButton = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.tableLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(48, 26);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(363, 120);
this.dataGrid1.TabIndex = 1;
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 2;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 77.28119F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 22.71881F));
this.tableLayoutPanel1.Controls.Add(this.cancelButton, 1, 0);
this.tableLayoutPanel1.Controls.Add(this.okButton, 0, 0);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.tableLayoutPanel1.Location = new System.Drawing.Point(10, 175);
this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(10, 3, 10, 3);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 1;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(457, 30);
this.tableLayoutPanel1.TabIndex = 3;
//
// cancelButton
//
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancelButton.Dock = System.Windows.Forms.DockStyle.Right;
this.cancelButton.Location = new System.Drawing.Point(374, 3);
this.cancelButton.Name = "cancelButton";
this.cancelButton.Size = new System.Drawing.Size(80, 24);
this.cancelButton.TabIndex = 0;
this.cancelButton.Text = "Cancel";
this.cancelButton.UseVisualStyleBackColor = true;
//
// okButton
//
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
this.okButton.Dock = System.Windows.Forms.DockStyle.Right;
this.okButton.Location = new System.Drawing.Point(275, 3);
this.okButton.Name = "okButton";
this.okButton.Size = new System.Drawing.Size(75, 24);
this.okButton.TabIndex = 1;
this.okButton.Text = "Ok";
this.okButton.UseVisualStyleBackColor = true;
//
// ParameterDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.cancelButton;
this.ClientSize = new System.Drawing.Size(477, 215);
this.ControlBox = false;
this.Controls.Add(this.tableLayoutPanel1);
this.Controls.Add(this.dataGrid1);
this.Name = "ParameterDialog";
this.Padding = new System.Windows.Forms.Padding(10);
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "ParameterDialog";
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.tableLayoutPanel1.ResumeLayout(false);
this.ResumeLayout(false);
}
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.Button cancelButton;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.DataGrid dataGrid1;
#endregion
}
}

10
samples/SharpReport/ReportSamples/ReportSamples.csproj

@ -53,12 +53,12 @@ @@ -53,12 +53,12 @@
<Compile Include="EventLogger.cs" />
<EmbeddedResource Include="ImageResource.resx" />
<Compile Include="BaseSample.cs" />
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
<Compile Include="SimpleReports.cs" />
<Compile Include="SimplePullModel.cs" />
<Compile Include="MissingConnection.cs" />
<Compile Include="SimpleUnbound.cs" />
<Compile Include="SimplePushModel.cs" />
<Compile Include="NorthWindSalesByYear.cs" />
<Compile Include="CustOrdersOrdersDetail.cs" />
<Compile Include="ParameterDialog.cs" />
</ItemGroup>
<ItemGroup>
<COMReference Include="Microsoft ActiveX Data Objects 2.7 Library">

36
samples/SharpReport/ReportSamples/SimplePullModel.cs

@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
/*
* Created by SharpDevelop.
* User: Forstmeier Helmut
* Date: 14.08.2006
* Time: 22:37
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Windows.Forms;
using SharpReportCore;
namespace ReportSamples
{
/// <summary>
/// Description of SimplePullModel.
/// </summary>
public class SimplePullModel:BaseSample
{
public SimplePullModel(){
}
public override void Run(){
try {
base.Run();
base.Engine.PreviewStandartReport(base.ReportName);
} catch (Exception e) {
MessageBox.Show(e.ToString(),this.ToString());
}
}
}
}

43
samples/SharpReport/ReportSamples/SimplePushModel.cs

@ -0,0 +1,43 @@ @@ -0,0 +1,43 @@
/*
* Created by SharpDevelop.
* User: Forstmeier Helmut
* Date: 14.08.2006
* Time: 22:41
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Data;
using System.Windows.Forms;
using SharpReportCore;
namespace ReportSamples
{
/// <summary>
/// Description of SimplePushModel.
/// </summary>
public class SimplePushModel:BaseSample
{
public SimplePushModel()
{
}
public override void Run(){
try {
base.Run();
DataTable table = SelectData();
if (table != null) {
base.Engine.PreviewPushDataReport(base.ReportName,table);
}
} catch (Exception e) {
MessageBox.Show(e.Message,this.ToString());
}
}
}
}

2
samples/SharpReport/ReportSamples/SimpleUnboundPullModel.cs

@ -38,7 +38,7 @@ namespace ReportSamples @@ -38,7 +38,7 @@ namespace ReportSamples
}
}
catch(Exception er){
MessageBox.Show(er.ToString(),"MainForm");
MessageBox.Show(er.ToString(),this.ToString());
}
}
private void SimplePullPrinting (object sender,SectionRenderEventArgs e) {

30
samples/SharpReport/ReportSamples/UnboundFormSheet.cs

@ -17,33 +17,27 @@ namespace ReportSamples @@ -17,33 +17,27 @@ namespace ReportSamples
/// <summary>
/// Description of UnboundFormSheet.
/// </summary>
public class UnboundFormSheet
public class UnboundFormSheet:BaseSample
{
public UnboundFormSheet()
public UnboundFormSheet():base()
{
}
public void Run() {
try
{
OpenFileDialog dg = new OpenFileDialog();
dg.Filter = "SharpReport files|*.srd";
dg.Title = "Select a report file: ";
public override void Run()
{
try {
if (dg.ShowDialog() == DialogResult.OK){
SharpReportCore.SharpReportEngine engine = new SharpReportCore.SharpReportEngine();
engine.SectionRendering += new EventHandler<SectionRenderEventArgs>(UnboundPrinting);
engine.SectionRendered += new EventHandler<SectionRenderEventArgs>(UnboundPrinted);
engine.PreviewStandartReport(dg.FileName.ToString());
}
}
catch(Exception er)
{
MessageBox.Show(er.ToString(),"MainForm");
base.Run();
base.Engine.SectionRendering += new EventHandler<SectionRenderEventArgs>(UnboundPrinting);
base.Engine.SectionRendered += new EventHandler<SectionRenderEventArgs>(UnboundPrinted);
base.Engine.PreviewStandartReport(base.ReportName);
} catch (Exception e) {
MessageBox.Show(e.Message,this.ToString());
}
}
private void UnboundPrinting (object sender,SectionRenderEventArgs e) {
System.Console.WriteLine("UnboundFormSheet");

7
samples/SharpReport/ReportSamples/UnboundPushModel.cs

@ -41,12 +41,13 @@ namespace ReportSamples @@ -41,12 +41,13 @@ namespace ReportSamples
if (table != null) {
engine.SectionRendering += new EventHandler<SectionRenderEventArgs>(PushPrinting);
engine.SectionRendered += new EventHandler<SectionRenderEventArgs>(PushPrinted);
// engine.PreviewPushDataReport(reportFileName,table);
engine.PrintPushDataReport(reportFileName,table);
engine.PreviewPushDataReport(reportFileName,table);
// engine.PrintPushDataReport(reportFileName,table);
}
}
}
catch (Exception){
catch (Exception e){
MessageBox.Show(e.Message,this.ToString());
}
}

2
samples/SharpReport/ReportsFromList/ContributersList.srd

File diff suppressed because one or more lines are too long

2
samples/SharpReport/ReportsFromList/EventLogReport.srd

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save