public void BindProductSalesChart(int year)
    {
        using (CartDataClassesDataContext context = new CartDataClassesDataContext())
        {
            var productSales = from o in context.Orders
                               where o.DatePlaced.Value.Year == year
                               group o by o.DatePlaced.Value.Month into g
                               orderby g.Key
                               select new
                               {
                                   Month = g,
                                   TopProducts = (from op in context.OrderProducts
                                                  where op.OrderDate.Value.Year == year && op.OrderDate.Value.Month == g.Key
                                                  group op by op.ProductID into opg
                                                  orderby opg.Count() descending
                                                  select new { ProductName = context.Products.Where(p => p.ProductID == opg.Key).Single().ProductName, ProductCount = opg.Count() }).Take(5)
                               };

            foreach (var sale in productSales)
            {
                Series series = new Series(Enum.Parse(typeof(Month), sale.Month.FirstOrDefault().DatePlaced.Value.Month.ToString()).ToString()) { ChartType = SeriesChartType.Bubble};
                foreach (var topProduct in sale.TopProducts){
                    DataPoint point = new DataPoint() { XValue = sale.Month.Key, YValues = new double[] { (double)topProduct.ProductCount }, Label = topProduct.ProductName };
                    series.Points.Add(point);

                }
                ProductSalesChart.Series.Add(series);
            }
        }
    }
