public Boolean altaDetalleProductoIngredientes(productos _producto, M_Registrar_Ingre _ingrediente)
        {
            int        insertar  = 0;
            bool       respuesta = false;
            SqlCommand comando   = new SqlCommand("sp_insertarRelacionProductosEingredinentes", conexion.openDataBase());

            comando.CommandType = System.Data.CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@idProducto", _producto.Id);
            comando.Parameters.AddWithValue("@idIngrediente", _ingrediente.Id);



            try
            {
                insertar = comando.ExecuteNonQuery();
                if (insertar < 0)
                {
                    respuesta = true;
                }
                conexion.closeDatabase();
            }
            catch (Exception)
            {
                conexion.closeDatabase();
                throw;
            }

            return(respuesta);
        }
Exemplo n.º 2
0
        public Boolean eliminarIngrediente(M_Registrar_Ingre _ingrediente)
        {
            int        elininar  = 0;
            bool       respuesta = false;
            SqlCommand comando   = new SqlCommand("sp_elininarIngrediente", conexion.openDataBase());

            comando.CommandType = System.Data.CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@nombre", _ingrediente.Ingrediente);


            try
            {
                elininar = comando.ExecuteNonQuery();
                if (elininar < 0)
                {
                    respuesta = true;
                }
                conexion.closeDatabase();
            }
            catch (Exception)
            {
                conexion.closeDatabase();
                throw;
            }

            return(respuesta);
        }
Exemplo n.º 3
0
        public DataSet SelectIngredintesDeProducto(M_Registrar_Ingre _ingrediente)
        {
            DataSet productDataSet = new DataSet();



            SqlCommand Comando = new SqlCommand();

            Comando.Connection = conexion.openDataBase();



            Comando.CommandType = CommandType.StoredProcedure;

            Comando.CommandText = "sp_DetalleIngredienteProducto";
            Comando.Parameters.AddWithValue("@idProducto", _ingrediente.Id);
            try
            {
                SqlDataAdapter myAdapter = new SqlDataAdapter(Comando);
                productDataSet = new DataSet();
                myAdapter.Fill(productDataSet);
            }
            catch (Exception ex)
            {
                string m = ex.Message;
                Comando.Dispose();
            }

            finally
            {
                conexion.closeDatabase();
            }

            return(productDataSet);
        }
Exemplo n.º 4
0
        private void button2_Click(object sender, EventArgs e)
        {
            M_Registrar_Ingre objCF = new M_Registrar_Ingre();
            C_Registrar_Ingre _cf   = new C_Registrar_Ingre();

            objCF.Ingrediente = txtNOmbredelte.Text;

            _cf.eliminarIngrediente(objCF);

            txtNOmbredelte.Text = "";
            llenarGrigIngredientes();
        }
Exemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            M_Registrar_Ingre _ingre        = new M_Registrar_Ingre();
            C_Registrar_Ingre cingredientes = new C_Registrar_Ingre();

            _ingre.Ingrediente = txtIngreAdd.Text;
            _ingre.Stock       = int.Parse(txtStock.Text);
            cingredientes.altaIngrediente(_ingre);
            llenarGrigIngredientes();
            txtIngreAdd.Text = "";
            txtStock.Text    = "";
        }
        public void llenarGrig()
        {
            // textBox1.Text = comboBox1.SelectedValue.ToString();
            C_Registrar_Ingre _Cingrediente = new C_Registrar_Ingre();
            M_Registrar_Ingre _ingrediente = new M_Registrar_Ingre();
            if (comboBox1.SelectedValue.ToString() != "sistemaRestaurante.modelo.productos")
            {
                _ingrediente.Id = int.Parse(comboBox1.SelectedValue.ToString());

                dgwingredientes.DataSource = _Cingrediente.SelectIngredintesDeProducto(_ingrediente).Tables[0];
                dgwingredientes.Visible = true;
            }
            label3.Text = comboBox1.Text;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            controlProducto _produ = new controlProducto();

            productos         _pro   = new productos();
            M_Registrar_Ingre _ingre = new M_Registrar_Ingre();



            foreach (DataGridViewRow rowss in dgwProducto.Rows)
            {
                string c = Convert.ToString(rowss.Cells[1].Value);

                if (c != "")
                {
                    _pro.Id   = int.Parse(cbPRODUCTOS.SelectedValue.ToString());
                    _ingre.Id = Convert.ToInt32(rowss.Cells[0].Value);
                    _produ.altaDetalleProductoIngredientes(_pro, _ingre);
                }

                lblm.Text = "Ingredientes Agregados";
            }
        }