Esempio n. 1
0
        public bool downloadDaily(string folderPath, string scriptName, bool bIsTestOn, bool bSaveData)
        {
            string outputsize = ddlDaily_OutputSize.SelectedValue;

            //if (StockApi.getDaily(folderPath, scriptName, outputsize: outputsize, bIsTestModeOn: bIsTestOn,
            //                        bSaveData: bSaveData, apiKey: Session["ApiKey"].ToString()) == null)
            //{
            //if we failed to get data from alphavantage we will try to get it from yahoo online with test flag = false
            if (StockApi.getDailyAlternate(folderPath, scriptName, outputsize: outputsize, bIsTestModeOn: bIsTestOn,
                                           bSaveData: bSaveData, apiKey: Session["ApiKey"].ToString()) == null)
            {
                textboxMessage.Text = Environment.NewLine + "Daily data not available for selected script.";
                return(false);
            }
            //}
            return(true);
        }
Esempio n. 2
0
        public void ShowGraph()
        {
            DataTable indexTable     = null;
            DataTable portfolioTable = null;
            DataTable valuationTable = null;
            DataTable tempData       = null;

            DataRow[] filteredRows = null;
            DataRow[] scriptRows;

            string fromDate = "", toDate = "";
            string expression = "";
            double tempQty    = 0;
            double tempCost;

            string      currentFundName;
            DataManager dataMgr = new DataManager();

            string folderPath = Session["DATAFOLDER"].ToString();

            if ((ViewState["PortfolioTable"] == null) || (((DataTable)ViewState["PortfolioTable"]).Rows.Count == 0))
            {
                portfolioTable = dataMgr.openMFPortfolio(Session["EMAILID"].ToString(),
                                                         Session["MFPORTFOLIONAME"].ToString(), Session["MFPORTFOLIOMASTERROWID"].ToString());
                ViewState["PortfolioTable"] = portfolioTable;
            }
            else
            {
                portfolioTable = (DataTable)ViewState["PortfolioTable"];
            }

            if ((ViewState["FetchedData"] == null) || (((DataTable)ViewState["FetchedData"]).Rows.Count == 0))
            {
                valuationTable = dataMgr.GetValuationLineGraph(Session["MFPORTFOLIOMASTERROWID"].ToString(), Session["EMAILID"].ToString(),
                                                               Session["MFPORTFOLIONAME"].ToString());

                ViewState["FetchedData"] = valuationTable;
                gridviewPortfolioValuation.DataSource = (DataTable)ViewState["FetchedData"];
                gridviewPortfolioValuation.DataBind();
            }
            if ((System.Convert.ToInt32((ViewState["SelectedIndex"].ToString())) != ddlIndex.SelectedIndex) &&
                (ddlIndex.SelectedIndex > 0))
            {
                //Some index is selected by user
                indexTable = StockApi.getDailyAlternate(folderPath, ddlIndex.SelectedValue, bIsTestModeOn: false, bSaveData: false,
                                                        apiKey: Session["ApiKey"].ToString());
                ViewState["FetchedIndexData"] = indexTable;
                ViewState["SelectedIndex"]    = ddlIndex.SelectedIndex;
            }

            if (ViewState["FromDate"] != null)
            {
                fromDate = ViewState["FromDate"].ToString();
            }
            if (ViewState["ToDate"] != null)
            {
                toDate = ViewState["ToDate"].ToString();
            }

            if ((fromDate.Length > 0) && (toDate.Length > 0))
            {
                tempData     = (DataTable)ViewState["FetchedData"];
                expression   = "DATE >= '" + fromDate + "' and DATE <= '" + toDate + "'";
                filteredRows = tempData.Select(expression);
                if ((filteredRows != null) && (filteredRows.Length > 0))
                {
                    valuationTable = filteredRows.CopyToDataTable();
                }

                tempData.Clear();
                tempData = null;

                if (ViewState["FetchedIndexData"] != null)
                {
                    tempData     = (DataTable)ViewState["FetchedIndexData"];
                    expression   = "Date >= '" + fromDate + "' and Date <= '" + toDate + "'";
                    filteredRows = tempData.Select(expression);
                    if ((filteredRows != null) && (filteredRows.Length > 0))
                    {
                        indexTable = filteredRows.CopyToDataTable();
                    }
                }
            }
            else
            {
                valuationTable = (DataTable)ViewState["FetchedData"];
                indexTable     = (DataTable)ViewState["FetchedIndexData"];
            }

            if (valuationTable != null)
            {
                if (chartPortfolioValuation.Annotations.Count > 0)
                {
                    chartPortfolioValuation.Annotations.Clear();
                }

                DataTable fundNameTable = portfolioTable.DefaultView.ToTable(true, "FundName");

                foreach (DataRow fundNameRow in fundNameTable.Rows)
                {
                    currentFundName = fundNameRow["FundName"].ToString();

                    scriptRows = valuationTable.Select("SCHEME_NAME='" + currentFundName + "'");

                    if (scriptRows.Length > 0)
                    {
                        if (listboxScripts.Items.FindByValue(currentFundName) == null)
                        {
                            ListItem li = new ListItem(currentFundName, currentFundName);
                            listboxScripts.Items.Add(li);
                        }

                        if (chartPortfolioValuation.Series.FindByName(currentFundName) == null)
                        {
                            chartPortfolioValuation.Series.Add(currentFundName);
                            chartPortfolioValuation.Series[currentFundName].Name        = currentFundName;
                            (chartPortfolioValuation.Series[currentFundName]).ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Line;
                            (chartPortfolioValuation.Series[currentFundName]).ChartArea = chartPortfolioValuation.ChartAreas[0].Name;

                            chartPortfolioValuation.Series[currentFundName].Legend        = chartPortfolioValuation.Legends[0].Name;
                            chartPortfolioValuation.Series[currentFundName].LegendText    = currentFundName;
                            chartPortfolioValuation.Series[currentFundName].LegendToolTip = currentFundName;
                            chartPortfolioValuation.Series[currentFundName].ToolTip       = currentFundName + ": Date:#VALX; Current Value:#VALY (Click to see details)";
                            chartPortfolioValuation.Series[currentFundName].PostBackValue = currentFundName + ",#VALX,#VALY1,#VALY2,#VALY3,#VALY4,#VALY5,#VALY6";
                        }

                        tempQty  = 0;
                        tempCost = 0.00;
                        (chartPortfolioValuation.Series[currentFundName]).Points.Clear();
                        foreach (DataRow itemRow in scriptRows)
                        {
                            (chartPortfolioValuation.Series[currentFundName]).Points.AddXY(itemRow["DATE"], itemRow["CurrentValue"]);

                            if ((itemRow["CumulativeUnits"] != System.DBNull.Value) && ((tempQty == 0) || (tempQty != System.Convert.ToDouble(itemRow["CumulativeUnits"]))))
                            {
                                tempQty = System.Convert.ToDouble(itemRow["CumulativeUnits"]);
                                (chartPortfolioValuation.Series[currentFundName]).Points[(chartPortfolioValuation.Series[currentFundName]).Points.Count - 1].MarkerSize  = 10;
                                (chartPortfolioValuation.Series[currentFundName]).Points[(chartPortfolioValuation.Series[currentFundName]).Points.Count - 1].MarkerStyle = System.Web.UI.DataVisualization.Charting.MarkerStyle.Diamond;
                                //(chartPortfolioValuation.Series[currentFundName]).Points[(chartPortfolioValuation.Series[currentFundName]).Points.Count - 1].Label = itemRow["CumulativeUnits"].ToString();
                            }

                            (chartPortfolioValuation.Series[currentFundName]).Points[(chartPortfolioValuation.Series[currentFundName]).Points.Count - 1].PostBackValue =
                                itemRow["SCHEME_NAME"] + "," + itemRow["DATE"] + "," + itemRow["NET_ASSET_VALUE"] + "," + itemRow["CurrentValue"] + "," + itemRow["CumulativeUnits"] + "," + itemRow["CumulativeCost"];
                        }
                        (chartPortfolioValuation.Series[currentFundName]).Points[(chartPortfolioValuation.Series[currentFundName]).Points.Count - 1].MarkerSize  = 10;
                        (chartPortfolioValuation.Series[currentFundName]).Points[(chartPortfolioValuation.Series[currentFundName]).Points.Count - 1].MarkerStyle = System.Web.UI.DataVisualization.Charting.MarkerStyle.Diamond;
                    }
                }

                if (indexTable != null)
                {
                    if (chartPortfolioValuation.Series.FindByName(ddlIndex.SelectedValue) == null)
                    {
                        chartPortfolioValuation.Series.Add(ddlIndex.SelectedValue);

                        chartPortfolioValuation.Series[ddlIndex.SelectedValue].Name        = ddlIndex.SelectedValue;
                        (chartPortfolioValuation.Series[ddlIndex.SelectedValue]).ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Line;
                        (chartPortfolioValuation.Series[ddlIndex.SelectedValue]).ChartArea = chartPortfolioValuation.ChartAreas[0].Name;

                        chartPortfolioValuation.Series[ddlIndex.SelectedValue].Legend        = chartPortfolioValuation.Legends[0].Name;
                        chartPortfolioValuation.Series[ddlIndex.SelectedValue].LegendText    = ddlIndex.SelectedValue;
                        chartPortfolioValuation.Series[ddlIndex.SelectedValue].LegendToolTip = ddlIndex.SelectedValue;

                        (chartPortfolioValuation.Series[ddlIndex.SelectedValue]).YValuesPerPoint = 4;
                        chartPortfolioValuation.Series[ddlIndex.SelectedValue].ToolTip           = ddlIndex.SelectedValue + ": Date:#VALX; Close:#VALY4 (Click to see details)";
                        chartPortfolioValuation.Series[ddlIndex.SelectedValue].PostBackValue     = ddlIndex.SelectedValue + ",#VALX,#VALY1,#VALY2,#VALY3,#VALY4";
                    }
                    (chartPortfolioValuation.Series[ddlIndex.SelectedValue]).Points.DataBindXY(indexTable.Rows, "Date", indexTable.Rows, "Open,High,Low,Close");

                    for (int i = 1; i < ddlIndex.Items.Count; i++)
                    {
                        Series tempSeries = chartPortfolioValuation.Series.FindByName(ddlIndex.Items[i].Value);
                        if (tempSeries != null)
                        {
                            if (ddlIndex.SelectedValue != ddlIndex.Items[i].Value)
                            {
                                chartPortfolioValuation.Series.Remove(tempSeries);
                            }
                        }
                    }
                }

                foreach (ListItem item in listboxScripts.Items)
                {
                    if (item.Value.Equals("All") && item.Selected)
                    {
                        foreach (Series itemSeries in chartPortfolioValuation.Series)
                        {
                            itemSeries.Enabled = true;
                        }
                        break;
                    }
                    else if (!item.Value.Equals("All") && (item.Selected))
                    {
                        chartPortfolioValuation.Series[item.Value].Enabled = true;
                    }
                    else if (!item.Value.Equals("All") && (!item.Selected))
                    {
                        chartPortfolioValuation.Series[item.Value].Enabled = false;
                    }
                }
            }
        }
