Browse Source

Wizard can work with Views from SqlServer

pull/14/head
peterforstmeier 15 years ago
parent
commit
1db7ea0d76
  1. 19
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/ReportWizard/WizardPanels/PullModelPanel.cs
  2. 43
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/ReportWizard/WizardPanels/ResultPanel.cs
  3. 45
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/DataManager.cs
  4. 2
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/SqlDataAccess.cs

19
src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/ReportWizard/WizardPanels/PullModelPanel.cs

@ -28,7 +28,7 @@ namespace ICSharpCode.Reports.Addin.ReportWizard
private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label3;
private bool firstDrag; private bool firstDrag;
private string connectionString; private string connectionString;
private CommandType commandType; // private CommandType commandType;
private ReportStructure reportStructure; private ReportStructure reportStructure;
private Properties customizer; private Properties customizer;
private IDatabaseObjectBase currentNode; private IDatabaseObjectBase currentNode;
@ -60,7 +60,7 @@ namespace ICSharpCode.Reports.Addin.ReportWizard
base.EnableCancel = true; base.EnableCancel = true;
this.firstDrag = true; this.firstDrag = true;
base.IsLastPanel = false; base.IsLastPanel = false;
commandType = CommandType.Text; //commandType = CommandType.Text;
this.txtSqlString.Enabled = false; this.txtSqlString.Enabled = false;
this.databasesTreeHost = new ElementHost() { Dock = DockStyle.Fill }; this.databasesTreeHost = new ElementHost() { Dock = DockStyle.Fill };
@ -90,12 +90,8 @@ namespace ICSharpCode.Reports.Addin.ReportWizard
} }
if (message == DialogMessage.Next) { if (message == DialogMessage.Next) {
commandType = CommandType.Text;
customizer.Set("SqlString", this.txtSqlString.Text.Trim()); customizer.Set("SqlString", this.txtSqlString.Text.Trim());
reportStructure.CommandType = commandType; //reportStructure.CommandType = commandType;
reportStructure.SqlString = this.txtSqlString.Text.Trim(); reportStructure.SqlString = this.txtSqlString.Text.Trim();
reportStructure.ConnectionString = connectionString; reportStructure.ConnectionString = connectionString;
base.EnableFinish = true; base.EnableFinish = true;
@ -176,9 +172,8 @@ namespace ICSharpCode.Reports.Addin.ReportWizard
// we insert Select * from.... otherwise we have to scan // we insert Select * from.... otherwise we have to scan
//the whole string for incorrect columnNames //the whole string for incorrect columnNames
this.txtSqlString.Clear(); this.txtSqlString.Clear();
// AbstractSharpQuerySchemaClass tbl = (AbstractSharpQuerySchemaClass)this.currentNode.SchemaClass;
this.txtSqlString.Text = "SELECT * FROM " + (draggedObject as ICSharpCode.Data.Core.Interfaces.ITable).Name; this.txtSqlString.Text = "SELECT * FROM " + (draggedObject as ICSharpCode.Data.Core.Interfaces.ITable).Name;
reportStructure.CommandType = CommandType.Text;
break; break;
case NodeType.ColumnImage: case NodeType.ColumnImage:
@ -187,9 +182,8 @@ namespace ICSharpCode.Reports.Addin.ReportWizard
{ {
this.txtSqlString.AppendText("SELECT "); this.txtSqlString.AppendText("SELECT ");
this.txtSqlString.AppendText(colName); this.txtSqlString.AppendText(colName);
} }
//FxCop : http://msdn.microsoft.com/library/bb386042(VS.100).aspx
else if (this.txtSqlString.Text.ToUpper(CultureInfo.InvariantCulture).IndexOf("where", StringComparison.OrdinalIgnoreCase) > 0) else if (this.txtSqlString.Text.ToUpper(CultureInfo.InvariantCulture).IndexOf("where", StringComparison.OrdinalIgnoreCase) > 0)
{ {
this.txtSqlString.AppendText(colName + " = ?"); this.txtSqlString.AppendText(colName + " = ?");
@ -199,6 +193,7 @@ namespace ICSharpCode.Reports.Addin.ReportWizard
this.txtSqlString.AppendText(", "); this.txtSqlString.AppendText(", ");
this.txtSqlString.AppendText(colName); this.txtSqlString.AppendText(colName);
} }
reportStructure.CommandType = CommandType.Text;
break; break;
case NodeType.ProcedureImage: case NodeType.ProcedureImage:
@ -207,7 +202,7 @@ namespace ICSharpCode.Reports.Addin.ReportWizard
// we can't use the dragobject because it returns an string like 'EXECUTE ProcName' // we can't use the dragobject because it returns an string like 'EXECUTE ProcName'
IProcedure procedure = draggedObject as IProcedure; IProcedure procedure = draggedObject as IProcedure;
this.txtSqlString.Text = "EXECUTE " + procedure.Name; this.txtSqlString.Text = "EXECUTE " + procedure.Name;
reportStructure.CommandType = CommandType.StoredProcedure;
// reportStructure.SharpQueryProcedure = new SharpQueryProcedure(new SharpQuery.Connection.OLEDBConnectionWrapper(this.connectionString), procedure.Parent.Name, procedure.SchemaName, string.Empty, procedure.Name); // reportStructure.SharpQueryProcedure = new SharpQueryProcedure(new SharpQuery.Connection.OLEDBConnectionWrapper(this.connectionString), procedure.Parent.Name, procedure.SchemaName, string.Empty, procedure.Name);
break; break;

43
src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/ReportWizard/WizardPanels/ResultPanel.cs

@ -50,6 +50,7 @@ namespace ICSharpCode.Reports.Addin.ReportWizard
#endregion #endregion
#region Fill data #region Fill data
private DataSet FillGrid() private DataSet FillGrid()
@ -62,7 +63,23 @@ namespace ICSharpCode.Reports.Addin.ReportWizard
model.ReportSettings.CommandText); model.ReportSettings.CommandText);
DataSet dataSet = ResultPanel.CreateDataSet (); DataSet dataSet = ResultPanel.CreateDataSet ();
this.txtSqlString.Text = model.ReportSettings.CommandText;
switch (model.ReportSettings.CommandType) {
case CommandType.Text:
this.txtSqlString.Text = model.ReportSettings.CommandText;
dataSet = BuildFromSqlString();
break;
case CommandType.StoredProcedure:
MessageService.ShowError("Stored Procedures are not suppurted at the moment");
break;
case CommandType.TableDirect:
MessageService.ShowError("TableDirect is not suppurted at the moment");
break;
default:
throw new Exception("Invalid value for CommandType");
}
if (model.ReportSettings.CommandType == CommandType.StoredProcedure){ if (model.ReportSettings.CommandType == CommandType.StoredProcedure){
/* /*
if (reportStructure.SharpQueryProcedure == null) { if (reportStructure.SharpQueryProcedure == null) {
@ -81,10 +98,10 @@ namespace ICSharpCode.Reports.Addin.ReportWizard
} }
// from here we create from an SqlString like "Select...." // from here we create from an SqlString like "Select...."
if (model.ReportSettings.CommandType == CommandType.Text){ // if (model.ReportSettings.CommandType == CommandType.Text){
this.txtSqlString.Text = model.ReportSettings.CommandText; // this.txtSqlString.Text = model.ReportSettings.CommandText;
dataSet = BuildFromSqlString(); // dataSet = BuildFromSqlString();
} // }
return dataSet; return dataSet;
} }
@ -247,6 +264,7 @@ namespace ICSharpCode.Reports.Addin.ReportWizard
#endregion #endregion
#region overrides #region overrides
public override bool ReceiveDialogMessage(DialogMessage message) public override bool ReceiveDialogMessage(DialogMessage message)
@ -257,9 +275,7 @@ namespace ICSharpCode.Reports.Addin.ReportWizard
} }
if (message == DialogMessage.Activated) if (message == DialogMessage.Activated)
{ {
this.model = reportStructure.CreateAndFillReportModel(); ShowData();
this.resultDataSet = FillGrid();
SetupGrid ();
base.EnableNext = true; base.EnableNext = true;
base.EnableFinish = true; base.EnableFinish = true;
@ -281,6 +297,17 @@ namespace ICSharpCode.Reports.Addin.ReportWizard
} }
void ShowData()
{
this.model = reportStructure.CreateAndFillReportModel();
this.resultDataSet = FillGrid();
if (resultDataSet.Tables.Count > 0) {
SetupGrid ();
}
}
private void SetupGrid() private void SetupGrid()
{ {
if (this.resultDataSet != null) { if (this.resultDataSet != null) {

45
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/DataManager.cs

@ -191,23 +191,7 @@ namespace ICSharpCode.Reports.Core {
} }
} }
/*
private void CheckReportColumns()
{
if (this.reportSettings.SortColumnCollection.Count > 0) {
if (this.dataViewStrategy.AvailableFields.Count > 0) {
foreach (SortColumn col in this.reportSettings.SortColumnCollection) {
string colName = col.ColumnName;
AbstractColumn c = this.dataViewStrategy.AvailableFields.Find (colName);
if (c == null) {
throw new WrongColumnException(col.ColumnName);
}
}
}
}
}
*/
#endregion #endregion
@ -245,23 +229,6 @@ namespace ICSharpCode.Reports.Core {
} }
} }
/*
public IndexList ChildRows
{
get {
return this.dataViewStrategy.ChildRows;
}
}
public bool IsGrouped
{
get {
return this.dataViewStrategy.IsGrouped;
}
}
*/
public bool IsSorted public bool IsSorted
{ {
@ -270,17 +237,11 @@ namespace ICSharpCode.Reports.Core {
} }
} }
/*
public bool IsFiltered
{
get {
return this.dataViewStrategy.IsFiltered;
}
}
*/
#endregion #endregion
#region System.IDisposable interface implementation #region System.IDisposable interface implementation
public void Dispose() { public void Dispose() {
this.Dispose(true); this.Dispose(true);
GC.SuppressFinalize(this); GC.SuppressFinalize(this);

2
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/SqlDataAccess.cs

@ -14,7 +14,7 @@ namespace ICSharpCode.Reports.Core
/// </summary> /// </summary>
/// ///
public class SqlDataAccessStrategy:IDataAccessStrategy internal class SqlDataAccessStrategy:IDataAccessStrategy
{ {
private ConnectionObject connectionObject; private ConnectionObject connectionObject;
private ReportSettings reportSettings; private ReportSettings reportSettings;

Loading…
Cancel
Save