Exemplo n.º 1
0
 private List <Error> ValidarDatos()
 {
     try
     {
         List <Error> Errores = new List <Error>();
         int          Aux     = 0;
         if (string.IsNullOrEmpty(this.txtTipoUsuario.Text.Trim()))
         {
             Errores.Add(new Error {
                 Numero = (Aux += 1), Descripcion = "Ingrese un tipo usuario válida.", ControlSender = this.txtTipoUsuario
             });
         }
         else
         if (!Validar.IsValidName(this.txtTipoUsuario.Text))
         {
             Errores.Add(new Error {
                 Numero = (Aux += 1), Descripcion = "Ingrese un tipo usuario válida.", ControlSender = this.txtTipoUsuario
             });
         }
         return(Errores);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 2
0
 private void btnBuscar_Click(object sender, EventArgs e)
 {
     try
     {
         if (!string.IsNullOrEmpty(this.txtBusqueda.Text.Trim()))
         {
             if (Validar.IsValidName(txtBusqueda.Text.Trim()))
             {
                 this.BusquedaServicio(this.txtBusqueda.Text.Trim());
             }
             else
             {
                 this.txtBusqueda.Text = string.Empty;
             }
         }
         else
         {
             this.LlenarGridCatServicio(false);
         }
     }
     catch (Exception ex)
     {
         LogError.AddExcFileTxt(ex, "frmCatServicios ~ btnBuscar_Click");
         MessageBox.Show(Comun.MensajeError, Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 3
0
 private List <Error> ValidarDatos()
 {
     try
     {
         List <Error> ListaErrores = new List <Error>();
         int          Aux          = 0;
         if (string.IsNullOrEmpty(this.txtNombre.Text.Trim()))
         {
             ListaErrores.Add(new Error {
                 Numero = (Aux += 1), Descripcion = "Debe ingresar el nombre.", ControlSender = this.txtNombre
             });
         }
         else
         {
             if (!Validar.IsValidName(this.txtNombre.Text.Trim()))
             {
                 ListaErrores.Add(new Error {
                     Numero = (Aux += 1), Descripcion = "Debe ingresar un nombre valido.", ControlSender = this.txtNombre
                 });
             }
         }
         if (string.IsNullOrEmpty(this.txtApePat.Text.Trim()))
         {
             ListaErrores.Add(new Error {
                 Numero = (Aux += 1), Descripcion = "Debe ingresar su apellido paterno.", ControlSender = this.txtApePat
             });
         }
         else
         {
             if (!Validar.IsValidName(this.txtApePat.Text.Trim()))
             {
                 ListaErrores.Add(new Error {
                     Numero = (Aux += 1), Descripcion = "Debe ingresar un apellido paterno valido.", ControlSender = this.txtApePat
                 });
             }
         }
         if (string.IsNullOrEmpty(this.txtApeMat.Text.Trim()))
         {
             ListaErrores.Add(new Error {
                 Numero = (Aux += 1), Descripcion = "Debe ingresar su apellido materno.", ControlSender = this.txtApeMat
             });
         }
         else
         {
             if (!Validar.IsValidName(this.txtApeMat.Text.Trim()))
             {
                 ListaErrores.Add(new Error {
                     Numero = (Aux += 1), Descripcion = "Debe ingresar su apellido materno valido.", ControlSender = this.txtApeMat
                 });
             }
         }
         return(ListaErrores);
     }
     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.txtTagImagen.Text))
         {
             Errores.Add(new Error {
                 Numero = (Aux += 1), Descripcion = "Ingrese el nombre de la imagen.", ControlSender = this.txtTagImagen
             });
         }
         else
         {
             if (!Validar.IsValidName(this.txtTagImagen.Text.Trim()))
             {
                 Errores.Add(new Error {
                     Numero = (Aux += 1), Descripcion = "Ingrese el nombre de la imagen válido.", ControlSender = this.txtTagImagen
                 });
             }
         }
         if (string.IsNullOrEmpty(this.txtAlt.Text))
         {
             Errores.Add(new Error {
                 Numero = (Aux += 1), Descripcion = "Ingrese la etiqueta Alt.", ControlSender = this.txtAlt
             });
         }
         else
         {
             if (!Validar.IsValidDescripcion(this.txtAlt.Text.Trim()))
             {
                 Errores.Add(new Error {
                     Numero = (Aux += 1), Descripcion = "Ingrese la etiqueta Alt válido.", ControlSender = this.txtAlt
                 });
             }
         }
         if (string.IsNullOrEmpty(this.txtTitle.Text))
         {
             Errores.Add(new Error {
                 Numero = (Aux += 1), Descripcion = "Ingrese la etiqueta Title.", ControlSender = this.txtTitle
             });
         }
         else
         {
             if (!Validar.IsValidDescripcion(this.txtTitle.Text.Trim()))
             {
                 Errores.Add(new Error {
                     Numero = (Aux += 1), Descripcion = "Ingrese la etiqueta Title válido.", ControlSender = this.txtTitle
                 });
             }
         }
         if (string.IsNullOrEmpty(this.txtNombreImagen.Text))
         {
             Errores.Add(new Error {
                 Numero = (Aux += 1), Descripcion = "Ingrese el nombre de la imagen web.", ControlSender = this.txtNombreImagen
             });
         }
         else
         {
             if (!Validar.IsValidDescripcion(this.txtNombreImagen.Text.Trim()))
             {
                 Errores.Add(new Error {
                     Numero = (Aux += 1), Descripcion = "Ingrese el nombre de la imagen web válido.", ControlSender = this.txtNombreImagen
                 });
             }
         }
         if (this.pbImagen.Image == null)
         {
             Errores.Add(new Error {
                 Numero = (Aux += 1), Descripcion = "Seleccione una imagen.", ControlSender = this.pbImagen
             });
         }
         return(Errores);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 6
0
        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;
            }
        }
Exemplo n.º 7
0
 private List <Error> ValidarDatos()
 {
     try
     {
         List <Error> Errores = new List <Error>();
         int          Aux = 0, ID = 0;
         if (string.IsNullOrEmpty(this.txtNombre.Text.Trim()))
         {
             Errores.Add(new Error {
                 Numero = (Aux += 1), Descripcion = "Debe ingresar un nombre del usuario.", ControlSender = this.txtNombre
             });
         }
         else
         {
             if (!Validar.IsValidName(this.txtNombre.Text.Trim()))
             {
                 Errores.Add(new Error {
                     Numero = (Aux += 1), Descripcion = "Debe ingresar un nombre del usuario 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 del usuario.", ControlSender = this.txtApellidoPat
             });
         }
         else
         {
             if (!Validar.IsValidName(this.txtApellidoPat.Text.Trim()))
             {
                 Errores.Add(new Error {
                     Numero = (Aux += 1), Descripcion = "Debe ingresar un apellido paterno del usuario válido.", ControlSender = this.txtApellidoPat
                 });
             }
         }
         if (string.IsNullOrEmpty(this.txtApellidoMat.Text.Trim()))
         {
             Errores.Add(new Error {
                 Numero = (Aux += 1), Descripcion = "Debe ingresar el apellido materno del usuario.", ControlSender = this.txtApellidoMat
             });
         }
         else
         {
             if (!Validar.IsValidName(this.txtApellidoMat.Text.Trim()))
             {
                 Errores.Add(new Error {
                     Numero = (Aux += 1), Descripcion = "Debe ingresar un apellido materno del usuario válido.", ControlSender = this.txtApellidoMat
                 });
             }
         }
         //Validar Combo Tipo Usuario
         if (this.cmbTipoUsuario.SelectedIndex == -1)
         {
             Errores.Add(new Error {
                 Numero = (Aux += 1), Descripcion = "Seleccione una opción en Tipo de Usuario", ControlSender = this.cmbTipoUsuario
             });
         }
         else
         {
             int.TryParse(this.cmbTipoUsuario.SelectedValue.ToString(), out ID);
             if (ID == 0)
             {
                 Errores.Add(new Error {
                     Numero = (Aux += 1), Descripcion = "Seleccione una opción en Tipo de Usuario.", ControlSender = this.cmbTipoUsuario
                 });
             }
         }
         //Validar Combo Puestos
         if (this.cmbCatPuesto.SelectedIndex == -1)
         {
             Errores.Add(new Error {
                 Numero = (Aux += 1), Descripcion = "Seleccione una opción en Puesto", ControlSender = this.cmbCatPuesto
             });
         }
         else
         {
             int.TryParse(this.cmbCatPuesto.SelectedValue.ToString(), out ID);
             if (ID == 0)
             {
                 Errores.Add(new Error {
                     Numero = (Aux += 1), Descripcion = "Seleccione una opción en Puesto.", ControlSender = this.cmbCatPuesto
                 });
             }
         }
         //Validar Combo Categorias
         if (this.cmbCategoriaPuesto.SelectedIndex == -1)
         {
             Errores.Add(new Error {
                 Numero = (Aux += 1), Descripcion = "Seleccione una opción en Categoría del puesto", ControlSender = this.cmbCategoriaPuesto
             });
         }
         else
         {
             CategoriasPuesto AuxCat = (CategoriasPuesto)this.cmbCategoriaPuesto.SelectedItem;
             if (string.IsNullOrEmpty(AuxCat.IDCategoria.Trim()))
             {
                 Errores.Add(new Error {
                     Numero = (Aux += 1), Descripcion = "Seleccione una opción en Categoría del puesto", ControlSender = this.cmbCategoriaPuesto
                 });
             }
         }
         if (!string.IsNullOrEmpty(this.txtCalle.Text.Trim()))
         {
             if (!Validar.IsValidDescripcion(this.txtCalle.Text.Trim()))
             {
                 Errores.Add(new Error {
                     Numero = (Aux += 1), Descripcion = "Debe ingresar un dato válido para <<Calle>>.", ControlSender = this.txtCalle
                 });
             }
         }
         if (!string.IsNullOrEmpty(this.txtColonia.Text.Trim()))
         {
             if (!Validar.IsValidDescripcion(this.txtColonia.Text.Trim()))
             {
                 Errores.Add(new Error {
                     Numero = (Aux += 1), Descripcion = "Debe ingresar un dato válido para <<Colonia>>.", ControlSender = this.txtColonia
                 });
             }
         }
         if (!string.IsNullOrEmpty(this.txtNumero.Text.Trim()))
         {
             if (!Validar.IsValidOnlyNumber(this.txtNumero.Text.Trim()))
             {
                 Errores.Add(new Error {
                     Numero = (Aux += 1), Descripcion = "Debe ingresar un dato válido para <<Número>>.", ControlSender = this.txtNumero
                 });
             }
         }
         if (this.dgvSucursal.SelectedRows.Count != 1)
         {
             Errores.Add(new Error {
                 Numero = (Aux += 1), Descripcion = "Seleccione la sucursal actual del usuario.", ControlSender = this.txtNumero
             });
         }
         return(Errores);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 8
0
        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;
            }
        }