private void dgvbanco_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex != -1) { if (dgvbanco.Rows[e.RowIndex].Cells["bmodificar"].Selected) { mensaje = ""; using (nb = new NBanco()) { nb.state = EntityState.Modificar; nb.IdBanco = Convert.ToInt32(dgvbanco.Rows[e.RowIndex].Cells["bid"].Value); nb.Nom_banco = dgvbanco.Rows[e.RowIndex].Cells["bnombre"].Value.ToString().ToUpper(); mensaje = nb.GuardarCambios(); Fill_Banco(); Messages.M_info(mensaje); nb.state = EntityState.Guardar; } } else if (dgvbanco.Rows[e.RowIndex].Cells["beliminar"].Selected) { mensaje = ""; using (nb = new NBanco()) { string nombre_ban = dgvbanco.CurrentRow.Cells["bnombre"].Value.ToString(); DialogResult result = Messages.M_question("¿Está seguro de eliminar " + nombre_ban + "?"); if (result == DialogResult.Yes) { nb.state = EntityState.Remover; nb.IdBanco = Convert.ToInt32(dgvbanco.Rows[e.RowIndex].Cells["bid"].Value); mensaje = nb.GuardarCambios(); if (mensaje.Contains("esta asignado.")) { Messages.M_error(mensaje); } else { Messages.M_info(mensaje); Fill_Banco(); } nb.state = EntityState.Guardar; } } } } }
private void btnguardar_Click(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(txtBanco.Text)) { ValidateChildren(); return; } mensaje = ""; using (nb = new NBanco()) { nb.Nom_banco = txtBanco.Text.Trim().ToUpper(); mensaje = nb.GuardarCambios(); } txtBanco.Text = string.Empty; txtBanco.Focus(); Fill_Banco(); }