Exemplo n.º 1
0
    protected void btnEnviar_Click(object sender, EventArgs e)
    {
        HttpWebRequest  req = (HttpWebRequest)WebRequest.Create("http://localhost:5830/Usuario.svc/Usuario/" + txtEmail.Value);
        HttpWebResponse res = null;

        req.ContentType = "application/json";
        res             = (HttpWebResponse)req.GetResponse();
        res             = req.GetResponse() as HttpWebResponse;
        StreamReader         reader         = new StreamReader(res.GetResponseStream());
        string               clienteJson    = reader.ReadToEnd();
        JavaScriptSerializer js             = new JavaScriptSerializer();
        UsuarioDominio       usuarioDominio = js.Deserialize <UsuarioDominio>(clienteJson);

        if (usuarioDominio == null)
        {
            req         = (HttpWebRequest)WebRequest.Create("http://localhost:5830/Usuario.svc/Usuario/Contrasena=" + txtContrasea.Value);
            res         = null;
            res         = (HttpWebResponse)req.GetResponse();
            res         = req.GetResponse() as HttpWebResponse;
            reader      = new StreamReader(res.GetResponseStream());
            clienteJson = reader.ReadToEnd();
            if (clienteJson == "false")
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('El primer caracter de la contraseña debe ser mayúsculas.')", true);
            }
            else
            {
                SWSoap.SWSoapClient   proxy   = new SWSoap.SWSoapClient();
                SWSoap.UsuarioDominio usuario = new SWSoap.UsuarioDominio();

                usuario.IdPerfil   = 2;
                usuario.Nombre     = txtNombre.Value;
                usuario.Apellido   = txtApellido.Value;
                usuario.Correo     = txtEmail.Value;
                usuario.Dni        = txtDni.Value;
                usuario.Contraseña = txtContrasea.Value;
                proxy.CrearUsuario(usuario);
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Usuario registrado.')", true);
            }
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('El correo ingresado ya se encuentra asociado a otro usuario.')", true);
        }
    }
Exemplo n.º 2
0
    protected void btnGuardar_Click(object sender, EventArgs e)
    {
        HttpWebRequest  req = (HttpWebRequest)WebRequest.Create("http://localhost:5830/Usuario.svc/Usuario/" + txtPlaca.Value + "/" + dtFechaInicio.Value.ToString());
        HttpWebResponse res = null;

        req.ContentType = "application/json";
        res             = (HttpWebResponse)req.GetResponse();
        res             = req.GetResponse() as HttpWebResponse;
        StreamReader         reader      = new StreamReader(res.GetResponseStream());
        string               clienteJson = reader.ReadToEnd();
        JavaScriptSerializer js          = new JavaScriptSerializer();
        SoatDominio          soatDominio = js.Deserialize <SoatDominio>(clienteJson);

        if (soatDominio == null)
        {
            SWSoap.SWSoapClient proxy = new SWSoap.SWSoapClient();
            SWSoap.SoatDominio  soat  = new SWSoap.SoatDominio();

            soat.Placa       = txtPlaca.Value;
            soat.Marca       = ddlMarca.SelectedValue;
            soat.FechaInicio = dtFechaInicio.Value.ToString();
            soat.Categoria   = txtCategoria.Value;
            soat.Contratante = txtContratante.Value;
            soat.Año         = int.Parse(ddlAño.SelectedValue.ToString());
            soat.Documento   = txtDocumento.Value;
            soat.Modelo      = ddlModelo.SelectedValue.ToString();
            soat.NroAsientos = txtNroAsientos.Value.ToString();
            soat.Direccion   = txtDireccion.Value;
            soat.UsoDiario   = ddlUso.SelectedValue.ToString();
            soat.NroSerie    = txtNroSerie.Value;
            proxy.CrearSoat(soat);
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('SOAT registrado.')", true);
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Ya tiene un SOAT Activo.')", true);
        }
    }