Example #1
0
        private void PaintTvPercent(TreeNode treeNode)
        {
            if (treeNode.Nodes.Count != 0)
            {
                Dictionary <decimal, decimal> dictionary = new Dictionary <decimal, decimal>();
                //child
                string query = string.Format(@"select cl.term as term, fd.val as val
                                    from curve_list cl join curves c on cl.cur_id = c.cur_id
                                    join ffd ffd on ffd.fi_id = cl.fi_id
                                    join fisd_dq fd on fd.fisd_id = ffd.fisd_id
                                    where c.ident = '{0}'
                                    and ffd.fif_id = 3
                                    and dat = to_date('{1}', 'dd.mm.yyyy')",
                                             treeNode.Text,
                                             dtpActualDate.Value.ToString("dd.MM.yyyy"));
                using (NpgsqlConnection connection = new NpgsqlConnection(_connection))
                {
                    connection.Open();
                    using (NpgsqlCommand command = new NpgsqlCommand())
                    {
                        command.Connection  = connection;
                        command.CommandText = query;
                        using (NpgsqlDataReader dataReader = command.ExecuteReader())
                        {
                            while (dataReader.Read())
                            {
                                decimal term = (decimal)dataReader["term"];
                                decimal val  = (decimal)dataReader["val"];
                                dictionary.Add(term, val);
                            }
                        }
                    }
                }

                if (dictionary.Count != 0)
                {
                    var t = new PaintWindow(dictionary)
                    {
                        Text = treeNode.Text
                    };
                    t.ShowDialog();
                }
            }
            else
            {
                PortfolioPosition position   = new BalancePosition(treeNode.Text, FinType.PercentCurve);
                TimeSeries        timeSeries = _provider.GetTimeSeries(position, TimeSeriesAttribute.Close);
                if (timeSeries != null || timeSeries.Series.Count != 0)
                {
                    var t = new PaintWindow(timeSeries.Series.ToDictionary(z => z.Key, z => z.Value));
                    t.ShowDialog();
                }
            }
        }
Example #2
0
        private void PaintTvCurrencies(TreeNode treeNode)
        {
            try
            {
                string ident = treeNode.Name;
                using (NpgsqlConnection connection = new NpgsqlConnection(_connection))
                {
                    connection.Open();
                    using (NpgsqlCommand command = new NpgsqlCommand())
                    {
                        command.Connection = connection;
                        string query = string.Format(
                            @"SELECT fd.dat as DAT, fd.val as VAL
                                                from fin_instrument fi join
	                                                ffd t on t.fi_id = fi.fi_id join
	                                                fisd_dq fd on fd.fisd_id = t.fisd_id join
	                                                data_source ds on ds.ds_id = t.ds_id
	                                                and fi.ident = '{0}'
	                                                and ds.ident = '{1}'
	                                                and t.fif_id = 3"    ,
                            ident,
                            "CBR");
                        command.CommandText = query;

                        using (NpgsqlDataReader dataReader = command.ExecuteReader())
                        {
                            Dictionary <DateTime, decimal> curvalues = new Dictionary <DateTime, decimal>();

                            while (dataReader.Read())
                            {
                                DateTime dateTime = (DateTime)dataReader["DAT"];
                                decimal  val      = (Decimal)dataReader["VAL"];
                                curvalues.Add(dateTime, val);
                            }

                            PaintWindow windows = new PaintWindow(curvalues)
                            {
                                Text = treeNode.Text
                            };
                            windows.ShowDialog();
                        }
                    }
                }
            }
            // If the file is not found, handle the exception and inform the user.
            catch (System.ComponentModel.Win32Exception)
            {
                MessageBox.Show("File not found.");
            }
        }
        private void dataGridView1_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            string title = dataGridView1.Columns[e.ColumnIndex].Name;

            UpdateTimeSeries();
            if (usedColumns.Contains(title))
            {
                var tt = values[title];
                var t  = new PaintWindow(tt)
                {
                    Text = _ident
                };
                t.ShowDialog();
            }
        }