Exemple #1
0
        public static IList <DAOProductos> Buscar(MySqlConnection con, string Nombre)
        {
            List <DAOProductos> lista   = new List <DAOProductos>();
            MySqlCommand        comando = new MySqlCommand(string.Format("SELECT productos.id_producto, productos.nombre,productos.precio_compra, productos.precio_venta,productos.estatus,proveedores.nombre,productos.cantidad,productos.stock_minimo,productos.stock_maximo,productos.precio_compra * productos.cantidad as 'TotalCompra',productos.id_proveedor from productos,proveedores where productos.nombre LIKE ('%{0}%') and productos.id_proveedor=proveedores.id_proveedor", Nombre), con);
            MySqlDataReader     reader  = comando.ExecuteReader();

            while (reader.Read())
            {
                DAOProductos Producto = new DAOProductos();
                Producto.id               = reader.GetInt32(0);
                Producto.nombre           = reader.GetString(1);
                Producto.precio_compra    = reader.GetFloat(2);
                Producto.precio_venta     = reader.GetFloat(3);
                Producto.estatus          = reader.GetString(4);
                Producto.nombre_proveedor = reader.GetString(5);
                Producto.cantidad         = reader.GetInt32(6);
                Producto.stock_minimo     = reader.GetInt32(7);
                Producto.stock_maximo     = reader.GetInt32(8);
                Producto.totalcompra      = reader.GetFloat(9);
                // Producto.id_proveedor = reader.GetInt32(10);

                lista.Add(Producto);
            }
            return(lista);
        }
Exemple #2
0
        public static int Agregar(MySqlConnection con, DAOProductos Productos, DAOProveedores nombre_proveedor)
        {
            int          retorno = 0;
            MySqlCommand comando = new MySqlCommand(string.Format("INSERT INTO productos (id_producto,nombre,precio_compra,precio_venta,id_proveedor,cantidad,stock_minimo,stock_maximo) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", Productos.id, Productos.nombre, Productos.precio_compra, Productos.precio_venta, nombre_proveedor.id, Productos.cantidad, Productos.stock_minimo, Productos.stock_maximo), con);

            retorno = comando.ExecuteNonQuery();

            return(retorno);
        }
Exemple #3
0
        internal static int Modificar(MySqlConnection con, DAOProductos Productos, DAOProveedores nombre_proveedor)
        {
            int          retorno = 0;
            MySqlCommand comando = new MySqlCommand(string.Format("UPDATE productos SET nombre='{0}',precio_compra='{1}',precio_venta='{2}',estatus='{3}',id_proveedor='{4}',cantidad='{5}',stock_minimo='{6}',stock_maximo='{7}' where id_producto='{8}' ", Productos.nombre, Productos.precio_compra, Productos.precio_venta, Productos.estatus, nombre_proveedor.id, Productos.cantidad, Productos.stock_minimo, Productos.stock_maximo, Productos.id), con);

            retorno = comando.ExecuteNonQuery();


            return(retorno);
        }
