[Quantproject-developers] QuantProject/b5_Presentation/Reporting/WindowsForm Report.cs,1.10,1.11
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2005-06-02 17:45:58
|
Update of /cvsroot/quantproject/QuantProject/b5_Presentation/Reporting/WindowsForm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7126/b5_Presentation/Reporting/WindowsForm Modified Files: Report.cs Log Message: It is now possible to save to disk the account report (o simply the account) currently visualized by the report form. Index: Report.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b5_Presentation/Reporting/WindowsForm/Report.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Report.cs 14 Apr 2005 18:35:58 -0000 1.10 --- Report.cs 2 Jun 2005 17:45:49 -0000 1.11 *************** *** 41,44 **** --- 41,49 ---- private AccountReport accountReport; private ReportTabControl reportTabControl; + private MainMenu mainMenu; + private System.Windows.Forms.MenuItem file; + private System.Windows.Forms.MenuItem saveAccount; + private System.Windows.Forms.MenuItem saveReport; + private SaveFileDialog saveFileDialog; public Report( Account account , IHistoricalQuoteProvider historicalQuoteProvider ) *************** *** 46,49 **** --- 51,55 ---- this.account = account; this.historicalQuoteProvider = historicalQuoteProvider; + this.initializeComponent(); } public Report( AccountReport accountReport ) *************** *** 51,56 **** this.accountReport = accountReport; this.account = this.accountReport.Account; } ! /// <summary> /// Populates the form and displays itself --- 57,87 ---- this.accountReport = accountReport; this.account = this.accountReport.Account; + this.initializeComponent(); } ! ! private void initializeComponent() ! { ! this.mainMenu = new MainMenu(); ! ! this.saveAccount = new MenuItem(); ! this.saveAccount.Text = "Save Account"; ! ! this.saveReport = new MenuItem(); ! this.saveReport.Text = "Save Report"; ! ! this.file = new MenuItem(); ! this.file.Text = "File"; ! this.mainMenu.MenuItems.AddRange(new MenuItem[] ! {this.file}); ! ! this.file.MenuItems.AddRange(new MenuItem[] ! {this.saveAccount, ! this.saveReport}); ! this.Menu = this.mainMenu; ! this.saveAccount.Click += new System.EventHandler(this.saveAccount_Click); ! this.saveReport.Click += new System.EventHandler(this.saveReport_Click); ! ! } ! /// <summary> /// Populates the form and displays itself *************** *** 104,107 **** --- 135,203 ---- return (DateTime)returnValue; } + + #region save account or report + + private void saveAccount_Click(object sender, System.EventArgs e) + { + this.saveAccountOrReport((MenuItem)sender); + } + + + private void saveReport_Click(object sender, System.EventArgs e) + { + this.saveAccountOrReport((MenuItem)sender); + } + + private void saveAccountOrReport_setSaveFileDialog(MenuItem sender) + { + this.saveFileDialog = new SaveFileDialog(); + if(sender.Text.EndsWith("Report")) + //if text property of the menu item sender contains at the end + // the word "Report", then it will be saved an account Report object + { + this.saveFileDialog.DefaultExt = "qPr"; + this.saveFileDialog.InitialDirectory = + System.Configuration.ConfigurationSettings.AppSettings["ReportsArchive"]; + } + else + //else the text property of the menu item sender contains at the end + // the word "Account"; so it will be saved an account object + { + this.saveFileDialog.DefaultExt = "qPa"; + this.saveFileDialog.InitialDirectory = + System.Configuration.ConfigurationSettings.AppSettings["AccountsArchive"]; + } + + this.saveFileDialog.AddExtension = true; + this.saveFileDialog.CreatePrompt = true; + this.saveFileDialog.OverwritePrompt = true; + this.saveFileDialog.Title = sender.Text; + //the saveFileDialog title is the same as the + //menu item clicked by the user + this.saveFileDialog.CheckPathExists = true; + } + + private void saveAccountOrReport(MenuItem sender) + { + this.saveAccountOrReport_setSaveFileDialog(sender); + this.saveFileDialog.FileOk += new System.ComponentModel.CancelEventHandler(this.fileOk_Click); + this.saveFileDialog.ShowDialog(); + } + + private void fileOk_Click(object sender, System.ComponentModel.CancelEventArgs e) + { + if(((SaveFileDialog)sender).Title.EndsWith("Report")) + QuantProject.ADT.FileManaging.ObjectArchiver.Archive(this.accountReport, + this.saveFileDialog.FileName); + else + QuantProject.ADT.FileManaging.ObjectArchiver.Archive(this.account, + this.saveFileDialog.FileName); + } + + + + + #endregion + // /// <summary> // /// Imports an existing account report |