Example #1
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            if (ValidarDatos())
            {
                int clave    = Convert.ToInt32(cmbID.SelectedItem.ToString());
                int cantidad = Convert.ToInt32(numCantidad.Value);

                bool aumentado = new AdmLibros().AumentarExistencia(conexion, clave, cantidad);

                if (aumentado)
                {
                    MessageBox.Show("Inventario Actualizado con Exito", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("ERROR", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    foreach (SqlError error in AdmLibros.Errores.Errors)
                    {
                        MessageBox.Show(error.Message);
                    }
                }
            }
            else
            {
                MessageBox.Show("Llena los Elementos Faltantes", "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (ValidaDatos())
            {
                string nombre   = txtNombre.Text;
                string autor    = txtAutor.Text;
                int    editor   = cmbEditorial.SelectedIndex + 1;
                int    cantidad = Convert.ToInt32(numCantidad.Value);

                bool agregado = new AdmLibros().AgregaLibro(conexion, nombre, editor, ObtenerFecha(), cantidad, autor);

                if (agregado)
                {
                    MessageBox.Show("Libro Agregado con Exito", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Limpiar();
                    LlenaID();
                }
                else
                {
                    MessageBox.Show("ERROR", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    foreach (SqlError error in AdmLibros.Errores.Errors)
                    {
                        MessageBox.Show(error.Message);
                    }
                }
            }
            else
            {
                MessageBox.Show("Llena los Elementos Faltantes", "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Example #3
0
        private void LlenaNombres()
        {
            List <string> Nombres = new AdmLibros().TodosNombres(conexion);

            for (int i = 0; i < Nombres.Count; i++)
            {
                this.cmbNombre.Items.Add(Nombres[i]);
            }
        }
Example #4
0
        private void LlenaIDs()
        {
            List <string> IDs = new AdmLibros().TodosID(conexion);

            for (int i = 0; i < IDs.Count; i++)
            {
                this.cmbID.Items.Add(IDs[i]);
            }
        }
        private void LlenaEditorial()
        {
            List <string> editorial = new AdmLibros().ObtenerEditorial(conexion);

            for (int i = 0; i < editorial.Count; i++)
            {
                this.cmbEditorial.Items.Add(editorial[i]);
            }
        }