diff --git a/src/AddIns/Misc/SharpReport/SharpReport/SharpReportManager.cs b/src/AddIns/Misc/SharpReport/SharpReport/SharpReportManager.cs index 08aad313a4..d34d0e8780 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/SharpReportManager.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/SharpReportManager.cs @@ -53,21 +53,19 @@ namespace SharpReport{ #region privates private ConnectionObject BuildConnectionObject (ReportSettings settings) { - System.Console.WriteLine("Manager:BuildConnectionObject"); - try { - if (settings.ConnectionString.Length > 0) { - System.Console.WriteLine("\tBuild from settings"); - return new ConnectionObject(settings.ConnectionString); - } else { - System.Console.WriteLine("\tBuild from DataLink"); - IConnection ole = OLEDBConnectionWrapper.CreateFromDataConnectionLink(); - - System.Console.WriteLine("\t Con Str {0}",ole.ConnectionString); - return new ConnectionObject(ole.ConnectionString); + if (settings.ReportType == GlobalEnums.enmReportType.DataReport) { + try { + if (settings.ConnectionString.Length > 0) { + return new ConnectionObject(settings.ConnectionString); + } else { + IConnection ole = OLEDBConnectionWrapper.CreateFromDataConnectionLink(); + return new ConnectionObject(ole.ConnectionString); + } + } catch (Exception) { + throw; } - } catch (Exception) { - throw; } + return null; } /// @@ -77,7 +75,7 @@ namespace SharpReport{ /// private ColumnCollection ReadColumnCollection() { - System.Console.WriteLine("ReadColumnCOllection"); + DataManager dataManager = null; if (baseDesignerControl == null) { return new ColumnCollection(); @@ -90,15 +88,13 @@ namespace SharpReport{ if (baseDesignerControl.ReportModel.ReportSettings.DataModel.Equals(GlobalEnums.enmPushPullModel.PushData)) { return new ColumnCollection(); } - System.Console.WriteLine("\tConnectionObject == null {0}",(base.ConnectionObject == null)); // PullData, query the Datasource and ask for the available Fields if (base.ConnectionObject == null) { - System.Console.WriteLine("\tlook for Connection"); base.ConnectionObject = this.BuildConnectionObject(baseDesignerControl.ReportModel.ReportSettings); } if (this.baseDesignerControl.ReportModel.ReportSettings.DataModel.Equals(GlobalEnums.enmPushPullModel.PullData)){ - System.Console.WriteLine("\t tryx to use DataManager"); + using (dataManager = new DataManager(base.ConnectionObject, baseDesignerControl.ReportModel.ReportSettings)) { dataManager.DataBind(); @@ -327,6 +323,12 @@ namespace SharpReport{ try { System.Console.WriteLine("--------------------"); System.Console.WriteLine("Manager:ReportPreview"); + + //Allways check for a valid ConnectionObject + if (base.ConnectionObject == null) { + base.ConnectionObject = this.BuildConnectionObject(baseDesignerControl.ReportModel.ReportSettings); + } + AbstractRenderer abstr = base.AbstractRenderer(model); if (abstr != null) { diff --git a/src/AddIns/Misc/SharpReport/SharpReportAddin/FieldsExplorer/FieldsExplorer.cs b/src/AddIns/Misc/SharpReport/SharpReportAddin/FieldsExplorer/FieldsExplorer.cs index dd422f3a12..6718bed06c 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportAddin/FieldsExplorer/FieldsExplorer.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportAddin/FieldsExplorer/FieldsExplorer.cs @@ -47,7 +47,7 @@ namespace SharpReportAddin { private TreeNode nodeParams; private ReportSettings reportSettings; - + private bool isFilled = false; #region Publics @@ -62,6 +62,7 @@ namespace SharpReportAddin { BuildNodes(); this.FillTree(); this.ExpandAll(); + isFilled = true; } @@ -107,6 +108,7 @@ namespace SharpReportAddin { this.NotifyReportView(); } } + #endregion #region TreeView Events @@ -234,7 +236,6 @@ namespace SharpReportAddin { } if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent is SharpReportView) { - WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.Saving -= new EventHandler (OnViewSaving); WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.Saving += new EventHandler (OnViewSaving); } @@ -244,8 +245,11 @@ namespace SharpReportAddin { } private void OnViewSaving (object sender, EventArgs e) { - UpdateSorting(); + if (this.isFilled) { + UpdateSorting(); UpdateGrouping(); + } + } #endregion diff --git a/src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportView.cs b/src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportView.cs index 123b7e8d47..130dfb46a0 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportView.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportView.cs @@ -93,6 +93,7 @@ namespace SharpReportAddin{ try { Type type = typeof(FieldsExplorer); SharpReportAddin.FieldsExplorer fe = (SharpReportAddin.FieldsExplorer)WorkbenchSingleton.Workbench.GetPad(type).PadContent; + if (fe != null) { this.designerControl.ReportModel.ReportSettings.AvailableFieldsCollection = reportManager.AvailableFieldsCollection; fe.Fill(this.designerControl.ReportModel.ReportSettings); @@ -340,6 +341,7 @@ namespace SharpReportAddin{ //Something was dropped on the designer private void OnItemDragDrop (object sender,ItemDragDropEventArgs e) { base.IsDirty = true; + this.SetFieldsExplorer(); } public void OnPropertyChanged (object sender, diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportEngine.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportEngine.cs index 7ef1700058..72354ab9f4 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportEngine.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportEngine.cs @@ -53,7 +53,7 @@ namespace SharpReportCore { } #region ParameterHandling - + private bool CheckReportParameters (ReportModel model,ReportParameters reportParameters) { System.Console.WriteLine("Engine"); if (model.ReportSettings.ReportType != GlobalEnums.enmReportType.FormSheet) { @@ -88,16 +88,14 @@ namespace SharpReportCore { SharpReportParametersEventArgs e = new SharpReportParametersEventArgs(); e.SqlParametersCollection = settings.SqlParametersCollection; e.ReportName = settings.ReportName; - System.Console.WriteLine("\tfire ParamsRequets"); ParametersRequest (this,e); } - } else { - - System.Console.WriteLine("\t No Parameters"); } + } } + void SetSqlParameters (ReportModel model,AbstractParametersCollection sqlParams) { if ((sqlParams == null)||(sqlParams.Count == 0)) { return; @@ -140,15 +138,13 @@ namespace SharpReportCore { if (settings.ReportType == GlobalEnums.enmReportType.DataReport) { if (settings.CommandText != null) { try { - System.Console.WriteLine("\tcheck for params"); GrapSqlParameters (settings); - System.Console.WriteLine("\tParamRequest done"); - System.Console.WriteLine("\t COnnection != null {0}",this.connectionObject != null); + if (this.connectionObject != null) { DataManager container = new DataManager(this.connectionObject, settings); - + System.Console.WriteLine("\t No of Records to print {0}",container.Count); if (container.DataBind() == true) { return container; } else {