Exemplo n.º 1
0
        private void productosToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            InsProductos _frmInsProductos = new InsProductos();

            _frmInsProductos.StartPosition = FormStartPosition.CenterScreen;
            _frmInsProductos.ShowDialog();
        }
Exemplo n.º 2
0
        private void btnProductos_Click_1(object sender, EventArgs e)
        {
            InsProductos _frmproducto = new InsProductos();

            _frmproducto.StartPosition = FormStartPosition.CenterScreen;
            _frmproducto.ShowDialog();
        }
        //Metodo para actualizar el valor seleccionado del List View
        private void UpdateData()
        {
            try
            {
                OleDbConnection cnnUpdate = new OleDbConnection(Conexion.CnnStr);
                cnnUpdate.Open();

                OleDbCommand cmdUpdate = new OleDbCommand();
                cmdUpdate.Connection = cnnUpdate;

                //insertamos el registro padre
                //cmdUpdate.CommandText = "UPDATE CAT_PRODUCTOS SET DESC_PRODUCTO='" + txtNombre.Text + "', ID_PRODUCTO='" + txtFolio.Text + "', P_U_VENTA=" + Convert.ToDecimal(txtPrecio.Text) + ", ID_UNIDAD_MEDIDA=" + varUnidad + ", CANTIDAD=" + Convert.ToInt32(txtCantidad.Text) + ", CANTIDAD_MIN=" + Convert.ToInt32(btnstockMinima.Text) + " WHERE DESC_PRODUCTO like '%" + varID_PRODUCTO + "%'";


                cmdUpdate.CommandText = "UPDATE CAT_PRODUCTOS SET DESC_PRODUCTO ='" + txtNombre.Text + "', P_U_VENTA=" + Convert.ToDecimal(txtPrecio.Text) + ", ID_UNIDAD_MEDIDA=" + varUnidad + ", CANTIDAD=" + Convert.ToInt32(txtCantidad.Text) + ", CANTIDAD_MIN=" + Convert.ToInt32(btnstockMinima.Text) + " WHERE DESC_PRODUCTO like '%" + varID_PRODUCTO + "%'";


                cmdUpdate.ExecuteNonQuery();

                MessageBox.Show("Se Modifico el Producto con Exito");


                InsProductos _frmInsProductos = new InsProductos();
                _frmInsProductos.StartPosition = FormStartPosition.Manual;
                _frmInsProductos.Show();

                this.Close();
            }

            catch (Exception ex)
            {
                MessageBox.Show("1.- No puedes modificar este articulo ya que tiene varias ventas relacionadas \n 2.- No Puedes Modiciar el Nombre \n 3.- La minimo Stock tiene que ser menor al actual cantidad \n 4.- Error de Sistema Verifiquelo con el Proveedor");
            }
        }
        //Metodo para agregar el valor seleccionado del List View
        private void AddData()
        {
            try
            {
                OleDbConnection cnnInsert = new OleDbConnection(Conexion.CnnStr);
                cnnInsert.Open();

                OleDbCommand cmdInsert = new OleDbCommand();
                cmdInsert.Connection = cnnInsert;

                //insertamos el registro padre
                cmdInsert.CommandText = "INSERT INTO CAT_PRODUCTOS (DESC_PRODUCTO, ID_PRODUCTO, P_U_VENTA, ID_UNIDAD_MEDIDA, CANTIDAD, P_U_COMPRA, ID_DEPARTAMENTO, CANTIDAD_MIN, IVA, P_U_MAYOREO, P_S_MAYOREO) VALUES('" + txtNombre.Text + "','" + txtFolio.Text + "'," + Convert.ToDecimal(txtPrecio.Text) + "," + varUnidad + "," + Convert.ToInt32(txtCantidad.Text) + ", 7.5,'100', " + Convert.ToInt32(btnstockMinima.Text) + ", 0.16," + txtPrecio.Text + "," + txtPrecio.Text + ")";

                cmdInsert.ExecuteNonQuery();

                MessageBox.Show("Se Agrego Producto con Exito");
                cnnInsert.Close();

                InsProductos _frmInsProductos = new InsProductos();
                _frmInsProductos.StartPosition = FormStartPosition.Manual;
                _frmInsProductos.Show();

                this.Close();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        //Metodo para eliminar el valor seleccionado del List View
        private void DeleteData()
        {
            if (varID_PRODUCTO != "")
            {
                try
                {
                    //Buscamos el Folio
                    OleDbConnection cnnReadData = new OleDbConnection(Conexion.CnnStr);

                    if (cnnReadData.State == ConnectionState.Open)
                    {
                        cnnReadData.Close();
                    }
                    else
                    {
                        cnnReadData.Open();
                    }


                    OleDbCommand cmdReadData = new OleDbCommand("SELECT ID_PRODUCTO, DESC_PRODUCTO ,CANTIDAD" +
                                                                " FROM CAT_PRODUCTOS" +
                                                                " WHERE DESC_PRODUCTO like '%" + varID_PRODUCTO + "%'", cnnReadData);

                    OleDbDataReader drReadData;
                    drReadData = cmdReadData.ExecuteReader();



                    OleDbConnection cnndetDelete = new OleDbConnection(Conexion.CnnStr);
                    cnndetDelete.Open();

                    OleDbCommand cmddetDelete = new OleDbCommand();
                    cmddetDelete.Connection = cnndetDelete;
                    //Eliminamos el Registro seleccionado DE DETALLE_VENTAS
                    cmddetDelete.CommandText = "DELETE FROM DETALLE_VENTAS WHERE ID_PRODUCTO like '%" + _FOLIO + "%'";

                    cmddetDelete.ExecuteNonQuery();



                    OleDbConnection cnnDelete = new OleDbConnection(Conexion.CnnStr);
                    cnnDelete.Open();
                    OleDbCommand cmdDelete = new OleDbCommand();
                    cmdDelete.Connection = cnnDelete;

                    //Eliminamos el Registro seleccionado
                    cmdDelete.CommandText = "DELETE FROM CAT_PRODUCTOS WHERE DESC_PRODUCTO like '%" + varID_PRODUCTO + "%'";

                    cmdDelete.ExecuteNonQuery();

                    MessageBox.Show("Se Elimino el Producto Seleccionado");


                    InsProductos _frmInsProductos = new InsProductos();
                    _frmInsProductos.StartPosition = FormStartPosition.Manual;
                    _frmInsProductos.Show();

                    this.Close();
                }

                catch (Exception ex)
                {
                    MessageBox.Show("Error: " + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            else
            {
                MessageBox.Show("Seleccione un Producto de la Lista");
            }
        }