Example #2
0
    protected void UploadButton_Click(object sender, EventArgs e)
    {
        if (!ProductFileUpload.HasFile)
        {
            return;
        }
        String fileName = ProductFileUpload.FileName;

        if (!AllowedFiles.Contains(Path.GetExtension(fileName)))
        {
            return;
        }

        fileName = Server.UrlDecode(fileName);
        String savePath = HttpRuntime.AppDomainAppPath + @"\ProductImages\";

        savePath += fileName;

        ProductFileUpload.SaveAs(savePath);
        //Add to database and get back the ID
        CartDataClassesDataContext context = new CartDataClassesDataContext();

        InvertedSoftware.ShoppingCart.DataLayer.Dynamic.Image image = new InvertedSoftware.ShoppingCart.DataLayer.Dynamic.Image();
        image.ImageName = Path.GetFileName(savePath);
        image.ImageURL  = fileName;
        image.ProductID = ProductID;
        image.SortOrder = 1;
        image.Active    = true;
        context.Images.InsertOnSubmit(image);
        context.SubmitChanges();


        //Create a thumbnail
        ImageProcessor processor = new ImageProcessor();

        processor.ProcessedImage = (Bitmap)System.Drawing.Image.FromFile(savePath);
        processor.resizeImage(75, 75).Save(HttpRuntime.AppDomainAppPath + @"\ProductImages\" + Path.GetFileNameWithoutExtension(savePath) + "_t" + Path.GetExtension(savePath));
        processor.ProcessedImage.Dispose();
        processor.ProcessedImage = null;

        InvertedSoftware.ShoppingCart.DataLayer.Dynamic.Image thumnail = new InvertedSoftware.ShoppingCart.DataLayer.Dynamic.Image();
        thumnail.ParentID  = image.ImageID;
        thumnail.ImageName = Path.GetFileNameWithoutExtension(savePath) + "_t";
        thumnail.ImageURL  = Path.GetFileNameWithoutExtension(savePath) + "_t" + Path.GetExtension(savePath);
        thumnail.ProductID = ProductID;
        thumnail.SortOrder = 1;
        thumnail.Active    = true;
        context.Images.InsertOnSubmit(thumnail);
        context.SubmitChanges();


        MessageLabel.Text = "Your file was saved as " + fileName + " <a href=\"Products/List.aspx\">Go back to Product list</a>";
    }
    public void BindSalesChart(int year)
    {
        using (CartDataClassesDataContext context = new CartDataClassesDataContext())
        {
            var sales = from o in context.Orders
                        where o.DatePlaced.Value.Year == year
                        group o by o.DatePlaced.Value.Month into g
                        orderby g.Key
                        select new {Month = g, Orders = g.Count()};

            foreach (var sale in sales)
                SalesChart.Series["Series1"].Points.AddXY(Enum.Parse(typeof(Month), sale.Month.Key.ToString()).ToString(), (double)sale.Orders);
        }
    }
    public void BindLastSalesRepeater()
    {
        using (CartDataClassesDataContext context = new CartDataClassesDataContext())
        {
            var sales = from o in context.Orders.Take(10)
                        join os in context.OrderStatus
                        on o.OrderStatusID equals os.OrderStatusID
                        orderby o.OrderDate descending
                        select new { o.OrderID, o.OrderNumber, o.OrderDate, os.OrderStatusName };

            LastSalesRepeater.DataSource = sales;
            LastSalesRepeater.DataBind();
        }
    }
Example #5
0
    public void BindLastSalesRepeater()
    {
        using (CartDataClassesDataContext context = new CartDataClassesDataContext())
        {
            var sales = from o in context.Orders.Take(10)
                        join os in context.OrderStatus
                        on o.OrderStatusID equals os.OrderStatusID
                        orderby o.OrderDate descending
                        select new { o.OrderID, o.OrderNumber, o.OrderDate, os.OrderStatusName };

            LastSalesRepeater.DataSource = sales;
            LastSalesRepeater.DataBind();
        }
    }
Example #6
0
    public void BindSalesChart(int year)
    {
        using (CartDataClassesDataContext context = new CartDataClassesDataContext())
        {
            var sales = from o in context.Orders
                        where o.DatePlaced.Value.Year == year
                        group o by o.DatePlaced.Value.Month into g
                        orderby g.Key
                        select new { Month = g, Orders = g.Count() };

            foreach (var sale in sales)
            {
                SalesChart.Series["Series1"].Points.AddXY(Enum.Parse(typeof(Month), sale.Month.Key.ToString()).ToString(), (double)sale.Orders);
            }
        }
    }
Example #7
0
    protected void UploadButton_Click(object sender, EventArgs e)
    {
        if (!ProductFileUpload.HasFile)
            return;
        String fileName = ProductFileUpload.FileName;
        if (!AllowedFiles.Contains(Path.GetExtension(fileName)))
            return;

        fileName = Server.UrlDecode(fileName);
        String savePath = HttpRuntime.AppDomainAppPath + @"\ProductImages\";
        savePath += fileName;

        ProductFileUpload.SaveAs(savePath);
        //Add to database and get back the ID
        CartDataClassesDataContext context = new CartDataClassesDataContext();
        InvertedSoftware.ShoppingCart.DataLayer.Dynamic.Image image = new InvertedSoftware.ShoppingCart.DataLayer.Dynamic.Image();
        image.ImageName = Path.GetFileName(savePath);
        image.ImageURL = fileName;
        image.ProductID = ProductID;
        image.SortOrder = 1;
        image.Active = true;
        context.Images.InsertOnSubmit(image);
        context.SubmitChanges();

        //Create a thumbnail
        ImageProcessor processor = new ImageProcessor();
        processor.ProcessedImage = (Bitmap)System.Drawing.Image.FromFile(savePath);
        processor.resizeImage(75, 75).Save(HttpRuntime.AppDomainAppPath + @"\ProductImages\" + Path.GetFileNameWithoutExtension(savePath) + "_t" + Path.GetExtension(savePath));
        processor.ProcessedImage.Dispose();
        processor.ProcessedImage = null;

        InvertedSoftware.ShoppingCart.DataLayer.Dynamic.Image thumnail = new InvertedSoftware.ShoppingCart.DataLayer.Dynamic.Image();
        thumnail.ParentID = image.ImageID;
        thumnail.ImageName = Path.GetFileNameWithoutExtension(savePath) + "_t";
        thumnail.ImageURL = Path.GetFileNameWithoutExtension(savePath) + "_t" + Path.GetExtension(savePath);
        thumnail.ProductID = ProductID;
        thumnail.SortOrder = 1;
        thumnail.Active = true;
        context.Images.InsertOnSubmit(thumnail);
        context.SubmitChanges();

        MessageLabel.Text = "Your file was saved as " + fileName + " <a href=\"Products/List.aspx\">Go back to Product list</a>";
    }
Example #8
0
    public void BindProductSalesChart(int year)
    {
        using (CartDataClassesDataContext context = new CartDataClassesDataContext())
        {
            var productSales = from o in context.Orders
                               where o.DatePlaced.Value.Year == year
                               group o by o.DatePlaced.Value.Month into g
                               orderby g.Key
                               select new
            {
                Month       = g,
                TopProducts = (from op in context.OrderProducts
                               where op.OrderDate.Value.Year == year && op.OrderDate.Value.Month == g.Key
                               group op by op.ProductID into opg
                               orderby opg.Count() descending
                               select new { ProductName = context.Products.Where(p => p.ProductID == opg.Key).Single().ProductName, ProductCount = opg.Count() }).Take(5)
            };


            foreach (var sale in productSales)
            {
                Series series = new Series(Enum.Parse(typeof(Month), sale.Month.FirstOrDefault().DatePlaced.Value.Month.ToString()).ToString())
                {
                    ChartType = SeriesChartType.Bubble
                };
                foreach (var topProduct in sale.TopProducts)
                {
                    DataPoint point = new DataPoint()
                    {
                        XValue = sale.Month.Key, YValues = new double[] { (double)topProduct.ProductCount }, Label = topProduct.ProductName
                    };
                    series.Points.Add(point);
                }
                ProductSalesChart.Series.Add(series);
            }
        }
    }