コード例 #1
0
        public static Plato infPalto(int idPlato, float cantPlatos)
        {
            Plato plato = new Plato();

            string connectionString = ConfigurationManager.ConnectionStrings["TiendaConString"].ConnectionString;

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand("INF_PLATO", connection);
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("cantPlato", cantPlatos);
                command.Parameters.AddWithValue("idplato", idPlato);

                try
                {
                    connection.Open();
                    SqlDataReader reader = command.ExecuteReader();


                    while (reader.Read())
                    {
                        plato.Id     = reader.GetInt32(0);
                        plato.Nombre = reader[1].ToString();
                        plato.Costo  = reader.GetDecimal(2);

                        reader.NextResult();

                        while (reader.Read())
                        {
                            Ingrediente ingrediente = new Ingrediente();

                            ingrediente.IdProducto    = reader.GetInt32(0);
                            ingrediente.Cantidad      = (float)reader.GetDouble(1);
                            ingrediente.Unidad.Nombre = reader[2].ToString();

                            plato.setIngredientes(ingrediente);
                        }
                    }
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

            return(plato);
        }
コード例 #2
0
ファイル: Plato.cs プロジェクト: Chukaro/analisis
        public static Plato infPalto(int idPlato, float cantPlatos)
        {
            Plato plato = new Plato();

            string connectionString = ConfigurationManager.ConnectionStrings["TiendaConString"].ConnectionString;

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand("INF_PLATO", connection);
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("cantPlato", cantPlatos);
                command.Parameters.AddWithValue("idplato", idPlato);

                try
                {
                    connection.Open();
                    SqlDataReader reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        plato.Id = reader.GetInt32(0);
                        plato.Nombre = reader[1].ToString();
                        plato.Costo = reader.GetDecimal(2);

                        reader.NextResult();

                        while (reader.Read())
                        {
                            Ingrediente ingrediente = new Ingrediente();

                            ingrediente.IdProducto = reader.GetInt32(0);
                            ingrediente.Cantidad = (float)reader.GetDouble(1);
                            ingrediente.Unidad.Nombre = reader[2].ToString();

                            plato.setIngredientes(ingrediente);
                        }

                    }

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

            return plato;
        }
コード例 #3
0
        public static List <Plato> datosPlatosProd(int id)
        {
            List <Plato> platos = new List <Plato>();

            string connectionString = ConfigurationManager.ConnectionStrings["TiendaConString"].ConnectionString;

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand("platosProduccion", connection);
                command.CommandType = CommandType.StoredProcedure;


                command.Parameters.AddWithValue("dProduccion", id);
                try
                {
                    connection.Open();
                    SqlDataReader reader = command.ExecuteReader();


                    while (reader.Read())
                    {
                        Plato plato = new Plato();

                        plato.Id    = reader.GetInt32(0);
                        plato.Costo = reader.GetDecimal(2);

                        //recuperar los ingredientes de los platos en una lista de lista

                        SqlCommand commandI = new SqlCommand("ingredienteDetalle", connection);
                        commandI.CommandType = CommandType.StoredProcedure;


                        commandI.Parameters.AddWithValue("idPlato", plato.Id);
                        commandI.Parameters.AddWithValue("cantidad", plato.Costo);

                        SqlDataReader readerI = commandI.ExecuteReader();

                        while (readerI.Read())
                        {
                            Ingrediente ing = new Ingrediente();

                            ing.Unidad.Nombre = readerI[3].ToString();
                            ing.Cantidad      = Validar.ConvertirAKilo(ing.Unidad.Nombre, (float)readerI.GetDouble(2));

                            plato.setIngredientes(ing);
                        }

                        platos.Add(plato);
                    }
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

            return(platos);
        }
コード例 #4
0
ファイル: Plato.cs プロジェクト: Chukaro/analisis
        public static List<Plato> datosPlatosProd(int id)
        {
            List<Plato> platos = new List<Plato>();

            string connectionString = ConfigurationManager.ConnectionStrings["TiendaConString"].ConnectionString;

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand("platosProduccion", connection);
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("dProduccion", id);
                try
                {
                    connection.Open();
                    SqlDataReader reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        Plato plato = new Plato();

                        plato.Id = reader.GetInt32(0);
                        plato.Costo = reader.GetDecimal(2);

                        //recuperar los ingredientes de los platos en una lista de lista

                        SqlCommand commandI = new SqlCommand("ingredienteDetalle", connection);
                        commandI.CommandType = CommandType.StoredProcedure;

                        commandI.Parameters.AddWithValue("idPlato", plato.Id);
                        commandI.Parameters.AddWithValue("cantidad", plato.Costo);

                        SqlDataReader readerI = commandI.ExecuteReader();

                        while (readerI.Read())
                        {
                            Ingrediente ing = new Ingrediente();

                            ing.Unidad.Nombre = readerI[3].ToString();
                            ing.Cantidad = Validar.ConvertirAKilo(ing.Unidad.Nombre, (float)readerI.GetDouble(2));

                            plato.setIngredientes(ing);
                        }

                        platos.Add(plato);
                    }

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

            return platos;
        }