Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1714 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
20 changed files with 646 additions and 139 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -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; |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -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()); |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
} |
@ -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()); |
||||
} |
||||
} |
||||
|
||||
} |
||||
} |
@ -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
|
||||
} |
||||
} |
@ -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()); |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
} |
@ -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()); |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
} |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue