Esempio n. 1
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (nom.Text == null || nom.Text.Equals(""))
     {
         MessageBox.Show("Porfavor ingrese el nombre...");
     }
     else
     {
         if (ape.Text == null || ape.Text.Equals(""))
         {
             MessageBox.Show("Porfavor ingrese el apellido...");
         }
         else
         {
             if (ced.Text.Length == 14 && char.IsLetter(ced.Text, 13))
             {
                 if (cod.Text == null || cod.Text.Equals(""))
                 {
                     MessageBox.Show("Porfavor ingresea el codigo");
                 }
                 else
                 {
                     String aux_1 = ced.Text.Insert(2, "-");
                     String aux_2 = aux_1.Insert(10, "-");
                     // Agregando elementos a la lista para luego mandarlo al fichero
                     lis.Add(new agregando_trabajador {
                         Nombre = nom.Text, Apellido = ape.Text, Cedula1 = aux_2, Codigo = cod.Text
                     });
                     this.Lista.ItemsSource = null;
                     this.Lista.ItemsSource = lis;
                     String a = nom.Text;
                     String b = ape.Text;
                     String c = cod.Text;
                     // limpiando las casillas de llenar datos
                     nom.Text = "";
                     ape.Text = "";
                     ced.Text = "";
                     cod.Text = "";
                     // Mandando datos al fichero
                     fichero fi = new fichero();
                     fi.agregar_Empleado(a, b, aux_2, c);
                 }
             }
             else
             {
                 MessageBox.Show("Porfavor ingrese el Cedula");
             }
         }
     }
 }