protected void Page_Load(object sender, EventArgs e)
        {
            string VinID = Request.QueryString["VinID"].ToString();

            string ProcessDate = String.Empty;
            DateTime dtProcessDate = DateTime.Today;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["ProcessDate"]))
            {
                ProcessDate = Request.QueryString["ProcessDate"].ToString();
                dtProcessDate = DateTime.Parse(ProcessDate);
            }

            string ReportType = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["ReportType"]))
            {
                ReportType = Request.QueryString["ReportType"].ToString();
            }

            string WeekNumber = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["WeekNumber"]))
            {
                WeekNumber = Request.QueryString["WeekNumber"].ToString();
            }

            string YearNumber = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["YearNumber"]))
            {
                YearNumber = Request.QueryString["YearNumber"].ToString();
            }

            string ReportPeriod = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["ReportPeriod"]))
            {
                ReportPeriod = Request.QueryString["ReportPeriod"].ToString();
            }

            int intWeekNumber = 0;
            int intYearNumber = 0;

            string DtRangeWeekly = String.Empty;
            if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
            {
                bool IsWeekNumeric = int.TryParse(WeekNumber, out intWeekNumber);
                if (IsWeekNumeric)
                {
                    intWeekNumber = int.Parse(WeekNumber);
                }

                bool IsYearNumeric = int.TryParse(YearNumber, out intYearNumber);
                if (IsYearNumeric)
                {
                    intYearNumber = int.Parse(YearNumber);
                }

                GetChartData gd = new GetChartData();
                DataTable DtRange = gd.GetDateRangeFromWeekNumber(intWeekNumber, intYearNumber);

                DtRangeWeekly = Convert.ToDateTime(DtRange.Rows[0]["StartDate"]).ToString("d") + " - " + Convert.ToDateTime(DtRange.Rows[0]["EndDate"]).ToString("d");
            }

            if (ReportPeriod == "Weekly")
            {
                lblHead.InnerText = "Weekly Vehicle Report";
            }
            else     if (ReportPeriod == "NREL")
            {
                lblHead.InnerText = "NREL Weekly Vehicle Report";
            }

            else
            {
                lblHead.InnerText = "Daily Vehicle Report";
            }

            //VinID = "221";
            //  ReportType = "GenVehicleData_VinSpeed";
            //ReportType = "GenVehicleData_CurrentVoltage";
            //ProcessDate = "04/13/2015";

            Vehicles Vehicle = new Vehicles();

            if (VinID != "")
            {
                int intVinID;
                bool IsVinNumeric = int.TryParse(VinID, out intVinID);

                if (IsVinNumeric)
                {
                    intVinID = int.Parse(VinID);

                    GetChartData gcd = new GetChartData();
                    Vehicle = gcd.GetVinInfo(intVinID);
                    GetChartData gd = new GetChartData();
                    ReportType = "OperationalData";

                    DataTable dataTable_OperationalData = new DataTable();

                    if (intWeekNumber > 0)
                    {
                         dataTable_OperationalData = gd.GetDashBoardData(intVinID, intWeekNumber,intYearNumber, ReportType);
                    }
                    else
                    {
                        dataTable_OperationalData = gd.GetDashBoardData(intVinID, dtProcessDate, ReportType);
                    }

                    ReportType = "HVACOperationMode";

                    DataTable dataTable_HVACOperationMode = new DataTable();
                    if (intWeekNumber > 0)
                    {
                         dataTable_HVACOperationMode = gd.GetDashBoardData(intVinID, intWeekNumber, intYearNumber, ReportType);
                    }
                    else
                    {
                         dataTable_HVACOperationMode = gd.GetDashBoardData(intVinID, dtProcessDate, ReportType);
                    }

                    ReportType = "AuxLoadsOnTime";
                    DataTable dataTable_AuxLoadsOnTime = new DataTable();
                    if (intWeekNumber > 0)
                    {
                         dataTable_AuxLoadsOnTime = gd.GetDashBoardData(intVinID, intWeekNumber, intYearNumber, ReportType);
                    }
                    else
                    {
                         dataTable_AuxLoadsOnTime = gd.GetDashBoardData(intVinID, dtProcessDate, ReportType);
                    }

                    ReportType = "PowerTrainData";
                    DataTable dataTable_PowerTrainData = new DataTable();
                    if (intWeekNumber > 0)
                    {
                         dataTable_PowerTrainData = gd.GetDashBoardData(intVinID, intWeekNumber, intYearNumber, ReportType);
                    }
                    else
                    {
                         dataTable_PowerTrainData = gd.GetDashBoardData(intVinID, dtProcessDate, ReportType);
                    }

                        ReportType = "DailyChargingData";
                        DataTable dataTable_DailyChargingData = new DataTable();
                        if (intWeekNumber > 0)
                        {
                            dataTable_DailyChargingData = gd.GetDashBoardDataTabular(intVinID, intWeekNumber, intYearNumber, ReportType);
                        }
                        else
                        {
                            // dataTable_OperationalData = gd.GetDashBoardDataTabular(intVinID, dtProcessDate, ReportType);
                        }

                            GV_DailyChargingData.Visible = true;
                            GV_DailyChargingData.DataSource = dataTable_DailyChargingData;
                            GV_DailyChargingData.DataBind();

                            ReportType = "DailyTempData";
                            DataTable dataTable_DailyTempData = new DataTable();
                            if (intWeekNumber > 0)
                            {
                                dataTable_DailyTempData = gd.GetDashBoardDataTabular(intVinID, intWeekNumber, intYearNumber, ReportType);
                            }
                            else
                            {
                                // dataTable_OperationalData = gd.GetDashBoardDataTabular(intVinID, dtProcessDate, ReportType);
                            }

                            GV_DailyTempData1.Visible = true;
                            GV_DailyTempData1.DataSource = dataTable_DailyTempData;
                           GV_DailyTempData1.DataBind();

                    GridView1.DataSource = dataTable_OperationalData;
                    GridView1.DataBind();

                    GridView3.DataSource = dataTable_HVACOperationMode;
                    GridView3.DataBind();

                    GridView4.DataSource = dataTable_AuxLoadsOnTime;
                    GridView4.DataBind();

                    GridView5.DataSource = dataTable_PowerTrainData;
                    GridView5.DataBind();

                    lblVin.InnerHtml = "<b>" + Vehicle.CustomerName + " - " + Vehicle.Vin;
                    if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                     lblDate.InnerHtml = "<b>" + DtRangeWeekly;
                    }
                    else
                    {
                    lblDate.InnerHtml = "<b>" + dtProcessDate.ToShortDateString();
                     }

                }
                else
                {
                    Response.Write(" Vehicle does not exists!");
                    Response.End();
                }

            }
            else
            {
                Response.Write(" Vehicle does not exists!");
                Response.End();
            }

            //switch (ReportType)
            //{

            //    case "TempData":
            //        ReportServices_DailyGrab_VinDashBoard_OperationalData(Vehicle, dtProcessDate);
            //        break;

            //    default:
            //        Response.Write(" Chart Type does not exists!");
            //        break;
            //}
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //string VinID = Request.QueryString["VinID"].ToString();
            //string ProcessDate = Request.QueryString["ProcessDate"].ToString();
            //string ReportPeriod = Request.QueryString["ReportPeriod"].ToString();

            //string ReportType = Request.QueryString["ReportType"].ToString();

            //string WeekNumber = Request.QueryString["WeekNumber"].ToString();
            //string YearNumber = Request.QueryString["YearNumber"].ToString();

            string VinID = Request.QueryString["VinID"].ToString();

            string ProcessDate = String.Empty;
            DateTime dtProcessDate = DateTime.Today;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["ProcessDate"]))
            {
                ProcessDate = Request.QueryString["ProcessDate"].ToString();
                dtProcessDate = DateTime.Parse(ProcessDate);
            }

            string ReportType = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["ReportType"]))
            {
                ReportType = Request.QueryString["ReportType"].ToString();
            }

            string WeekNumber = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["WeekNumber"]))
            {
                WeekNumber = Request.QueryString["WeekNumber"].ToString();
            }

            string YearNumber = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["YearNumber"]))
            {
                YearNumber = Request.QueryString["YearNumber"].ToString();
            }

            string ReportPeriod = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["ReportPeriod"]))
            {
                ReportPeriod = Request.QueryString["ReportPeriod"].ToString();
            }

            int intWeekNumber = 0;
            int intYearNumber = 0;

            string DtRangeWeekly = String.Empty;
            if (ReportPeriod == "Weekly")
            {
                bool IsWeekNumeric = int.TryParse(WeekNumber, out intWeekNumber);
                if (IsWeekNumeric)
                {
                    intWeekNumber = int.Parse(WeekNumber);
                }

                bool IsYearNumeric = int.TryParse(YearNumber, out intYearNumber);
                if (IsYearNumeric)
                {
                    intYearNumber = int.Parse(YearNumber);
                }

                GetChartData gd = new GetChartData();
                DataTable DtRange = gd.GetDateRangeFromWeekNumber(intWeekNumber, intYearNumber);

                DtRangeWeekly = Convert.ToDateTime(DtRange.Rows[0]["StartDate"]).ToString("d") + " - " + Convert.ToDateTime(DtRange.Rows[0]["EndDate"]).ToString("d");
            }

            Vehicles Vehicle = new Vehicles();

            if (VinID != "")
            {
                int intVinID;
                bool IsVinNumeric = int.TryParse(VinID, out intVinID);

                if (IsVinNumeric)
                {
                    intVinID = int.Parse(VinID);

                    GetChartData gcd = new GetChartData();
                    Vehicle = gcd.GetVinInfo(intVinID);
                    GetChartData gd = new GetChartData();

                    DataTable dataTable_TempData = new DataTable();

                    if (intWeekNumber > 0)
                    {
                        dataTable_TempData = gd.GetDashBoardDataTabular(intVinID, intWeekNumber, intYearNumber, ReportType);
                    }
                    else
                    {
                        dataTable_TempData = gd.GetDashBoardDataTabular(intVinID, dtProcessDate, ReportType);
                    }

                    if (ReportType == "DailyChargingData")
                    {
                        GV_DailyChargingData.Visible = true;
                        GV_DailyChargingData.DataSource = dataTable_TempData;
                        GV_DailyChargingData.DataBind();
                    }

                    if (ReportType == "DailyTempData")
                    {
                        GV_DailyTempData.Visible = true;
                        GV_DailyTempData.DataSource = dataTable_TempData;
                        GV_DailyTempData.DataBind();
                    }

                    if (ReportType == "DailyBatteryData")
                    {
                        GV_DailyBatteryData.Visible = true;
                        GV_DailyBatteryData.DataSource = dataTable_TempData;
                        GV_DailyBatteryData.DataBind();
                    }

                }
                else
                {
                    Response.Write(" Vehicle does not exists!");
                    Response.End();
                }

            }
            else
            {
                Response.Write(" Vehicle does not exists!");
                Response.End();
            }
        }
        private void ReportServices_DailyGrab_GenVehicleData_VinChgEnergyHist(Vehicles v, int WeekNumber, int YearNumber)
        {
            GetChartData gd = new GetChartData();

            DataTable DtRange = gd.GetDateRangeFromWeekNumber(WeekNumber, YearNumber);
            DataTable dataTable = gd.Dt_DailyGrab_GetVenChgEnergyHist(v.VinID, WeekNumber, YearNumber, Rounding);

            string mainTitle = string.Format("Chrg Energy kWh - {0} - {1}  ", Convert.ToDateTime(DtRange.Rows[0]["StartDate"]).ToString("d"), Convert.ToDateTime(DtRange.Rows[0]["EndDate"]).ToString("d"));

            string subTitle = string.Format("{0} - {1}", v.CustomerName, v.Vin);
               hcFrutas.Title = new Title(mainTitle);
               hcFrutas.SubTitle = new SubTitle(subTitle);

               hcFrutas.Theme = "grid";
               hcFrutas.Legend = new Legend { align = Align.right, layout = Layout.vertical, verticalAlign = VerticalAlign.top, x = -10, y = 70, borderWidth = 0 };
               hcFrutas.Appearance = new Appearance { renderTo = "container", animation = false };
               hcFrutas.YAxis.Add(new YAxisItem { title = new Title("Chrg Energy kWh") });

            //Get point collection
            var pointCollectionChgEnergy = new PointCollection();
            var pointCollectionCat = new PointCollection();
            //var pointCollectionSocMax = new PointCollection();
            //var pointCollectionSocDas = new PointCollection();

            List<string> buckets = new List<string>();

            // Add string using Add method

            foreach (DataRow row in dataTable.Rows)
            {
                pointCollectionChgEnergy.Add(new Point(Convert.ToDouble(row["Chg_Energy_kwh"])));
                buckets.Add(row["ProcessDate"].ToString());

            }

            //Add data to serie
              hcFrutas.XAxis.Add(new XAxisItem { type = AxisDataType.linear, tickColor = "#ccc", categories = buckets.ToArray(), tickLength = 1, title = new Title("Date") });

               var series = new Collection<Serie> { new Serie { name = "Chrg Energy kWh", data = pointCollectionChgEnergy.ToArray(), type = RenderType.column, showInLegend = false } };

            //hcVendas.PlotOptions = new PlotOptionsLine { marker = new Marker { enabled = true }, dataLabels = new DataLabels { enabled = true } };
               hcFrutas.PlotOptions = new PlotOptionsColumn { groupPadding = 0, pointPadding = 0, shadow = true, borderWidth = 2, borderColor = "#666", dataLabels = new DataLabels { enabled = true } };

            //Bind the control
               hcFrutas.DataSource = series;
               hcFrutas.DataBind();
        }
        private void ReportServices_DailyGrab_GenVehicleData_VinChargingHist(Vehicles v, int WeekNumber, int YearNumber)
        {
            GetChartData gd = new GetChartData();
            DataTable DtRange = gd.GetDateRangeFromWeekNumber(WeekNumber,YearNumber);
            DataTable dataTable = gd.Dt_DailyGrab_GetVenChargingHist(v.VinID, WeekNumber, YearNumber, Rounding);

            string mainTitle = string.Format("Vehicle Charging - {0} - {1}  ", Convert.ToDateTime(DtRange.Rows[0]["StartDate"]).ToString("d"), Convert.ToDateTime(DtRange.Rows[0]["EndDate"]).ToString("d"));

            string subTitle = string.Format("{0} - {1}", v.CustomerName, v.Vin);
               hcFrutas.Title = new Title(mainTitle);
               hcFrutas.SubTitle = new SubTitle(subTitle);

               hcFrutas.Theme = "grid";
               hcFrutas.Legend = new Legend { align = Align.right, layout = Layout.vertical, verticalAlign = VerticalAlign.top, x = -10, y = 70, borderWidth = 0 };
               hcFrutas.Appearance = new Appearance { renderTo = "container", animation = false };
               hcFrutas.YAxis.Add(new YAxisItem { title = new Title("Occurence") });

            //Get point collection
            var pointCollectionBrakePedal = new PointCollection();
            var pointCollectionCat = new PointCollection();
            //var pointCollectionSocMax = new PointCollection();
            //var pointCollectionSocDas = new PointCollection();

            List<string> buckets = new List<string>();

            // Add string using Add method

            foreach (DataRow row in dataTable.Rows)
            {
                pointCollectionBrakePedal.Add(new Point(Convert.ToDouble(row["TimeInMins"])));
                buckets.Add(row["BucketEnd"].ToString());
                //pointCollectionSocMax.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCes_usi_SoCmax_pct"])));
                //pointCollectionSocDas.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCbo_usi_DashSOC_pct"])));
                // pointCollection.Add(new Point(DateTime.Parse(row["Time_Occur"].ToString()), Convert.ToDouble(row["SocMin"])));
            }

            //Add data to serie
            //hcVendas.XAxis.Add(new XAxisItem { title = new Title("Time Buckets"), categories = pointCollectionCat.ToArray()  });
            //hcFrutas.XAxis.Add(new XAxisItem { type = AxisDataType.linear, categories = buckets.ToArray(), tickColor = "#ccc", tickLength = 50, labels = (new Labels() { rotation = -90, step = 1, y = 30 }) });
               hcFrutas.XAxis.Add(new XAxisItem { type = AxisDataType.linear, tickColor = "#ccc", categories = buckets.ToArray(), tickLength = 1, title = new Title("Charinging Time in Min") });

            var series = new Collection<Serie> { new Serie { name = "Counts", data = pointCollectionBrakePedal.ToArray(), type = RenderType.column, showInLegend = false } };

            //hcVendas.PlotOptions = new PlotOptionsLine { marker = new Marker { enabled = true }, dataLabels = new DataLabels { enabled = true } };
               hcFrutas.PlotOptions = new PlotOptionsColumn { groupPadding = 0, pointPadding = 0, shadow = true, borderWidth = 2, borderColor = "#666", dataLabels = new DataLabels { enabled = true } };

            //Bind the control
               hcFrutas.DataSource = series;
               hcFrutas.DataBind();
        }
        private void ReportServices_DailyGrab_GenChargerData_ChargerHist(Chargers v, int WeekNumber, int YearNumber)
        {
            GetChartData gd = new GetChartData();

            DataTable DtRange = gd.GetDateRangeFromWeekNumber(WeekNumber, YearNumber);
            DataTable dataTable = gd.Dt_DailyGrab_GetChargerStatusHist(v.ChargingStationID, WeekNumber, YearNumber, Rounding);

            string mainTitle = string.Format("Chrg Status - {0} - {1}  ", Convert.ToDateTime(DtRange.Rows[0]["StartDate"]).ToString("d"), Convert.ToDateTime(DtRange.Rows[0]["EndDate"]).ToString("d"));

            string subTitle = string.Format("{0} - {1}", v.CustomerName, v.ChargingStationID);
               hcFrutas.Title = new Title(mainTitle);
               hcFrutas.SubTitle = new SubTitle(subTitle);
               hcFrutas.Width = 800;
               hcFrutas.Theme = "grid";
               hcFrutas.Legend = new Legend { align = Align.right, layout = Layout.vertical, verticalAlign = VerticalAlign.top, x = -10, y = 70, borderWidth = 0 };
               hcFrutas.Appearance = new Appearance { renderTo = "container", animation = false };
               hcFrutas.YAxis.Add(new YAxisItem { title = new Title("Chrg Status") });

            //Get point collection
            var pointCollectionChgStatusCnt = new PointCollection();

            var pointCollectionChg_TotalDocking = new PointCollection();
            var pointCollectionChg_Complete = new PointCollection();
            var pointCollectionChg_Fail = new PointCollection();
            var pointCollectionChg_OpErrors = new PointCollection();
            var pointCollectionChg_OpAborts = new PointCollection();

            var pointCollectionCat = new PointCollection();
            //var pointCollectionSocMax = new PointCollection();
            //var pointCollectionSocDas = new PointCollection();

            List<string> buckets = new List<string>();
            List<string> status = new List<string>();

            // Add string using Add method

            foreach (DataRow row in dataTable.Rows)
            {
                pointCollectionChg_TotalDocking.Add(new Point(Convert.ToDouble(row["TotalDocking"])));
                pointCollectionChg_Complete.Add(new Point(row["Complete"]));
                pointCollectionChg_Fail.Add(new Point(row["Fail"]));
                pointCollectionChg_OpErrors.Add(new Point(row["OpErrors"]));
                pointCollectionChg_OpAborts.Add(new Point(row["OpAborts"]));

                buckets.Add(row["DateLabel"].ToString());
                //status.Add(row["col"].ToString());

            }

            //Add data to serie
               hcFrutas.XAxis.Add(new XAxisItem { type = AxisDataType.linear, tickColor = "#ccc", categories = buckets.ToArray(), tickLength = 1, title = new Title("Date") });

               var series = new Collection<Serie> { new Serie { name = "TotalDocking",  data = pointCollectionChg_TotalDocking.ToArray(), type = RenderType.column, showInLegend = true } ,
                                                new Serie { name = "Complete",      data = pointCollectionChg_Complete.ToArray(), type = RenderType.column, showInLegend = true } ,
                                                new Serie { name = "Fail",          data = pointCollectionChg_Fail.ToArray(), type = RenderType.column, showInLegend = true } ,
                                                new Serie { name = "OpErrors",      data = pointCollectionChg_OpErrors.ToArray(), type = RenderType.column, showInLegend = true } ,
                                                new Serie { name = "OpAborts",      data = pointCollectionChg_OpAborts.ToArray(), type = RenderType.column, showInLegend = true }
               };

             //  var series = new Collection<Serie> { new Serie { name = "Charge Status", data = pointCollectionChgStatusCnt.ToArray(), type = RenderType.column, showInLegend = false }, new Serie { name = "Charge", data = pointCollectionCat.ToArray(), type = RenderType.column, showInLegend = false } };
               // var series = new Collection<Serie> { new Serie { name = "SocMin", data = pointCollectionSocMin.ToArray() }, new Serie { name = "SocMax", data = pointCollectionSocMax.ToArray() }, new Serie { name = "SocDash", data = pointCollectionSocDas.ToArray() } };

            //hcVendas.PlotOptions = new PlotOptionsLine { marker = new Marker { enabled = true }, dataLabels = new DataLabels { enabled = true } };
               hcFrutas.PlotOptions = new PlotOptionsColumn
               {
               groupPadding = 0,
               pointPadding = 0,
               shadow = true,
               borderWidth = 2,
               borderColor = "#666",
            //   dataLabels = new DataLabels { enabled = true ,formatter="function() { if(this.y != 0) { return this.y;}}"}
               dataLabels = new DataLabels { enabled = true }

               };

            //Bind the control
               hcFrutas.DataSource = series;
               hcFrutas.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string VinID =string.Empty;

            if (!String.IsNullOrEmpty(Request.QueryString["VinID"]))
            {
                VinID = Request.QueryString["VinID"].ToString();

            }

            string ChargingStationID = string.Empty;

            if (!String.IsNullOrEmpty(Request.QueryString["ChargingStationID"]))
            {
                ChargingStationID = Request.QueryString["ChargingStationID"].ToString();

            }

            string ProcessDate = String.Empty;
            DateTime dtProcessDate = DateTime.Today;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["ProcessDate"]))
            {
                ProcessDate = Request.QueryString["ProcessDate"].ToString();
                dtProcessDate = DateTime.Parse(ProcessDate);
            }

            string ReportType = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["ReportType"]))
            {
                ReportType = Request.QueryString["ReportType"].ToString();
            }

            string WeekNumber = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["WeekNumber"]))
            {
                WeekNumber = Request.QueryString["WeekNumber"].ToString();
            }

            string YearNumber = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["YearNumber"]))
            {
                YearNumber = Request.QueryString["YearNumber"].ToString();
            }

            string ReportPeriod = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["ReportPeriod"]))
            {
                ReportPeriod = Request.QueryString["ReportPeriod"].ToString();
            }

            int intWeekNumber = 0;
            int intYearNumber = 0;

            string DtRangeWeekly = String.Empty;
            if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
            {
                bool IsWeekNumeric = int.TryParse(WeekNumber, out intWeekNumber);
                if (IsWeekNumeric)
                {
                    intWeekNumber = int.Parse(WeekNumber);
                }

                bool IsYearNumeric = int.TryParse(YearNumber, out intYearNumber);
                if (IsYearNumeric)
                {
                    intYearNumber = int.Parse(YearNumber);
                }

                GetChartData gd = new GetChartData();
                DataTable DtRange = gd.GetDateRangeFromWeekNumber(intWeekNumber, intYearNumber);

                DtRangeWeekly = Convert.ToDateTime(DtRange.Rows[0]["StartDate"]).ToString("d") + " - " + Convert.ToDateTime(DtRange.Rows[0]["EndDate"]).ToString("d");
            }

            //string ReportType = Request.QueryString["ReportType"].ToString();
            //string ReportPeriod = Request.QueryString["ReportPeriod"].ToString();
            //string WeekNumber = Request.QueryString["WeekNumber"].ToString();
            //string YearNumber = Request.QueryString["YearNumber"].ToString();

            //VinID = "221";
            //  ReportType = "GenVehicleData_VinSpeed";
            //ReportType = "GenVehicleData_CurrentVoltage";
            //ProcessDate = "04/13/2015";
            //DateTime dtProcessDate = DateTime.Parse(ProcessDate);

            Vehicles Vehicle = new Vehicles();

            if (VinID != "")
            {
                int intVinID;
                bool IsVinNumeric = int.TryParse(VinID, out intVinID);

                if (IsVinNumeric)
                {
                    intVinID = int.Parse(VinID);

                    GetChartData gcd = new GetChartData();
                    Vehicle = gcd.GetVinInfo(intVinID);

                }
                else
                {
                    Response.Write(" Vehicle does not exists!");
                    Response.End();
                }

            }
            //else
            //{
            //    Response.Write(" Vehicle does not exists!");
            //    Response.End();
            //}

            Chargers Charger = new Chargers();
            int intChargingStationID = 0;

            if (ChargingStationID != "")
            {

                bool IsChargerNumeric = int.TryParse(ChargingStationID, out intChargingStationID);

                if (IsChargerNumeric)
                {
                    intChargingStationID = int.Parse(ChargingStationID);

                    GetChartData gcd = new GetChartData();
                    Charger = gcd.GetChargerInfo(intChargingStationID);

                }
                else
                {
                    Response.Write(" Charger does not exists!");
                    Response.End();
                }

            }
            //else
            //{
            //    Response.Write(" Charger does not exists!");
            //    Response.End();
            //}

            switch (ReportType)
            {

                case "GenVehicleData_VinSpeedHist":
                    if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinSpeedHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinSpeedHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinEfficiencyHist":
                     if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinEfficiencyHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinEfficiencyHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinAccelPedalHist":
                     if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinAccelPedalHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinAccelPedalHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinBrakePedalHist":
                    if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinBrakePedalHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinBrakePedalHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinChargingHist":
                    if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinChargingHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinChargingHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinVoltageHist":
                    if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinVoltageHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinVoltageHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinSocMinHist":
                     if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinSocMinHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinSocMinHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinBatteryTempMaxHist":
                    if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinBatteryTempMaxHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinBatteryTempMaxHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinPECoolantTempHist":
                     if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinPECoolantTempHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinPECoolantTempHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinDCDCConverterPowerHist":
                     if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinDCDCConverterPowerHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinDCDCConverterPowerHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinTractionMotorRotorTempHist":
                    if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinTractionMotorRotorTempHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinTractionMotorRotorTempHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinStatorTempHist":
                     if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinStatorTempHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinStatorTempHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinTractionMotorInverterTempHist":
                     if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinTractionMotorInverterTempHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinTractionMotorInverterTempHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinTractionMotorIGBTTempHist":
                    if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinTractionMotorIGBTTempHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinTractionMotorIGBTTempHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinRadiatorFanSpeedHist":
                    if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinRadiatorFanSpeedHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinRadiatorFanSpeedHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinBatteryCoolantPumpHist":
                    if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinBatteryCoolantPumpHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinBatteryCoolantPumpHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinMinAirPressureHist":
                     if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinMinAirPressureHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinMinAirPressureHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinTransTempHist":
                     if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinTransTempHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinTransTempHist(Vehicle, dtProcessDate);
                    }

                    break;

                case "GenVehicleData_VinChgEnergyHist":
                    if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
                    {
                        ReportServices_DailyGrab_GenVehicleData_VinChgEnergyHist(Vehicle, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        //do nothing
                    }

                    break;

                    case "GenVehicleData_ChargerStatusHist":
                    if (ReportPeriod == "Weekly")
                    {
                        ReportServices_DailyGrab_GenChargerData_ChargerHist(Charger, intWeekNumber, intYearNumber);
                    }
                    else
                    {
                        //do nothing
                    }

                    break;

                default:
                    Response.Write(" Chart Type does not exists!");
                    break;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string VinID = Request.QueryString["VinID"].ToString();

            string ProcessDate = String.Empty;
            DateTime dtProcessDate = DateTime.Today;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["ProcessDate"]))
            {
                ProcessDate = Request.QueryString["ProcessDate"].ToString();
                dtProcessDate = DateTime.Parse(ProcessDate);
            }

            string ReportType = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["ReportType"]))
            {
                ReportType = Request.QueryString["ReportType"].ToString();
            }

            string WeekNumber = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["WeekNumber"]))
            {
                WeekNumber = Request.QueryString["WeekNumber"].ToString();
            }

            string YearNumber = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["YearNumber"]))
            {
                YearNumber = Request.QueryString["YearNumber"].ToString();
            }

            string ReportPeriod = String.Empty;
            if (!string.IsNullOrWhiteSpace(Request.QueryString["ReportPeriod"]))
            {
                ReportPeriod = Request.QueryString["ReportPeriod"].ToString();
            }

            int intWeekNumber = 0;
            int intYearNumber = 0;

            string DtRangeWeekly = String.Empty;
            if (ReportPeriod == "Weekly" || ReportPeriod == "NREL")
            {
                bool IsWeekNumeric = int.TryParse(WeekNumber, out intWeekNumber);
                if (IsWeekNumeric)
                {
                    intWeekNumber = int.Parse(WeekNumber);
                }

                bool IsYearNumeric = int.TryParse(YearNumber, out intYearNumber);
                if (IsYearNumeric)
                {
                    intYearNumber = int.Parse(YearNumber);
                }

                GetChartData gd = new GetChartData();
                DataTable DtRange = gd.GetDateRangeFromWeekNumber(intWeekNumber, intYearNumber);

                DtRangeWeekly = Convert.ToDateTime(DtRange.Rows[0]["StartDate"]).ToString("d") + " - " + Convert.ToDateTime(DtRange.Rows[0]["EndDate"]).ToString("d");
            }

            if (ReportPeriod == "Weekly")
            {
                lblHead.InnerHtml = "<br/><br/><b>Weekly Vehicle Report";
            }
            else if (ReportPeriod == "NREL")
            {
                lblHead.InnerHtml = "<br/><br/><b>NREL Weekly Vehicle Report";
            }

            else if (ReportPeriod == "DailyBattery")
            {
                lblHead.InnerHtml = "<br/><br/><b>Daily Battery Report";
            }

            else if (ReportPeriod == "DailyBatteryAllCust")
            {
                lblHead.InnerHtml = "<br/><br/><b>Daily Battery Status Report";
            }

            else
            {
                lblHead.InnerHtml = "<br/><br/><b>Daily Vehicle Report";
            }

             Vehicles Vehicle = new Vehicles();

            if (VinID != "")
            {
                int intVinID;
                bool IsVinNumeric = int.TryParse(VinID, out intVinID);

                if (IsVinNumeric)
                {
                    intVinID = int.Parse(VinID);

                    GetChartData gcd = new GetChartData();
                    Vehicle = gcd.GetVinInfo(intVinID);

                    lblVin.InnerHtml = "<br/><br/><b>" + Vehicle.CustomerName + "  -  " + Vehicle.Vin;
                    if (ReportPeriod == "Weekly")
                    {
                     lblDate.InnerHtml = "<br/><br/><b>Report Dates: " + DtRangeWeekly;
                    }
                    else if (ReportPeriod == "NREL")
                    {
                        lblDate.InnerHtml = "<br/><br/><b>Report Dates: " + DtRangeWeekly;
                    }
                    else if (ReportPeriod == "DailyBattery")
                    {
                        lblDate.InnerHtml = "<br/><br/><b>Report Dates: " + dtProcessDate.ToShortDateString();
                    }
                    else if (ReportPeriod == "DailyBatteryAllCust")
                    {
                        lblDate.InnerHtml = "<br/><br/><b>Report Dates: " + dtProcessDate.ToShortDateString();
                        lblVin.Visible = false;
                        splashImg.Visible = false;
                    }

                    else
                    {
                        lblDate.InnerHtml = "<br/><br/><b>Report Date: " + dtProcessDate.ToShortDateString();
                    }

                }
                else
                {
                    lblVin.InnerHtml = "<br/><br/><b>" + " Vehicle does not exists!";
                    Response.End();
                }

            }
            else
            {
                lblVin.InnerHtml = "<b>" + " Vehicle does not exists!";
                Response.End();
            }

            //VinID = "221";
            //  ReportType = "GenVehicleData_VinSpeed";
            //ReportType = "GenVehicleData_CurrentVoltage";
            //ProcessDate = "04/13/2015";
        }