예제 #1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            string sURL          = string.Empty;
            string sSName        = string.Empty;
            long   DownloadBytes = 0;

            try
            {
                sSName = _dvStocks[(int)ddlStock.SelectedIndex]["YFCode"].ToString();
                sURL   = string.Format(URLYahoo, sSName,
                                       dtpStart.Value.ToString("MM"),
                                       dtpStart.Value.ToString("dd"),
                                       dtpStart.Value.ToString("yyyy"),
                                       dtpEnd.Value.ToString("MM"),
                                       dtpEnd.Value.ToString("dd"),
                                       dtpEnd.Value.ToString("yyyy"),
                                       _mode);
                //Console.WriteLine(sURL);

                SaveFileDialog saveFileDlgExport = new SaveFileDialog();
                saveFileDlgExport.Title            = "Save file [Historical Data from Yahoo]";
                saveFileDlgExport.FileName         = sSName = _dvStocks[(int)ddlStock.SelectedIndex]["ShortName"].ToString();
                saveFileDlgExport.Filter           = "CSV (*.csv)|*.csv";
                saveFileDlgExport.InitialDirectory = CommonDoubleM._DoubleMPath;
                if (saveFileDlgExport.ShowDialog() == DialogResult.OK)
                {
                    Cursor        = Cursors.WaitCursor;
                    DownloadBytes = CommonDoubleM.DownloadFile(sURL, saveFileDlgExport.FileName, _pBar);

                    if (DownloadBytes > -1)
                    {
                        _lblMsgDoubleM.Text = "Download " + CommonDoubleM.FormatBytes(DownloadBytes);
                    }
                    else
                    {
                        _lblMsgDoubleM.Text = "No data available for selected date, please change the date & try again..";
                    }

                    Cursor = Cursors.Default;
                }
            }
            catch (Exception ex)
            {
                _lblMsgDoubleM.Text = ex.Message;
                CommonDoubleM.LogDM(ex.Message);
            }
        }
예제 #2
0
        private void tsbtnDownload_Click(object sender, EventArgs e)
        {
            frmDateTime pfrmDT;
            long        DownloadBytes = 0;

            ToolStripMenuItem obj = (ToolStripMenuItem)sender;

            //Console.WriteLine(obj.Name);
            switch (obj.Name)
            {
            case "tsbtnDownloadBSE":
                pfrmDT = new frmDateTime("Historical date for BSE", false, true);
                if (pfrmDT.ShowDialog() != DialogResult.OK)
                {
                    pfrmDT.Dispose();
                    break;
                }
                pfrmDT.Dispose();

                saveFileDlgExport.Title            = "Save file [Historical Data from BSE]";
                saveFileDlgExport.FileName         = string.Empty;
                saveFileDlgExport.Filter           = "Zip (*.zip)|*.zip";
                saveFileDlgExport.InitialDirectory = CommonDoubleM._DoubleMPath;
                if (saveFileDlgExport.ShowDialog() == DialogResult.OK)
                {
                    Cursor        = Cursors.WaitCursor;
                    DownloadBytes = CommonDoubleM.getHitoricalData((short)CommonDoubleM.StockExchange.BSE,
                                                                   saveFileDlgExport.FileName, pBarDM);
                    if (DownloadBytes > -1)
                    {
                        lblDMMsg.Text = "Download " + CommonDoubleM.FormatBytes(DownloadBytes);
                    }
                    else
                    {
                        lblDMMsg.Text = "No data available for selected date, please change the date & try again..";
                    }
                    Cursor = Cursors.Default;
                }
                break;

            case "tsbtnDownloadNSE":
                pfrmDT = new frmDateTime("Historical date for NSE", false, true);
                if (pfrmDT.ShowDialog() != DialogResult.OK)
                {
                    pfrmDT.Dispose();
                    break;
                }
                pfrmDT.Dispose();

                saveFileDlgExport.Title            = "Save file [Historical Data from NSE]";
                saveFileDlgExport.FileName         = string.Empty;
                saveFileDlgExport.Filter           = "CSV (*.csv)|*.csv";
                saveFileDlgExport.InitialDirectory = CommonDoubleM._DoubleMPath;
                if (saveFileDlgExport.ShowDialog() == DialogResult.OK)
                {
                    Cursor        = Cursors.WaitCursor;
                    DownloadBytes = CommonDoubleM.getHitoricalData((short)CommonDoubleM.StockExchange.NSE,
                                                                   saveFileDlgExport.FileName, pBarDM);
                    if (DownloadBytes > -1)
                    {
                        lblDMMsg.Text = "Download " + CommonDoubleM.FormatBytes(DownloadBytes);
                    }
                    else
                    {
                        lblDMMsg.Text = "No data available for selected date, please change the date & try again..";
                    }
                    Cursor = Cursors.Default;
                }
                break;

            case "tsbtnDownloadY":
                frmYahoo pYahoo = new frmYahoo(_pdalStock, lblDMMsg, pBarDM);
                pYahoo.ShowDialog();
                break;
            }
        }