Пример #1
0
        public static void actualizarIngreso(DetalleIngreso detalle, int idIngreso)
        {
            string conn = ConfigurationManager.ConnectionStrings["TiendaConString"].ConnectionString;

            using (SqlConnection connection = new SqlConnection(conn))
            {
                SqlCommand actualizarDetalle = new SqlCommand("ActualizarIngreso", connection);
                actualizarDetalle.CommandType = CommandType.StoredProcedure;

                try
                {
                    connection.Open();

                    actualizarDetalle.Parameters.AddWithValue("idDetalle", detalle.IdDetalle);
                    actualizarDetalle.Parameters.AddWithValue("idProducto", detalle.IdProducto);
                    actualizarDetalle.Parameters.AddWithValue("cantidad", detalle.Cantidad);
                    actualizarDetalle.Parameters.AddWithValue("precioCompra", detalle.PrecioCompra);
                    actualizarDetalle.Parameters.AddWithValue("idIngreso", idIngreso);
                    actualizarDetalle.Parameters.AddWithValue("unidad", detalle.IdUnidad);


                    actualizarDetalle.ExecuteNonQuery();



                    SqlCommand comandStock = new SqlCommand("ActualizarStock", connection);

                    comandStock.CommandType = CommandType.StoredProcedure;
                    comandStock.Parameters.AddWithValue("idProducto", detalle.IdProducto);
                    comandStock.Parameters.AddWithValue("stock", detalle.Cantidad);

                    comandStock.ExecuteNonQuery();
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Пример #2
0
        public static void actualizarIngreso(DetalleIngreso detalle, int idIngreso)
        {
            string conn = ConfigurationManager.ConnectionStrings["TiendaConString"].ConnectionString;

            using (SqlConnection connection = new SqlConnection(conn))
            {
                SqlCommand actualizarDetalle = new SqlCommand("ActualizarIngreso", connection);
                actualizarDetalle.CommandType = CommandType.StoredProcedure;

                try
                {
                    connection.Open();

                    actualizarDetalle.Parameters.AddWithValue("idDetalle", detalle.IdDetalle);
                    actualizarDetalle.Parameters.AddWithValue("idProducto", detalle.IdProducto);
                    actualizarDetalle.Parameters.AddWithValue("cantidad", detalle.Cantidad);
                    actualizarDetalle.Parameters.AddWithValue("precioCompra", detalle.PrecioCompra);
                    actualizarDetalle.Parameters.AddWithValue("idIngreso", idIngreso);
                    actualizarDetalle.Parameters.AddWithValue("unidad", detalle.IdUnidad);

                    actualizarDetalle.ExecuteNonQuery();

                    SqlCommand comandStock = new SqlCommand("ActualizarStock", connection);

                    comandStock.CommandType = CommandType.StoredProcedure;
                    comandStock.Parameters.AddWithValue("idProducto", detalle.IdProducto);
                    comandStock.Parameters.AddWithValue("stock", detalle.Cantidad);

                    comandStock.ExecuteNonQuery();

                }
                catch (SqlException ex)
                {
                    throw ex;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Пример #3
0
 public static void ActualizarIngreso(DetalleIngreso ing, int idIngreso)
 {
     DAL.Ingreso.actualizarIngreso(ing, idIngreso);
 }
Пример #4
0
 public void setDetalle(DetalleIngreso det)
 {
     detalleIngreso.Add(det);
 }
Пример #5
0
        public static List <DetalleIngreso> BuscarIngreso(int idDetalle)
        {
            string connectionString = ConfigurationManager.ConnectionStrings["TiendaConString"].ConnectionString;

            // Proporcionar la cadena de consulta
            // string queryString = "Select IdPersona, Nombre,  ApPaterno from Persona where Nombre like '%{0}%' or ApPaterno like '%{1}%'";


            //Lista de Clientes recuperados
            List <DetalleIngreso> listaDetalle = new List <DetalleIngreso>();

            // Crear y abrir la conexión en un bloque using.
            // Esto asegura que todos los recursos serán cerrados
            // y dispuestos cuando el código sale

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                // Crear el objeto Command.
                SqlCommand command = new SqlCommand("infoDetalleIngreso", connection);
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("idDetalle", idDetalle);

                // Abre la conexión en un bloque try / catch
                // Crear y ejecutar el DataReader, escribiendo
                // el conjunto de resultados a la ventana de la consola.
                try
                {
                    connection.Open();
                    SqlDataReader reader = command.ExecuteReader();
                    while (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            DetalleIngreso det = new DetalleIngreso();
                            //Ingreso ing = new Ingreso();
                            det.IdDetalle    = reader.GetInt32(0);
                            det.IdIngreso    = reader.GetInt32(1);
                            det.Cantidad     = (float)reader.GetDouble(2);
                            det.PrecioCompra = reader.GetDecimal(3);
                            det.IdProducto   = reader.GetInt32(4);
                            det.IdUnidad     = reader.GetInt32(5);


                            listaDetalle.Add(det);
                        }

                        reader.NextResult();
                    }
                    reader.Close();
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

            return(listaDetalle);
        }
Пример #6
0
        public static List<DetalleIngreso> BuscarIngreso(int idDetalle)
        {
            string connectionString = ConfigurationManager.ConnectionStrings["TiendaConString"].ConnectionString;

            // Proporcionar la cadena de consulta
            // string queryString = "Select IdPersona, Nombre,  ApPaterno from Persona where Nombre like '%{0}%' or ApPaterno like '%{1}%'";

            //Lista de Clientes recuperados
            List<DetalleIngreso> listaDetalle = new List<DetalleIngreso>();

            // Crear y abrir la conexión en un bloque using.
            // Esto asegura que todos los recursos serán cerrados
            // y dispuestos cuando el código sale

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                // Crear el objeto Command.
                SqlCommand command = new SqlCommand("infoDetalleIngreso", connection);
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("idDetalle", idDetalle);

                // Abre la conexión en un bloque try / catch
                // Crear y ejecutar el DataReader, escribiendo
                // el conjunto de resultados a la ventana de la consola.
                try
                {
                    connection.Open();
                    SqlDataReader reader = command.ExecuteReader();
                    while (reader.HasRows)
                    {
                        while (reader.Read())
                        {

                            DetalleIngreso det = new DetalleIngreso();
                            //Ingreso ing = new Ingreso();
                            det.IdDetalle = reader.GetInt32(0);
                            det.IdIngreso = reader.GetInt32(1);
                            det.Cantidad = (float)reader.GetDouble(2);
                            det.PrecioCompra = reader.GetDecimal(3);
                            det.IdProducto = reader.GetInt32(4);
                            det.IdUnidad = reader.GetInt32(5);

                            listaDetalle.Add(det);

                        }

                        reader.NextResult();
                    }
                    reader.Close();

                }
                catch (SqlException ex)
                {
                    throw ex;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

            return listaDetalle;
        }
Пример #7
0
 public void setDetalle(DetalleIngreso det)
 {
     detalleIngreso.Add(det);
 }