/// <summary> /// metodo para manejar el evento para agregar un cliente juridico /// </summary> /// <returns>booleano que refleja el exito de la operacion</returns> public bool agregarEmpresa() { List <String> alfabeticos = new List <String>(); List <String> alfanumericos = new List <String>(); List <String> numericos = new List <String>(); alfabeticos.Add(vista.apellidoContacto); alfabeticos.Add(vista.nombreContacto); alfanumericos.Add(vista.direccionEmpresa); alfanumericos.Add(vista.nombreEmpresa); alfanumericos.Add(vista.rifEmpresa); numericos.Add(vista.cedulaContacto); numericos.Add(vista.codTelefono); numericos.Add(vista.telefonoCliente); Regex expresion = new Regex(@"[0-9]{1,9}(\.[0-9]{0,2})?$"); if (Validaciones.ValidarCamposVacios(alfabeticos) && Validaciones.ValidarCamposVacios(alfabeticos) && Validaciones.ValidarCamposVacios(numericos)) { if (Validaciones.ValidarCaracteresAlfabeticos(alfabeticos)) { if (Validaciones.ValidarExpresionRegular(numericos, expresion)) { FabricaEntidades fabrica = new FabricaEntidades(); List <Entidad> contactos = new List <Entidad>(); try { Entidad direccion = fabrica.ObtenerDireccion(vista.comboPais.SelectedValue, vista.comboEstado.SelectedValue, vista.comboCiudad.SelectedValue, vista.direccionEmpresa, vista.codigoPostalEmpresa); Entidad telefono = fabrica.ObtenerTelefono(vista.codTelefono, vista.telefonoCliente); Entidad contacto = fabrica.ObtenerContacto(vista.cedulaContacto, vista.nombreContacto, vista.apellidoContacto, vista.comboCargo.SelectedValue, telefono); contactos.Add(contacto); Entidad clientej = fabrica.ObtenerClienteJuridico(vista.nombreEmpresa, contactos, direccion, vista.rifEmpresa, "aquivaellogo"); Comando <Entidad, bool> comando = FabricaComandos.CrearComandoAgregarClienteJuridico(); if (comando.Ejecutar(clientej)) { HttpContext.Current.Response.Redirect(RecursoInterfazM2.ListarEmpresas + 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_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); } }