private List <Error> ValidarDatos() { try { List <Error> Errores = new List <Error>(); int Aux = 0; if (string.IsNullOrEmpty(this.txtNombreSucursal.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese el nombre de la sucursal.", ControlSender = this.txtNombreSucursal }); } else { if (!Validar.IsValidDescripcion(this.txtNombreSucursal.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese un nombre de sucursal válido.", ControlSender = this.txtNombreSucursal }); } } if (this.cmbEmpresa.SelectedIndex == -1) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Debe seleccionar la empresa de la lista.", ControlSender = this.cmbEmpresa }); } else { int IDEmpresa = 0; int.TryParse(this.cmbEmpresa.SelectedValue.ToString(), out IDEmpresa); if (IDEmpresa == 0) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Debe seleccionar la empresa de la lista.", ControlSender = this.cmbEmpresa }); } } if (this.cmbTipoSucursal.SelectedIndex == -1) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Debe seleccionar el tipo de sucursal de la lista.", ControlSender = this.cmbTipoSucursal }); } else { int IDTipoSucursal = 0; int.TryParse(this.cmbTipoSucursal.SelectedValue.ToString(), out IDTipoSucursal); if (IDTipoSucursal == 0) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Debe seleccionar el tipo de sucursal de la lista.", ControlSender = this.cmbTipoSucursal }); } } if (this.cmbPais.SelectedIndex == -1) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Debe seleccionar un país 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 un país de la lista.", ControlSender = this.cmbPais }); } } if (this.cmbEstado.SelectedIndex == -1) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Debe seleccionar un 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 un estado de la lista.", ControlSender = this.cmbEstado }); } } if (this.cmbMunicipio.SelectedIndex == -1) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Debe seleccionar un 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 un municipio de la lista.", ControlSender = this.cmbMunicipio }); } } if (!string.IsNullOrEmpty(this.txtCodigoPostal.Text.Trim())) { if (!Validar.IsValidZipCode(this.txtCodigoPostal.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese un código postal válido.", ControlSender = this.txtCodigoPostal }); } } 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 (!string.IsNullOrEmpty(this.txtDireccion.Text.Trim())) { if (!Validar.IsValidDescripcion(this.txtDireccion.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese una dirección válida.", ControlSender = this.txtDireccion }); } } if (!ValidarHorario()) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Seleccione al menos un horario.", ControlSender = this.txtDireccion }); } if (string.IsNullOrEmpty(this.txtRFC.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese el RFC.", 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 representante.", ControlSender = this.txtRepresentante }); } else { if (!Validar.IsValidName(this.txtRepresentante.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese un nombre de representate válido.", ControlSender = this.txtRepresentante }); } } if (string.IsNullOrEmpty(this.txtRegimenFiscal.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese el régimen fiscal.", ControlSender = this.txtRegimenFiscal }); } else { if (!Validar.IsValidName(this.txtRegimenFiscal.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese un régimen fiscal válido.", ControlSender = this.txtRegimenFiscal }); } } 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.txtRazonSocial.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese la razón social.", ControlSender = this.txtRazonSocial }); } if (string.IsNullOrEmpty(txtNombreComercial.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese el nombre comercial.", ControlSender = this.txtNombreComercial }); } if (string.IsNullOrEmpty(txtRFC.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese el RFC.", ControlSender = this.txtRFC }); } else { if (!Validar.IsValidRFC(this.txtRFC.Text)) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese un RFC válido.", ControlSender = this.txtRFC }); } } if (string.IsNullOrEmpty(this.txtPorcentajeIva.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese el porcentaje de IVA.", ControlSender = this.txtPorcentajeIva }); } if (string.IsNullOrEmpty(this.txtPagoDiasFestivos.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese el porcentaje de pagos dias festivos.", ControlSender = this.txtPagoDiasFestivos }); } if (string.IsNullOrEmpty(this.txtPagoDiasVaciones.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese el porcentaje de pagos dias vacaciones.", ControlSender = this.txtPagoDiasVaciones }); } if (string.IsNullOrEmpty(this.txtPagosDiaDomingo.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese el porcentaje de pago dias domingo.", ControlSender = this.txtPagosDiaDomingo }); } if (string.IsNullOrEmpty(txtFaltasRetrasos.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese un numero dia válido", ControlSender = this.txtFaltasRetrasos }); } else { if (!Validar.IsValidOnlyNumber(this.txtFaltasRetrasos.Text)) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese un numero dia válido.", ControlSender = this.txtFaltasRetrasos }); } } if (string.IsNullOrEmpty(this.txtPorcDesc.Text.Trim())) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese el porcentaje de descuento por cumpleaños.", ControlSender = this.txtPorcDesc }); } else { decimal Porc = 0; if (!decimal.TryParse(this.txtPorcDesc.Text.Trim(), out Porc)) { Errores.Add(new Error { Numero = (Aux += 1), Descripcion = "Ingrese un dato válido para porcentaje de descuento por cumpleaños.", ControlSender = this.txtPorcDesc }); } } return(Errores); } catch (Exception ex) { throw ex; } }