Exemple #1
0
        public void agregarIngredientePorComida(IngreditePorComida nuevo)
        {
            AccesoDatosManager accesoDatos = new AccesoDatosManager();

            try
            {
                accesoDatos.setearSP("AgregarIngredientePorComida");
                accesoDatos.Comando.Parameters.Clear();
                accesoDatos.Comando.Parameters.AddWithValue("@IdComidas", nuevo.Comida.Id);
                accesoDatos.Comando.Parameters.AddWithValue("@IdIngredientes", nuevo.Ingrediente.Id);
                accesoDatos.Comando.Parameters.AddWithValue("@Cantidad", nuevo.Cantidad);
                accesoDatos.Comando.Parameters.AddWithValue("@FechaCreacion", nuevo.FechaCreacion);
                accesoDatos.Comando.Parameters.AddWithValue("@UsuarioCreacion", nuevo.UsuarioCreacion.IdUsuario);
                accesoDatos.Comando.Parameters.AddWithValue("@FechaModificacion", nuevo.FechaModificacion);
                accesoDatos.Comando.Parameters.AddWithValue("@UsuarioModificacion", nuevo.UsuarioModificacion.IdUsuario);
                accesoDatos.Comando.Parameters.AddWithValue("@Estado", nuevo.Estado);


                accesoDatos.abrirConexion();
                accesoDatos.ejecutarAccion();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                accesoDatos.cerrarConexion();
            }
        }
Exemple #2
0
        private void btnAgregarIngredienteporcomida_Click(object sender, EventArgs e)
        {
            IngredientePorComidaNegocio porComidaNegocio = new IngredientePorComidaNegocio();
            Comida             comida             = new Comida();
            Ingrediente        ingrediente        = new Ingrediente();
            DateTime           fecha              = DateTime.Today;
            IngreditePorComida ingreditePorComida = new IngreditePorComida();

            comida      = (Comida)cboComida.SelectedItem;
            ingrediente = (Ingrediente)dgvIngredienteppcc.CurrentRow.DataBoundItem;
            ingreditePorComida.Ingrediente         = ingrediente;
            ingreditePorComida.Comida              = comida;
            ingreditePorComida.UsuarioCreacion     = Usuario.UsuarioLogin;
            ingreditePorComida.UsuarioModificacion = Usuario.UsuarioLogin;
            ingreditePorComida.FechaCreacion       = fecha.ToLocalTime();
            ingreditePorComida.FechaModificacion   = fecha.ToLocalTime();
            string canti;

            canti = Microsoft.VisualBasic.Interaction.InputBox("Ingrese Cantidad:", "Agregar cantidad a la Comida", "0", 100, 100);
            ingreditePorComida.Cantidad = Convert.ToDecimal(canti);
            porComidaNegocio.validarIngredienteporComida(ingreditePorComida);
        }
Exemple #3
0
        public void validarIngredienteporComida(IngreditePorComida nuevo)
        {
            AccesoDatosManager conexion;

            try
            {
                conexion = new AccesoDatosManager();
                conexion.setearConsulta("select IdComidas, IdIngredientes, Estado from INGREDIETESPORCOMIDAS Where IdComidas=@IdComidas and IdIngredientes=@IdIngredientes");
                conexion.Comando.Parameters.Clear();
                conexion.Comando.Parameters.AddWithValue("@IdComidas", nuevo.Comida.Id);
                conexion.Comando.Parameters.AddWithValue("@IdIngredientes", nuevo.Ingrediente.Id);

                conexion.abrirConexion();
                conexion.ejecutarConsulta();
                if (conexion.Lector.Read())
                {
                    nuevo.Estado = (bool)conexion.Lector["Estado"];
                    if (false == nuevo.Estado)
                    {
                        nuevo.Comida.Id      = (int)conexion.Lector["IdComidas"];
                        nuevo.Ingrediente.Id = (int)conexion.Lector["IdIngredientes"];
                        nuevo.Estado         = true;
                        //modificarIngrediente(nuevo);
                    }
                    nuevo.Comida.Id      = (int)conexion.Lector["IdComidas"];
                    nuevo.Ingrediente.Id = (int)conexion.Lector["IdIngredientes"];
                }
                else
                {
                    nuevo.Estado = true;
                    agregarIngredientePorComida(nuevo);
                }
                conexion.cerrarConexion();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #4
0
        public List <IngreditePorComida> ListarIngredienteporcomida(int id)
        {
            List <IngreditePorComida> listado     = new List <IngreditePorComida>();
            AccesoDatosManager        accesoDatos = new AccesoDatosManager();
            IngreditePorComida        Ingre       = new IngreditePorComida();
            TipoComida tipoComida = new TipoComida();

            try
            {
                accesoDatos.setearConsulta("select i.IdIngrediente, i.NombreIngrediente,  ic.Cantidad  from INGREDIENTES as i inner join INGREDIETESPORCOMIDAS as ic on i.IdIngrediente= ic.IdIngredientes	where IdComidas=@Idcomida and ic.Estado=1");
                accesoDatos.Comando.Parameters.Clear();
                accesoDatos.Comando.Parameters.AddWithValue("@Idcomida", id);
                accesoDatos.abrirConexion();
                accesoDatos.ejecutarConsulta();

                while (accesoDatos.Lector.Read())
                {
                    Ingre                    = new IngreditePorComida();
                    Ingre.Ingrediente        = new Ingrediente();
                    Ingre.Ingrediente.Id     = (int)accesoDatos.Lector["IdIngrediente"];
                    Ingre.Ingrediente.Nombre = accesoDatos.Lector["NombreIngrediente"].ToString();
                    Ingre.Cantidad           = (decimal)accesoDatos.Lector["Cantidad"];
                    listado.Add(Ingre);
                }


                return(listado);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                accesoDatos.cerrarConexion();
            }
        }