Ejemplo n.º 1
0
        private void LoadUserFuelChart()
        {
            FuelBLL fuelBll = new FuelBLL();

            if (_userObj != null)
            {
                hcFrutas.Series.Clear();

                List<Fuel> fuelList = fuelBll.GetUserFuels(_userObj.UserId);

                if (fuelList != null)
                {
                    //Defining Axis

                    ArrayList Dates = new ArrayList();
                    ArrayList Gallons = new ArrayList();

                    foreach (var userFuel in fuelList)
                    {
                        Dates.Add(userFuel.FillDate.ToString("MMM"));
                        Gallons.Add(userFuel.AvgMilesPerGallon);
                    }

                    //Title configuration
                    hcFrutas.Title = new Title("Miles Per Gallon");
                    hcFrutas.SubTitle = new SubTitle("Fuel Data");

                    //Defining Axis
                    hcFrutas.YAxis.Add(new YAxisItem { title = new Title("Gallons"), min = 0, max = 100, tickInterval=10, allowDecimals = true });
                    hcFrutas.XAxis.Add(new XAxisItem { title = new Highchart.Core.Title("Fill Date"), categories = new object[]{ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"} });

                    //data
                    var series = new Collection<Serie>();
                   // series.Add(new Serie { name = DateTime.Now.ToShortDateString(), data = new object[] { 20 } });

                    //data
                    //var series = new Collection<Serie>();
                    foreach (var userFuel in fuelList)
                    {
                        ArrayList avgMilesPerGallon = new ArrayList();

                        for (int i = 1; i <= 12; i++)
                        {
                            if (i == userFuel.FillDate.Month)
                            {
                                avgMilesPerGallon.Add(userFuel.AvgMilesPerGallon);
                            }
                            else
                            {
                                avgMilesPerGallon.Add(0.0);
                            }
                        }
                        series.Add(new Serie { name = userFuel.FillDate.ToShortDateString(), data = avgMilesPerGallon.ToArray() });
                    }

                    //configuring Visual
                    hcFrutas.PlotOptions = new Highchart.Core.PlotOptions.PlotOptionsColumn { borderColor = "#dedede", borderRadius = 4 };

                    //bind
                    hcFrutas.DataSource = series;
                    hcFrutas.DataBind();

                }
            }
        }
Ejemplo n.º 2
0
 private void loadUserFuels()
 {
     FuelBLL fuelBll = new FuelBLL();
     List<Fuel> fuelList =  fuelBll.GetUserFuels(_userObj.UserId);
     if (fuelList != null)
     {
         foreach (var fuel in fuelList)
         {
             _fuel.Add(fuel.FuelId, fuel.Odometer);
         }
     }
 }
Ejemplo n.º 3
0
        private void BindUserFuelDetails()
        {
            FuelBLL fuelBll = new FuelBLL();

            if (_userObj != null)
            {
                List<Fuel> fuelList = fuelBll.GetUserFuels(_userObj.UserId);

                bool isHideFirstRow = false;

                if (fuelList != null)
                {
                    gvDetails.DataSource = fuelList;
                    gvDetails.DataBind();
                }
                else
                {
                    isHideFirstRow = true;
                    List<Fuel> fuels = new List<Fuel>();
                    fuels.Add(new Fuel());
                    gvDetails.DataSource = fuels;
                    gvDetails.DataBind();
                    gvDetails.ShowFooter = true;
                }

                if (isHideFirstRow)
                {
                    //Hide the first row if it's empty
                    gvDetails.Rows[0].Visible = false;
                }
            }
        }