[Quantproject-developers] QuantProject/b91_QuantProject AccountViewer.cs,1.1,1.2
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2005-02-26 15:12:16
|
Update of /cvsroot/quantproject/QuantProject/b91_QuantProject In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29355/b91_QuantProject Modified Files: AccountViewer.cs Log Message: It is now possible to add accounts to the form and order them by fitness Index: AccountViewer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b91_QuantProject/AccountViewer.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AccountViewer.cs 4 Feb 2005 00:01:48 -0000 1.1 --- AccountViewer.cs 26 Feb 2005 15:12:07 -0000 1.2 *************** *** 4,7 **** --- 4,12 ---- using System.ComponentModel; using System.Windows.Forms; + using System.Data; + using QuantProject.Business.Financial.Accounting; + using QuantProject.ADT.FileManaging; + + namespace QuantProject.Principale *************** *** 12,17 **** --- 17,25 ---- public class AccountViewer : System.Windows.Forms.Form { + private ArrayList accountsArrayList = new ArrayList(); private System.Windows.Forms.Button buttonAddAccounts; private System.Windows.Forms.DataGrid dataGridAccounts; + private DataTable accountsTable; + private System.Windows.Forms.Button buttonViewReport; private System.ComponentModel.Container components = null; *************** *** 22,25 **** --- 30,34 ---- // InitializeComponent(); + this.setTableAndGrid(); // *************** *** 27,31 **** // } ! /// <summary> /// Clean up --- 36,48 ---- // } ! ! private void setTableAndGrid() ! { ! this.accountsTable = new DataTable(); ! this.accountsTable.Columns.Add("AccountName", System.Type.GetType("System.String")); ! this.accountsTable.Columns.Add("Fitness", Type.GetType("System.Double")); ! this.accountsTable.Columns.Add("Account", Type.GetType("System.Object")); ! this.dataGridAccounts.DataSource = this.accountsTable; ! } /// <summary> /// Clean up *************** *** 49,52 **** --- 66,70 ---- this.buttonAddAccounts = new System.Windows.Forms.Button(); this.dataGridAccounts = new System.Windows.Forms.DataGrid(); + this.buttonViewReport = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.dataGridAccounts)).BeginInit(); this.SuspendLayout(); *************** *** 54,60 **** // buttonAddAccounts // ! this.buttonAddAccounts.Location = new System.Drawing.Point(320, 112); this.buttonAddAccounts.Name = "buttonAddAccounts"; ! this.buttonAddAccounts.Size = new System.Drawing.Size(120, 32); this.buttonAddAccounts.TabIndex = 1; this.buttonAddAccounts.Text = "Add Accounts ..."; --- 72,78 ---- // buttonAddAccounts // ! this.buttonAddAccounts.Location = new System.Drawing.Point(8, 160); this.buttonAddAccounts.Name = "buttonAddAccounts"; ! this.buttonAddAccounts.Size = new System.Drawing.Size(96, 32); this.buttonAddAccounts.TabIndex = 1; this.buttonAddAccounts.Text = "Add Accounts ..."; *************** *** 64,78 **** // this.dataGridAccounts.DataMember = ""; this.dataGridAccounts.HeaderForeColor = System.Drawing.SystemColors.ControlText; - this.dataGridAccounts.Location = new System.Drawing.Point(8, 0); this.dataGridAccounts.Name = "dataGridAccounts"; ! this.dataGridAccounts.Size = new System.Drawing.Size(296, 264); this.dataGridAccounts.TabIndex = 2; // // AccountViewer // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); ! this.ClientSize = new System.Drawing.Size(456, 266); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.dataGridAccounts, this.buttonAddAccounts}); --- 82,106 ---- // this.dataGridAccounts.DataMember = ""; + this.dataGridAccounts.Dock = System.Windows.Forms.DockStyle.Top; this.dataGridAccounts.HeaderForeColor = System.Drawing.SystemColors.ControlText; this.dataGridAccounts.Name = "dataGridAccounts"; ! this.dataGridAccounts.Size = new System.Drawing.Size(464, 144); this.dataGridAccounts.TabIndex = 2; // + // buttonViewReport + // + this.buttonViewReport.Location = new System.Drawing.Point(336, 160); + this.buttonViewReport.Name = "buttonViewReport"; + this.buttonViewReport.Size = new System.Drawing.Size(96, 32); + this.buttonViewReport.TabIndex = 3; + this.buttonViewReport.Text = "View Report"; + this.buttonViewReport.Click += new System.EventHandler(this.buttonViewReport_Click); + // // AccountViewer // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); ! this.ClientSize = new System.Drawing.Size(464, 266); this.Controls.AddRange(new System.Windows.Forms.Control[] { + this.buttonViewReport, this.dataGridAccounts, this.buttonAddAccounts}); *************** *** 84,92 **** } #endregion private void buttonAddAccounts_Click(object sender, System.EventArgs e) { ! //add code her for loading accounts } ! } } --- 112,176 ---- } #endregion + + + private void updateForm_updateGrid() + { + this.dataGridAccounts.Refresh(); + } + + private void updateForm_updateTable() + { + Account account; + foreach(Object item in this.accountsArrayList) + { + DataRow rowToAdd = this.accountsTable.NewRow(); + account = (Account)item; + rowToAdd["AccountName"] = account.Key; + rowToAdd["Fitness"] = account.GetFitnessValue(); + rowToAdd["Account"] = account; + this.accountsTable.Rows.Add(rowToAdd); + } + } + + private void updateForm() + { + this.updateForm_updateTable(); + this.updateForm_updateGrid(); + } + + #region Add Accounts + + private string[] buttonAddAccounts_Click_extractAccounts_selectAccounts() + { + OpenFileDialog openFileDialog = new OpenFileDialog(); + openFileDialog.Title = "Select accounts please ..."; + openFileDialog.Multiselect = true; + openFileDialog.CheckFileExists = true; + openFileDialog.ShowDialog(); + return openFileDialog.FileNames; + } + + private void buttonAddAccounts_Click_extractAccounts() + { + string[] accountsSelection = this.buttonAddAccounts_Click_extractAccounts_selectAccounts(); + foreach(string fileName in accountsSelection) + { + this.accountsArrayList.Add((Account)ObjectArchiver.Extract(fileName)); + } + } private void buttonAddAccounts_Click(object sender, System.EventArgs e) { ! this.accountsArrayList.Clear(); ! this.buttonAddAccounts_Click_extractAccounts(); ! this.updateForm(); } ! #endregion ! ! private void buttonViewReport_Click(object sender, System.EventArgs e) ! { ! MessageBox.Show("TO DO ..."); ! } ! ! } } |