private void button2_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; try { if ((DescripcionPag.Text.Equals("") || MontoPag.Text.Equals("")) || (DescripcionPag.Text.Equals("") && MontoPag.Text.Equals(""))) { MessageBox.Show("¡No debe haber espacios en blanco!", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { if (edicionPag == 0) { cn.InsertarPagos(DescripcionPag.Text, MontoPag.Text, FechaPag.Text); MessageBox.Show("¡Pago insertado con exito!", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information); MostrarPagos(); DescripcionPag.Text = ""; MontoPag.Text = ""; FechaPag.Value = DateTime.Now; DescripcionPag.Focus(); } else { cn.EditarPagos(idPag, DescripcionPag.Text, MontoPag.Text, FechaPag.Text); MessageBox.Show("¡Pago editado con exito!", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information); MostrarPagos(); edicionPag = 0; idPag = null; BGuardarPag.Text = "Guardar"; DescripcionPag.Text = ""; MontoPag.Text = ""; FechaPag.Value = DateTime.Now; DescripcionPag.Focus(); } } Cursor.Current = Cursors.Default; } catch (System.FormatException) { MessageBox.Show("¡Ingrese cantidades correctas!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); } catch (Exception ex) { MessageBox.Show("¡Ha ocurrido un error! " + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
private void button1_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; if (DPagos.Rows.Count == 0) { MessageBox.Show("¡No puede eliminar ya que no existen registros!", "Vacio", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { if (MessageBox.Show("¿Esta seguro de eliminar el pedido?", "Salir", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { if (ideliPag == null) { MessageBox.Show("¡Haga click en un registro y seguidamente eliminelo!", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { cn.EliminarPagos(ideliPag); MessageBox.Show("¡Ha eliminado el registro con exito!", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information); MostrarPagos(); DescripcionPag.Focus(); if (edicionPag == 1) { edicionPag = 0; BGuardarPag.Text = "Guardar"; DescripcionPag.Text = ""; MontoPag.Text = ""; FechaPag.Value = DateTime.Now; } ideliPag = null; } Cursor.Current = Cursors.Default; } catch (Exception ex) { MessageBox.Show("¡Ha ocurrido un error! " + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } else { MessageBox.Show("¡Ha cancelado la eliminacion!", "Cancelacion", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } }