Example #1
0
    private void Carrega()
    {
        VendaBD bd   = new VendaBD();
        DataSet ds   = bd.SelectAll();
        int     rows = ds.Tables[0].Rows.Count;

        if (rows > 0)
        {
            GridView1.DataSource = ds.Tables[0].DefaultView;
            GridView1.DataBind();
            GridView1.Visible = true;
        }

        DataTable dt = ds.Tables[0];

        GridView1.DataSource = ds.Tables[0].DefaultView;
        GridView1.DataBind();
        lblMensagem.Text  = "Venda(s) encontrada(s) : " + rows.ToString();
        GridView1.Visible = true;
        int acumula = 0;

        for (int l = 0; l < dt.Rows.Count; l++)
        {
            if (dt.Rows[l]["VEN_QUANTIDADE"].ToString() != "")
            {
                int total = Convert.ToInt32(dt.Rows[l]["VEN_QUANTIDADE"]);
                acumula += total;
            }
        }
        lblMensagem0.Text = "Quantidade de Produto(s) Vendido(s) : " + acumula.ToString();
    }
Example #2
0
        private void Carrega()
        {
            VendaBD bd = new VendaBD();
            DataSet ds = bd.SelectAll();

            GridView1.DataSource = ds.Tables[0].DefaultView;
            GridView1.DataBind();
        }
Example #3
0
    private void CarregaGrafico()
    {
        VendaBD bd = new VendaBD();
        DataSet ds = bd.SelectAll();

        string dados = "";

        //varre linhas do dataset
        dados = dados + "['Nome', 'Quantidade'],";
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            DataRow dr = ds.Tables[0].Rows[i];

            string nome       = Convert.ToString(dr["VEN_CLIENTE"] + " - ") + Convert.ToString(dr["VEN_PRODUTO"]);
            int    quantidade = Convert.ToInt32(dr["VEN_QUANTIDADE"]);

            dados = dados + "['" + nome + "', " + quantidade + "],";
        }

        string grafico = "";

        grafico = grafico + "<script type='text/javascript'>";
        grafico = grafico + "google.load('visualization', '1', {packages:['corechart']});";
        grafico = grafico + "function drawChart() {";
        grafico = grafico + "var data = google.visualization.arrayToDataTable([";
        grafico = grafico + dados;
        grafico = grafico + "]);";
        grafico = grafico + "var options = {";
        grafico = grafico + "title: '',";
        grafico = grafico + "is3D: true ";
        grafico = grafico + "};";
        grafico = grafico + "var chart = new google.visualization.PieChart(document.getElementById('chart_div'));";
        grafico = grafico + "chart.draw(data, options);";
        grafico = grafico + "}";
        grafico = grafico + "google.setOnLoadCallback(drawChart);";
        grafico = grafico + "</script>";

        Literal1.Text = grafico;
    }