public void CalculateResults()
 {
     PleaseWait pw = new PleaseWait();
     pw.Show();
     Application.DoEvents();
     decimal TotalDividendCount = 0;
     decimal TotalDividendStockValue = 0;
     decimal YearDiv = 0;
     decimal QuarterDiv = 0;
     decimal MonthlyDiv = 0;
     decimal DividendTotalPercentage = 0;
     decimal MarketTotalPrice = 0;
     DataTable dt = DividendStocks.GetCurrentDividends();
     decimal Purchaseprice = 0;
     string Stocks = Uti.GetMultiSymbols(dt);
     string[] AnnualDiv = Uti.SplitStockData(YahooFinance.GetValues(Stocks, "d", true));
     string[] DivYield = Uti.SplitStockData(YahooFinance.GetValues(Stocks, "y", true));
     // l1 is last trade price, c1 change in price, b is bid price, a is ask price; Ask price is current price as you're asking for a price when selling therefore that is the price of your portfolio
     string[] CurrentStockPrice = Uti.SplitStockData(YahooFinance.GetValues(Stocks, "a", true));
     //decimal val = dt.Rows.Count;
     //decimal StatusVal = 0;
     //val = Math.Round(90 / val, 0);
     for (int i = 0; i < dt.Rows.Count; i++)
     {
         string id = dt.Rows[i]["id"].ToString();
         Purchaseprice = Convert.ToDecimal(dt.Rows[i]["purchaseprice"]);
         YearDiv += (Convert.ToDecimal(dt.Rows[i]["numberofshares"]) * Convert.ToDecimal(AnnualDiv[i]));
         TotalDividendStockValue += (Convert.ToDecimal(dt.Rows[i]["numberofshares"]) * Purchaseprice);
         TotalDividendCount++;
         DividendTotalPercentage += DivYield[i] == "N/A" ? 0 : Convert.ToDecimal(DivYield[i]);
         if (dt.Rows[i]["symbol"].ToString() == "SIL")
         {
             DividendTotalPercentage += (decimal).09;
         }
         //if (dt.Rows[i]["symbol"].ToString() == "GDX")
         //{
         //    DividendTotalPercentage -= Convert.ToDecimal(DivYield[i]);
         //    DividendTotalPercentage += (decimal).80;
         //}
         MarketTotalPrice += (Convert.ToDecimal(dt.Rows[i]["numberofshares"]) * Convert.ToDecimal(CurrentStockPrice[i]));
         //StatusVal += val;
         //if (StatusVal < 88)
         //    pbStatus.InvokeEx(x => x.Value = Convert.ToInt32(StatusVal));
     }
     DividendTotalPercentage = DividendTotalPercentage / TotalDividendCount;
     QuarterDiv = (YearDiv / 4);
     MonthlyDiv = (YearDiv / 12);
     //pbStatus.InvokeEx(x => x.Value = 100);
     //pbStatus.InvokeEx(x => x.Visible = false);
     //lblStatus.InvokeEx(x => x.Visible = false);
     pw.Close();
     MessageBox.Show("Cost Basis: $" + Math.Round(TotalDividendStockValue, 2) + "\n\nMarket Value: $" + Math.Round(MarketTotalPrice, 2) + "\n\nAnnual Dividend: $" + Math.Round(YearDiv, 2) + "\n\n" + "Quarterly Dividend: $" + Math.Round(QuarterDiv, 2) + "\n\nMonthly Dividend: $" + Math.Round(MonthlyDiv, 2) + "\n\nPortfolio Dividend Yield: " + Math.Round(DividendTotalPercentage, 2) + "%");
 }
 public void AddRemoveDividends(ListView lv, string stockActive)
 {
     PleaseWait pw = new PleaseWait();
     pw.Show();
     Application.DoEvents();
     UncheckNextBuy();
     for (int i = 0; i < lv.Items.Count; i++)
     {
         if (lstID.Contains(Convert.ToInt32(lv.Items[i].Tag)))
         {
             DividendStocks.MoveStock(lv.Items[i].Tag.ToString(), lv.Items[i].SubItems[1].Text, stockActive);
         }
     }
     LoadDividends(lvCurrentDividends, "true");
     LoadDividends(lvAllDividends, "false");
     SelectStocks();
     pw.Close();
 }
        static void Main()
        {
            bool ok;
            var m = new System.Threading.Mutex(true, "DividendDreams", out ok);

            if (!ok)
            {
                MessageBox.Show("Another instance is already running.");
                return;
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            PleaseWait = new DividendLiberty.PleaseWait();
            PleaseWait.lblMsg.Text = "Connecting to yahoo for stock data..";
            PleaseWait.lblMsg.Visible = true;
            PleaseWait.Show();
            Application.DoEvents();
            Application.Run(MainMenu = new MainMenu());
        }
 public void AddRemoveDividends(ListBox lb, string stockActive)
 {
     PleaseWait pw = new PleaseWait();
     pw.Show();
     Application.DoEvents();
     lstID.Clear();
     int selectedItemsCount = lb.SelectedItems.Count;
     if (selectedItemsCount > 1)
     {
         foreach (DataRowView drv in lb.SelectedItems)
         {
             DividendStocks.UpdateDividendStock(drv.Row["id"].ToString(), stockActive);
             lstID.Add(Convert.ToInt32(drv.Row["id"]));
         }
     }
     else
     {
         DividendStocks.UpdateDividendStock(lb.SelectedValue.ToString(), stockActive);
     }
     LoadAllDividends();
     LoadCurrentDividends();
     SelectStocks(selectedItemsCount);
     pw.Close();
 }
 private void importStocksToolStripMenuItem_Click(object sender, EventArgs e)
 {
     string path = uti.GetImportPath();
     if (path != "")
     {
         PleaseWait pw = new PleaseWait();
         pw.Show();
         Application.DoEvents();
         uti.ImportXML(path);
         string cachePath = Path.Combine(Directory.GetCurrentDirectory(), uti.GetFileName(FileTypes.cache));
         File.Copy(cachePath, uti.GetFilePath(FileTypes.cache), true);
         //if (File.Exists(uti.GetFilePath(FileTypes.cache)))
         //{
             //string pathCache = uti.GetFilePath(FileTypes.cache);
             //File.Delete(pathCache);
             LoadCacheDividends();
             LoadDividends(lvAllDividends, "false");
             LoadDividends(lvCurrentDividends, "true");
             pw.Close();
             MessageBox.Show("Successfully Imported!");
         //}
     }
 }
 private void getDividendsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     PleaseWait pw = new PleaseWait();
     pw.Show();
     Application.DoEvents();
     try
     {
         GetDividendPrice(pw);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error in calculating. Please try again.");
     }
 }
 private void exportStocksToolStripMenuItem_Click(object sender, EventArgs e)
 {
     string path = uti.GetExportPath();
     if (path != "")
     {
         PleaseWait pw = new PleaseWait();
         pw.Show();
         Application.DoEvents();
         uti.ExportXML(path);
         pw.Close();
         MessageBox.Show("Successfully Exported!");
     }
 }
 public void OpenDividends(bool edit, bool currentDiv)
 {
     List<StockInfo> lstStockInfo = new List<StockInfo>();
     PleaseWait pw = new PleaseWait();
     pw.Show();
     Application.DoEvents();
     if (_Dividends == null || _Dividends.IsDisposed)
     {
         if (edit)
         {
             if (currentDiv)
             {
                 if (uti.DividendStatsValid(lstID))
                 {
                     lstStockInfo = GetStockInfoList(lvCurrentDividends);
                 }
                 else
                 {
                     pw.Close();
                     return;
                 }
             }
             else
             {
                 if (uti.DividendStatsValid(lstID))
                 {
                     lstStockInfo = GetStockInfoList(lvAllDividends);
                 }
                 else
                 {
                     pw.Close();
                     return;
                 }
             }
             _Dividends = new Dividends(edit, currentDiv, lstStockInfo);
         }
         else
         {
             _Dividends = new Dividends(edit, currentDiv);
         }
         _Dividends.Show();
     }
     else
     {
         _Dividends.Close();
         if (edit)
         {
             if (currentDiv)
             {
                 if (uti.DividendStatsValid(lstID))
                 {
                     lstStockInfo = GetStockInfoList(lvCurrentDividends);
                 }
                 else
                 {
                     pw.Close();
                     return;
                 }
             }
             else
             {
                 if (uti.DividendStatsValid(lstID))
                 {
                     lstStockInfo = GetStockInfoList(lvAllDividends);
                 }
                 else
                 {
                     pw.Close();
                     return;
                 }
             }
             _Dividends = new Dividends(edit, currentDiv, lstStockInfo);
         }
         else
         {
             _Dividends = new Dividends(edit, currentDiv);
         }
         //if (_Dividends.WindowState == FormWindowState.Minimized)
         //{
         //    _Dividends.WindowState = FormWindowState.Normal;
         //}
         //else
         //{
         //    _Dividends.BringToFront();
         //}
         _Dividends.Show();
     }
     pw.Close();
 }
 public void GetSharePrice(PleaseWait pw)
 {
     uti.ClearListViewColors(lvAllDividends);
     decimal totalPrice = 0;
     string[] msg = new string[9999];
     string msgShow = "";
     int cnt = 1;
     int divider = DividendStocks.GetTotalSharePrice(lstID, out totalPrice, out msg);
     pw.Close();
     if (divider > 20)
     {
         for (int i = 0; i < divider; i++)
         {
             msgShow += msg[i];
             if (cnt % 10 == 0)
             {
                 MessageBox.Show(msgShow);
                 msgShow = "";
             }
             if (i == divider - 1)
             {
                 if (i % 10 == 0)
                 {
                     MessageBox.Show(msgShow);
                 }
                 MessageBox.Show("Total: $" + Math.Round(totalPrice, 2).ToString());
             }
             cnt++;
         }
     }
     else
     {
         MessageBox.Show(uti.GenerateFullResultMsg(msg, divider) + "Total: $" + Math.Round(totalPrice, 2).ToString());
     }
 }
        public static void CalculateResults()
        {
            PleaseWait pw = new PleaseWait();
            pw.Show();
            Application.DoEvents();
            uti.ClearListViewColors(Program.MainMenu.lvAllDividends);
            uti.ClearListViewColors(Program.MainMenu.lvCurrentDividends);
            Program.MainMenu.lstID.Clear();
            decimal TotalDividendCount = 0;
            decimal TotalDividendStockValue = 0;
            decimal YearDiv = 0;
            decimal QuarterDiv = 0;
            decimal MonthlyDiv = 0;
            decimal DividendTotalPercentage = 0;
            //decimal MarketTotalPrice = 0;
            DataTable dt = uti.GetXMLData(FileTypes.xml);
            decimal Purchaseprice = 0;
            string symbols = uti.GetStockSymbols(dt, ",", true, true);
            DataTable dtCache = uti.FilterDataTable(uti.GetXMLData(FileTypes.cache), symbols);
            string[] AnnualDiv = uti.GetColValues(dtCache, DivCacheCodes.annualDiv.ToString());
            string[] DivYield = uti.GetColValues(dtCache, DivCacheCodes.divPercent.ToString());
            //string[] AnnualDiv = uti.SplitStockData(YahooFinance.GetValues(symbols, YahooFinance.GetCodes(YahooCodes.annualDividend), true));
            //string[] DivYield = uti.SplitStockData(YahooFinance.GetValues(symbols, YahooFinance.GetCodes(YahooCodes.dividendYield), true));

            // l1 is last trade price, c1 change in price, b is bid price, a is ask price; Ask price is current price as you're asking for a price when selling therefore that is the price of your portfolio
            string[] CurrentStockPrice = uti.GetColValues(dtCache, DivCacheCodes.currentPrice.ToString());
            //string[] CurrentStockPrice = uti.SplitStockData(YahooFinance.GetValues(symbols, YahooFinance.GetCodes(YahooCodes.currentPrice), true));
            //decimal val = dt.Rows.Count;
            //decimal StatusVal = 0;
            //val = Math.Round(90 / val, 0);
            bool hasAllAnnualDiv = true;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i]["active"].ToString() == "true")
                {
                    string id = dt.Rows[i]["id"].ToString();
                    Purchaseprice = Convert.ToDecimal(dt.Rows[i]["cost"]);
                    if (AnnualDiv[i] == "" || AnnualDiv[i] == "0.00")
                    {
                        hasAllAnnualDiv = false;
                    }
                    YearDiv += AnnualDiv[i] == "N/A" ? 0 : AnnualDiv[i] == "" ? 0 : (Convert.ToDecimal(dt.Rows[i]["shares"]) * Convert.ToDecimal(AnnualDiv[i]));
                    TotalDividendStockValue += (Convert.ToDecimal(dt.Rows[i]["shares"]) * Purchaseprice);
                    TotalDividendCount++;
                    DividendTotalPercentage += DivYield[i] == "N/A" ? 0 : DivYield[i].ToString() == "" ? 0 : Convert.ToDecimal(DivYield[i]);
                    //MarketTotalPrice += (Convert.ToDecimal(dt.Rows[i]["shares"]) * (CurrentStockPrice[i].ToString() == "N/A" ? 0 : Convert.ToDecimal(CurrentStockPrice[i])));
                    //StatusVal += val;
                    //if (StatusVal < 88)
                    //    pbStatus.InvokeEx(x => x.Value = Convert.ToInt32(StatusVal));
                }
            }
            DividendTotalPercentage = DividendTotalPercentage / TotalDividendCount;
            QuarterDiv = (YearDiv / 4);
            MonthlyDiv = (YearDiv / 12);
            //pbStatus.InvokeEx(x => x.Value = 100);
            //pbStatus.InvokeEx(x => x.Visible = false);
            //lblStatus.InvokeEx(x => x.Visible = false);
            pw.Close();
            if (hasAllAnnualDiv)
            {
                MessageBox.Show("Cost Basis: $" + Math.Round(TotalDividendStockValue, 2) + "\n\nAnnual Dividend: $" + Math.Round(YearDiv, 2) + "\n\n" + "Quarterly Average Dividend: $" + Math.Round(QuarterDiv, 2) + "\n\nMonthly Average Dividend: $" + Math.Round(MonthlyDiv, 2) + "\n\nPortfolio Dividend Yield: " + Math.Round(DividendTotalPercentage, 2) + "%");
            }
            else
            {
                MessageBox.Show("Yahoo could not retrieve all stock's annual dividends for the total calculation. Please try again later.");
            }
        }
