Пример #1
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            clsAgregar agregaL = new clsAgregar();

            agregaL.ISBN       = Convert.ToInt32(txtISBN.Text);
            agregaL.Titulo     = txtTitulo.Text;
            agregaL.NumEdicion = Convert.ToInt32(txtNoEdicion.Text);
            agregaL.Año        = Convert.ToInt32(txtAñoP.Text);
            agregaL.Autor      = txtAutor.Text;
            agregaL.PaisP      = txtPaisP.Text;
            agregaL.Sinopsis   = txtSinopsis.Text;
            agregaL.Carrera    = txtCarrera.Text;
            agregaL.Materia    = txtMateria.Text;


            DaoAgregar metodo = new DaoAgregar();

            if (metodo.MAgregarlibro(agregaL))
            {
                MessageBox.Show("Agregado Correctamente");
            }
            else
            {
                MessageBox.Show("Algo salio mal");
            }
        }
Пример #2
0
        public bool MAgregarlibro(clsAgregar agre)
        {
            MySqlConnection conexxion = new MySqlConnection();
            MySqlCommand    comando   = new MySqlCommand();

            try
            {
                conexxion.ConnectionString = "server=192.168.1.74; database=biblioteca; user=admin; pwd=itsur123;";
                conexxion.Open();

                comando.CommandText = "InsertarLibro";
                comando.Connection  = conexxion;
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.Parameters.AddWithValue("Id", null);
                comando.Parameters.AddWithValue("Isbn", agre.ISBN);
                comando.Parameters.AddWithValue("Titulo", agre.Titulo);
                comando.Parameters.AddWithValue("NumEdicion", agre.NumEdicion);
                comando.Parameters.AddWithValue("Año", agre.Año);
                comando.Parameters.AddWithValue("Autor", agre.Autor);
                comando.Parameters.AddWithValue("PaisP", agre.PaisP);
                comando.Parameters.AddWithValue("Sinopsis", agre.Sinopsis);
                comando.Parameters.AddWithValue("Carrera", agre.Carrera);
                comando.Parameters.AddWithValue("Materia", agre.Materia);
                comando.ExecuteNonQuery();
            }
            catch
            {
                return(false);
            }
            finally
            {
                comando.Dispose();
                conexxion.Close();
                conexxion.Dispose();
            }

            return(true);
        }