public antecedente darAntecedentePorId(int id)
        {
            antecedente antecedente = null;
            String      urlRelativa = "darAntecedente";
            var         url         = $"" + urlGeneral + urlRelativa + "?id=" + id;
            var         request     = (HttpWebRequest)WebRequest.Create(url);

            request.Method      = "GET";
            request.ContentType = "application/json";
            request.Accept      = "application/json";

            try
            {
                using (WebResponse response = request.GetResponse())
                {
                    using (Stream strReader = response.GetResponseStream())
                    {
                        if (strReader == null)
                        {
                            return(antecedente);
                        }
                        using (StreamReader objReader = new StreamReader(strReader))
                        {
                            string responseBody = objReader.ReadToEnd();
                            antecedente = JsonConvert.DeserializeObject <antecedente>(responseBody);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error! " + ex);
            }
            return(antecedente);
        }
        public void llenarGrilla(List <antecedente> lista)
        {
            List <antecedente> antecedentes = lista;

            dgvCiudadano.Rows.Clear();
            for (int i = 0; i < antecedentes.Count; i++)
            {
                antecedente antecedente = antecedentes.ElementAt(i);
                dgvCiudadano.Rows.Insert(i, antecedente.id, antecedente.ciudadanoDi, antecedente.delitoCodigo, antecedente.fechaDelito, antecedente.sentencia, antecedente.estado);
            }
        }
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            //btn buscar
            try
            {
                if (textBox1.Text.Trim() == "" || textBox3.Text.Trim() == "")
                {
                    if (textBox1.Text.Trim() == "")
                    {
                        MessageBox.Show("El numero de identificación se encuentra vacío, por favor escribelo e intentalo de nuevo");
                    }
                    else if (textBox3.Text.Trim() == "")
                    {
                        MessageBox.Show("El numero del delito se encuentra vacío, por favor escribelo e intentalo de nuevo");
                    }
                    else
                    {
                        MessageBox.Show("Existen valores vacíos, por favor verifica los cuadros de texto e intentalo de nuevo");
                    }
                }
                else
                {
                    List <antecedente> antecedentes = new List <antecedente>();
                    int caso = -1;
                    if (!String.IsNullOrEmpty(textBox1.Text) && !String.IsNullOrEmpty(textBox3.Text))
                    {
                        String ciudadanoDi  = textBox1.Text;
                        int    codigoDelito = Int32.Parse(textBox3.Text);
                        antecedentes = controller.darAntecedentesPorCiudadanoYDelito(ciudadanoDi, codigoDelito);
                        caso         = 1;
                    }
                    else if (!String.IsNullOrEmpty(textBox1.Text) && String.IsNullOrEmpty(textBox3.Text))
                    {
                        antecedentes = controller.darAntecedentesPorCiudadano(textBox1.Text);
                        caso         = 2;
                    }
                    else if (String.IsNullOrEmpty(textBox1.Text) && !String.IsNullOrEmpty(textBox3.Text))
                    {
                        antecedentes = controller.darAntecedentesPorDelito(Int32.Parse(textBox3.Text));
                        caso         = 3;
                    }
                    else
                    {
                        antecedente anteced = controller.darAntecedentePorId(Int32.Parse(txtDi.Text));
                        antecedentes.Add(anteced);
                        caso = 4;
                    }
                    if (antecedentes.Count > 0)
                    {
                        String codigoId = "" + antecedentes.ElementAt(0).id;
                        txtDi.Text            = codigoId;
                        txtSentencia.Text     = "" + antecedentes.ElementAt(0).sentencia;
                        txtEstado.Text        = "" + antecedentes.ElementAt(0).estado;
                        txtCiudad.Text        = "" + antecedentes.ElementAt(0).ciudad;
                        dateTimePicker1.Value = antecedentes.ElementAt(0).fechaDelito;
                    }
                    else
                    {
                        switch (caso)
                        {
                        case 1:
                            MessageBox.Show("El ciudadano no tiene dicho antecedente");
                            break;

                        case 2:
                            MessageBox.Show("El ciudadano no tiene antecedentes");
                            break;

                        case 3:
                            MessageBox.Show("Ningun ciudadano tiene ese antecedente");
                            break;

                        case 4:
                            MessageBox.Show("No hay antecedente con el id especificado");
                            break;

                        default:
                            MessageBox.Show("Ha ocurrido un error en el servidor contacte con el servicio de soporte técnico");
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error! " + ex);
            }
        }