public void Buscar() { LibroBO oLibroBO = new LibroBO(); CtrlLibro oLibroCtrl = new CtrlLibro(); if (txtISBN.Text.Trim().Length != 0) { oLibroBO.ISBN = Convert.ToInt32(txtISBN.Text.Trim()); } if (txtAutor.Text.Trim().Length != 0) { oLibroBO.Autor = txtAutor.Text.Trim(); } if (txtNombre.Text.Trim().Length != 0) { oLibroBO.Titulo = txtNombre.Text.Trim(); } if (txtEditorial.Text.Trim().Length != 0) { oLibroBO.Editorial = txtEditorial.Text.Trim(); } if (txtPrecio.Text.Trim().Length != 0) { oLibroBO.Precio = Convert.ToInt32(txtPrecio.Text.Trim()); } dsReporte = oLibroCtrl.BusquedaLibro(oLibroBO); dgvAlumno.AutoGenerateColumns = false; dgvAlumno.DataSource = dsReporte.Tables[0]; }
public int AltaLibro(object obj) { LibroBO data = (LibroBO)obj; cmd = new SQLiteCommand(); dsLibros = new DataSet(); da = new SQLiteDataAdapter(); con = new Conexion(); cmd.Connection = con.establecerConexion(); con.abrirConexion(); sql = "INSERT INTO Libro(Titulo,Autor,Editorial,Precio,Imagen)" + "VALUES('" + data.Titulo.Trim() + "','" + data.Autor.Trim() + "','" + data.Editorial.Trim() + "','" + data.Precio.ToString() + "','" + data.Imagen.Trim() + "')"; cmd.CommandText = sql; int i = cmd.ExecuteNonQuery(); if (i <= 0) { return(0); } return(1); }
public int modificaLibro(object obj) { LibroBO data = (LibroBO)obj; cmd = new SQLiteCommand(); dsLibros = new DataSet(); da = new SQLiteDataAdapter(); con = new Conexion(); cmd.Connection = con.establecerConexion(); con.abrirConexion(); sql = "UPDATE Libro SET Titulo='" + data.Titulo.Trim() + "',Autor='" + data.Autor.Trim() + "',Editorial='" + data.Editorial.Trim() + "',Precio='" + data.Precio.ToString() + "' WHERE ISBN='" + data.ISBN.ToString() + "'"; cmd.CommandText = sql; int i = cmd.ExecuteNonQuery(); if (i <= 0) { return(0); } return(1); }
public DataSet BusquedaLibro(object obj) { string cadenaWhere = ""; bool edo = false; LibroBO data = (LibroBO)obj; cmd = new SQLiteCommand(); dsLibros = new DataSet(); da = new SQLiteDataAdapter(); con = new Conexion(); cmd.Connection = con.establecerConexion(); con.abrirConexion(); if (data.ISBN > 0) { cadenaWhere = cadenaWhere + " ISBN=" + data.ISBN + " and"; edo = true; } if (data.Titulo != null) { cadenaWhere = cadenaWhere + " Titulo='" + data.Titulo.Trim() + "' and"; edo = true; } if (data.Autor != null) { cadenaWhere = cadenaWhere + " Autor='" + data.Autor.Trim() + "' and"; edo = true; } if (data.Editorial != null) { cadenaWhere = cadenaWhere + " Editorial='" + data.Editorial.Trim() + "' and"; edo = true; } if (data.Precio > 0) { cadenaWhere = cadenaWhere + " Precio=" + data.Precio + " and"; edo = true; } if (data.Imagen != null) { cadenaWhere = cadenaWhere + " Imagen='" + data.Imagen.Trim() + "' and"; edo = true; } if (edo == true) { cadenaWhere = " WHERE " + cadenaWhere.Remove(cadenaWhere.Length - 3, 3); } sql = " SELECT * FROM Libro " + cadenaWhere; cmd.CommandText = sql; DataSet ds = new DataSet(); da.SelectCommand = cmd; da.Fill(dsLibros); con.cerrarConexion(); return(dsLibros); }
public Editar(string operacion, LibroBO oLibroBO) { InitializeComponent(); if (operacion == "Edicion") { btnGuardar.Visible = false; // btnGuardarSeguir.Visible = false; this.BuscarLibro(oLibroBO); } }
private void dgvAlumno_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex > -1) { if (this.dgvAlumno.Columns[e.ColumnIndex].Name == "editar") { LibroBO oLibroBO = new LibroBO(); oLibroBO.ISBN = Convert.ToInt32(this.dgvAlumno.Rows[e.RowIndex].Cells["ISBN"].Value); GUI.Editar ofrmSQLiteEditar = new GUI.Editar("Edicion", oLibroBO); ofrmSQLiteEditar.ShowDialog(); dgvAlumno.DataSource = null; } } }
public void eliminar() { LibroBO oLibroBO = new LibroBO(); CtrlLibro oCtrlLibro = new CtrlLibro(); oLibroBO.ISBN = Convert.ToInt32(txtISBN.Text.Trim()); int i = oCtrlLibro.eliminaLibro(oLibroBO); if (i == 1) { MessageBox.Show("Los datos se eliminaron correctamente"); } else { MessageBox.Show("Los datos no se eliminaron, intenta de nuevo"); } }
public void modificar() { string mensaje = ""; if (txtNombre.Text.Trim().Length == 0) { mensaje = mensaje + "Introduce el Nombre \n"; } if (txtAutor.Text.Trim().Length == 0) { mensaje = mensaje + "Introduce el Autor \n"; } if (txtEditorial.Text.Trim().Length == 0) { mensaje = mensaje + "Introduce la Editorial \n"; } if (txtPrecio.Text.Trim().Length == 0) { mensaje = mensaje + "Introduce el Precio \n"; } if (txtPrecio.Text.Trim().Length == 0) { mensaje = mensaje + "Introduce el Teléfono \n"; } if (mensaje.Trim().Length == 0) { LibroBO oLibroBO = new LibroBO(); CtrlLibro LibroCtrl = new CtrlLibro(); oLibroBO.ISBN = Convert.ToInt32(txtISBN.Text.Trim()); oLibroBO.Titulo = txtNombre.Text.Trim(); oLibroBO.Autor = txtAutor.Text.Trim(); oLibroBO.Editorial = txtEditorial.Text.Trim(); oLibroBO.Precio = Convert.ToInt32(txtPrecio.Text.Trim()); LibroCtrl.modificaLibro(oLibroBO); MessageBox.Show("El libro se modifico correctamete"); } else { MessageBox.Show("Favor de ingresar los siguientes datos:\n" + mensaje); } }
public int eliminaLibro(object obj) { LibroBO data = (LibroBO)obj; cmd = new SQLiteCommand(); dsLibros = new DataSet(); da = new SQLiteDataAdapter(); con = new Conexion(); cmd.Connection = con.establecerConexion(); con.abrirConexion(); sql = "DELETE FROM Libro WHERE ISBN=" + data.ISBN.ToString(); cmd.CommandText = sql; int i = cmd.ExecuteNonQuery(); if (i <= 0) { return(0); } return(1); }
public void BuscarLibro(LibroBO oLibroBO) { //AlumnoBO oAlumnoBO = new AlumnoBO(); CtrlLibro CtrlLibro = new CtrlLibro(); DataTable dt = CtrlLibro.BusquedaLibro(oLibroBO).Tables[0]; if (dt.Rows.Count != 0) { txtISBN.Text = dt.Rows[0]["ISBN"].ToString(); txtNombre.Text = dt.Rows[0]["Titulo"].ToString(); txtAutor.Text = dt.Rows[0]["Autor"].ToString(); txtEditorial.Text = dt.Rows[0]["Editorial"].ToString(); txtPrecio.Text = dt.Rows[0]["Precio"].ToString(); pbImagen.Image = this.AbrirImagen(dt.Rows[0]["Imagen"].ToString()); } else { this.Close(); } }
public void agregar() { string mensaje = ""; if (txtNombre.Text.Trim().Length == 0) { mensaje = mensaje + "Introduce el Nombre \n"; } if (txtAutor.Text.Trim().Length == 0) { mensaje = mensaje + "Introduce el Autor \n"; } if (txtEditorial.Text.Trim().Length == 0) { mensaje = mensaje + "Introduce la Editorial \n"; } if (txtPrecio.Text.Trim().Length == 0) { mensaje = mensaje + "Introduce el Precio \n"; } if (mensaje.Trim().Length == 0) { LibroBO oLibroBO = new LibroBO(); CtrlLibro oServicio = new CtrlLibro(); oLibroBO.Titulo = txtNombre.Text.Trim(); oLibroBO.Autor = txtAutor.Text.Trim(); oLibroBO.Editorial = txtEditorial.Text.Trim(); oLibroBO.Precio = Convert.ToInt32(txtPrecio.Text.Trim()); GuardarImagen(); oLibroBO.Imagen = imagen; oServicio.creaLibro(oLibroBO); MessageBox.Show("El Libro se guardo correctamete"); } else { MessageBox.Show("Favor de ingresar los siguientes datos:\n" + mensaje); } }