[Quantproject-developers] QuantProject/b5_Presentation/Reporting/WindowsForm Report.cs, 1.20, 1.21
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:16:33
|
Update of /cvsroot/quantproject/QuantProject/b5_Presentation/Reporting/WindowsForm In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv14863/Reporting/WindowsForm Modified Files: Report.cs ReportGrid.cs ReportShower.cs Log Message: The new revision moves toward an intraday enabled framework. EndOfDayDate time has been removed, DateTime is used now. The code has been changed accordingly. Index: ReportGrid.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b5_Presentation/Reporting/WindowsForm/ReportGrid.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ReportGrid.cs 6 Feb 2008 23:13:48 -0000 1.2 --- ReportGrid.cs 29 Sep 2008 21:15:57 -0000 1.3 *************** *** 3,7 **** ReportTabControl.cs ! Copyright (C) 2003 Glauco Siliprandi --- 3,7 ---- ReportTabControl.cs ! Copyright (C) 2003 Glauco Siliprandi *************** *** 19,25 **** along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ using System; using System.Windows.Forms; using QuantProject.Business.Financial.Accounting.Reporting; --- 19,27 ---- along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ using System; + using System.Data; using System.Windows.Forms; + using QuantProject.Business.Financial.Accounting.Reporting; *************** *** 32,39 **** --- 34,110 ---- public class ReportGrid : DataGrid { + private ReportTable reportTable; + private DataGridTableStyle dataGridStyle; + public ReportGrid( ReportTable reportTable ) { + this.reportTable = reportTable; this.DataSource = reportTable.DataTable; + this.setFormat(); + } + + #region setFormat + + private void setDataGridTableStyle() + { + this.dataGridStyle = new DataGridTableStyle(); + dataGridStyle.MappingName = this.reportTable.DataTable.TableName; + this.TableStyles.Add( dataGridStyle ); } + + #region addDataGridColumnStyles + + #region setFormatForDateTimeColumn + + #region setFormatForDateTimeColumn_actually + // private DataGridTextBoxColumn getDataGridTextBoxColumn( + // int columnIndex ) + // { + // DataGridTableStyle dataGridTableStyle = + // this.TableStyles[ 0 ]; + // DataGridTextBoxColumn dataGridTextBoxColumn = + // ( DataGridTextBoxColumn )dataGridTableStyle.GridColumnStyles[ + // columnIndex ]; + //// dataGridTableStyle.GridColumnStyles.a + // return dataGridTextBoxColumn; + // } + private DataGridTextBoxColumn addDataGridTextBoxColumn( int columnIndex ) + { + DataGridTextBoxColumn dataGridTextBoxColumn = + new DataGridTextBoxColumn(); + dataGridTextBoxColumn.MappingName = + this.reportTable.DataTable.Columns[ columnIndex ].ColumnName; + dataGridTextBoxColumn.HeaderText = + this.reportTable.DataTable.Columns[ columnIndex ].ColumnName; + this.TableStyles[ 0 ].GridColumnStyles.Add( dataGridTextBoxColumn ); + return dataGridTextBoxColumn; + } + #endregion setFormatForDateTimeColumn_actually + + private void addDataGridColumnStyle( int columnIndex ) + { + DataGridTextBoxColumn dataGridTextBoxColumn = + this.addDataGridTextBoxColumn( columnIndex ); + if ( this.reportTable.DataTable.Columns[ columnIndex ].DataType == + System.Type.GetType("System.DateTime") ) + dataGridTextBoxColumn.Format = "u"; + } + #endregion setFormatForDateTimeColumn + + private void addDataGridColumnStyles() + { + for( int columnIndex = 0 ; + columnIndex < this.reportTable.DataTable.Columns.Count ; + columnIndex++ ) + this.addDataGridColumnStyle( columnIndex ); + } + #endregion addDataGridColumnStyles + + private void setFormat() + { + this.setDataGridTableStyle(); + this.addDataGridColumnStyles(); + } + #endregion setFormat } } Index: ReportShower.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b5_Presentation/Reporting/WindowsForm/ReportShower.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ReportShower.cs 19 Feb 2006 17:54:36 -0000 1.3 --- ReportShower.cs 29 Sep 2008 21:15:57 -0000 1.4 *************** *** 3,7 **** ReportShower.cs ! Copyright (C) 2003 Marco Milletti --- 3,7 ---- ReportShower.cs ! Copyright (C) 2003 Marco Milletti *************** *** 19,23 **** along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ using System; --- 19,23 ---- along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ using System; *************** *** 35,48 **** public class ReportShower : System.Windows.Forms.Form { ! private System.Windows.Forms.Button buttonShowReport; ! private System.Windows.Forms.Label label1; ! private System.Windows.Forms.Label label2; ! private System.Windows.Forms.Label label3; ! private System.Windows.Forms.NumericUpDown numDaysForEquityLine; ! private System.Windows.Forms.DateTimePicker endingDate; ! private System.Windows.Forms.TextBox reportName; ! private Report report; ! private System.Windows.Forms.Label label4; ! private System.Windows.Forms.TextBox benchmark; /// <summary> --- 35,48 ---- public class ReportShower : System.Windows.Forms.Form { ! private System.Windows.Forms.Button buttonShowReport; ! private System.Windows.Forms.Label label1; ! private System.Windows.Forms.Label label2; ! private System.Windows.Forms.Label label3; ! private System.Windows.Forms.NumericUpDown numDaysForEquityLine; ! private System.Windows.Forms.DateTimePicker endingDate; ! private System.Windows.Forms.TextBox reportName; ! private Report report; ! private System.Windows.Forms.Label label4; ! private System.Windows.Forms.TextBox benchmark; /// <summary> *************** *** 59,64 **** // ! this.report = report; ! this.endingDate.Value = this.report.GetLastTradeDate(); // } --- 59,64 ---- // ! this.report = report; ! this.endingDate.Value = this.report.GetLastTradeDate(); // } *************** *** 86,224 **** private void InitializeComponent() { ! this.numDaysForEquityLine = new System.Windows.Forms.NumericUpDown(); ! this.endingDate = new System.Windows.Forms.DateTimePicker(); ! this.reportName = new System.Windows.Forms.TextBox(); ! this.buttonShowReport = new System.Windows.Forms.Button(); ! this.label1 = new System.Windows.Forms.Label(); ! this.label2 = new System.Windows.Forms.Label(); ! this.label3 = new System.Windows.Forms.Label(); ! this.label4 = new System.Windows.Forms.Label(); ! this.benchmark = new System.Windows.Forms.TextBox(); ! ((System.ComponentModel.ISupportInitialize)(this.numDaysForEquityLine)).BeginInit(); ! this.SuspendLayout(); ! // ! // numDaysForEquityLine ! // ! this.numDaysForEquityLine.Location = new System.Drawing.Point(144, 64); ! this.numDaysForEquityLine.Minimum = new System.Decimal(new int[] { ! 1, ! 0, ! 0, ! 0}); ! this.numDaysForEquityLine.Name = "numDaysForEquityLine"; ! this.numDaysForEquityLine.Size = new System.Drawing.Size(64, 20); ! this.numDaysForEquityLine.TabIndex = 0; ! this.numDaysForEquityLine.Value = new System.Decimal(new int[] { ! 1, ! 0, ! 0, ! 0}); ! // ! // endingDate ! // ! this.endingDate.Location = new System.Drawing.Point(112, 112); ! this.endingDate.Name = "endingDate"; ! this.endingDate.Size = new System.Drawing.Size(136, 20); ! this.endingDate.TabIndex = 1; ! // ! // reportName ! // ! this.reportName.Location = new System.Drawing.Point(104, 16); ! this.reportName.Name = "reportName"; ! this.reportName.Size = new System.Drawing.Size(176, 20); ! this.reportName.TabIndex = 2; ! this.reportName.Text = "My report"; ! // ! // buttonShowReport ! // ! this.buttonShowReport.Location = new System.Drawing.Point(80, 208); ! this.buttonShowReport.Name = "buttonShowReport"; ! this.buttonShowReport.Size = new System.Drawing.Size(128, 40); ! this.buttonShowReport.TabIndex = 3; ! this.buttonShowReport.Text = "Show"; ! this.buttonShowReport.Click += new System.EventHandler(this.buttonShowReport_Click); ! // ! // label1 ! // ! this.label1.Location = new System.Drawing.Point(8, 16); ! this.label1.Name = "label1"; ! this.label1.Size = new System.Drawing.Size(96, 16); ! this.label1.TabIndex = 4; ! this.label1.Text = "Report Name"; ! // ! // label2 ! // ! this.label2.Location = new System.Drawing.Point(8, 64); ! this.label2.Name = "label2"; ! this.label2.Size = new System.Drawing.Size(128, 32); ! this.label2.TabIndex = 5; ! this.label2.Text = "Num Days for equity line"; ! // ! // label3 ! // ! this.label3.Location = new System.Drawing.Point(8, 112); ! this.label3.Name = "label3"; ! this.label3.Size = new System.Drawing.Size(96, 16); ! this.label3.TabIndex = 6; ! this.label3.Text = "Ending Date"; ! // ! // label4 ! // ! this.label4.Location = new System.Drawing.Point(10, 160); ! this.label4.Name = "label4"; ! this.label4.Size = new System.Drawing.Size(96, 16); ! this.label4.TabIndex = 8; ! this.label4.Text = "Benchmark"; ! // ! // benchmark ! // ! this.benchmark.Location = new System.Drawing.Point(106, 160); ! this.benchmark.Name = "benchmark"; ! this.benchmark.Size = new System.Drawing.Size(176, 20); ! this.benchmark.TabIndex = 7; ! this.benchmark.Text = ""; ! // ! // ReportShower ! // ! this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); ! this.ClientSize = new System.Drawing.Size(292, 266); ! this.Controls.AddRange(new System.Windows.Forms.Control[] { ! this.label4, ! this.benchmark, ! this.label3, ! this.label2, ! this.label1, ! this.buttonShowReport, ! this.reportName, ! this.endingDate, ! this.numDaysForEquityLine}); ! this.Name = "ReportShower"; ! this.Text = "ReportShower"; ! ((System.ComponentModel.ISupportInitialize)(this.numDaysForEquityLine)).EndInit(); ! this.ResumeLayout(false); ! } #endregion ! private void buttonShowReport_Click(object sender, System.EventArgs e) ! { ! try ! { ! if(this.benchmark.Text == "") ! throw new Exception("Benchmark symbol is requested!"); ! this.report.Clear(); System.Console.WriteLine( DateTime.Now ); ! this.report.Show(this.reportName.Text, (int)this.numDaysForEquityLine.Value, ! new EndOfDayDateTime(this.endingDate.Value, ! EndOfDaySpecificTime.MarketClose), ! this.benchmark.Text); System.Console.WriteLine( DateTime.Now ); } ! ! catch(Exception ex) ! { ! MessageBox.Show(ex.ToString()); ! } ! } } } --- 86,227 ---- private void InitializeComponent() { ! this.numDaysForEquityLine = new System.Windows.Forms.NumericUpDown(); ! this.endingDate = new System.Windows.Forms.DateTimePicker(); ! this.reportName = new System.Windows.Forms.TextBox(); ! this.buttonShowReport = new System.Windows.Forms.Button(); ! this.label1 = new System.Windows.Forms.Label(); ! this.label2 = new System.Windows.Forms.Label(); ! this.label3 = new System.Windows.Forms.Label(); ! this.label4 = new System.Windows.Forms.Label(); ! this.benchmark = new System.Windows.Forms.TextBox(); ! ((System.ComponentModel.ISupportInitialize)(this.numDaysForEquityLine)).BeginInit(); ! this.SuspendLayout(); ! // ! // numDaysForEquityLine ! // ! this.numDaysForEquityLine.Location = new System.Drawing.Point(144, 64); ! this.numDaysForEquityLine.Minimum = new System.Decimal(new int[] { ! 1, ! 0, ! 0, ! 0}); ! this.numDaysForEquityLine.Name = "numDaysForEquityLine"; ! this.numDaysForEquityLine.Size = new System.Drawing.Size(64, 20); ! this.numDaysForEquityLine.TabIndex = 0; ! this.numDaysForEquityLine.Value = new System.Decimal(new int[] { ! 1, ! 0, ! 0, ! 0}); ! // ! // endingDate ! // ! this.endingDate.Location = new System.Drawing.Point(112, 112); ! this.endingDate.Name = "endingDate"; ! this.endingDate.Size = new System.Drawing.Size(136, 20); ! this.endingDate.TabIndex = 1; ! // ! // reportName ! // ! this.reportName.Location = new System.Drawing.Point(104, 16); ! this.reportName.Name = "reportName"; ! this.reportName.Size = new System.Drawing.Size(176, 20); ! this.reportName.TabIndex = 2; ! this.reportName.Text = "My report"; ! // ! // buttonShowReport ! // ! this.buttonShowReport.Location = new System.Drawing.Point(80, 208); ! this.buttonShowReport.Name = "buttonShowReport"; ! this.buttonShowReport.Size = new System.Drawing.Size(128, 40); ! this.buttonShowReport.TabIndex = 3; ! this.buttonShowReport.Text = "Show"; ! this.buttonShowReport.Click += new System.EventHandler(this.buttonShowReport_Click); ! // ! // label1 ! // ! this.label1.Location = new System.Drawing.Point(8, 16); ! this.label1.Name = "label1"; ! this.label1.Size = new System.Drawing.Size(96, 16); ! this.label1.TabIndex = 4; ! this.label1.Text = "Report Name"; ! // ! // label2 ! // ! this.label2.Location = new System.Drawing.Point(8, 64); ! this.label2.Name = "label2"; ! this.label2.Size = new System.Drawing.Size(128, 32); ! this.label2.TabIndex = 5; ! this.label2.Text = "Num Days for equity line"; ! // ! // label3 ! // ! this.label3.Location = new System.Drawing.Point(8, 112); ! this.label3.Name = "label3"; ! this.label3.Size = new System.Drawing.Size(96, 16); ! this.label3.TabIndex = 6; ! this.label3.Text = "Ending Date"; ! // ! // label4 ! // ! this.label4.Location = new System.Drawing.Point(10, 160); ! this.label4.Name = "label4"; ! this.label4.Size = new System.Drawing.Size(96, 16); ! this.label4.TabIndex = 8; ! this.label4.Text = "Benchmark"; ! // ! // benchmark ! // ! this.benchmark.Location = new System.Drawing.Point(106, 160); ! this.benchmark.Name = "benchmark"; ! this.benchmark.Size = new System.Drawing.Size(176, 20); ! this.benchmark.TabIndex = 7; ! this.benchmark.Text = ""; ! // ! // ReportShower ! // ! this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); ! this.ClientSize = new System.Drawing.Size(292, 266); ! this.Controls.AddRange(new System.Windows.Forms.Control[] { ! this.label4, ! this.benchmark, ! this.label3, ! this.label2, ! this.label1, ! this.buttonShowReport, ! this.reportName, ! this.endingDate, ! this.numDaysForEquityLine}); ! this.Name = "ReportShower"; ! this.Text = "ReportShower"; ! ((System.ComponentModel.ISupportInitialize)(this.numDaysForEquityLine)).EndInit(); ! this.ResumeLayout(false); ! } #endregion ! private void buttonShowReport_Click(object sender, System.EventArgs e) ! { ! try ! { ! if(this.benchmark.Text == "") ! throw new Exception("Benchmark symbol is requested!"); ! this.report.Clear(); System.Console.WriteLine( DateTime.Now ); ! this.report.Show( ! this.reportName.Text, ! (int)this.numDaysForEquityLine.Value, ! HistoricalEndOfDayTimer.GetMarketClose( this.endingDate.Value ) , ! // new EndOfDayDateTime(this.endingDate.Value, ! // EndOfDaySpecificTime.MarketClose), ! this.benchmark.Text); System.Console.WriteLine( DateTime.Now ); } ! ! catch(Exception ex) ! { ! MessageBox.Show(ex.ToString()); ! } ! } } } Index: Report.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b5_Presentation/Reporting/WindowsForm/Report.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Report.cs 19 Aug 2008 17:13:01 -0000 1.20 --- Report.cs 29 Sep 2008 21:15:56 -0000 1.21 *************** *** 41,45 **** { private Account account; ! private IHistoricalQuoteProvider historicalQuoteProvider; private AccountReport accountReport; private ReportTabControl reportTabControl; --- 41,45 ---- { private Account account; ! private HistoricalMarketValueProvider historicalMarketValueProvider; private AccountReport accountReport; private ReportTabControl reportTabControl; *************** *** 68,75 **** } ! public Report( Account account , IHistoricalQuoteProvider historicalQuoteProvider ) { this.account = account; ! this.historicalQuoteProvider = historicalQuoteProvider; this.initializeComponent(); } --- 68,76 ---- } ! public Report( ! Account account , HistoricalMarketValueProvider historicalMarketValueProvider ) { this.account = account; ! this.historicalMarketValueProvider = historicalMarketValueProvider; this.initializeComponent(); } *************** *** 122,131 **** /// </summary> private void create_set_accountReport( string reportName , ! int numDaysForInterval , EndOfDayDateTime endDateTime , string buyAndHoldTicker ) { if ( this.accountReport == null ) this.accountReport = this.account.CreateReport( reportName , numDaysForInterval , endDateTime , buyAndHoldTicker , ! this.historicalQuoteProvider ); } private void create_populateForm( bool showBenchmark ) --- 123,132 ---- /// </summary> private void create_set_accountReport( string reportName , ! int numDaysForInterval , DateTime endDateTime , string buyAndHoldTicker ) { if ( this.accountReport == null ) this.accountReport = this.account.CreateReport( reportName , numDaysForInterval , endDateTime , buyAndHoldTicker , ! this.historicalMarketValueProvider ); } private void create_populateForm( bool showBenchmark ) *************** *** 148,152 **** /// <param name="benchmark"></param> public void Create( string reportName , int numDaysForInterval , ! EndOfDayDateTime endDateTime , string benchmark ) { this.Create( reportName , numDaysForInterval , endDateTime , --- 149,153 ---- /// <param name="benchmark"></param> public void Create( string reportName , int numDaysForInterval , ! DateTime endDateTime , string benchmark ) { this.Create( reportName , numDaysForInterval , endDateTime , *************** *** 160,164 **** } public void Create( string reportName , int numDaysForInterval , ! EndOfDayDateTime endDateTime , string benchmark , bool showBenchmark ) { this.checkAlreadyCreated(); --- 161,165 ---- } public void Create( string reportName , int numDaysForInterval , ! DateTime endDateTime , string benchmark , bool showBenchmark ) { this.checkAlreadyCreated(); *************** *** 168,172 **** } public void Show( string reportName , ! int numDaysForInterval , EndOfDayDateTime endDateTime , string benchmark ) { if ( this.accountReport == null ) --- 169,173 ---- } public void Show( string reportName , ! int numDaysForInterval , DateTime endDateTime , string benchmark ) { if ( this.accountReport == null ) |