private List <Error> ValidarDatos() { try { List <Error> Errores = new List <Error>(); int Aux = 0, ID = 0; //Validar Razon Social del Proveedor if (string.IsNullOrEmpty(this.txtNombre.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese el nombre del instructor.", ControlSender = this.txtNombre }); } else { if (!Validar.IsValidDescripcion(this.txtNombre.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese un nombre del instructor válido.", ControlSender = this.txtNombre }); } } //Validar Nombre Comercial del Proveedor if (string.IsNullOrEmpty(this.txtApellidoPat.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese el apellido paterno.", ControlSender = this.txtApellidoPat }); } else { if (!Validar.IsValidDescripcion(this.txtApellidoPat.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese el apellido paterno válido.", ControlSender = this.txtApellidoPat }); } } //Validar Regimen Fiscal del Proveedor if (string.IsNullOrEmpty(this.txtApellidoMat.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese el apellido materno.", ControlSender = this.txtApellidoMat }); } else { if (!Validar.IsValidDescripcion(this.txtApellidoMat.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese el apellido materno válido.", ControlSender = this.txtApellidoMat }); } } //Validar Correo del Proveedor if (!string.IsNullOrEmpty(this.txtCorreo.Text.Trim())) { if (!Validar.IsValidMail(this.txtCorreo.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese un correo válido.", ControlSender = this.txtCorreo }); } } //Validar Numero Telefono del Proveedor if (!string.IsNullOrEmpty(this.txtTelefono.Text.Trim())) { if (!Validar.IsValidPhoneNumber(this.txtTelefono.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese un número telefónico válido.", ControlSender = this.txtTelefono }); } } if (this.cmbGenero.SelectedIndex == -1) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Seleccione una opción del genero", ControlSender = this.cmbGenero }); } else { int.TryParse(this.cmbGenero.SelectedValue.ToString(), out ID); if (ID == 0) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Seleccione una opción de genero.", ControlSender = this.cmbGenero }); } } if (this.dtpFechaNac.Value > DateTime.Today.AddYears(-15)) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese una fecha de nacimiento válida.", ControlSender = this.dtpFechaNac }); } return(Errores); } catch (Exception ex) { throw ex; } }
private List <Error> ValidarDatos() { try { List <Error> Errores = new List <Error>(); int Aux = 0; //Validar Razon Social del Proveedor if (string.IsNullOrEmpty(this.txtRazonSocial.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese la razón social del proveedor.", ControlSender = this.txtRazonSocial }); } else { if (!Validar.IsValidDescripcion(this.txtRazonSocial.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese una razón social válida.", ControlSender = this.txtRazonSocial }); } } //Validar Nombre Comercial del Proveedor if (string.IsNullOrEmpty(this.txtNombreComercial.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese el nombre comercial del proveedor.", ControlSender = this.txtNombreComercial }); } else { if (!Validar.IsValidDescripcion(this.txtNombreComercial.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese un nombre comercial válido.", ControlSender = this.txtNombreComercial }); } } //Validar Regimen Fiscal del Proveedor if (string.IsNullOrEmpty(this.txtRegimenFiscal.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese el regimen fiscal del proveedor.", ControlSender = this.txtRegimenFiscal }); } else { if (!Validar.IsValidDescripcion(this.txtRegimenFiscal.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese un regimen fiscal válido.", ControlSender = this.txtRegimenFiscal }); } } //Validar RFC del Proveedor if (string.IsNullOrEmpty(this.txtRFC.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese el RFC del proveedor.", ControlSender = this.txtRFC }); } else { if (!Validar.IsValidRFC(this.txtRFC.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese un RFC válido.", ControlSender = this.txtRFC }); } } //if (string.IsNullOrEmpty(this.txtRepresentante.Text.Trim())) // Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese el nombre del agente de ventas.", ControlSender = this.txtRepresentante }); //Validar Representante del Proveedor if (!string.IsNullOrEmpty(this.txtRepresentante.Text.Trim())) { if (!Validar.IsValidName(this.txtRepresentante.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese un nombre válido.", ControlSender = this.txtRepresentante }); } } //Validar Correo del Proveedor if (!string.IsNullOrEmpty(this.txtCorreo.Text.Trim())) { if (!Validar.IsValidMail(this.txtCorreo.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese un correo válido.", ControlSender = this.txtCorreo }); } } //Validar Numero Telefono del Proveedor if (!string.IsNullOrEmpty(this.txtTelefono.Text.Trim())) { if (!Validar.IsValidPhoneNumber(this.txtTelefono.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese un número telefónico válido.", ControlSender = this.txtTelefono }); } } //Validar Calle del Proveedor if (!string.IsNullOrEmpty(this.txtCalle.Text.Trim())) { if (!Validar.IsValidDescripcion(this.txtCalle.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese la calle válida.", ControlSender = this.txtCalle }); } } //Validar Colonia del Proveedor if (!string.IsNullOrEmpty(this.txtColonia.Text.Trim())) { if (!Validar.IsValidDescripcion(this.txtColonia.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese la Colonia válida.", ControlSender = this.txtColonia }); } } //Validar Numero de Casa del Proveedor if (!string.IsNullOrEmpty(this.txtNumeroCasa.Text.Trim())) { if (!Validar.IsValidOnlyNumber(this.txtNumeroCasa.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese la Colonia válida.", ControlSender = this.txtNumeroCasa }); } } //Validar Codigo Postal del Proveedor if (!string.IsNullOrEmpty(this.txtCodigoPostal.Text.Trim())) { if (!Validar.IsValidZipCode(this.txtCodigoPostal.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese el código postal válida.", ControlSender = this.txtCodigoPostal }); } } //Validar Combo Pais del Proveedor if (this.cmbPais.SelectedIndex == -1) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Debe seleccionar el Pais de la lista.", ControlSender = this.cmbPais }); } else { int IDPais = 0; int.TryParse(this.cmbPais.SelectedValue.ToString(), out IDPais); if (IDPais == 0) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Debe seleccionar el Pais de la lista.", ControlSender = this.cmbPais }); } } //Validar Combo Estados del Proveedor if (this.cmbEstado.SelectedIndex == -1) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Debe seleccionar el Estado de la lista.", ControlSender = this.cmbEstado }); } else { int IDEstado = 0; int.TryParse(this.cmbEstado.SelectedValue.ToString(), out IDEstado); if (IDEstado == 0) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Debe seleccionar el Estado de la lista.", ControlSender = this.cmbEstado }); } } //Validar Combo Municipio del Proveedor if (this.cmbMunicipio.SelectedIndex == -1) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Debe seleccionar el Municipio de la lista.", ControlSender = this.cmbMunicipio }); } else { int IDMunicipio = 0; int.TryParse(this.cmbMunicipio.SelectedValue.ToString(), out IDMunicipio); if (IDMunicipio == 0) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Debe seleccionar el Municipio de la lista.", ControlSender = this.cmbMunicipio }); } } return(Errores); } catch (Exception ex) { throw ex; } }
private List <Error> ValidarDatos() { try { List <Error> Errores = new List <Error>(); int Aux = 0; if (string.IsNullOrEmpty(this.txtNombre.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Debe ingresar un nombre de cliente.", ControlSender = this.txtNombre }); } else { if (!Validar.IsValidName(this.txtNombre.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Debe ingresar un nombre de cliente válido.", ControlSender = this.txtNombre }); } } if (string.IsNullOrEmpty(this.txtApellidoPat.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Debe ingresar el apellido paterno de cliente.", ControlSender = this.txtApellidoPat }); } else { if (!Validar.IsValidName(this.txtApellidoPat.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Debe ingresar un apellido paterno válido.", ControlSender = this.txtApellidoPat }); } } if (!string.IsNullOrEmpty(this.txtApellidoMat.Text.Trim())) { if (!Validar.IsValidName(this.txtApellidoMat.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Debe ingresar un apellido materno válido.", ControlSender = this.txtApellidoMat }); } } if (this.cmbGenero.SelectedIndex == -1) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Debe seleccionar un género de la lista.", ControlSender = this.cmbGenero }); } else { int IDGenero = 0; int.TryParse(this.cmbGenero.SelectedValue.ToString(), out IDGenero); if (IDGenero == 0) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Debe seleccionar un género de la lista.", ControlSender = this.cmbGenero }); } } if (!string.IsNullOrEmpty(this.txtCorreo.Text.Trim())) // Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Debe ingresar el correo electrónico del cliente.", ControlSender = this.txtCorreo }); //else { if (!Validar.IsValidMail(this.txtCorreo.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Debe ingresar una dirección de correo electrónico válida.", ControlSender = this.txtCorreo }); } } if (string.IsNullOrEmpty(this.txtTelefono.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Debe ingresar un número telefónico del cliente.", ControlSender = this.txtTelefono }); } else { if (!Validar.IsValidPhoneNumber(this.txtTelefono.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Debe ingresar un número telefónico válido.", ControlSender = this.txtTelefono }); } } if (this.dtpFechaNac.Value > DateTime.Today.AddYears(-15)) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese una fecha de nacimiento válida.", ControlSender = this.dtpFechaNac }); } return(Errores); } catch (Exception ex) { throw ex; } }