Esempio n. 11
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (txtNumberOfShares.Text == "")
     {
         MessageBox.Show("Please enter number of shares.");
         return;
     }
     try
     {
         decimal.Parse(txtNumberOfShares.Text);
     }
     catch
     {
         MessageBox.Show("Please enter numbers only.");
         txtNumberOfShares.Focus();
         return;
     }
     if (txtPurchasePrice.Text == "")
     {
         MessageBox.Show("Please enter purchase price.");
         return;
     }
     try
     {
         decimal.Parse(txtPurchasePrice.Text);
     }
     catch
     {
         MessageBox.Show("Please enter numbers only.");
         txtPurchasePrice.Focus();
         return;
     }
     PleaseWait pw = new PleaseWait();
     pw.Show();
     Application.DoEvents();
     if (Edit)
     {
         DividendStocks.UpdateShare(Convert.ToDecimal(txtPurchasePrice.Text), Convert.ToDecimal(txtNumberOfShares.Text), DividendPriceID, dtpPurchaseDate.Value);
     }
     else
     {
         DividendStocks.NewShare(Convert.ToDecimal(txtPurchasePrice.Text), Convert.ToDecimal(txtNumberOfShares.Text), ID, dtpPurchaseDate.Value);
     }
     MainMenu._Dividends.LoadDividendStock();
     LoadAllMainDividends();
     SelectCurrentStock();
     pw.Close();
     this.Close();
 }
 public void OpenDividends(bool edit, string id, string symbol)
 {
     PleaseWait pw = new PleaseWait();
     pw.Show();
     Application.DoEvents();
     if (_Dividends == null || _Dividends.IsDisposed)
     {
         _Dividends = new Dividends(edit, id, CurrentDiv, symbol);
         _Dividends.Show();
     }
     else
     {
         if (_Dividends.WindowState == FormWindowState.Minimized)
         {
             _Dividends.WindowState = FormWindowState.Normal;
         }
         else
         {
             _Dividends.BringToFront();
         }
     }
     pw.Close();
 }
 public void HighlightPayDate(ListBox lb)
 {
     PleaseWait pw = new PleaseWait();
     pw.Show();
     Application.DoEvents();
     lb.ClearSelected();
     decimal totalDiv = 0;
     decimal quarterlyDiv = 0;
     int cnt = 0;
     string monthYear = "";
     string dtpMonthYear = "";
     string individualDivData = "";
     DataTable dt = DividendStocks.GetCurrentDividends();
     for (int i = 0; i < lb.Items.Count; i++)
     {
         DataRowView drv = lb.Items[i] as DataRowView;
         string[] date = drv["symbolName"].ToString().Split('*');
         string[] symbolSplit = date[0].Split('-');
         string symbol = symbolSplit[0].Trim();
         if (date.Length == 2)
         {
             monthYear = date[1].ToString();
             if (monthYear != "N/A")
             {
                 date = monthYear.Split('/');
                 monthYear = date[0].Trim() + "/" + date[2];
                 dtpMonthYear = dtpPayDate.Value.ToString("MM/yyyy");
                 //string dividendInterval = GetDividendInterval(Convert.ToInt32(drv["id"]), dt);
                 //if (dividendInterval == "Monthly")
                 //{
                 //    lb.SelectedIndices.Add(i);
                 //    totalDiv += GetDiv(Convert.ToInt32(drv["id"]), dt);
                 //    individualDivData += symbol + ": $" + Math.Round((GetDiv(Convert.ToInt32(drv["id"]), dt) / 4), 2) + "\n\n";
                 //}
                 if (monthYear == dtpMonthYear)
                 {
                     lb.SelectedIndices.Add(i);
                     totalDiv += GetDiv(Convert.ToInt32(drv["id"]), dt);
                     individualDivData += symbol + ": $" + Math.Round((GetDiv(Convert.ToInt32(drv["id"]), dt) / 4), 2) + "\n\n";
                     cnt++;
                 }
             }
         }
     }
     HighlightActive = false;
     quarterlyDiv = totalDiv / 4;
     pw.Close();
     if (cnt != 0)
     {
         MessageBox.Show(string.Format("{0} results\n\n" + "{1} \n\n" + individualDivData + "Total: ${2}\n\n", cnt, "Dividends for " + dtpMonthYear + ":",  Math.Round(quarterlyDiv, 2)));
     }
     else
     {
         MessageBox.Show(string.Format("No Results for {0}", dtpMonthYear));
     }
 }
 public void GetDividendPrice(PleaseWait pw)
 {
     uti.ClearListViewColors(lvAllDividends);
     decimal TotalDividendPrice = 0;
     decimal QuarterlyDividendPrice = 0;
     decimal MonthlyDividendPrice = 0;
     string[] msg = new string[9999];
     int divider = DividendStocks.GetDividendPrice(lvCurrentDividends, lstID, out TotalDividendPrice, out QuarterlyDividendPrice, out MonthlyDividendPrice, out msg);
     pw.Close();
     string msgShow = "";
     int cnt = 1;
     if (divider > 10)
     {
         for (int i = 0; i < divider; i++)
         {
             msgShow += msg[i];
             if (cnt % 10 == 0)
             {
                 MessageBox.Show(msgShow);
                 msgShow = "";
             }
             if (i == divider - 1)
             {
                 if (i % 10 == 0)
                 {
                     MessageBox.Show(msgShow);
                 }
                 MessageBox.Show(msg[cnt] + "Monthly: $" + Math.Round(MonthlyDividendPrice, 2).ToString() + "\nQuarterly: $" + Math.Round(QuarterlyDividendPrice, 2) + "\nYearly: $" + Math.Round(TotalDividendPrice, 2));
             }
             cnt++;
         }
     }
     else
     {
         MessageBox.Show(uti.GenerateFullResultMsg(msg, divider) + "Monthly: $" + Math.Round(MonthlyDividendPrice, 2).ToString() + "\nQuarterly: $" + Math.Round(QuarterlyDividendPrice, 2) + "\nYearly: $" + Math.Round(TotalDividendPrice, 2));
     }
 }
 public static void HighlightPayDate(ListView lv)
 {
     PleaseWait pw = new PleaseWait();
     pw.Show();
     Application.DoEvents();
     Program.MainMenu.lstID.Clear();
     decimal totalDiv = 0;
     decimal quarterlyDiv = 0;
     int cnt = 0;
     string monthYear = "";
     string dtpMonthYear = Program.MainMenu.dtpPayDate.Value.ToString("M/yyyy");
     string individualDivData = "";
     decimal div = 0;
     //lv.SelectedItems.Clear();
     uti.ClearListViewColors(lv);
     Program.MainMenu.lstID.Clear();
     string stockSymbols = GetHighlightSymbols(lv);
     DataTable dt = uti.FilterDataTable(uti.GetXMLData(FileTypes.cache), stockSymbols);
     string[] annualDiv = uti.GetColValues(dt, DivCacheCodes.annualDiv.ToString());
     //string[] AnnualDiv = uti.SplitStockData(YahooFinance.GetValues(stockSymbols, YahooFinance.GetCodes(YahooCodes.annualDividend), true));
     int annDivCnt = 0;
     for (int i = 0; i < lv.Items.Count; i++)
     {
         string date = lv.Items[i].SubItems[5].Text;
         string[] dateSplit = date.Split('/');
         if (date != "N/A" && date != "")
         {
             monthYear = dateSplit[0].Trim() + "/" + dateSplit[2];
             string dividendInterval = lv.Items[i].SubItems[8].Text.ToString();
             //if (dividendInterval == "Monthly")
             //{
             //    lv.SelectedIndices.Add(i);
             //    totalDiv +=
             //    individualDivData += symbol + ": $" + Math.Round((GetDiv(Convert.ToInt32(drv["id"]), dt) / 4), 2) + "\n\n";
             //}
             if (monthYear == dtpMonthYear)
             {
                 lv.Items[i].BackColor = uti.HighlightBarColor;
                 lv.Items[i].ForeColor = uti.ForeColorSelected;
                 uti.ChangedListViewItemBold(lv, i, true, false);
                 lv.Items[i].Selected = true;
                 lv.Items[i].Focused = true;
                 lv.TopItem = lv.Items[i];
                 string symbol = lv.Items[i].SubItems[1].Text.ToString();
                 try
                 {
                     div = annualDiv[annDivCnt] == "N/A" ? 0 : Convert.ToDecimal(annualDiv[annDivCnt]);
                     annDivCnt++;
                 }
                 catch
                 {
                     pw.Close();
                     MessageBox.Show("Could not highlight, yahoo connection was lost. Please try again later.");
                     return;
                 }
                 decimal divReceived = uti.GetDivPrice(Convert.ToDecimal(lv.Items[i].SubItems[9].Text.ToString()), div);
                 totalDiv += divReceived;
                 individualDivData += symbol + ": $" + Math.Round(divReceived / 4, 2) + " (Pay Date: " + lv.Items[i].SubItems[5].Text.ToString() + ")\n\n";
                 Program.MainMenu.lstID.Add(Convert.ToInt32(lv.Items[i].Tag));
                 cnt++;
             }
         }
     }
     lv.SelectedItems.Clear();
     quarterlyDiv = totalDiv / 4;
     pw.Close();
     if (cnt != 0)
     {
         MessageBox.Show(string.Format("{0} results\n\n" + "{1} \n\n" + individualDivData + "Total: ${2}\n\n", cnt, "Dividends for " + dtpMonthYear + "", Math.Round(quarterlyDiv, 2)));
     }
     else
     {
         MessageBox.Show(string.Format("No Results for {0}", dtpMonthYear));
     }
 }
 private void reloadYahooStockInfoToolStripMenuItem_Click(object sender, EventArgs e)
 {
     PleaseWait pw = new PleaseWait();
     pw.Show();
     Application.DoEvents();
     LoadCacheDividends();
     LoadDividends(lvAllDividends, "false");
     LoadDividends(lvCurrentDividends, "true");
     pw.Close();
 }
 private void btnSave_Click(object sender, EventArgs e)
 {
     PleaseWait pw = new PleaseWait();
     if (!ValidateAll())
     {
         return;
     }
     if (Edit)
     {
         if (LstStockInfo[0].Symbol != txtSymbol.Text.Trim().ToUpper())
         {
             if (uti.ValidateStock(txtSymbol.Text.Trim()))
             {
                 MessageBox.Show(string.Format("{0} already exist.", txtSymbol.Text.ToUpper()));
                 return;
             }
         }
         this.Hide();
         pw.Show();
         Application.DoEvents();
         uti.ClearListViewColors(Program.MainMenu.lvAllDividends);
         uti.ClearListViewColors(Program.MainMenu.lvCurrentDividends);
         DividendStocks.UpdateDividendStock(LstStockInfo[0].ID, Symbol, txtSymbol.Text, ddlIndustry.Text, ddlDividendInterval.Text, FileTypes.xml);
         DividendStocks.UpdateDividendStock(LstStockInfo[0].ID, Symbol, txtSymbol.Text, ddlIndustry.Text, ddlDividendInterval.Text, FileTypes.cache);
         DividendStocks.UpdateShare(LstStockInfo[0].ID, Symbol, txtCost.Text, txtNumberOfShares.Text, dtpPurchaseDate.Value.ToString("MM-dd-yyyy"));
         Program.MainMenu.LoadCacheDividends();
         ReloadMainDividends();
         Program.MainMenu.CurrentDiv = !Program.MainMenu.CurrentDiv;
         Program.MainMenu.SelectStocks();
         pw.Close();
         this.Close();
     }
     else
     {
         if (uti.ValidateStock(txtSymbol.Text.Trim()))
         {
             MessageBox.Show(string.Format("{0} already exist.", txtSymbol.Text.ToUpper()));
             return;
         }
         this.Hide();
         pw.Show();
         Application.DoEvents();
         uti.ClearListViewColors(Program.MainMenu.lvAllDividends);
         uti.ClearListViewColors(Program.MainMenu.lvCurrentDividends);
         string newID = DividendStocks.NewDividendStock(txtSymbol.Text.ToUpper(), ddlIndustry.Text, ddlDividendInterval.Text);
         DividendStocks.UpdateShare(newID, txtSymbol.Text, txtCost.Text, txtNumberOfShares.Text, dtpPurchaseDate.Value.ToString("MM-dd-yyyy"));
         AddCache(newID);
         Program.MainMenu.lstID.Clear();
         Program.MainMenu.lstID.Add(Convert.ToInt32(newID));
         Program.MainMenu.LoadCacheDividends();
         ReloadMainDividends();
         Program.MainMenu.CurrentDiv = true;
         Program.MainMenu.SelectStocks();
         pw.Close();
         this.Close();
     }
 }