private void button2_Click(object sender, EventArgs e) { try { DialogResult Opcion; Opcion = MessageBox.Show("Realmente Desea Eliminar los Registros", "Sistema de Ventas", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (Opcion == DialogResult.OK) { string Codigo; string Rpta = ""; foreach (DataGridViewRow row in dataGridView1.Rows) { if (Convert.ToBoolean(row.Cells[0].Value)) { Codigo = Convert.ToString(row.Cells[1].Value); Rpta = NAño.Eliminar(Convert.ToInt32(Codigo)); if (Rpta.Equals("OK")) { this.mensajeok("Se Eliminó Correctamente el registro"); } else { this.mensajeerror(Rpta); } } } this.buscarnombre(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
private void buscarnombre() { this.dataGridView1.DataSource = NAño.buscarnombre(this.txtbuscar.Text); this.OcultarColumnas(); label10.Text = "Total de Registros: " + Convert.ToString(dataGridView1.Rows.Count); }
private void Mostrar() { this.dataGridView1.DataSource = NAño.Mostrar(); this.OcultarColumnas(); label10.Text = "Total de Registros: " + Convert.ToString(dataGridView1.Rows.Count); }
private void btnGuardar_Click(object sender, EventArgs e) { try { string rpta = ""; if (this.txtnombre.Text == string.Empty) { mensajeerror("Falta ingresar algunos datos, serán remarcados"); if (this.textBox1.Text.Length == 0) { errorProvider1.SetError(this.textBox1, "ingrese el Año"); } else { errorProvider1.SetError(this.textBox1, ""); } if (this.txtnombre.Text.Length == 0) { errorProvider1.SetError(this.txtnombre, "ingrese el Nombre del Año"); } else { errorProvider1.SetError(this.txtnombre, ""); } } else { if (this.isnuevo) { rpta = NAño.Insertar(this.txtnombre.Text.Trim().ToUpper(), textBox1.Text); } else { rpta = NAño.Editar(Convert.ToInt32(this.txtiddamnificado.Text), this.txtnombre.Text.Trim().ToUpper(), this.textBox1.Text.Trim().ToUpper()); } if (rpta.Equals("OK")) { if (this.isnuevo) { this.mensajeok("Se Insertó de forma correcta el registro"); } else { this.mensajeok("Se Actualizó de forma correcta el registro"); } } else { this.mensajeerror(rpta); } this.isnuevo = false; this.iseditar = false; this.botones(); this.Limpiar(); this.buscarnombre(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }