Example #1
0
        public Boolean altaProducto(productos _producto, CatProducto _CatProduc)
        {
            int        insertar  = 0;
            bool       respuesta = false;
            SqlCommand comando   = new SqlCommand("sp_A_table_Producto", conexion.openDataBase());

            comando.CommandType = System.Data.CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@Nombre", _producto.NombreProducto);
            comando.Parameters.AddWithValue("@Desc", _producto.Descripcion);
            comando.Parameters.AddWithValue("@Precio", _producto.Precio);
            comando.Parameters.AddWithValue("@idCat", _CatProduc.Id);


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

            return(respuesta);
        }
Example #2
0
        public DataSet SelectProductoByCattegoria(CatProducto _catPr)
        {
            DataSet productDataSet = new DataSet();



            SqlCommand Comando = new SqlCommand();

            Comando.Connection = conexion.openDataBase();



            Comando.CommandType = CommandType.StoredProcedure;

            Comando.CommandText = "sp_C_Table_AllProducts";
            Comando.Parameters.AddWithValue("@idCategoria", _catPr.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);
        }
Example #3
0
        public List <CatProducto> seleccionarCatProducto()
        {
            List <CatProducto> listaCtProducto = new List <CatProducto>();

            MySqlCommand Comando = new MySqlCommand();

            Comando.Connection  = Clase_ConeccionDB.obtenerConeccion();
            Comando.CommandType = CommandType.StoredProcedure;
            Comando.CommandText = "selectCatProduto";


            try
            {
                IDataReader lector = Comando.ExecuteReader();
                while (lector.Read())
                {
                    CatProducto _catProduto = new CatProducto();
                    _catProduto.Id        = int.Parse(lector[0].ToString());
                    _catProduto.Categoria = lector[1].ToString();
                    listaCtProducto.Add(_catProduto);
                }
            }
            catch (Exception ex)
            {
                string m = ex.Message;
                Comando.Dispose();
            }

            finally
            {
            }

            return(listaCtProducto);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string respuestas = "";

            productos       _producto = new productos();
            CatProducto     cPr       = new CatProducto();
            controlProducto cProdu    = new controlProducto();

            _producto.NombreProducto = txtNombre.Text;
            _producto.Descripcion    = txtDes.Text;
            _producto.Precio         = int.Parse(txtPrecio.Text);
            cPr.Id = int.Parse(cbCat.SelectedValue.ToString());



            _producto.Respuesta = cProdu.altaProducto(_producto, cPr);

            if (_producto.Respuesta == true)
            {
                respuestas  = "Agregado Exitoso";
                label5.Text = respuestas;
            }
            else
            {
                respuestas  = "Error al insertar";
                label5.Text = respuestas;
            }


            txtNombre.Text = "";
            txtDes.Text    = "";
            txtPrecio.Text = "";
        }
Example #5
0
        public void llenarGrig()
        {
            ControlProducto _Cproducto         = new ControlProducto();
            CatProducto     _categoriaproducto = new CatProducto();

            if (cbCategoria.SelectedValue.ToString() != "sistemaRestaurante.modelo.CatProducto")
            {
            }
        }
Example #6
0
        public void llenarGrig()
        {
            controlProducto _Cproducto         = new controlProducto();
            CatProducto     _categoriaproducto = new CatProducto();

            if (cbCategoria.SelectedValue.ToString() != "sistemaRestaurante.modelo.CatProducto")
            {
                _categoriaproducto.Id = int.Parse(cbCategoria.SelectedValue.ToString());

                dgwMenu.DataSource = _Cproducto.SelectProductoByCattegoria(_categoriaproducto).Tables[0];
                dgwMenu.Visible    = true;
            }
        }
        public async Task <ActionResult> insertarcategoriasProductosdeEmpresa([FromBody] CatProducto cp)
        {
            var response = new ResponseBase();

            try
            {
                response = await this.catProducto.InsertarCategoriaProducto(cp);
            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
                return(StatusCode(500, response));
            }
            return(Ok(response));
        }
        public List <CatProducto> seleccionarCatProducto()
        {
            List <CatProducto> listaCtProducto = new List <CatProducto>();

            SqlCommand Comando = new SqlCommand();

            Comando.Connection = conexion.openDataBase();

            Comando.CommandType = CommandType.StoredProcedure;

            Comando.CommandText = "sp_C_Table_CatProducto";
            // CatProducto _catP = new CatProducto();
            // _catP.Categoria = "Seleccione";

            //   listaCtProducto.Add(_catP);

            try
            {
                IDataReader lector = Comando.ExecuteReader();
                while (lector.Read())
                {
                    CatProducto _catProduto = new CatProducto();
                    _catProduto.Id        = int.Parse(lector[0].ToString());
                    _catProduto.Categoria = lector[1].ToString();
                    listaCtProducto.Add(_catProduto);
                }
            }
            catch (Exception ex)
            {
                string m = ex.Message;
                Comando.Dispose();
            }

            finally
            {
                conexion.closeDatabase();
            }

            return(listaCtProducto);
        }
        public async Task <ResponseBase> InsertarCategoriaProducto(CatProducto cp)
        {
            var response = new ResponseBase();

            try
            {
                using (var connection = new SqlConnection(con.getConnection()))
                {
                    using (var command = new SqlCommand("Catalogos.spInsertarCategoriaProducto", connection))
                    {
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.Clear();
                        command.Parameters.AddWithValue("@idCatProducto", 0);
                        command.Parameters.AddWithValue("@nombre", cp.nombre);
                        command.Parameters.AddWithValue("@descripcion", cp.descripcion);
                        command.Parameters.AddWithValue("@idEmpresa", cp.idEmpresa);
                        command.Parameters.AddWithValue("@menu", cp.menu);
                        command.Parameters["@idCatProducto"].Direction = ParameterDirection.Output;
                        connection.Open();
                        var result = await command.ExecuteNonQueryAsync();

                        if (result > 0)
                        {
                            response.success = true;
                            response.message = "Datos Insertados Correctamente";
                            response.id      = Convert.ToInt32(command.Parameters["@idCatProducto"].Value);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
            }
            return(response);
        }