Esempio n. 3
0
        public void FillData()
        {
            DataTable tempData    = null;
            DataTable dailyNAVSMA = null;
            DataTable indexTable  = null;

            DataRow[]   filteredRows = null;
            string      expression   = "";
            DataManager dataMgr      = new DataManager();
            string      folderPath   = Session["DATAFOLDER"].ToString();

            int    smallperiod   = Int32.Parse(textboxSMASmallPeriod.Text.ToString());
            int    longperiod    = Int32.Parse(textboxSMALongPeriod.Text.ToString());
            int    buySpan       = Int32.Parse(textboxBuySpan.Text.ToString());
            int    sellSpan      = Int32.Parse(textboxSellSpan.Text.ToString());
            string schemeCode    = Request.QueryString["schemecode"].ToString();
            double simulationQty = double.Parse(textboxSimulationQty.Text.ToString());

            //if we were called from portfolio page then get the portfolio data for selected scheme
            //if (Request.QueryString["schemecode"] != null)
            if ((Session["MFPORTFOLIONAME"] != null) && (Session["MFPORTFOLIOMASTERROWID"] != null))
            {
                if ((ddlShowHidePortfolio.SelectedIndex == 0) && ((ViewState["VALUATION_TABLE"] == null) || (((DataTable)ViewState["VALUATION_TABLE"]).Rows.Count == 0)))
                {
                    tempData = dataMgr.GetValuationLineGraph(Session["MFPORTFOLIOMASTERROWID"].ToString(), Session["EMAILID"].ToString(),
                                                             Session["MFPORTFOLIONAME"].ToString());

                    expression   = "SCHEME_CODE = '" + schemeCode + "'";
                    filteredRows = tempData.Select(expression);
                    if ((filteredRows != null) && (filteredRows.Length > 0))
                    {
                        ViewState["VALUATION_TABLE"] = (DataTable)filteredRows.CopyToDataTable();

                        //gridviewPortfolioValuation.DataSource = (DataTable)ViewState["VALUATION_TABLE"];
                        //gridviewPortfolioValuation.DataBind();
                    }
                }
            }
            if ((ViewState["FetchedData"] == null) || (((DataTable)ViewState["FetchedData"]).Rows.Count == 0))
            {
                dailyNAVSMA = dataMgr.getBacktestFromSMA(Int32.Parse(schemeCode),
                                                         fromDate: ((ViewState["FromDate"] == null) || (ViewState["FromDate"].ToString().Equals(""))) ? null : ViewState["FromDate"].ToString(),
                                                         toDate: ((ViewState["ToDate"] == null) || (ViewState["ToDate"].ToString().Equals(""))) ? null : ViewState["ToDate"].ToString(),
                                                         smallPeriod: smallperiod, longPeriod: longperiod, buySpan: buySpan, sellSpan: sellSpan, simulationQty: simulationQty);
                if (dailyNAVSMA != null)
                {
                    ViewState["FetchedData"] = dailyNAVSMA;

                    //gridviewBackTestMF.DataSource = (DataTable)ViewState["FetchedData"];
                    //gridviewBackTestMF.DataBind();
                }
            }

            if ((System.Convert.ToInt32((ViewState["SelectedIndex"].ToString())) != ddlIndex.SelectedIndex) && (ddlIndex.SelectedIndex > 0))
            {
                //Some index is selected by user
                indexTable = StockApi.getDailyAlternate(folderPath, ddlIndex.SelectedValue, bIsTestModeOn: false, bSaveData: false,
                                                        apiKey: Session["ApiKey"].ToString());
                ViewState["FetchedIndexData"] = indexTable;
                ViewState["SelectedIndex"]    = ddlIndex.SelectedIndex;
            }
        }
