[Quantproject-developers] QuantDownloader/Downloader/TickerSelectors TickerGroupsViewer.cs,1.6,1.7 T
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2004-12-01 22:54:12
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/TickerSelectors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23933/Downloader/TickerSelectors Modified Files: TickerGroupsViewer.cs TickerViewer.cs TickerViewerMenu.cs Log Message: Updated TickerViewer (now it's possible to modify the database directly through the form) Index: TickerGroupsViewer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/TickerSelectors/TickerGroupsViewer.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TickerGroupsViewer.cs 5 Sep 2004 13:57:00 -0000 1.6 --- TickerGroupsViewer.cs 1 Dec 2004 22:54:01 -0000 1.7 *************** *** 300,307 **** this.menuItemRemoveGroup = new System.Windows.Forms.MenuItem(); this.menuItemRenameGroup = new System.Windows.Forms.MenuItem(); this.imageListGroupsAndTickers = new System.Windows.Forms.ImageList(this.components); this.splitter1 = new System.Windows.Forms.Splitter(); this.listViewGroupsAndTickers = new System.Windows.Forms.ListView(); - this.menuItemTickerSelector = new System.Windows.Forms.MenuItem(); this.SuspendLayout(); // --- 300,307 ---- this.menuItemRemoveGroup = new System.Windows.Forms.MenuItem(); this.menuItemRenameGroup = new System.Windows.Forms.MenuItem(); + this.menuItemTickerSelector = new System.Windows.Forms.MenuItem(); this.imageListGroupsAndTickers = new System.Windows.Forms.ImageList(this.components); this.splitter1 = new System.Windows.Forms.Splitter(); this.listViewGroupsAndTickers = new System.Windows.Forms.ListView(); this.SuspendLayout(); // *************** *** 343,346 **** --- 343,352 ---- this.menuItemRenameGroup.Click += new System.EventHandler(this.menuItemRenameGroup_Click); // + // menuItemTickerSelector + // + this.menuItemTickerSelector.Index = 3; + this.menuItemTickerSelector.Text = "&Ticker Selector"; + this.menuItemTickerSelector.Click += new System.EventHandler(this.menuItemTickerSelector_Click); + // // imageListGroupsAndTickers // *************** *** 361,364 **** --- 367,371 ---- // this.listViewGroupsAndTickers.Activation = System.Windows.Forms.ItemActivation.TwoClick; + this.listViewGroupsAndTickers.AllowDrop = true; this.listViewGroupsAndTickers.Dock = System.Windows.Forms.DockStyle.Fill; this.listViewGroupsAndTickers.Location = new System.Drawing.Point(123, 0); *************** *** 369,378 **** this.listViewGroupsAndTickers.View = System.Windows.Forms.View.Details; this.listViewGroupsAndTickers.ItemActivate += new System.EventHandler(this.listViewGroupsAndTickers_ItemActivate); ! // ! // menuItemTickerSelector ! // ! this.menuItemTickerSelector.Index = 3; ! this.menuItemTickerSelector.Text = "&Ticker Selector"; ! this.menuItemTickerSelector.Click += new System.EventHandler(this.menuItemTickerSelector_Click); // // TickerGroupsViewer --- 376,383 ---- this.listViewGroupsAndTickers.View = System.Windows.Forms.View.Details; this.listViewGroupsAndTickers.ItemActivate += new System.EventHandler(this.listViewGroupsAndTickers_ItemActivate); ! this.listViewGroupsAndTickers.DragDrop += new System.Windows.Forms.DragEventHandler(this.listViewGroupsAndTickers_DragDrop); ! this.listViewGroupsAndTickers.DragEnter += new System.Windows.Forms.DragEventHandler(this.listViewGroupsAndTickers_DragEnter); ! this.listViewGroupsAndTickers.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.listViewGroupsAndTickers_ItemDrag); ! this.listViewGroupsAndTickers.DragLeave += new System.EventHandler(this.listViewGroupsAndTickers_DragLeave); // // TickerGroupsViewer *************** *** 504,511 **** this.selectedGroupID = (string)this.treeViewGroups.SelectedNode.Tag; this.selectedGroupDescription = this.treeViewGroups.SelectedNode.Text; ! this.updateListView(this.treeViewGroups.SelectedNode); ! } #region Update List View --- 509,517 ---- this.selectedGroupID = (string)this.treeViewGroups.SelectedNode.Tag; this.selectedGroupDescription = this.treeViewGroups.SelectedNode.Text; ! this.Text = "Ticker-Groups Viewer " + this.treeViewGroups.SelectedNode.FullPath; ! this.updateListView(this.treeViewGroups.SelectedNode); } + #region Update List View *************** *** 858,861 **** --- 864,889 ---- tickerSelectorForm.Show(); } + + private void listViewGroupsAndTickers_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e) + { + DoDragDrop(this.listViewGroupsAndTickers.SelectedItems, DragDropEffects.Copy); + } + + private void listViewGroupsAndTickers_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) + { + //MessageBox.Show("Finished drag and drop"); + } + + private void listViewGroupsAndTickers_DragLeave(object sender, System.EventArgs e) + { + //DragAction + + //MessageBox.Show("Try to leave data here"); + } + + private void listViewGroupsAndTickers_DragEnter(object sender, System.Windows.Forms.DragEventArgs e) + { + //MessageBox.Show("Drag here?"); + } Index: TickerViewer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/TickerSelectors/TickerViewer.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TickerViewer.cs 27 Jun 2004 19:21:42 -0000 1.3 --- TickerViewer.cs 1 Dec 2004 22:54:01 -0000 1.4 *************** *** 28,31 **** --- 28,32 ---- using System.Data; using System.Data.OleDb; + using QuantProject.DataAccess; using QuantProject.DataAccess.Tables; using QuantProject.Data.DataTables; *************** *** 61,65 **** private System.Windows.Forms.ComboBox comboBoxSecondOperator; private DataTable tableTickers; ! public TickerViewer() { --- 62,67 ---- private System.Windows.Forms.ComboBox comboBoxSecondOperator; private DataTable tableTickers; ! private bool skipRowChangedEvent;// event must be launched only by ! // user's changes public TickerViewer() { *************** *** 67,72 **** this.dataGrid1.ContextMenu = new TickerViewerMenu(this); this.tableTickers = new DataTable("tickers"); ! this.dataGrid1.DataSource = this.tableTickers; this.setStyle_dataGrid1(); } --- 69,75 ---- this.dataGrid1.ContextMenu = new TickerViewerMenu(this); this.tableTickers = new DataTable("tickers"); ! this.dataGrid1.DataSource = this.tableTickers; this.setStyle_dataGrid1(); + this.AcceptButton = this.buttonFindTickers; } *************** *** 158,166 **** // buttonFindTickers // ! this.buttonFindTickers.Location = new System.Drawing.Point(136, 256); this.buttonFindTickers.Name = "buttonFindTickers"; this.buttonFindTickers.Size = new System.Drawing.Size(104, 24); ! this.buttonFindTickers.TabIndex = 3; ! this.buttonFindTickers.Text = "Find Tickers"; this.buttonFindTickers.Click += new System.EventHandler(this.buttonFindTickers_Click); // --- 161,169 ---- // buttonFindTickers // ! this.buttonFindTickers.Location = new System.Drawing.Point(152, 232); this.buttonFindTickers.Name = "buttonFindTickers"; this.buttonFindTickers.Size = new System.Drawing.Size(104, 24); ! this.buttonFindTickers.TabIndex = 0; ! this.buttonFindTickers.Text = "&Find Tickers"; this.buttonFindTickers.Click += new System.EventHandler(this.buttonFindTickers_Click); // *************** *** 196,200 **** this.panel2.Location = new System.Drawing.Point(432, 0); this.panel2.Name = "panel2"; ! this.panel2.Size = new System.Drawing.Size(392, 478); this.panel2.TabIndex = 7; // --- 199,203 ---- this.panel2.Location = new System.Drawing.Point(432, 0); this.panel2.Name = "panel2"; ! this.panel2.Size = new System.Drawing.Size(400, 478); this.panel2.TabIndex = 7; // *************** *** 213,217 **** this.groupBoxDateQuoteFilter.Location = new System.Drawing.Point(8, 80); this.groupBoxDateQuoteFilter.Name = "groupBoxDateQuoteFilter"; ! this.groupBoxDateQuoteFilter.Size = new System.Drawing.Size(376, 160); this.groupBoxDateQuoteFilter.TabIndex = 14; this.groupBoxDateQuoteFilter.TabStop = false; --- 216,220 ---- this.groupBoxDateQuoteFilter.Location = new System.Drawing.Point(8, 80); this.groupBoxDateQuoteFilter.Name = "groupBoxDateQuoteFilter"; ! this.groupBoxDateQuoteFilter.Size = new System.Drawing.Size(384, 136); this.groupBoxDateQuoteFilter.TabIndex = 14; this.groupBoxDateQuoteFilter.TabStop = false; *************** *** 316,320 **** // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); ! this.ClientSize = new System.Drawing.Size(824, 478); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.splitter1, --- 319,323 ---- // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); ! this.ClientSize = new System.Drawing.Size(832, 478); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.splitter1, *************** *** 390,393 **** --- 393,406 ---- this.tableTickers = Tickers.GetTableOfFilteredTickers(this.textBoxStringToFind.Text, this.textBoxStringToFindInName.Text); + + this.tableTickers.Columns[Tickers.CompanyName].AllowDBNull = false; + this.tableTickers.Columns[Tickers.CompanyName].DefaultValue = "-"; + this.tableTickers.Columns[Tickers.Ticker].AllowDBNull = false; + this.tableTickers.Columns[Tickers.Ticker].DefaultValue = "tickerSymbol"; + + this.tableTickers.RowChanged += new DataRowChangeEventHandler(this.row_Changed); + this.tableTickers.RowDeleted += new DataRowChangeEventHandler(this.row_Deleted); + this.dataGrid1.DataSource = this.tableTickers; + this.dataGrid1.ReadOnly = false; } else *************** *** 400,409 **** this.comboBoxSecondOperator.Text, this.dateTimePickerLastDate.Value); } - // these two lines in order to avoid "strange" exceptions ... - this.dataGrid1.DataSource = null; - this.dataGrid1.DataSource = this.tableTickers; - // - this.dataGrid1.Refresh(); } catch(Exception ex) --- 413,419 ---- this.comboBoxSecondOperator.Text, this.dateTimePickerLastDate.Value); + this.dataGrid1.DataSource = this.tableTickers; + this.dataGrid1.ReadOnly = true; } } catch(Exception ex) *************** *** 469,474 **** } } - } --- 479,547 ---- } } + + private void row_Changed( object sender, DataRowChangeEventArgs e ) + { + this.rowModified_Manager(e); + } + + private void row_Deleted( object sender, DataRowChangeEventArgs e ) + { + this.rowModified_Manager(e); + } + + private void rowModified_Manager(DataRowChangeEventArgs rowChangeEventArgs) + { + if(this.skipRowChangedEvent) + return; + DialogResult userAnswer = MessageBox.Show( "Do you want to commit these changes permanently to the database?", + "Confirmation for permanent commit", + MessageBoxButtons.YesNo); + + if(userAnswer == DialogResult.Yes) + { + this.saveChangesToCurrentRow(rowChangeEventArgs); + } + else + { + this.skipRowChangedEvent = true; + this.tableTickers.RejectChanges(); + this.skipRowChangedEvent = false; + } + } + + private void saveChangesToCurrentRow(DataRowChangeEventArgs rowChangeEventArgs) + { + try + { + if(rowChangeEventArgs.Action == DataRowAction.Add) + { + string sqlInsertString = + "INSERT INTO tickers(tiTicker, tiCompanyName) VALUES('" + + (string)rowChangeEventArgs.Row["tiTicker"] + "', '" + + (string)rowChangeEventArgs.Row["tiCompanyName"] + "')"; + SqlExecutor.ExecuteNonQuery(sqlInsertString); + this.skipRowChangedEvent = true; + } + else + { + DataTable changedData = this.tableTickers.GetChanges(); + this.skipRowChangedEvent = true; + OleDbSingleTableAdapter adapter = new OleDbSingleTableAdapter(); + adapter.SetAdapter("tickers"); + adapter.OleDbDataAdapter.Update(changedData); + this.tableTickers.AcceptChanges(); + } + } + catch(Exception ex) + { + MessageBox.Show(ex.ToString()); + this.tableTickers.RejectChanges(); + } + finally + { + this.skipRowChangedEvent = false; + } + } } Index: TickerViewerMenu.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/TickerSelectors/TickerViewerMenu.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TickerViewerMenu.cs 27 Aug 2004 23:20:48 -0000 1.6 --- TickerViewerMenu.cs 1 Dec 2004 22:54:01 -0000 1.7 *************** *** 134,137 **** --- 134,149 ---- DataTable tableOfSelectedTickers = iTickerSelector.GetTableOfSelectedTickers(); string currentTicker; + //user confirmation + if(tableOfSelectedTickers.Rows.Count > 5) + { + if(DialogResult.No == MessageBox.Show( "This operation may be very long: \n" + + "Do you want to continue?", "Confirmation", + MessageBoxButtons.YesNo)) + { + Cursor.Current = Cursors.Default; + return; + } + } + //ok foreach(DataRow row in tableOfSelectedTickers.Rows) { *************** *** 139,143 **** QuantProject.DataAccess.Tables.Quotes.ComputeAndCommitCloseToCloseRatios(currentTicker); } ! Cursor.Current = Cursors.WaitCursor; --- 151,155 ---- QuantProject.DataAccess.Tables.Quotes.ComputeAndCommitCloseToCloseRatios(currentTicker); } ! Cursor.Current = Cursors.Default; |