private void RemoveWatchListSelection_Click(object sender, RoutedEventArgs e)
        {
            WatchListEntry entryToBeRemoved = null;

            foreach (var item in WatchListListView.Items)
            {
                var watchListItem = item as WatchListEntry;
                var container     = WatchListListView.ContainerFromItem(watchListItem) as ListViewItem;
                var ItemGridView  = container.ContentTemplateRoot as Grid;

                SolidColorBrush brush = ItemGridView.Background as SolidColorBrush;
                if (brush != null)
                {
                    if (brush.Color == WatchListSelectionColor)
                    {
                        ItemGridView.Background = null;
                        entryToBeRemoved        = watchListItem;
                    }
                }
            }

            if (entryToBeRemoved != null)
            {
                watchListEntries.Remove(entryToBeRemoved);
            }
        }
Exemple #2
0
        private string GetBSEDownloadUrl(WatchListEntry wle)
        {
            string bseDownloadUrl = @"http://www.bseindia.com/stockinfo/stockprc2_excel.aspx?scripcd={0}&FromDate={1}&ToDate={2}&OldDMY=D";
            string strFromDate    = string.Format("{0:MM/dd/yyyy}", fromDate);
            string strToDate      = string.Format("{0:MM/dd/yyyy}", toDate);

            bseDownloadUrl = string.Format(bseDownloadUrl, wle.BSESymbol.Trim(), strFromDate.Trim(), strToDate.Trim());

            return(bseDownloadUrl);
        }
Exemple #3
0
        private string GetNSEDownloadUrl(WatchListEntry wle)
        {
            string nseDownloadUrl = @"http://www.nseindia.com/content/equities/scripvol/datafiles/{0}-TO-{1}{2}EQN.csv";
            string strFromDate    = string.Format("{0:dd-MM-yyyy}", fromDate);
            string strToDate      = string.Format("{0:dd-MM-yyyy}", toDate);

            nseDownloadUrl = string.Format(nseDownloadUrl, strFromDate.Trim(), strToDate.Trim(), wle.NSESymbol.Trim());

            return(nseDownloadUrl);
        }
        public IQueryable <WatchListEntry> GetAll()
        {
            List <WatchListEntry> watchListEntries = new List <WatchListEntry>();

            using (OleDbConnection conn = new OleDbConnection(this.ConnectionString))
            {
                using (OleDbCommand cmd = new OleDbCommand(this.SelectAllCommand, conn))
                {
                    try
                    {
                        if (conn.State != System.Data.ConnectionState.Open)
                        {
                            conn.Open();
                        }

                        OleDbDataAdapter dataAdapter = new OleDbDataAdapter(cmd);
                        DataSet          ds          = new DataSet();
                        dataAdapter.Fill(ds);

                        DataTable      watchListTable = ds.Tables[0];
                        WatchListEntry watchListEntry = null;
                        for (int i = 0; i < watchListTable.Rows.Count; ++i)
                        {
                            watchListEntry = new WatchListEntry();

                            watchListEntry.Id         = Convert.ToInt32(watchListTable.Rows[i]["Id"]);
                            watchListEntry.BSESymbol  = Convert.ToString(watchListTable.Rows[i]["BSESymbol"]);
                            watchListEntry.NSESymbol  = Convert.ToString(watchListTable.Rows[i]["NSESymbol"]);
                            watchListEntry.Name       = Convert.ToString(watchListTable.Rows[i]["Name"]);
                            watchListEntry.AltName1   = Convert.ToString(watchListTable.Rows[i]["AltName1"]);
                            watchListEntry.AltName2   = Convert.ToString(watchListTable.Rows[i]["AltName2"]);
                            watchListEntry.TempName   = Convert.ToString(watchListTable.Rows[i]["TempName"]);
                            watchListEntry.Active     = Convert.ToInt32(watchListTable.Rows[i]["Active"]);
                            watchListEntry.Alert      = Convert.ToInt32(watchListTable.Rows[i]["Alert"]);
                            watchListEntry.ModifiedOn = Convert.ToInt32(watchListTable.Rows[i]["ModifiedOn"]);
                            watchListEntry.CreatedOn  = Convert.ToInt32(watchListTable.Rows[i]["CreatedOn"]);

                            watchListEntries.Add(watchListEntry);
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("[Error] GetAll() failed.", this.DataSource);
                        Console.WriteLine(e.Message);
                    }
                }
            }

            return(watchListEntries.AsQueryable());
        }