Esempio n. 1
0
        public void buscarVenta()
        {
            apartados ap = new apartados();

            try
            {
                SqlCommand buscar_venta = new SqlCommand("busca_VentaDiaria", conexion);
                buscar_venta.CommandType = CommandType.StoredProcedure;

                buscar_venta.Parameters.AddWithValue("@fecha", Convert.ToDateTime(dateTimePicker1.Text));

                totalApartados.DataSource = ap.listaAnticipos(conexion, dateTimePicker1.Text);
                pagosDiarios.DataSource   = ap.listaPagosfecha(conexion, dateTimePicker1.Text);



                SqlCommand total = new SqlCommand("sumaTotal_Venta", conexion);
                total.CommandType = CommandType.StoredProcedure;
                total.Parameters.AddWithValue("@fecha", Convert.ToDateTime(dateTimePicker1.Text));

                SqlDataAdapter adaptador  = new SqlDataAdapter();
                SqlDataAdapter adap       = new SqlDataAdapter();
                DataTable      tabla      = new DataTable();
                DataTable      totalVenta = new DataTable();
                adaptador.SelectCommand = buscar_venta;
                adap.SelectCommand      = total;
                adaptador.Fill(tabla);
                adap.Fill(totalVenta);
                dataGridView1.DataSource = tabla;
                dataGridTotal.DataSource = totalVenta;

                foreach (DataGridViewRow item in dataGridTotal.Rows)
                {
                    totalDia = item.Cells[0].Value.ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conexion.Close();
            }
        }