예제 #1
0
        private void btn_guardar_Click(object sender, EventArgs e)
        {
            try
            {
                entidades.Producto producto = new entidades.Producto(); //Creamos un objeto de la capa de Entidades para poder acceder a sus objetos
                negocio            cnegocio = new negocio();            //Creamos un objeto de la capa de negocio para poder acceder a sus funciones
                producto.nombre      = txt_nombre.Text;                 //Llenamos el objeto persona con la informacion de los cuadros de texto/
                producto.descripcion = txt_descripcion.Text;
                producto.marca       = Convert.ToInt32(cbo_marca.SelectedIndex + 1);
                codmarca             = Convert.ToInt32(cbo_marca.SelectedIndex + 1);
                producto.precio      = Convert.ToDouble(txt_precio.Text);
                producto.categoria   = Convert.ToInt32(cbo_cat.SelectedIndex + 1);
                producto.porcentaje  = Convert.ToInt32(txt_comision.Text);
                cnegocio.InsertarProducto(producto);                                    //Llamamos a la funcion Ninsertar a traves del objeto de la capa de negocio y le enviamos como parametro nuestro objeto persona

                string         scad1 = "SELECT max(id_producto) from producto";
                OdbcCommand    mcd1  = new OdbcCommand(scad1, Conexion.ObtenerConexion());
                OdbcDataReader mdr1  = mcd1.ExecuteReader();
                while (mdr1.Read())
                {
                    codproducto = mdr1.GetInt32(0);
                }

                string         scad3 = "SELECT id_bodega from bodega";
                OdbcCommand    mcd3  = new OdbcCommand(scad3, Conexion.ObtenerConexion());
                OdbcDataReader mdr3  = mcd3.ExecuteReader();

                while (mdr3.Read())
                {
                    codbodega = mdr3.GetInt32(0);

                    try
                    {
                        OdbcCommand mySqlComando = new OdbcCommand(
                            string.Format("INSERT INTO existencia_bodega (id_producto, id_marca, id_bodega, cantidad) values ('{0}','{1}','{2}','0')", codproducto, codmarca, codbodega),
                            seguridad.Conexion.ObtenerConexionODBC()
                            );
                        mySqlComando.ExecuteNonQuery();                 //se ejecuta el query
                        MessageBox.Show("Insertado existencia");
                    }
                    catch
                    {
                        MessageBox.Show("Error de insercion");          //si el try-catch encontro algun error indica mensaje de fracaso
                    }
                }
            } catch { MessageBox.Show("Debe llenar todos los campos"); }
            limpiar();
            deshabilitar();
        }
예제 #2
0
        private void btn_guardar_Click(object sender, EventArgs e)
        {
            entidades.Producto producto = new entidades.Producto(); //Creamos un objeto de la capa de Entidades para poder acceder a sus objetos
            negocio            cnegocio = new negocio();            //Creamos un objeto de la capa de negocio para poder acceder a sus funciones

            producto.nombre      = txt_nombre.Text;                 //Llenamos el objeto persona con la informacion de los cuadros de texto/
            producto.descripcion = txt_descripcion.Text;
            producto.marca       = Convert.ToInt32(cbo_marca.SelectedIndex + 1);
            producto.precio      = Convert.ToDouble(txt_precio.Text);
            producto.categoria   = Convert.ToInt32(cbo_cat.SelectedIndex + 1);
            producto.porcentaje  = Convert.ToInt32(txt_comision.Text);
            cnegocio.InsertarProducto(producto);                                    //Llamamos a la funcion Ninsertar a traves del objeto de la capa de negocio y le enviamos como parametro nuestro objeto persona
            limpiar();
            deshabilitar();
        }
예제 #3
0
        private void btn_eliminar_Click(object sender, EventArgs e)
        {
            entidades.Producto producto = new entidades.Producto();
            Int32 selectedRowCount      =
                dgv_producto.Rows.GetRowCount(DataGridViewElementStates.Selected);

            if (selectedRowCount > 0)
            {
                producto.codigo = Convert.ToString(dgv_producto.CurrentRow.Cells[0].Value);
                negocio neg = new negocio();
                neg.EliminarProducto(producto);
            }
            else
            {
                MessageBox.Show("Debe seleccionar una fila");
            }
        }
예제 #4
0
        public static entidades.Producto Obtenerclte(int id_cl)
        {
            entidades.Producto cl = new entidades.Producto();

            OdbcConnection conexion = Conexion.ObtenerConexion();

            OdbcCommand    _comando = new OdbcCommand(String.Format("select id_producto, nombre, id_marca from producto where id_producto= {0}", id_cl), conexion);
            OdbcDataReader _reader  = _comando.ExecuteReader();

            while (_reader.Read())
            {
                cl.codigo = _reader.GetString(0);
                cl.nombre = _reader.GetString(1);
                cl.marca  = _reader.GetInt32(2);
            }

            conexion.Close();
            return(cl);
        }
예제 #5
0
 private void btn_agregar_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgv_bien.SelectedRows.Count == 1)
         {
             int id = Convert.ToInt16(dgv_bien.CurrentRow.Cells[0].Value);
             busq = Clsopbien.Obtenerclte(id);
             this.Close();
         }
         else
         {
             MessageBox.Show("Debe de seleccionar una fila");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
예제 #6
0
        private void btn_bproducto_Click(object sender, EventArgs e)
        {
            try
            {
                frmbuscproducto buscl = new frmbuscproducto();
                buscl.ShowDialog();


                if (buscl.busq != null)
                {
                    clsprod = buscl.busq;

                    txt_prod.Text = Convert.ToString(buscl.busq.nombre);
                    idprod        = Convert.ToInt16(buscl.busq.codigo);
                    idmarc        = Convert.ToInt16(buscl.busq.marca);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
예제 #7
0
        public static List <entidades.Producto> Buscar(string prod) //Método tipo lista, que retornar el resultado dela busqueda
        {
            List <entidades.Producto> _lista = new List <entidades.Producto>();
            //MessageBox.Show(credi);
            OdbcCommand _comando = new OdbcCommand(String.Format(
                                                       "select id_producto, id_marca, nombre, descripcion, precio_unidad, id_categoria from producto where nombre like '%{0}%'", prod), Conexion.ObtenerConexion());
            OdbcDataReader _reader = _comando.ExecuteReader();

            while (_reader.Read())
            {
                entidades.Producto produc = new entidades.Producto();
                produc.codigo      = _reader.GetString(0);
                produc.marca       = _reader.GetInt32(1);
                produc.nombre      = _reader.GetString(2);
                produc.descripcion = _reader.GetString(2);
                produc.precio      = _reader.GetInt32(3);
                produc.categoria   = _reader.GetInt32(4);


                _lista.Add(produc);
            }

            return(_lista);
        }