private void btnAdd_Click(object sender, EventArgs e) { //agregamos un libro con las clases que ya tenemos //try..chatch, no se usa en todo, se recomienda en las interacciones finales, conexion a bd, conversiones, uso de WS, operaciones try { #region procesoant //var nameBook = txtNameBook.Text; //var publishDate = dtpDatePublish.Value;//obtenemos el valor //var numberPage = nupNumberPage.Value; //var salePrice = txtSalePrice.Text; //var purchasePrice = txtPurchasePrice.Text; //var isAvaible = chkIsAvaible.Checked; //var book = new Book //{ // NameBook = nameBook, // DatePublishBook = publishDate, // NumberPages = Convert.ToInt32(numberPage), // SalePrice = (float)Convert.ToDecimal(salePrice), // PurchasePrice= (float)Convert.ToDecimal(purchasePrice), // //PurchasePrice=float.Parse(purchasePrice), // //PurchasePrice=double.Parse(purchasePrice), // IsAvaible=isAvaible //}; #endregion var book = GetBookForm(); if (book != null) { var logic = new BookLogic(); if (logic.AddBook(book)) { ClearForm(); MessageBox.Show("Libro creado"); } else { MessageBox.Show("No se pudo generar registro"); } } } catch (Exception ex) { MessageBox.Show("Ups! se ha generado un error, favor de validar con el administrador"); //throw; //lanza la execpsion } }
private void btnSave_Click(object sender, EventArgs e) { try { var confirmResult = MessageBox.Show("¿Desea agregar?", "Confirmar operación", MessageBoxButtons.YesNo); if (confirmResult == DialogResult.Yes) { Cursor.Current = Cursors.WaitCursor; var book = GetBookForm(); if (book == null) { return; } ///Instancia de capa logica var logic = new BookLogic(); if (logic.AddBook(book)) { ClearForm(); MessageBox.Show("Libro Guardado", "Exito!", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Ups! se ha generado un error"); } } else { //TO DO } } catch (Exception ex) { MessageBox.Show("Ups! se ha generado un error"); SetNotificationTip("Error", "Favor notificar a supervisor", ToolTipIcon.Error); CustomLogger.logger.Error(ex); CustomLogger.logger.Info(ex.Message); CustomLogger.loggerDataBase.Error(ex); } finally { LoadDataGrid(); } }
private void btnAdd_Click(object sender, EventArgs e) { try { //var nameBook = txtNameBook.Text; //var publishDate = dtpDatePublish.Value; //var numberPage = nupNumberPages.Value; //var salePrice = txtSalePrice.Text; //var purchasePrice = txtPurchasePrice.Text; //var isAvaible = chkIsAvaible.Checked; //var book = new Book //{ // NameBook = nameBook, // DatePublishBook = publishDate, // NumberPages = Convert.ToInt32(numberPage), // SalePrice = (float)Convert.ToDecimal(salePrice), // PurchasePrice = (double)Convert.ToDecimal(purchasePrice), // IsAvaible = isAvaible //}; var book = GetBookForm(); if (book != null) { var logic = new BookLogic(); if (logic.AddBook(book)) { ClearForm(); MessageBox.Show("Libro Creado"); LoadData(); } else { MessageBox.Show("No se pudo generar registro"); } } } catch (Exception ex) { MessageBox.Show("Ups! se ha generado un error, Favor de validar con el adminsitrador"); Logger.logger.Error(ex);// se nanda la excepcion al log } }
private void btnSave_Click(object sender, EventArgs e) { try { var book = GetBookForm(); if (book == null) { return; } ///Instancia de capa logica var logic = new BookLogic(); if (logic.AddBook(book)) { ClearForm(); MessageBox.Show("Libro Guardado", "Exito!", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Ups! se ha generado un error"); } } catch (Exception ex) { MessageBox.Show("Ups! se ha generado un error"); Logger.logger.Error(ex); Logger.logger.Info(ex.Message); } finally { LoadDataGrid(); } }