예제 #1
0
        private void dgvDetails_CellEnter(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex > -1)
            {
                string __almacen  = (sender as DataGridView).Columns[e.ColumnIndex].HeaderText.Substring(0, 2);
                string __articulo = (sender as DataGridView).Rows[e.RowIndex].Cells[0].Value.ToString();

                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();
                dgvVentas.DataSource = vts.GetVentas(command);

                //using (SqlConnection connection = new SqlConnection(ClasesSGUV.Propiedades.conectionSGUV))
                //{
                //    using (SqlCommand command = new SqlCommand("PJ_Compras", connection))
                //    {

                //        command.CommandType = CommandType.StoredProcedure;

                //        command.Parameters.AddWithValue("@TipoConsulta", 14);
                //        command.Parameters.AddWithValue("@Almacenes", __almacen);
                //        command.Parameters.AddWithValue("@Articulo", (sender as DataGridView).Rows[e.RowIndex].Cells[0].Value);

                //        SqlDataAdapter da = new SqlDataAdapter();
                //        da.SelectCommand = command;

                //        DataTable table = new DataTable();
                //        da.Fill(table);

                //        dgvVentas.DataSource = table;

                foreach (DataGridViewColumn item in dgvVentas.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;
                    }
                }
                //    }
                //}
            }
        }
예제 #2
0
        private void gridTransferencias_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                int row    = gridTransferencias.CurrentCell.RowIndex;
                int column = gridTransferencias.CurrentCell.ColumnIndex;

                gridVentasT.DataSource = null;
                if (row > -1)
                {
                    string _articulo = gridTransferencias.Rows[row].Cells[(int)Columnas.Articulo].Value.ToString();
                    string _almacen  = gridTransferencias.Columns[column].HeaderText.Trim().Substring(0, 2);

                    //CargarVentas(_articulo, _almacen, gridVentasT);

                    CargarDetalle(_articulo, _almacen, gridDetalleT);
                    FormatoDetalle(gridDetalleT);

                    //////////////
                    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();
                    gridVentasT.DataSource = vts.GetVentas(command);


                    foreach (DataGridViewColumn item in gridVentasT.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)
            {
            }
        }
예제 #3
0
        private void gridDetalle_CellEnter(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex > -1)
                {
                    string _articulo = (sender as DataGridView).Rows[e.RowIndex].Cells[(int)ColumnasDetalle.Articulo].Value.ToString();
                    string _almacen  = (sender as DataGridView).Columns[e.ColumnIndex].HeaderText.Substring(0, 2);

                    //this.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)
            {
            }
        }