Esempio n. 1
0
        private async Task GetDni()
        {
            bool canConvert = int.TryParse(txtDNI.Text, out int Dni);

            if (canConvert && txtDNI.Text.Length == 8)
            {
                try
                {
                    DNI dni = await ConsultaDni.GetDni(txtDNI.Text);

                    if (dni != null)
                    {
                        txtNombres.Text   = dni.nombres;
                        txtApellidos.Text = $"{dni.apellidoPaterno} {dni.apellidoMaterno}";
                    }

                    await Dispatcher.BeginInvoke(new System.Action(() => { Keyboard.Focus(txtDireccion); }),
                                                 System.Windows.Threading.DispatcherPriority.Loaded);
                }
                catch (Exception ex)
                {
                    DialogResult result = CustomMessageBox.Show($"{ex.Message}", CustomMessageBox.CMessageBoxTitle.Información, CustomMessageBox.CMessageBoxButton.Aceptar, CustomMessageBox.CMessageBoxButton.No);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Muestra Nombre y apellido, Nacionalidad y DNI.
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(Nombre + ", " + Apellido);
            sb.AppendLine("NACIONALIDAD: " + Nacionalidad.ToString());
            sb.AppendLine("DNI: " + DNI.ToString());
            return(sb.ToString());
        }
Esempio n. 3
0
        public override string ToString()
        {
            StringBuilder miCadena = new StringBuilder();

            miCadena.AppendLine("Nombre: " + this.Nombre + " - Apellido: " + this.Apellido);
            miCadena.AppendLine("DNI: " + DNI.ToString());
            miCadena.AppendLine("Nacionalidad: " + this.Nacionalidad.ToString());
            return(miCadena.ToString());
        }
Esempio n. 4
0
 /// <summary>
 /// Método para asignarle un password al usuario que se registra
 /// </summary>
 /// <returns>
 /// true: si ninguno de los campos está vacío. false: si hay algún error
 /// </returns>
 public bool SetPassword()
 {
     if (this.DNI != null & this.Name != null & this.Lastname != null)
     {
         Password = DNI.Substring(4, 4) + "0000" + Name.First() + Lastname.First();
         return(true);
     }
     else
     {
         return(false);
     }
 }
        public void ParseValido()
        {
            var a = DNI.Parse("18.627.585");

            Assert.Equal("18.627.585", a.ToString());

            var b = DNI.Parse("18627585");

            Assert.Equal("18.627.585", a.ToString());

            var c = DNI.Parse("0018627585");

            Assert.Equal("18.627.585", a.ToString());
        }
Esempio n. 6
0
        public async static Task <DNI> GetDni(string dni)
        {
            string         endpoint = $"https://dniruc.apisperu.com/api/v1/dni/{dni}?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6Imd1c3Rhdm8uZ2F2YW5jaG8ubEBnbWFpbC5jb20ifQ.E2rJjAZ93Dg5JvqH-DDwGPiO9QBoGBE110WfL7Ff0xE";
            HttpWebRequest request  = WebRequest.Create(endpoint) as HttpWebRequest;

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

            HttpWebResponse response = await request.GetResponseAsync() as HttpWebResponse;

            StreamReader reader = new StreamReader(response.GetResponseStream());
            string       json   = await reader.ReadToEndAsync();

            DNI dniObtained = JsonConvert.DeserializeObject <DNI>(json);

            return(dniObtained);
        }
 public string this[int i]
 {
     get
     {
         if (i == 1)
         {
             return((Sexo == 1) ? ("Hombre") : ("Mujer"));
         }
         else
         if (i == 2)
         {
             return(DNI.ToString());
         }
         else
         if (i == 3)
         {
             return(FechaNacimiento.ToShortTimeString());
         }
         else
         if (i == 4)
         {
             return(Edad.ToString());
         }
         return("Indice invalido");
     }
     set
     {
         if (i == 1)
         {
             Sexo = ((Sexo == 1) ? (1) : (2));
         }
         else
         if (i == 2)
         {
             DNI = (Convert.ToInt32(value));
         }
         else
         if (i == 3)
         {
             FechaNacimiento = Convert.ToDateTime(value);
         }
         // no se puede asignar edad. se calcula.
     }
 }
Esempio n. 8
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            RecepcionistaEN t = obj as RecepcionistaEN;

            if (t == null)
            {
                return(false);
            }
            if (DNI.Equals(t.DNI))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 9
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            ClienteEN t = obj as ClienteEN;

            if (t == null)
            {
                return(false);
            }
            if (DNI.Equals(t.DNI))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 10
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            AdministradorEN t = obj as AdministradorEN;

            if (t == null)
            {
                return(false);
            }
            if (DNI.Equals(t.DNI))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 11
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            VeterinarioEN t = obj as VeterinarioEN;

            if (t == null)
            {
                return(false);
            }
            if (DNI.Equals(t.DNI))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 12
0
        public string AdoEliminar()
        {
            try
            {
                string dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "adoDB_SBX.db3");
                bool   exists = File.Exists(dbPath);

                if (exists)
                {
                    connection = new SqliteConnection("Data Source=" + dbPath);
                    connection.Open();

                    var commandsInsert = new[] {
                        " DELETE FROM  [Cliente] " +
                        " WHERE  [DNI] = '" + DNI.Trim() + "'"
                    };
                    foreach (var command in commandsInsert)
                    {
                        using (var c = connection.CreateCommand())
                        {
                            c.CommandText = command;
                            var i = c.ExecuteNonQuery();
                        }
                    }

                    output = "Cliente eliminado correctamente";
                    connection.Close();
                }
                else
                {
                    output += "No existe base de datos";
                }
            }
            catch (Exception ex)
            {
                output = "Error: " + ex.Message;
            }

            return(output);
        }
Esempio n. 13
0
        public string AdoEditar()
        {
            try
            {
                string dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "adoDB_SBX.db3");
                bool   exists = File.Exists(dbPath);

                if (exists)
                {
                    connection = new SqliteConnection("Data Source=" + dbPath);
                    connection.Open();

                    var commandsInsert = new[] {
                        " UPDATE  [Cliente] SET [Nombre] = '" + Nombre + "',[Ciudad] = '" + Ciudad + "',[Direccion] = '" + Direccion + "',[Telefono] = '" + Telefono + "',[Celular] = '" + Celular + "',[Email] = '" + Email + "',[SitioWeb] = '" + SitioWeb + "' " +
                        " WHERE  [DNI] = '" + DNI.Trim() + "'"
                    };
                    foreach (var command in commandsInsert)
                    {
                        using (var c = connection.CreateCommand())
                        {
                            c.CommandText = command;
                            var i = c.ExecuteNonQuery();
                        }
                    }

                    output = "Cliente Editado correctamente";
                    connection.Close();
                }
                else
                {
                    output += "No existe base de datos";
                }
            }
            catch (Exception ex)
            {
                output = "Error: " + ex.Message;
            }

            return(output);
        }
