/// <summary> /// metodo que se encarga del evento del boton para agregar un cliente /// </summary> /// <returns></returns> public bool agregarCliente() { List <String> alfabeticos = new List <String>(); List <String> alfanumericos = new List <String>(); List <String> numericos = new List <String>(); List <String> correo = new List <String>(); alfabeticos.Add(vista.apellidoNatural); alfabeticos.Add(vista.nombreNatural); correo.Add(vista.correoCliente); alfanumericos.Add(vista.direccionCliente); numericos.Add(vista.cedulaNatural); numericos.Add(vista.codigoPostalCliente); numericos.Add(vista.codTelefono); numericos.Add(vista.telefonoCliente); Regex expresion = new Regex(@"[0-9]{1,9}(\.[0-9]{0,2})?$"); Regex expresion2 = new Regex(@"\d{1,5}\s\w.\s(\b\w*\b\s){1,2}\w*\."); Regex expresion3 = new Regex(@"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z"); if (Validaciones.ValidarCamposVacios(alfabeticos) && Validaciones.ValidarCamposVacios(alfabeticos) && Validaciones.ValidarCamposVacios(numericos) && Validaciones.ValidarCamposVacios(correo)) { if (Validaciones.ValidarCaracteresAlfabeticos(alfabeticos)) { if (Validaciones.ValidarExpresionRegular(correo, expresion3)) { if (Validaciones.ValidarExpresionRegular(numericos, expresion)) { FabricaEntidades fabrica = new FabricaEntidades(); try { Entidad laDireccion = fabrica.ObtenerDireccion(vista.comboPais.SelectedValue, vista.comboEstado.SelectedValue, vista.comboCiudad.SelectedValue, vista.direccionCliente, vista.codigoPostalCliente); Entidad elTelefono = fabrica.ObtenerTelefono(vista.codTelefono, vista.telefonoCliente); Entidad elCliente = fabrica.ObtenerClienteNatural(vista.nombreNatural, vista.apellidoNatural, vista.correoCliente, laDireccion, elTelefono, vista.cedulaNatural); Comando <Entidad, bool> comando = FabricaComandos.CrearComandoAgregarClienteNatural(); if (comando.Ejecutar(elCliente)) { HttpContext.Current.Response.Redirect(RecursoInterfazM2.ListarClientes + RecursoInterfazM2.Codigo_Exito_Agregar); } return(true); } catch (Exception ex) { vista.alertaClase = RecursoInterfazM2.Alerta_Clase_Error; vista.alertaRol = RecursoInterfazM2.Alerta_Rol; vista.alerta = RecursoInterfazM2.Alerta_Html + ex.Message + RecursoInterfazM2.Alerta_Html_Final; return(false); } } else { vista.alertaClase = RecursoInterfazM2.Alerta_Clase_Error; vista.alertaRol = RecursoInterfazM2.Alerta_Rol; vista.alerta = RecursoInterfazM2.Alerta_Html + RecursoInterfazM2.Alerta_Error_Numericos + RecursoInterfazM2.Alerta_Html_Final; return(false); } } else { vista.alertaClase = RecursoInterfazM2.Alerta_Clase_Error; vista.alertaRol = RecursoInterfazM2.Alerta_Rol; vista.alerta = RecursoInterfazM2.Alerta_Html + RecursoInterfazM2.Alerta_Error_Correo + RecursoInterfazM2.Alerta_Html_Final; return(false); } } else { vista.alertaClase = RecursoInterfazM2.Alerta_Clase_Error; vista.alertaRol = RecursoInterfazM2.Alerta_Rol; vista.alerta = RecursoInterfazM2.Alerta_Html + RecursoInterfazM2.Alerta_Error_Alfabeticos + RecursoInterfazM2.Alerta_Html_Final; return(false); } } else { vista.alertaClase = RecursoInterfazM2.Alerta_Clase_Error; vista.alertaRol = RecursoInterfazM2.Alerta_Rol; vista.alerta = RecursoInterfazM2.Alerta_Html + RecursoInterfazM2.Alerta_Error_CamposVacios + RecursoInterfazM2.Alerta_Html_Final; return(false); } }