private void btnSave_Click(object sender, EventArgs e) { try { string rpta = ""; if (this.txtName.Text == string.Empty || txtLastname.Text == String.Empty) { MensajeError("Falta Ingresar algunos datos, serán remarcados"); errorIcono.SetError(txtName, "Ingrese un Nombre"); errorIcono.SetError(txtLastname, "Ingrese Apellidps"); } else { rpta = Ncustumer.Insert(this.txtName.Text.Trim().ToUpper(), this.txtLastname.Text.Trim().ToUpper(), this.txtPhone.Text.Trim(), this.txtMovil.Text.Trim(), this.txtEmail.Text.Trim().ToUpper(), this.txtComments.Text.Trim().ToUpper(), Convert.ToInt32(this.cbTypeCustumer.SelectedValue)); if (rpta.Equals("OK")) { this.MensajeOk("Se inserto de forma correcta el registro"); } else { this.MensajeError(rpta); } this.Limpiar(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
private void btnEliminar_Click(object sender, EventArgs e) { try { DialogResult Opcion; Opcion = MessageBox.Show("Realmente desea eliminar registros", "Despacho Valles", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (Opcion == DialogResult.OK) { string Codigo; string Rpta = ""; foreach (DataGridViewRow row in dataListado.Rows) { if (Convert.ToBoolean(row.Cells[0].Value)) { Codigo = Convert.ToString(row.Cells[1].Value); Rpta = Ncustumer.Delete(Convert.ToInt32(Codigo)); if (Rpta.Equals("OK")) { this.MensajeOk("se elimino correctamete el registro"); } else { this.MensajeError(Rpta); } } } this.Mostar(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
//metodo mostrar private void Mostar() { this.dataListado.DataSource = Ncustumer.Show(); this.OcultarColumnas(); lbltotal.Text = "Total de Registros: " + Convert.ToString(dataListado.Rows.Count); }
//metodo buscar por el nombre private void BuscarNombre() { this.dataListado.DataSource = Ncustumer.TextSearch(this.txtBuscar.Text); this.OcultarColumnas(); lbltotal.Text = "Total de Registros: " + Convert.ToString(dataListado.Rows.Count); }