示例#1
0
    void FillGridView()
    {
        if (sqlcon.State == ConnectionState.Closed)
        {
            sqlcon.Open();
        }
        string           sales_grid_query = "Select SalesProductName, SalesCompanyName, SalesQuantity from Sales";
        MySqlCommand     cmd2             = new MySqlCommand(sales_grid_query, sqlcon);
        MySqlDataAdapter sda = new MySqlDataAdapter(cmd2);
        DataTable        dt  = new DataTable();

        sda.Fill(dt);
        sqlcon.Close();
        SalesGrid.DataSource = dt;
        SalesGrid.DataBind();
    }
示例#2
0
    //protected void SaveSell()
    //{
    //    if (sqlcon.State == ConnectionState.Closed)
    //        sqlcon.Open();
    //    string insertquery = "insert into Sales (SalesProductName, SalesCompanyName, SalesQuantity) values ('"+TextBox2.Text+ "','"+TextBox2.Text+ "','"+txtQuantity2.Text+"')";
    //    SqlCommand cmd1 = new SqlCommand(insertquery, sqlcon);
    //    cmd1.ExecuteNonQuery();
    //    sqlcon.Close();
    //    //lblsuccessmassage.Text = "Saved Successfully";
    //   FillGridView();



    //}
    void FillGridView()
    {
        if (sqlcon.State == ConnectionState.Closed)
        {
            sqlcon.Open();
        }
        string         sales_grid_query = "Select * from Qutation";
        SqlCommand     cmd2             = new SqlCommand(sales_grid_query, sqlcon);
        SqlDataAdapter sda = new SqlDataAdapter(cmd2);
        DataTable      dt  = new DataTable();

        sda.Fill(dt);
        sqlcon.Close();
        SalesGrid.DataSource = dt;
        SalesGrid.DataBind();
    }
        private void initSalesChart()
        {
            string       cacheKey     = "0AD3A3DA-15F1-4f43-82A3-C0AC3262399D";
            CacheWrapper cacheWrapper = Cache[cacheKey] as CacheWrapper;
            Dictionary <string, object> salesData;

            if (cacheWrapper == null)
            {
                //GET SALES
                DateTime localNow   = LocaleHelper.LocalNow;
                DateTime last60Days = (new DateTime(localNow.Year, localNow.Month, localNow.Day, 0, 0, 0)).AddDays(-60);
                IList <ProductSummary> productSales = ReportDataSource.GetSalesByProduct(last60Days, DateTime.MaxValue, 8, 0, "TotalPrice DESC");
                if (productSales.Count > 0)
                {
                    SalesChart1.Series["Sales"].Points.Clear();
                    for (int i = 0; i < productSales.Count; i++)
                    {
                        int       roundedTotal = (int)Math.Round((double)productSales[i].TotalPrice, 0);
                        DataPoint point        = new DataPoint(SalesChart1.Series["Sales"]);
                        point.SetValueXY(productSales[i].Name, new object[] { roundedTotal });
                        SalesChart1.Series["Sales"].Points.Add(point);
                    }
                    SalesChart1.DataBind();

                    //BIND THE DATA GRID
                    SalesGrid.DataSource = productSales;
                    SalesGrid.DataBind();

                    //CACHE THE DATA
                    salesData = new Dictionary <string, object>();
                    salesData["DataSource"] = productSales;
                    cacheWrapper            = new CacheWrapper(salesData);
                    Cache.Remove(cacheKey);
                    Cache.Add(cacheKey, cacheWrapper, null, LocaleHelper.LocalNow.AddMinutes(5).AddSeconds(-1), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.High, null);
                }
                else
                {
                    //NO PRODUCTS HAVE BEEN SOLD YET
                    Control container = SalesChart1.Parent;
                    container.Controls.Clear();
                    Panel noViewsPanel = new Panel();
                    noViewsPanel.CssClass = "emptyData";
                    Label noViewsMessage = new Label();
                    noViewsMessage.Text = "No products have been sold yet.";
                    noViewsPanel.Controls.Add(noViewsMessage);
                    container.Controls.Add(noViewsPanel);

                    // REMOVE SALES DATA TAB
                    Tabs.Tabs[1].Visible = false;
                }
            }
            else
            {
                //USE CACHED VALUES
                salesData = (Dictionary <string, object>)cacheWrapper.CacheValue;
                IList <ProductSummary> productSales = (List <ProductSummary>)salesData["DataSource"];
                SalesChart1.Series["Sales"].Points.Clear();
                for (int i = 0; i < productSales.Count; i++)
                {
                    int       roundedTotal = (int)Math.Round((double)productSales[i].TotalPrice, 0);
                    DataPoint point        = new DataPoint(SalesChart1.Series["Sales"]);
                    point.SetValueXY(productSales[i].Name, new object[] { roundedTotal });
                    SalesChart1.Series["Sales"].Points.Add(point);
                }
                SalesChart1.DataBind();
                SalesGrid.DataSource = productSales;
                SalesGrid.DataBind();
            }
        }