private bool Comprobaciones() { bool result = true; List <Control> listaControles = new List <Control>(); listaControles.Add(this.txtNombre); listaControles.Add(this.txtTelefono); listaControles.Add(this.ListaCargo); listaControles = ComprobacionesControles.ComprobacionesInsertar(listaControles); if (listaControles.Count > 0) { result = false; int contador = 0; foreach (Control control in listaControles) { foreach (Control con in this.Controls) { if (con.Name == control.Name) { this.errorProvider1.SetError(control, "Campo obligatorio"); contador += 1; break; } } if (contador > listaControles.Count) { break; } } } return(result); }
private bool Comprobaciones() { bool result = true; try { List <Control> listaControles = new List <Control>(); listaControles.Add(this.txtNombre); listaControles.Add(this.txtPrecio); listaControles.Add(this.ListaTipoBebidas); listaControles = ComprobacionesControles.ComprobacionesInsertar(listaControles); if (listaControles.Count > 0) { result = false; int contador = 0; foreach (Control control in listaControles) { foreach (Control con in this.Controls) { if (con.Name == control.Name) { this.errorProvider1.SetError(control, "Campo obligatorio"); contador += 1; break; } } if (contador > listaControles.Count) { break; } } } } catch (Exception ex) { Mensajes.MensajeErrorCompleto(this.Name, "Comprobaciones", "Hubo un error al comprobar controles", ex.Message); } return(result); }