Esempio n. 4
0
        public void ShowGraph(string fileName)
        {
            bool      bIsTestOn      = true;
            DataTable portfolioTable = null;
            DataTable valuationTable = null;
            DataTable indexTable     = null;
            DataTable tempData       = null;
            string    folderPath     = Server.MapPath("~/scriptdata/");
            string    currentFundName;
            string    searchPath;
            //int markerInterval = 10;
            //int i = 0;
            double tempQty = 0;
            double tempCost;
            string fromDate = "", toDate = "";
            string expression = "";

            DataRow[] filteredRows = null;
            DataRow[] scriptRows;

            try
            {
                if (File.Exists(fileName))
                {
                    if (Session["IsTestOn"] != null)
                    {
                        bIsTestOn = System.Convert.ToBoolean(Session["IsTestOn"]);
                    }

                    if (Session["TestDataFolderMF"] != null)
                    {
                        folderPath = Session["TestDataFolderMF"].ToString();
                    }

                    //portfolioTable = StockApi.GetValuation(folderPath, fileName, bIsTestOn);
                    //portfolioTable = MFAPI.openMFPortfolio(folderPath, fileName);

                    if ((ViewState["PortfolioTable"] == null) || (((DataTable)ViewState["PortfolioTable"]).Rows.Count == 0))
                    {
                        portfolioTable = MFAPI.openMFPortfolio(folderPath, fileName);
                        ViewState["PortfolioTable"] = portfolioTable;
                    }
                    else
                    {
                        portfolioTable = (DataTable)ViewState["PortfolioTable"];
                    }

                    if ((ViewState["FetchedData"] == null) || (((DataTable)ViewState["FetchedData"]).Rows.Count == 0))
                    {
                        //if (Session["IsTestOn"] != null)
                        //{
                        //    bIsTestOn = System.Convert.ToBoolean(Session["IsTestOn"]);
                        //}

                        //if (Session["TestDataFolderMF"] != null)
                        //{
                        //    folderPath = Session["TestDataFolderMF"].ToString();
                        //}

                        valuationTable           = MFAPI.GetMFValuationLine(folderPath, fileName, portfolioTable: portfolioTable);
                        ViewState["FetchedData"] = valuationTable;
                        gridviewPortfolioValuation.DataSource = (DataTable)ViewState["FetchedData"];
                        gridviewPortfolioValuation.DataBind();
                    }

                    if ((System.Convert.ToInt32((ViewState["SelectedIndex"].ToString())) != ddlIndex.SelectedIndex) &&
                        (ddlIndex.SelectedIndex > 0))
                    {
                        //if (Session["IsTestOn"] != null)
                        //{
                        //    bIsTestOn = System.Convert.ToBoolean(Session["IsTestOn"]);
                        //}

                        //if (Session["TestDataFolderMF"] != null)
                        //{
                        //    folderPath = Session["TestDataFolderMF"].ToString();
                        //}

                        //Some index is selected by user
                        indexTable = StockApi.getDailyAlternate(folderPath, ddlIndex.SelectedValue, bIsTestModeOn: false, bSaveData: false,
                                                                apiKey: Session["ApiKey"].ToString());
                        ViewState["FetchedIndexData"] = indexTable;
                        ViewState["SelectedIndex"]    = ddlIndex.SelectedIndex;
                    }
                    //else
                    //{
                    if (ViewState["FromDate"] != null)
                    {
                        fromDate = ViewState["FromDate"].ToString();
                    }
                    if (ViewState["ToDate"] != null)
                    {
                        toDate = ViewState["ToDate"].ToString();
                    }

                    if ((fromDate.Length > 0) && (toDate.Length > 0))
                    {
                        tempData     = (DataTable)ViewState["FetchedData"];
                        expression   = "Date >= '" + fromDate + "' and Date <= '" + toDate + "'";
                        filteredRows = tempData.Select(expression);
                        if ((filteredRows != null) && (filteredRows.Length > 0))
                        {
                            valuationTable = filteredRows.CopyToDataTable();
                        }

                        tempData.Clear();
                        tempData = null;

                        if (ViewState["FetchedIndexData"] != null)
                        {
                            tempData     = (DataTable)ViewState["FetchedIndexData"];
                            expression   = "Date >= '" + fromDate + "' and Date <= '" + toDate + "'";
                            filteredRows = tempData.Select(expression);
                            if ((filteredRows != null) && (filteredRows.Length > 0))
                            {
                                indexTable = filteredRows.CopyToDataTable();
                            }
                        }
                    }
                    else
                    {
                        valuationTable = (DataTable)ViewState["FetchedData"];
                        indexTable     = (DataTable)ViewState["FetchedIndexData"];
                    }
                    //}

                    if (valuationTable != null)
                    {
                        if (chartPortfolioValuation.Annotations.Count > 0)
                        {
                            chartPortfolioValuation.Annotations.Clear();
                        }

                        DataTable fundNameTable = portfolioTable.DefaultView.ToTable(true, "FundName");

                        foreach (DataRow fundNameRow in fundNameTable.Rows)
                        {
                            currentFundName = fundNameRow["FundName"].ToString();

                            scriptRows = valuationTable.Select("SCHEME_NAME='" + currentFundName + "'");

                            if (scriptRows.Length > 0)
                            {
                                if (listboxScripts.Items.FindByValue(currentFundName) == null)
                                {
                                    ListItem li = new ListItem(currentFundName, currentFundName);
                                    listboxScripts.Items.Add(li);
                                }

                                if (chartPortfolioValuation.Series.FindByName(currentFundName) == null)
                                {
                                    chartPortfolioValuation.Series.Add(currentFundName);
                                    chartPortfolioValuation.Series[currentFundName].Name        = currentFundName;
                                    (chartPortfolioValuation.Series[currentFundName]).ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Line;
                                    (chartPortfolioValuation.Series[currentFundName]).ChartArea = chartPortfolioValuation.ChartAreas[0].Name;

                                    chartPortfolioValuation.Series[currentFundName].Legend        = chartPortfolioValuation.Legends[0].Name;
                                    chartPortfolioValuation.Series[currentFundName].LegendText    = currentFundName;
                                    chartPortfolioValuation.Series[currentFundName].LegendToolTip = currentFundName;
                                    chartPortfolioValuation.Series[currentFundName].ToolTip       = currentFundName + ": Date:#VALX; NAV:#VALY3; Cumulative Units:#VALY5; Current Value:#VALY (Click to see details)";
                                    chartPortfolioValuation.Series[currentFundName].PostBackValue = currentFundName + ",#VALX,#VALY,#VALY1,#VALY2,#VALY3,#VALY4,#VALY5,#VALY6";
                                }

                                tempQty  = 0;
                                tempCost = 0.00;
                                (chartPortfolioValuation.Series[currentFundName]).Points.Clear();
                                foreach (DataRow itemRow in scriptRows)
                                {
                                    (chartPortfolioValuation.Series[currentFundName]).Points.AddXY(itemRow["DATE"], itemRow["CurrentValue"]);

                                    if ((itemRow["CumulativeUnits"] != System.DBNull.Value) && ((tempQty == 0) || (tempQty != System.Convert.ToDouble(itemRow["CumulativeUnits"]))))
                                    {
                                        tempQty = System.Convert.ToDouble(itemRow["CumulativeUnits"]);
                                        (chartPortfolioValuation.Series[currentFundName]).Points[(chartPortfolioValuation.Series[currentFundName]).Points.Count - 1].MarkerSize  = 10;
                                        (chartPortfolioValuation.Series[currentFundName]).Points[(chartPortfolioValuation.Series[currentFundName]).Points.Count - 1].MarkerStyle = System.Web.UI.DataVisualization.Charting.MarkerStyle.Diamond;
                                        //(chartPortfolioValuation.Series[currentFundName]).Points[(chartPortfolioValuation.Series[currentFundName]).Points.Count - 1].Label = itemRow["CumulativeUnits"].ToString();
                                    }
                                    (chartPortfolioValuation.Series[currentFundName]).Points[(chartPortfolioValuation.Series[currentFundName]).Points.Count - 1].PostBackValue =
                                        itemRow["SCHEME_NAME"] + "," + itemRow["DATE"] + "," + itemRow["NET_ASSET_VALUE"] +
                                        itemRow["CurrentValue"] + "," + itemRow["CumulativeUnits"] + "," + itemRow["CumulativeCost"];
                                }
                                (chartPortfolioValuation.Series[currentFundName]).Points[(chartPortfolioValuation.Series[currentFundName]).Points.Count - 1].MarkerSize  = 10;
                                (chartPortfolioValuation.Series[currentFundName]).Points[(chartPortfolioValuation.Series[currentFundName]).Points.Count - 1].MarkerStyle = System.Web.UI.DataVisualization.Charting.MarkerStyle.Diamond;
                            }
                        }

                        if (indexTable != null)
                        {
                            if (chartPortfolioValuation.Series.FindByName(ddlIndex.SelectedValue) == null)
                            {
                                chartPortfolioValuation.Series.Add(ddlIndex.SelectedValue);

                                chartPortfolioValuation.Series[ddlIndex.SelectedValue].Name        = ddlIndex.SelectedValue;
                                (chartPortfolioValuation.Series[ddlIndex.SelectedValue]).ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Line;
                                (chartPortfolioValuation.Series[ddlIndex.SelectedValue]).ChartArea = chartPortfolioValuation.ChartAreas[0].Name;

                                chartPortfolioValuation.Series[ddlIndex.SelectedValue].Legend        = chartPortfolioValuation.Legends[0].Name;
                                chartPortfolioValuation.Series[ddlIndex.SelectedValue].LegendText    = ddlIndex.SelectedValue;
                                chartPortfolioValuation.Series[ddlIndex.SelectedValue].LegendToolTip = ddlIndex.SelectedValue;

                                (chartPortfolioValuation.Series[ddlIndex.SelectedValue]).YValuesPerPoint = 4;
                                chartPortfolioValuation.Series[ddlIndex.SelectedValue].ToolTip           = ddlIndex.SelectedValue + ": Date:#VALX; Close:#VALY4 (Click to see details)";
                                chartPortfolioValuation.Series[ddlIndex.SelectedValue].PostBackValue     = ddlIndex.SelectedValue + ",#VALX,#VALY1,#VALY2,#VALY3,#VALY4";
                            }
                            (chartPortfolioValuation.Series[ddlIndex.SelectedValue]).Points.DataBindXY(indexTable.Rows, "Date", indexTable.Rows, "Open,High,Low,Close");
                        }

                        for (int i = 1; i < ddlIndex.Items.Count; i++)
                        {
                            Series tempSeries = chartPortfolioValuation.Series.FindByName(ddlIndex.Items[i].Value);
                            if (tempSeries != null)
                            {
                                if (ddlIndex.SelectedValue != ddlIndex.Items[i].Value)
                                {
                                    chartPortfolioValuation.Series.Remove(tempSeries);
                                }
                            }
                        }

                        foreach (ListItem item in listboxScripts.Items)
                        {
                            if (item.Value.Equals("All") && item.Selected)
                            {
                                foreach (Series itemSeries in chartPortfolioValuation.Series)
                                {
                                    itemSeries.Enabled = true;
                                }
                                break;
                            }
                            else if (!item.Value.Equals("All") && (item.Selected))
                            {
                                chartPortfolioValuation.Series[item.Value].Enabled = true;
                            }
                            else if (!item.Value.Equals("All") && (!item.Selected))
                            {
                                chartPortfolioValuation.Series[item.Value].Enabled = false;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //Response.Write("<script language=javascript>alert('Exception while generating graph: " + ex.Message + "')</script>");
                Page.ClientScript.RegisterStartupScript(GetType(), "myScript", "alert('Exception while generating graph:" + ex.Message + "');", true);
            }
        }