Beispiel #1
0
        private async void button3_Click(object sender, EventArgs e)
        {
            EmpleadoClient empleado = new EmpleadoClient("http://localhost:2038/");

            GetEmpleadoConsultarQuery param = new GetEmpleadoConsultarQuery();

            param.RestKey = soapkey;
            param.DNI     = textBox1.Text;

            var response = await empleado.EmpleadoConsultar.Get(param);

            var stream = await response.RawContent.ReadAsStreamAsync();

            using (var contentStream = await response.RawContent.ReadAsStreamAsync())
            {
                contentStream.Seek(0, SeekOrigin.Begin);
                using (var sr = new StreamReader(contentStream))
                {
                    MultipleEmpleadoConsultarGet salida = JsonConvert.DeserializeObject <MultipleEmpleadoConsultarGet>(sr.ReadToEnd());

                    if (salida.Empleado != null)
                    {
                        textBox2.Text        = salida.Empleado.DNI;
                        textBox3.Text        = salida.Empleado.Nombre;
                        textBox4.Text        = salida.Empleado.Apellidos;
                        textBox5.Text        = salida.Empleado.Direccion;
                        textBox6.Text        = salida.Empleado.Poblacion;
                        textBox7.Text        = salida.Empleado.Telefono;
                        textBox8.Text        = salida.Empleado.Email;
                        dateTimePicker1.Text = salida.Empleado.Fecha_nacimiento.ToString();
                        textBox10.Text       = salida.Empleado.NSS;
                        textBox11.Text       = salida.Empleado.IBAN;
                    }
                    else
                    {
                        MessageBox.Show("Error: \n Codigo: " + salida.Error.Codigo + "\n Mensaje: " + salida.Error.Mensaje);
                    }
                }
            };
        }
Beispiel #2
0
        private async void button3_Click(object sender, EventArgs e)
        {
            EmpleadoClient empleado = new EmpleadoClient("http://localhost:2038/");

            GetEmpleadoConsultarQuery param = new GetEmpleadoConsultarQuery();

            param.RestKey = soapkey;
            param.DNI     = textBox1.Text;

            var response = await empleado.EmpleadoConsultar.Get(param);

            var stream = await response.RawContent.ReadAsStreamAsync();

            using (var contentStream = await response.RawContent.ReadAsStreamAsync())
            {
                contentStream.Seek(0, SeekOrigin.Begin);
                using (var sr = new StreamReader(contentStream))
                {
                    MultipleEmpleadoConsultarGet salida = JsonConvert.DeserializeObject <MultipleEmpleadoConsultarGet>(sr.ReadToEnd());

                    if (salida.Empleado != null)
                    {
                        textBox2.Text        = salida.Empleado.DNI;
                        textBox3.Text        = salida.Empleado.Nombre;
                        textBox4.Text        = salida.Empleado.Apellidos;
                        textBox5.Text        = salida.Empleado.Direccion;
                        textBox6.Text        = salida.Empleado.Poblacion;
                        textBox7.Text        = salida.Empleado.Telefono;
                        textBox8.Text        = salida.Empleado.Email;
                        dateTimePicker1.Text = salida.Empleado.Fecha_nacimiento.ToString();
                        textBox10.Text       = salida.Empleado.NSS;
                        textBox11.Text       = salida.Empleado.IBAN;

                        button1.Enabled = true;
                        deshabilitarTextBox();
                    }
                    else
                    {
                        button1.Enabled      = false;
                        textBox2.Text        = "";
                        textBox3.Text        = "";
                        textBox4.Text        = "";
                        textBox5.Text        = "";
                        textBox6.Text        = "";
                        textBox7.Text        = "";
                        textBox8.Text        = "";
                        dateTimePicker1.Text = "";
                        textBox10.Text       = "";
                        textBox11.Text       = "";
                        MessageBox.Show("Error: \n Codigo: " + salida.Error.Codigo + "\n Mensaje: " + salida.Error.Mensaje);
                    }
                }
            };

            /*string dni, Nombre, Apellidos, Direccion, Poblacion, Telefono, Email, NSS, IBAN, errores="";
             * dni = textBox1.Text;
             * DateTime Fecha_nacimiento;
             * Nombre = "";//empleado.consultar(ref dni, this.soapkey, out Apellidos, out Direccion, out Poblacion, out Telefono, out Email, out Fecha_nacimiento, out NSS, out IBAN, out errores);
             *
             * if (errores.Equals("")){
             * /* textBox2.Text = dni;
             *  textBox3.Text = Nombre;
             *  textBox4.Text = Apellidos;
             *  textBox5.Text = Direccion;
             *  textBox6.Text = Poblacion;
             *  textBox7.Text = Telefono;
             *  textBox8.Text = Email;
             *  dateTimePicker1.Text = Fecha_nacimiento.ToString();
             *  textBox10.Text = NSS;
             *  textBox11.Text = IBAN;
             *
             *  button1.Enabled = true;
             *
             *  // disable
             *  deshabilitarTextBox();
             * } else{
             *  button1.Enabled = false;
             *  textBox2.Text = "";
             *  textBox3.Text = "";
             *  textBox4.Text = "";
             *  textBox5.Text = "";
             *  textBox6.Text = "";
             *  textBox7.Text = "";
             *  textBox8.Text = "";
             *  dateTimePicker1.Text = "";
             *  textBox10.Text = "";
             *  textBox11.Text = "";
             *  MessageBox.Show("Error: " + errores);
             *
             * }
             */
        }