Beispiel #1
0
 public static void DeleteDB()
 {
     using (ContextoDatos db = new ContextoDatos())
     {
         if (db.DatabaseExists())
         {
             db.DeleteDatabase();
         }
     }
 }
Beispiel #2
0
 public static bool DatabaseExist()
 {
     using (ContextoDatos db = new ContextoDatos())
      {
          return db.DatabaseExists();
      }
 }
        void loadUsers()
        {
            listBox1.ItemsSource = null;
            List<Usuario> listaUsuarios = new List<Usuario>();
            ContextoDatos ctx = new ContextoDatos();
            var data = ctx.Users.OrderBy(o => o.Nombre);
            if(ctx.DatabaseExists())
            {
                foreach (User user in data)
                {
                    listaUsuarios.Add(new Usuario { Id = user.Id, Nombre = user.Nombre });
                }

                listBox1.ItemsSource = listaUsuarios;
            }
        }
Beispiel #4
0
 public static void CrearDBSiNoExiste()
 {
     using (ContextoDatos db = new ContextoDatos())
     {
         if (!db.DatabaseExists())
         {
             db.CreateDatabase();
         }
     }
 }
Beispiel #5
0
        void loadUsers()
        {
            listBox1.ItemsSource = null;
            List<Usuario> listaUsuarios = new List<Usuario>();
            ContextoDatos ctx = new ContextoDatos();
            var data = ctx.Users.OrderBy(o=>o.Nombre);
            if(ctx.DatabaseExists())
            {
                foreach(User user in data)
                {
                    if((App.Current as App).CurrentUser.HasValue)
                    {
                        if(user.Id  == (App.Current as App).CurrentUser.Value)
                            listaUsuarios.Add(new Usuario{ Id = user.Id, Nombre = user.Nombre, Selected = true});
                        else
                            listaUsuarios.Add(new Usuario{ Id = user.Id, Nombre = user.Nombre});
                    }
                    else
                    {
                        listaUsuarios.Add(new Usuario{ Id = user.Id, Nombre = user.Nombre});
                    }

                }
                listBox1.ItemsSource = listaUsuarios;

            }
        }