Esempio n. 14
0
        public Estudiante(string dni, string nombres, string apellidos, DateTime fechaNacimiento) : base(dni, nombres, apellidos, fechaNacimiento)
        {
            Codigo = Apellidos.Substring(0, 3) + DNI.Substring(4, 4);

            Estudiantes.Add(this);
        }
Esempio n. 15
0
File: Form1.cs Progetto: fpp93/2_dam
 private void Boton_Click(object sender, EventArgs e)
 {
     personas.Add(new Persona(DNI.Text, Nombre.Text, Apellidos.Text, Fecha.Text, int.Parse(Peso.Text), int.Parse(Altura.Text)));
     DNI.Clear();
 }
Esempio n. 16
0
 public void ParseRechazarCaracteresRaros()
 {
     Assert.Throws <ArgumentException>(() => DNI.Parse("18-627-585"));
     Assert.Throws <ArgumentException>(() => DNI.Parse("dni 18627585"));
     Assert.Throws <ArgumentException>(() => DNI.Parse("018627595"));
 }
Esempio n. 17
0
 public override string ToString()
 {
     return(Apellido.Trim() + "," + "DNI:" + DNI.ToString());
 }
Esempio n. 18
0
        public void DebeMostrarSalidaFormateada()
        {
            var a = new DNI(18627585);

            Assert.Equal("18.627.585", a.ToString());
        }
Esempio n. 19
0
 public void New_Crear()
 {
     var d = new DNI(18627585);
 }