Browse Source

Working on samples

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1677 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Peter Forstmeier 19 years ago
parent
commit
6ca65981b5
  1. 22
      samples/SharpReport/ReportSamples/MainForm.Designer.cs
  2. 244
      samples/SharpReport/ReportSamples/MainForm.cs
  3. 22
      samples/SharpReport/ReportSamples/MultipageUnboundPullModel.cs
  4. 7
      samples/SharpReport/ReportSamples/ReportSamples.csproj
  5. 1
      samples/SharpReport/ReportSamples/SimpleUnboundPullModel.cs

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

@ -42,7 +42,6 @@ namespace ReportSamples @@ -42,7 +42,6 @@ namespace ReportSamples
this.simpleFormsSheetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.unboundFormSheetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.pullMpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.customersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.employeeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.missingConnectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.pushModelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -100,26 +99,18 @@ namespace ReportSamples @@ -100,26 +99,18 @@ namespace ReportSamples
// pullMpToolStripMenuItem
//
this.pullMpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.customersToolStripMenuItem,
this.employeeToolStripMenuItem,
this.missingConnectionToolStripMenuItem});
this.pullMpToolStripMenuItem.Name = "pullMpToolStripMenuItem";
this.pullMpToolStripMenuItem.Size = new System.Drawing.Size(65, 20);
this.pullMpToolStripMenuItem.Text = "PullModell";
//
// customersToolStripMenuItem
//
this.customersToolStripMenuItem.Name = "customersToolStripMenuItem";
this.customersToolStripMenuItem.Size = new System.Drawing.Size(173, 22);
this.customersToolStripMenuItem.Text = "Customers";
this.customersToolStripMenuItem.Click += new System.EventHandler(this.CustomersClick);
//
// employeeToolStripMenuItem
//
this.employeeToolStripMenuItem.Name = "employeeToolStripMenuItem";
this.employeeToolStripMenuItem.Size = new System.Drawing.Size(173, 22);
this.employeeToolStripMenuItem.Text = "Employee";
this.employeeToolStripMenuItem.Click += new System.EventHandler(this.EmployeeClick);
this.employeeToolStripMenuItem.Text = "PullModel";
this.employeeToolStripMenuItem.Click += new System.EventHandler(this.PullModelClick);
//
// missingConnectionToolStripMenuItem
//
@ -139,9 +130,9 @@ namespace ReportSamples @@ -139,9 +130,9 @@ namespace ReportSamples
// emlpoyeesToolStripMenuItem
//
this.emlpoyeesToolStripMenuItem.Name = "emlpoyeesToolStripMenuItem";
this.emlpoyeesToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
this.emlpoyeesToolStripMenuItem.Text = "Employees-Push";
this.emlpoyeesToolStripMenuItem.Click += new System.EventHandler(this.EmployeesPushClick);
this.emlpoyeesToolStripMenuItem.Size = new System.Drawing.Size(138, 22);
this.emlpoyeesToolStripMenuItem.Text = "SimplePush";
this.emlpoyeesToolStripMenuItem.Click += new System.EventHandler(this.SimplePushClick);
//
// unboundToolStripMenuItem
//
@ -158,7 +149,7 @@ namespace ReportSamples @@ -158,7 +149,7 @@ namespace ReportSamples
//
this.unboundToolStripMenuItem1.Name = "unboundToolStripMenuItem1";
this.unboundToolStripMenuItem1.Size = new System.Drawing.Size(218, 22);
this.unboundToolStripMenuItem1.Text = "Unbound";
this.unboundToolStripMenuItem1.Text = "SimpleUnbound";
this.unboundToolStripMenuItem1.Click += new System.EventHandler(this.UnboundToolStripMenuItem1Click);
//
// unboundPullModelToolStripMenuItem
@ -237,7 +228,6 @@ namespace ReportSamples @@ -237,7 +228,6 @@ namespace ReportSamples
private System.Windows.Forms.ToolStripMenuItem emlpoyeesToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem missingConnectionToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem employeeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem customersToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem simpleFormsSheetToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem pushModelToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem pullMpToolStripMenuItem;

244
samples/SharpReport/ReportSamples/MainForm.cs

