private void cmdEliminar_Click(object sender, EventArgs e) { try { DialogResult Opcion; Opcion = MessageBox.Show("Desea Eliminar estos registros", "Sistema S&B", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (Opcion == DialogResult.Yes) { string Codigo; string Rpta = ""; foreach (DataGridViewRow row in dgvVendedor.Rows) { if (Convert.ToBoolean(row.Cells[0].Value)) { Codigo = Convert.ToString(row.Cells[1].Value); Rpta = NVendedor.Eliminar(Convert.ToInt32(Codigo)); if (Rpta.Equals("OK")) { MensajeOk("El Registro se Eliminó con Exito"); } else { MensajeError(Rpta); } } } Mostrar(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
//Método buscarnombre private void BuscarNombre() { dgvVendedor.DataSource = NVendedor.BuscarNombre(Convert.ToString(txtBuscar.Text)); OcultarColumnas(); lblTotal.Text = "Cantidad de Registros: " + Convert.ToString(dgvVendedor.Rows.Count); }
private void Mostrar() { dgvVendedor.DataSource = NVendedor.mostrar(); OcultarColumnas(); lblTotal.Text = "Cantidad de Registros: " + Convert.ToString(dgvVendedor.Rows.Count); }
private void btnGuardar_Click(object sender, EventArgs e) { DateTime FechaActual = DateTime.Now; try { string rpta = ""; if (txtCodigo.Text == string.Empty | txtNombre.Text == string.Empty) { if (txtCodigo.Text == string.Empty) { MensajeError("Falta ingresar algunos datos, serán remarcados"); errorIcono.SetError(txtCodigo, "Ingrese el código de la presentación"); } if (txtNombre.Text == string.Empty) { MensajeError("Falta ingresar algunos datos, serán remarcados"); errorIcono.SetError(txtNombre, "Ingrese el nombre de la presentación"); } if (txtPorc.Text == string.Empty) { MensajeError("Falta ingresar algunos datos, serán remarcados"); errorIcono.SetError(txtNombre, "Ingrese el porcentaje de comisión del vendedor así sea cero 0"); } } else { if (IsNuevo) { rpta = NVendedor.Insertar(Convert.ToInt32(txtCodigo.Text), txtNombre.Text, Convert.ToInt32(txtPorc.Text)); } else { rpta = NVendedor.Editar(Convert.ToInt32(txtCodigo.Text), txtNombre.Text, Convert.ToInt32(txtPorc.Text)); } if (rpta.Equals("OK")) { if (IsNuevo) { MensajeOk("El registro fue ingresado con exito"); } else { MensajeOk("El registro fue modificado con exito"); } } else { MensajeError(rpta); } IsNuevo = false; IsEditar = false; Botones(); LimpiarFrm(); Mostrar(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }