Пример #1
0
        public static SQLiteConnection GetConn()
        {
            var pasta   = new LocalRootFolder();
            var arquivo = pasta.CreateFile("teste.db", CreationCollisionOption.OpenIfExists);

            return(new SQLiteConnection(arquivo.Path));
        }
Пример #2
0
        public DatabaseHelper()
        {
            var pasta   = new LocalRootFolder();
            var arquivo = pasta.CreateFile(DbFileName, CreationCollisionOption.OpenIfExists);

            sqliteconnection = new SQLiteConnection(arquivo.Path);
            sqliteconnection.CreateTable <CepModel>();
        }
Пример #3
0
        public Contexto()
        {
            var pasta   = new LocalRootFolder();
            var arquivo = pasta.CreateFile("bizudb", PCLExt.FileStorage.CreationCollisionOption.OpenIfExists);

            conexao = new SQLiteConnection(arquivo.Path);
            conexao.CreateTable <Usuario>();
        }
Пример #4
0
        public SQLiteConnection PegarConnection()
        {
            //Cria uma pasta base local para o dispositivo
            var path = new LocalRootFolder();
            //Cria o arquivo
            var arquivo = path.CreateFile(nomeArquivoDB, CreationCollisionOption.OpenIfExists);

            return(new SQLite.SQLiteConnection(arquivo.Path));
        }
Пример #5
0
        public DbAccess()
        {
            var pasta   = new LocalRootFolder();
            var arquivo = pasta.CreateFile("banco.db3", CreationCollisionOption.OpenIfExists);

            _sqLiteConnection = new SQLiteConnection(arquivo.Path);

            _sqLiteConnection.CreateTable <Usuario>();
        }
Пример #6
0
        public static SQLiteConnection Get()
        {
            var pasta   = new LocalRootFolder();
            var arquivo = pasta.CreateFile("BancoGas.db"
                                           , PCLExt.FileStorage.CreationCollisionOption.OpenIfExists);

            return(new SQLiteConnection(arquivo.Path));

            // return new SQLiteConnection(@"C:\temp\BancoGas.db");
        }
Пример #7
0
        public App()
        {
            var pasta   = new LocalRootFolder();
            var arquivo = pasta.CreateFile("banco.db", CreationCollisionOption.OpenIfExists);

            Conexao = new SQLiteConnection(arquivo.Path);

            Conexao.CreateTable <Model>();
            InitializeComponent();
            MainPage = new MainPage();
        }
Пример #8
0
        public App()
        {
            var pasta   = new LocalRootFolder();
            var arquivo = pasta.CreateFile("banco.db", CreationCollisionOption.OpenIfExists);

            Conexao = new SQLiteConnection(arquivo.Path);
            Conexao.Execute("create table if not exists informacoes (id integer primary key autoincrement, info text)");

            InitializeComponent();
            MainPage = new MainPage();
        }
Пример #9
0
        public DatabaseHelper()
        {
            //cria uma pasta base local para o dispositivo
            var pasta = new LocalRootFolder();
            //cria o arquivo
            var arquivo = pasta.CreateFile(DbFileName, CreationCollisionOption.OpenIfExists);

            //abre o BD
            sqliteconnection = new SQLiteConnection(arquivo.Path);
            //cria a tabela no BD
            sqliteconnection.CreateTable <Note>();
        }
Пример #10
0
        public App()
        {
            var pasta   = new LocalRootFolder();
            var arquivo = pasta.CreateFile("ConsultaClimaApp.db", PCLExt.FileStorage.CreationCollisionOption.OpenIfExists);

            Conexao = new SQLiteConnection(arquivo.Path);
            Conexao.Execute("CREATE TABLE IF NOT EXISTS Favoritos (Id INTEGER PRIMARY KEY AUTOINCREMENT, IdCidade INTEGER, NomeCidade TEXT, Clima TEXT, Temperatura TEXT)");

            InitializeComponent();

            MainPage = new NavigationPage(new CidadeFavoritaPage());
        }
Пример #11
0
        private async Task <bool> CheckDatabase()
        {
            // IFolder interface comes from PCLStorage, check if database file is there
            var rootFolder = new LocalRootFolder();
            ExistenceCheckResult exists = await rootFolder.CheckExistsAsync(DatabaseName + ".db3");

            if (exists == ExistenceCheckResult.FileExists)
            {
                return(true);
            }

            return(false);
        }
Пример #12
0
 public static SQLiteAsyncConnection GetSqliteConnection()
 {
     if (_connection == null)
     {
         //Cria uma pasta base local para o dispositivo
         var path = new LocalRootFolder();
         //Cria o arquivo
         var arquivo = path.CreateFile(DbFileName, CreationCollisionOption.OpenIfExists);
         //Abre o BD
         _connection = new SQLiteAsyncConnection(arquivo.Path);
     }
     return(_connection);
 }
Пример #13
0
        /// <summary>
        /// Permet de retourner une connexion au fichier SQLite si le fichier n'existe pas il est crée
        /// </summary>
        /// <example>
        /// <code>
        /// var db = new DatabaseHelper()
        /// ;
        ///
        /// </code>
        /// </example>

        public DatabaseHelper()
        {
            // crée un dossier personnel local pour le périphérique
            var paste = new LocalRootFolder();
            // crée le fichier
            var archve = paste.CreateFile(DbFileName, CreationCollisionOption.OpenIfExists);

            // open ou BD
            sqliteconnection = new SQLiteConnection(archve.Path);

            //sqliteconnection = DependencyService.Get<ISQLite>().GetConnection();
            InitAsync().Wait();
        }
Пример #14
0
        public App()
        {
            var Pasta = new LocalRootFolder();
            var Banco = Pasta.CreateFile("BancoX.db", PCLExt.FileStorage.CreationCollisionOption.OpenIfExists);

            Conexao = new SQLite.SQLiteConnection(Banco.Path);

            Conexao.Execute("CREATE TABLE IF NOT EXISTS Login (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE" +
                            ", nome TEXT NOT NULL, usuario TEXT NOT NULL UNIQUE, email TEXT NOT NULL UNIQUE, senha TEXT NOT NULL, cep NOT NULL)");

            InitializeComponent();

            MainPage = new NavigationPage(new TelaHamburguer());
        }
Пример #15
0
        public App()
        {
            //Criação do Banco de Dados
            var pasta   = new LocalRootFolder();
            var arquivo = pasta.CreateFile("Cliente.db", CreationCollisionOption.OpenIfExists);

            Conexao = new SQLiteConnection(arquivo.Path);
            // Criação da Tabela
            Conexao.Execute("create table if not exists Consumidor (id integer primary key autoincrement, nome text,telefone text,email text,nascimento integer)");

            InitializeComponent();

            MainPage = new NavigationPage(new MainPage());
        }
        public override void GetRootFoldersAsync(Action <IEnumerable <IFolder> > callback)
        {
            ObservableCollection <IFolder> roots = new ObservableCollection <IFolder>();

            LocalRootFolder pcFolder = new LocalRootFolder();

            ComposeRoutes(pcFolder);
            roots.Add(pcFolder);

            if (!callback.IsNull())
            {
                callback(roots);
            }
        }
Пример #17
0
        public override void GetRootFoldersAsync(Action <IEnumerable <IFolder> > callback)
        {
            ObservableCollection <IFolder> roots = new ObservableCollection <IFolder>();

            LocalRootFolder pcFolder = new LocalRootFolder();

            roots.Add(pcFolder);

            IList <string> personPaths = new List <string>()
            {
                Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
                Environment.GetFolderPath(Environment.SpecialFolder.Personal),
                Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
            };

            LocalVirtualFolder personFolder = null;

            foreach (var path in personPaths)
            {
                DataSourceShell item = GetShellItem(path);
                if (!item.IsNull())
                {
                    using (item)
                    {
                        personFolder = new LocalVirtualFolder(item);
                        roots.Add(personFolder);
                    }
                    break;
                }
            }

            if (!personFolder.IsNull())
            {
                pcFolder.GetItemAsync(personFolder.FullPath, (item) =>
                {
                    if (!item.IsNull() && (item is IFolder))
                    {
                        personFolder.RealFolder = item as IFolder;
                        personFolder.IsExpanded = true;
                    }
                });
            }


            if (!callback.IsNull())
            {
                callback(roots);
            }
        }
Пример #18
0
        public DatabaseHelper()
        {
            // Criando uma pasta base local para o dispositivo
            var folder = new LocalRootFolder();

            // Criando o arquivo
            var file = folder.CreateFile(DbFileName, CreationCollisionOption.OpenIfExists);

            // Abrindo o Base de Dados
            sqliteconnection = new SQLiteConnection(file.Path);

            // Criando a tabela no BD
            sqliteconnection.CreateTable <Product>();
            sqliteconnection.CreateTable <Category>();
        }
Пример #19
0
        public void Banco()
        {
            try
            {
                var Pasta = new LocalRootFolder();
                var Banco = Pasta.CreateFile("BancoX.db", PCLExt.FileStorage.CreationCollisionOption.OpenIfExists);
                Conexao = new SQLite.SQLiteConnection(Banco.Path);

                Conexao.Execute("CREATE TABLE IF NOT EXISTS Login (id INTEGER PRIMARY KEY AUTOINCREMENT NOTNULL UNIQUE" +
                                ", nome TEXT NOTNULL, usuario TEXT NOTNULL UNIQUE, email TEXT NOTNULL UNIQUE, senha TEXT NOTNULL, cep NOTNULL)");
            }
            catch
            {
                //DisplayAlert("Houveu um Problema", "Banco de dados", "OK");
            }
        }
        public async System.Threading.Tasks.Task SalvandoJsonLocalAsync(string codigoRastreio, string Iresponse)
        {
            var localPasta = new LocalRootFolder();
            var pasta      = localPasta.CreateFolder("TRACKS", CreationCollisionOption.OpenIfExists);
            var arquivo    = pasta.CreateFile(codigoRastreio + ".json", CreationCollisionOption.ReplaceExisting);

            if (arquivo.Exists)
            {
                StreamWriter sw = File.CreateText(arquivo.Path);
                await sw.WriteAsync(Iresponse);

                sw.Close();

                DisplayAlert("Concluído", "Sua encomenda foi adicionada", "OK");
                this.Navigation.PopModalAsync();
            }
        }
Пример #21
0
        public async static Task <string> SaveOrUpdatePhoto(Stream stream, string email)
        {
            //Create File Photo
            var rootFolder = new LocalRootFolder();
            var folder     = await rootFolder.CreateFolderAsync(email, CreationCollisionOption.OpenIfExists);

            var file = await folder.CreateFileAsync("profile.jpg", CreationCollisionOption.ReplaceExisting);

            var memory = new MemoryStream();

            stream.CopyTo(memory);
            byte[] bytes = memory.ToArray();

            file.WriteAllBytes(bytes);
            Settings.UrlPhoto = file.Path;
            return(file.Path);
        }
Пример #22
0
        public App()
        {
            var pasta = new LocalRootFolder();

            var arquivo = pasta.CreateFile("BancoDecoracoes.db", PCLExt.FileStorage.CreationCollisionOption.OpenIfExists);

            conexao = new SQLite.SQLiteConnection(arquivo.Path);

            conexao.Execute("CREATE TABLE IF NOT EXISTS Usuarios (ID INTEGER PRIMARY KEY AUTOINCREMENT,NOME TEXT,NomeUsuario TEXT,SENHA TEXT)");

            conexao.Execute("CREATE TABLE IF NOT EXISTS Orcamento (ID INTEGER PRIMARY KEY AUTOINCREMENT,Nome TEXT,Endereco TEXT,Bairro TEXT,Complemento TEXT,Telefone INTEGER)");


            InitializeComponent();

            MainPage = new NavigationPage(new TeladeLogin());
        }
Пример #23
0
 public string GetString()
 {
     if (Device.RuntimePlatform == Device.UWP)
     {
         string path = ApplicationData.Current.LocalFolder.Path + "\\" + dbName;
         return(path);
     }
     else
     {
         //cria uma pasta base local para o dispositivo
         var pasta = new LocalRootFolder();
         //cria o arquivo
         var arquivo =
             pasta.CreateFile(dbName, PCLExt.FileStorage.CreationCollisionOption.OpenIfExists);
         //abre o BD
         return(arquivo.Path);
     }
 }
Пример #24
0
        static async Task Init()
        {
            if (connection != null)
            {
                return;
            }

            var folder = new LocalRootFolder();
            var file   = folder.CreateFile("recipeBook", PCLExt.FileStorage.CreationCollisionOption.OpenIfExists);

            connection = new SQLiteAsyncConnection(file.Path);
            await connection.CreateTableAsync <Ingredient>();

            Console.WriteLine("Ingredient Table Created");

            await connection.CreateTableAsync <RecipeModel>();

            Console.WriteLine("RecipeModel Table Created");
        }
Пример #25
0
        public App()
        {
            //Local do banco
            var pasta = new LocalRootFolder();

            //Crio o arquivo do banco (se ele não existir)
            // se ele existir, abor ele
            var arquivo = pasta.CreateFile("banco.db", PCLExt.FileStorage.CreationCollisionOption.OpenIfExists);

            //faço a "conexao"
            Conexao = new SQLite.SQLiteConnection(arquivo.Path);

            // Criar uma tabela, se ela não existir
            Conexao.Execute("CREATE TABLE IF NOT EXISTS informacoes (id INTEGER PRIMARY KEY AUTOINCREMENT, info TEXT)");

            InitializeComponent();

            MainPage = new MainPage();
        }
Пример #26
0
        public App()
        {
            var pasta = new LocalRootFolder();

            var arquivo = pasta.CreateFile("banco.db", PCLExt.FileStorage.CreationCollisionOption.OpenIfExists);

            Conexao = new SQLite.SQLiteConnection(arquivo.Path);

            Conexao.Execute("CREATE TABLE IF NOT EXISTS cliente (ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, nome_cliente TEXT (255) NOT NULL, cpf BIGINTEGER UNIQUE NOT NULL, data_nascimento TEXT (15) NOT NULL, sexo TEXT (15) NOT NULL, email TEXT (255) UNIQUE NOT NULL, telefone_celular INTEGER (15) NOT NULL, observacao TEXT (255) NOT NULL)");
            Conexao.Execute("CREATE TABLE IF NOT EXISTS funcionario (ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, nome_funcionario TEXT (255) NOT NULL, cpf BIGINTEGER UNIQUE NOT NULL, data_nascimento TEXT (15) NOT NULL, sexo TEXT (15) NOT NULL, email TEXT (255) UNIQUE NOT NULL, telefone_celular INTEGER (15) NOT NULL, horario_atendimento TEXT (255) NOT NULL)");
            Conexao.Execute("CREATE TABLE IF NOT EXISTS promocao (ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, status TEXT (50) NOT NULL, nome_promocao TEXT (255) UNIQUE NOT NULL, descricao TEXT (255) NOT NULL, tempo TEXT (50) NOT NULL, valor TEXT NOT NULL)");
            Conexao.Execute("CREATE TABLE IF NOT EXISTS servico (ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, status TEXT (50) NOT NULL, nome_servico TEXT (255) UNIQUE NOT NULL, descricao TEXT (255) NOT NULL, tempo TEXT (50) NOT NULL, valor TEXT NOT NULL)");
            Conexao.Execute("CREATE TABLE IF NOT EXISTS usuario (ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, usuario TEXT (100) UNIQUE NOT NULL, senha TEXT (100) NOT NULL, email TEXT (255) UNIQUE NOT NULL)");
            Conexao.Execute("CREATE TABLE IF NOT EXISTS agendamento (ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, nome_cliente TEXT (255) NOT NULL, nome_funcionario TEXT (255) NOT NULL, servico TEXT (255) NOT NULL, horario TEXT (50) NOT NULL, duracao TEXT (50) NOT NULL, data TEXT (50) NOT NULL)");

            InitializeComponent();

            MainPage = new NavigationPage(new MainPage());
            //MainPage = new MainPage();
        }
Пример #27
0
        public Contents()
        {
            // Criar/Abrir Base de Dados
            var pasta   = new LocalRootFolder();
            var arquivo = pasta.CreateFile("SenhasDB", PCLExt.FileStorage.CreationCollisionOption.OpenIfExists);

            conexao = new SQLiteConnection(arquivo.Path);

            // Criar/Abrir Tabela Passwords
            conexao.CreateTable <Passwords>();
            conexao.CreateTable <User>();

            // Incluir Senha Acesso
            if (conexao.Find <User>(1) == null)
            {
                User user = new User();
                user.Email = "*****@*****.**";
                user.Senha = Login.MD5Hash("1234");

                Inserir(user);
            }
        }
Пример #28
0
        public App()
        {
            var Pasta   = new LocalRootFolder();
            var Arquivo = Pasta.CreateFile("BancoX.db", PCLExt.FileStorage.CreationCollisionOption.OpenIfExists);

            Conexao = new SQLite.SQLiteConnection(Arquivo.Path);

            Conexao.Execute("CREATE TABLE IF NOT EXISTS Login (ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE" +
                            ",Nome TEXT (300) NOT NULL," +
                            " Usuario TEXT (500) NOT NULL UNIQUE," +
                            " Email TEXT (300) NOT NULL UNIQUE," +
                            " Senha TEXT (255) NOT NULL," +
                            " CEP INTEGER (8) NOT NULL)");

            Conexao.Execute("CREATE TABLE IF NOT EXISTS Pedido (ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE" +
                            ",Quarto INTEGER NOT NULL" +
                            ",Banheiro INTEGER NOT NULL" +
                            ",Cozinha INTEGER NOT NULL" +
                            ",Sala INTEGER NOT NULL" +
                            ",Data TEXT (10) NOT NULL" +
                            ",Hora TEXT (10) NOT NULL" +
                            ",Empregado TEXT (300) NOT NULL" +
                            ",Total INTEGER NOT NULL)");

            Conexao.Execute("CREATE TABLE IF NOT EXISTS Funcionario (ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE" +
                            ",Nome TEXT (200) NOT NULL" +
                            ",CPF TEXT (11) NOT NULL" +
                            ",CEP TEXT (8) NOT NULL" +
                            ",RG TEXT (12) NOT NULL" +
                            ",Observacao TEXT (300) NOT NULL)");



            InitializeComponent();

            MainPage = new NavigationPage(new MainPage());
            NavigationPage.SetHasNavigationBar(this, false);
        }
Пример #29
0
        }                                                            //conexao com o banco de dados

        public App()
        {
            var pasta = new LocalRootFolder();

            ////crio o arquivo do banco (se ele não existir)
            ////Se ele existir, só quero que abra

            var arquivo = pasta.CreateFile("confrariapp.db", PCLExt.FileStorage.CreationCollisionOption.OpenIfExists);

            ////faço a "conexao"
            conexao = new SQLite.SQLiteConnection(arquivo.Path);

            ////criar a tabela, se ela não existir
            conexao.Execute("CREATE TABLE IF NOT EXISTS CadastroCliente (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, nome TEXT NOT NULL, login TEXT NOT NULL, data TEXT NOT NULL, telefone INTEGER NOT NULL, senha TEXT NOT NULL)");
            conexao.Execute("CREATE TABLE IF NOT EXISTS CadastroBebida (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, nome TEXT NOT NULL, descricao TEXT NOT NULL, valor TEXT NOT NULL, categoria TEXT NOT NULL)");
            conexao.Execute("CREATE TABLE IF NOT EXISTS CadastroPorcao (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, nome TEXT NOT NULL, descricao TEXT NOT NULL, valor TEXT NOT NULL, categoria TEXT NOT NULL)");
            conexao.Execute("CREATE TABLE IF NOT EXISTS CadastroSuvenir (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, nome TEXT NOT NULL, descricao TEXT NOT NULL, valor TEXT NOT NULL, categoria TEXT NOT NULL)");
            conexao.Execute("CREATE TABLE IF NOT EXISTS CadastroReserva (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, nomeCliente TEXT NOT NULL, qtdpessoas INTEGER NOT NULL, data TEXT NOT NULL, observacao TEXT NOT NULL)");
            conexao.Execute("CREATE TABLE IF NOT EXISTS CadastroProgramacao (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, nomeprog TEXT NOT NULL, data TEXT NOT NULL, descricao TEXT NOT NULL)");

            InitializeComponent();
            MainPage = new NavigationPage(new LoginPage());
        }
        private void ComposeRoutes(LocalRootFolder pcRoot)
        {
            if (pcRoot.IsNull())
            {
                return;
            }

            IFolder         parent         = pcRoot;
            IList <IFolder> createdFolders = new List <IFolder>();

            foreach (string folderPath in folderPaths)
            {
                //FindParent(folderPath, ref parents);
                parent = pcRoot;
                string[] splitedFolders = folderPath.Split(new string[] { PATH_SPLITER }, StringSplitOptions.RemoveEmptyEntries);
                string   path           = string.Empty;
                for (int i = 0; i < splitedFolders.Length; i++)
                {
                    path += splitedFolders[i] + PATH_SPLITER;
                    DirectoryInfo directory = new DirectoryInfo(path);
                    if (directory.IsNull())
                    {
                        break;
                    }
                    StaticLocalFolder currentFolder = createdFolders.FirstOrDefault(item => (0 == string.Compare(path, item.FullPath, true))) as StaticLocalFolder;
                    if (currentFolder.IsNull())
                    {
                        currentFolder = new StaticLocalFolder(directory, parent);
                        currentFolder.Folders.Clear();
                        createdFolders.Add(currentFolder);
                        parent.Folders.Add(currentFolder);
                    }

                    parent = currentFolder;
                }
            }
        }