@ -31,226 +31,7 @@ namespace ReportSamples @@ -31,226 +31,7 @@ namespace ReportSamples
}
private void MissingConnection () {
try
{
string connectionString="";
OpenFileDialog dg = new OpenFileDialog();
dg.Filter = "SharpReport files|*.srd";
dg.Title = "Select a report file: ";
if (dg.ShowDialog() == DialogResult.OK)
{
SharpReportCore.SharpReportEngine mn = new SharpReportCore.SharpReportEngine();
SharpReportCore.ReportParameters pn = new SharpReportCore.ReportParameters();
// sql = "Provider=SQLOLEDB.1;Password=xxx;Persist Security Info=True;User ID=xxx;Initial Catalog=Northwind;Data Source=WS161";
connectionString = this.ConnectionStringFromMsDataLink();
// pn.ConnectionObject = new ConnectionObject(sql);
pn.ConnectionObject = this.ConnectionFromConnectionBuilder(connectionString);
// pn.SqlParameters.Clear();
// pn.SqlParameters.Add(new SharpReportCore.SqlParameter("@OrderID",System.Data.DbType.Int32,10248));
// pn.SortColumnCollection.Add(new SortColumn("UnitPrice",System.ComponentModel.ListSortDirection.Descending));
mn.PreviewStandartReport(dg.FileName.ToString(),pn);
// mn.PrintStandartReport(dg.FileName.ToString(),pn);
}
}
catch(Exception er)
{
MessageBox.Show(er.ToString(),": MainForm");
}
}
private void OpenPull()
{
try
{
OpenFileDialog dg = new OpenFileDialog();
dg.Filter = "SharpReport files|*.srd";
dg.Title = "Select a report file: ";
if (dg.ShowDialog() == DialogResult.OK){
SharpReportCore.SharpReportEngine mn = new SharpReportCore.SharpReportEngine();
mn.PreviewStandartReport(dg.FileName.ToString());
// mn.PrintStandartReport(dg.FileName.ToString());
}
}
catch(Exception er)
{
MessageBox.Show(er.ToString(),"MainForm");
}
}
#region unbound
private void OpenUnbound() {
try{
OpenFileDialog dg = new OpenFileDialog();
dg.Filter = "SharpReport files|*.srd";
dg.Title = "Select a report file: ";
if (dg.ShowDialog() == DialogResult.OK){
SharpReportCore.SharpReportEngine mn = new SharpReportCore.SharpReportEngine();
mn.SectionRendering += new EventHandler<SectionRenderEventArgs>(UnboundPrinting);
mn.SectionRendered += new EventHandler<SectionRenderEventArgs>(UnboundPrinted);
mn.PreviewStandartReport(dg.FileName.ToString());
}
}
catch(Exception er){
MessageBox.Show(er.ToString(),"MainForm");
}
}
private void UnboundPrinting (object sender,SectionRenderEventArgs e) {
// System.Console.WriteLine("");
// System.Console.WriteLine("--------------");
// System.Console.WriteLine("MainForm:OnTestPrinting <{0}> for PageNr <{1}>",e.CurrentSection,e.PageNumber);
// System.Console.WriteLine("\t <{0}> Items",e.Section.Items.Count);
//
//
switch (e.CurrentSection) {
case GlobalEnums.enmSection.ReportHeader:
System.Console.WriteLine("\tI found the ReportHeader");
break;
case GlobalEnums.enmSection.ReportPageHeader:
BaseTextItem t = (BaseTextItem)e.Section.Items.Find("reportTextItem1");
if (t != null) {
t.Location = new Point(80,5);
t.Text = "Label";
}
BaseDataItem bb = (BaseDataItem)e.Section.Items.Find("reportDbTextItem1");
if (bb != null) {
bb.DrawBorder = true;
bb.Location = new Point(200,5);
bb.DbValue = "Hello World";
}
System.Console.WriteLine("\tI found the Pageheader");
break;
case GlobalEnums.enmSection.ReportDetail:
System.Console.WriteLine("\tI found the ReportDetail");
BaseDataItem bdi = (BaseDataItem)e.Section.Items.Find("reportDbTextItem1");
if (bdi != null) {
bdi.BackColor = Color.LightGray;
bdi.Location = new Point(200,5);
bdi.DbValue = "Unbound Field in DetailSection";
}
break;
case GlobalEnums.enmSection.ReportPageFooter:
System.Console.WriteLine("\tI found the PageFooter");
BaseReportItem b = (BaseReportItem)e.Section.Items.Find("pageNumber1");
if (b != null) {
b.BackColor = Color.AliceBlue;
} else {
string s = String.Format ("<{0}> not found");
MessageBox.Show (s);
}
break;
case GlobalEnums.enmSection.ReportFooter:
System.Console.WriteLine("\tI found the ReportFooter");
break;
default:
break;
}
System.Console.WriteLine("");
}
private void UnboundPrinted (object sender,SectionRenderEventArgs e) {
// System.Console.WriteLine("MainForm:Rendering done for <{0}>",e.CurrentSection);
System.Console.WriteLine("----------");
}
#endregion
///<summary>Preferd Method to initialise the <see cref="SharpReportCore.ConnectionObject"></see>
/// hav a look to
/// <http://msdn2.microsoft.com/en-us/library/system.data.oledb.oledbconnectionstringbuilder(VS.80).aspx>
/// <example><code>
/// public void OleDbConnectionBuilderForSqlServer () {
/// OleDbConnectionStringBuilder builder = new OleDbConnectionStringBuilder();
/// builder["Provider"] = "SQLOLEDB.1";
/// builder["Integrated Security"] = "SSPI";
/// builder["Initial Catalog"] = "NorthWind";
/// System.Console.WriteLine("{0}",builder.ConnectionString);
/// ConnectionObject obj = new ConnectionObject(builder);
/// Assert.IsTrue(obj.Connection.State == ConnectionState.Closed,"Connection should be closed");
/// obj.Connection.Open();
/// Assert.IsTrue(obj.Connection.State == ConnectionState.Open,"Connection should be opend");
///}
/// </code></example>
/// </summary>
///
private SharpReportCore.ConnectionObject ConnectionFromConnectionBuilder (string sql) {
System.Data.Common.DbConnectionStringBuilder builder = new System.Data.OleDb.OleDbConnectionStringBuilder(sql);
return new SharpReportCore.ConnectionObject (builder.ConnectionString);
}
private string ConnectionStringFromMsDataLink() {
ADODB._Connection AdoConnection;
MSDASC.DataLinks dataLink = new MSDASC.DataLinks();
AdoConnection = null;
AdoConnection = (ADODB._Connection) dataLink.PromptNew();
return AdoConnection.ConnectionString;
}
///<summary>This Report is send directly to the Printer, PrintDialog is
/// showing when UseStandartPrinter to 'false'</summary>
private void OpenPushModell()
{
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 mn = new SharpReportCore.SharpReportEngine();
reportFileName = dg.FileName.ToString();
DataTable table = SelectData();
if (table != null) {
mn.PreviewPushDataReport(reportFileName,table);
// mn.PrintPushDataReport(reportFileName,table);
}
}
}
catch (Exception){
}
}
private 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;
}
public MainForm()
{
//
@ -265,32 +46,35 @@ namespace ReportSamples @@ -265,32 +46,35 @@ namespace ReportSamples
void SimpleFormsSheetClick(object sender, System.EventArgs e)
{
OpenPull();
SimplePullModel simplePull = new SimplePullModel();
simplePull.Run();
}
void CustomersClick(object sender, System.EventArgs e)
{
OpenPull();
}
void EmployeeClick(object sender, System.EventArgs e)
void PullModelClick(object sender, System.EventArgs e)
{
OpenPull();
SimplePullModel simplePull = new SimplePullModel();
simplePull.Run();
}
void MissingConnectionClick(object sender, System.EventArgs e)
{
MissingConnection();
MissingConnection missingConnection = new MissingConnection();
missingConnection.Run();
}
void EmployeesPushClick(object sender, System.EventArgs e)
void SimplePushClick(object sender, System.EventArgs e)
{
OpenPushModell();
SimplePushModel simplePush = new SimplePushModel();
simplePush.Run();
}
void UnboundToolStripMenuItem1Click(object sender, System.EventArgs e)
{
this.OpenUnbound();
SimpleUnbound simpleUnbound = new SimpleUnbound();
simpleUnbound.Run();
}
void UnboundPullModelToolStripMenuItemClick(object sender, System.EventArgs e){

22
samples/SharpReport/ReportSamples/MultipageUnboundPullModel.cs

@ -8,7 +8,6 @@ @@ -8,7 +8,6 @@
*/
using System;
using System.Windows.Forms;
using SharpReportCore;
@ -17,7 +16,7 @@ namespace ReportSamples{ @@ -17,7 +16,7 @@ namespace ReportSamples{
/// <summary>
/// Description of MultipageUnboundPullModel.
/// </summary>
public class MultiPageUnboundPullModel{
public class MultiPageUnboundPullModel :BaseSample{
int rowNr;
int rowsPerPage;
System.DateTime startTime;
@ -26,18 +25,17 @@ namespace ReportSamples{ @@ -26,18 +25,17 @@ namespace ReportSamples{
public MultiPageUnboundPullModel(){
}
public void Run() {
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){
base.Run();
if (!String.IsNullOrEmpty(base.ReportName)) {
MessageBox.Show("got it");
SharpReportCore.SharpReportEngine mn = new SharpReportCore.SharpReportEngine();
mn.SectionRendering += new EventHandler<SectionRenderEventArgs>(MultipagePrinting);
mn.SectionRendered += new EventHandler<SectionRenderEventArgs>(MultipagePrinted);
this.startTime = System.DateTime.Now;
mn.PreviewStandartReport(dg.FileName.ToString());
base.Engine.SectionRendering += new EventHandler<SectionRenderEventArgs>(MultipagePrinting);
base.Engine.SectionRendered += new EventHandler<SectionRenderEventArgs>(MultipagePrinted);
this.startTime = System.DateTime.Now;
base.Engine.PreviewStandartReport(base.ReportName);
}
}
catch(Exception er){

7
samples/SharpReport/ReportSamples/ReportSamples.csproj

@ -52,6 +52,13 @@ @@ -52,6 +52,13 @@
<Compile Include="ContributersList.cs" />
<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="MissingConnection.cs" />
<Compile Include="SimpleUnbound.cs" />
</ItemGroup>
<ItemGroup>
<COMReference Include="Microsoft ActiveX Data Objects 2.7 Library">

1
samples/SharpReport/ReportSamples/SimpleUnboundPullModel.cs

@ -23,6 +23,7 @@ namespace ReportSamples @@ -23,6 +23,7 @@ namespace ReportSamples
public SimpleUnboundPullModel(){
}
public void Run() {
try{
OpenFileDialog dg = new OpenFileDialog();

Loading…
Cancel
Save