private void button1_Click(object sender, EventArgs e) { gridTotal.DataSource = null; string almacen = cbAlmacen.Text.Substring(0, 2) == "00" ? string.Empty : cbAlmacen.Text.Substring(0, 2); string linea = cbLinea.SelectedValue.ToString() == "0" ? string.Empty : cbLinea.SelectedValue.ToString(); SqlCommand command = new SqlCommand("sp_HistorialVentas"); command.Parameters.AddWithValue("@TipoConsulta", 1); command.Parameters.AddWithValue("@Almacen", almacen); command.Parameters.AddWithValue("@Articulo", txtArticulo.Text); command.Parameters.AddWithValue("@Linea", linea); Clases.Ventas vts = new Clases.Ventas(); gridTotal.DataSource = vts.GetVentas(command); foreach (DataGridViewColumn item in gridTotal.Columns) { if (item.Index > 2) { item.Width = 60; item.DefaultCellStyle.Format = "N0"; item.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; } else { item.Width = 100; item.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; } } //SqlConnection c = new SqlConnection(ClasesSGUV.Propiedades.conectionSGUV); //SqlCommand command = new SqlCommand("PJ_TransferenciasP", c); //command.CommandType = CommandType.StoredProcedure; //command.Parameters.AddWithValue("@TipoConsulta", 4); //command.Parameters.AddWithValue("@Articulo", txtArticulo.Text); //command.Parameters.AddWithValue("@Linea", cbLinea.SelectedValue); //command.Parameters.AddWithValue("@AlmacenDestino", almacen); //command.Parameters.AddWithValue("@AlmacenOrigen", string.Empty); //command.Parameters.AddWithValue("@Proveedor", string.Empty); //command.Parameters.AddWithValue("@Importacion", string.Empty); //DataTable table = new DataTable(); //SqlDataAdapter adapter = new SqlDataAdapter(); //adapter.SelectCommand = command; //adapter.SelectCommand.CommandTimeout = 0; //adapter.Fill(table); //gridTotal.DataSource = table; }
private void gridDetalle_Click(object sender, EventArgs e) { try { int row = gridDetalle.CurrentCell.RowIndex; int column = gridDetalle.CurrentCell.ColumnIndex; gridVentas.DataSource = null; if (row >= 0 && column >= 1) { string _articulo = gridDetalle.Rows[row].Cells[0].Value.ToString(); string _almacen = gridDetalle.Columns[column].HeaderText.Trim().Substring(0, 2); //CargarVentas(_articulo, _almacen, gridVentas); SqlCommand command = new SqlCommand("sp_HistorialVentas"); command.Parameters.AddWithValue("@TipoConsulta", 1); command.Parameters.AddWithValue("@Almacen", _almacen); command.Parameters.AddWithValue("@Articulo", _articulo); Clases.Ventas vts = new Clases.Ventas(); gridVentas.DataSource = vts.GetVentas(command); foreach (DataGridViewColumn item in gridVentas.Columns) { if (item.Index > 1) { item.Width = 60; item.DefaultCellStyle.Format = "N0"; item.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; } else { item.Width = 75; item.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; } } } } catch (Exception) { } }