Exemple #4
0
        private void btn_AgregarProducto_Click(object sender, EventArgs e)
        {
            {
                if (MessageBox.Show("Seguro que desea Agregar?", "Confirmación Agregar", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    try
                    {
                        if (con.Abrirconexion() == true)
                        {
                            DAOProductos Producto = new DAOProductos();
                            Producto.nombre         = txt_nombre.Text;
                            nombre_proveedor.nombre = cb_proveedor.Text;
                            DAOProveedores.Buscarid(con.con, nombre_proveedor);

                            Producto.precio_compra = float.Parse(txt_precio_compra.Text);
                            Producto.precio_venta  = float.Parse(txt_precio_venta.Text);
                            Producto.stock_minimo  = int.Parse(txt_stock_minimo.Text);
                            Producto.stock_maximo  = int.Parse(txt_stock_maximo.Text);

                            Producto.cantidad = int.Parse(txt_cantidad.Text);



                            int resultado = DAOProductos.Agregar(con.con, Producto, nombre_proveedor);

                            if (resultado > 0)
                            {
                                txt_nombre.Clear();
                                txt_precio_compra.Clear();
                                txt_precio_venta.Clear();
                                txt_stock_maximo.Clear();
                                txt_stock_minimo.Clear();
                                txt_cantidad.Clear();
                            }
                        }
                    }
                    catch (MySql.Data.MySqlClient.MySqlException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    this.Close();
                    Catalogos.formulario.Productos.Show();
                    Catalogos.formulario.Productos.ListarProductos(con.con, "");

                    Catalogos.formulario.AgregarProducto = null;
                    // Catalogos.formulario.Productos.Show();

                    //Catalogos.formulario.Productos.ListarProductos(con.con, "");


                    con.Cerrarconexion();
                }
            }
        }
Exemple #5
0
        private void btn_Vender_Click(object sender, EventArgs e)
        {
            if (dgv_vender.RowCount < 2)
            {
                MessageBox.Show("Inserte un Producto");
                txt_Cantidad.Focus();
            }
            else
            {
                if (MessageBox.Show("Seguro que desea realizar la venta?", "Confirmación Venta", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    try
                    {
                        if (con.Abrirconexion() == true)
                        {
                            DAOVender Vender = new DAOVender();

                            for (int i = 0; i < id_cliente.Count; i++)
                            {
                                MessageBox.Show(id_producto[i]);
                                if (i == 1)
                                {
                                    id_venta.id            = DAOVender.Buscarid(con.con);
                                    Vender.id              = id_venta.id;
                                    id_venta.id_movimiento = DAOMovimientos.Buscarid(con.con);
                                    Vender.id_movimiento   = id_venta.id_movimiento;
                                }
                                Vender.cliente  = id_cliente[i];
                                Vender.producto = id_producto[i];
                                Vender.cantidad = int.Parse(cantidad[i]);
                                if (total[i] == total.Count - 1)
                                {
                                    Vender.total = totalll;
                                }
                                else
                                {
                                    Vender.total = total[i];
                                }
                                Vender.fecha_venta = fecha_venta[i];
                                int resultado = DAOVender.Agregar(con.con, Vender);
                                MessageBox.Show("Venta Almacenada!");
                                txt_Cantidad.Text = "1";
                                txt_Total.Clear();
                                dgv_vender.Rows.Clear();
                            }
                        }
                    }
                    catch (MySql.Data.MySqlClient.MySqlException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    con.Cerrarconexion();
                }
            }
        }
Exemple #6
0
        public static float BuscarPrecioCompra(MySqlConnection con, DAOProductos Precio)
        {
            MySqlCommand    comando = new MySqlCommand(string.Format("select precio_compra from productos where nombre='{0}'", Precio.nombre), con);
            MySqlDataReader reader  = comando.ExecuteReader();

            while (reader.Read())
            {
                Precio.precio_compra = reader.GetFloat(0);
            }
            return(Precio.precio_compra);
        }
Exemple #7
0
 private void Cargartotales()
 {
     try
     {
         if (con.Abrirconexion() == true)
         {
             lbl_tc.Text = DAOProductos.TotalCompra(con.con) + " $".ToString();
             con.Cerrarconexion();
         }
     }
     catch (MySql.Data.MySqlClient.MySqlException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemple #8
0
 private void btn_AgregarCliente_Click(object sender, EventArgs e)
 {
     if (txt_Cantidad.Text == "" || txt_Cantidad.Text == "0")
     {
         MessageBox.Show("Ingrese una cantidad valida!");
         txt_Cantidad.Focus();
     }
     else if (txt_Total.Text == "")
     {
         MessageBox.Show("Presione enter en el campo de 'Cantidad' para ver la cantidad en almacen..");
         txt_Cantidad.Focus();
     }
     else if (int.Parse(txt_Cantidad.Text) > int.Parse(txt_Total.Text))
     {
         MessageBox.Show("No hay suficiente en almacen..");
     }
     else
     {
         {
             id_producto.Add(cb_Producto.Text);
             id_cliente.Add(cb_cliente.Text);
             DateTime localDate = DateTime.Now;
             fecha_venta.Add(localDate.ToString());
             cantidad.Add(txt_Cantidad.Text);
             precio_vent.nombre = cb_Producto.Text;
             try
             {
                 if (con.Abrirconexion() == true)
                 {
                     DAOProductos.BuscarPrecio(con.con, precio_vent);
                     con.Cerrarconexion();
                 }
             }
             catch (MySql.Data.MySqlClient.MySqlException ex)
             {
                 MessageBox.Show(ex.Message);
             }
             totall = precio_vent.precio_venta * int.Parse(txt_Cantidad.Text);
             total.Add(totall);
             totalll = totalll + totall;
             dgv_vender.Rows.Add(cb_cliente.Text, cb_Producto.Text, txt_Cantidad.Text, totalll);
             lbl_total.Text = totalll.ToString();
         }
     }
 }
        private void btn_Calcular_Click(object sender, EventArgs e)
        {
            Int32 selectedRowCount =
                dgvComprar.Rows.GetRowCount(DataGridViewElementStates.Selected);

            precio_comp.id     = int.Parse(dgvComprar.CurrentRow.Cells[0].Value.ToString());
            precio_comp.nombre = dgvComprar.CurrentRow.Cells[1].Value.ToString();
            try
            {
                if (con.Abrirconexion() == true)
                {
                    DAOProductos.BuscarPrecioCompra(con.con, precio_comp);
                    con.Cerrarconexion();
                }
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            {
                MessageBox.Show(ex.Message);
            }
            total          = int.Parse(txt_Cantidad.Text) * precio_comp.precio_compra;
            lbl_total.Text = total.ToString();
        }
 public void ListarProductos(MySqlConnection con, string Nombre)
 {
     dgvComprar.DataSource = DAOProductos.Buscar(con, Nombre);
     dgvComprar.AutoResizeColumns();
 }