예제 #1
0
        private void SQLiteTest()
        {
            SQLiteManager <Client>    managerClient    = new SQLiteManager <Client>(ApplicationData.Current.LocalFolder.Path + "\\mydb");
            SQLiteManager <Product>   managerProduct   = new SQLiteManager <Product>(ApplicationData.Current.LocalFolder.Path + "\\mydb");
            EntityGenerator <Client>  generatorClient  = new EntityGenerator <Client>();
            EntityGenerator <Product> generatorProduct = new EntityGenerator <Product>();

            List <Client> clients = generatorClient.GenerateListItems() as List <Client>;

            foreach (var item in clients)
            {
                item.Products = generatorProduct.GenerateListItems() as List <Product>;
            }
            int resultClient  = managerClient.InsertAll(clients);
            var client1Result = managerClient.Find <Client>(clients[0].Id);
            var client2Result = managerClient.Get <Client>(clients[0].Id);

            var client3Result = managerClient.FindWithQuery <Client>("SELECT * FROM client WHERE id = @p1", new object[] { 20 });
            var client4Result = managerClient.Query <Client>("SELECT * FROM client WHERE id = @p1", new object[] { 20 });
            //var client5Result = managerClient.Execute("INSERT INTO client VALUES(666,'name','surname',666,666)");

            //managerClient.BeginTransaction();
            //for (int x = 64; x < 666; x++)
            //{
            //    managerClient.ExecuteScalar<Client>("INSERT INTO client VALUES(@p1,'name','surname',@p2,@p3)", new object[] { x, x+1, x+2 });
            //}
            //managerClient.Commit();

            List <Client> clients1 = generatorClient.GenerateListItems() as List <Client>;

            managerClient.InsertOrReplaceAll(clients1);

            clients[0].Id   = 1971277679;
            clients[0].Name = "trololol";
            managerClient.Update(clients[0]);

            managerClient.Delete <Client>(clients[0].Id);
            managerClient.DeleteAll <Client>();

            List <Product> products       = generatorProduct.GenerateListItems() as List <Product>;
            int            resultProduct  = managerProduct.InsertAll(products);
            var            product1Result = managerProduct.Find <Product>(products[0].Id);
        }
예제 #2
0
        async void OnLoginClicked(object sender, EventArgs e)
        {
            var           m    = new UserMethods();
            var           mth  = new Methodlar();
            SQLiteManager sqlm = new SQLiteManager();
            ContentPage   p    = new ContentPage();


            if (g.usernameEntry.Text == "" || g.usernameEntry.Text == null || g.passwordEntry.Text == "" || g.passwordEntry.Text == null)
            {
                await this.DisplayAlert("Info Error", "Please enter POSDA account or Password", "OK");
            }
            else
            {
                try
                {
                    p = mth.showProgress("Sign In POSDA...", this);

                    g.user.user     = g.usernameEntry.Text;
                    g.user.pass     = g.passwordEntry.Text;
                    g.user.cust     = g.custEntry.Text;
                    g.user.cpss     = g.cpssEntry.Text;
                    g.user.remember = g.rememberSwt.On;
                    g.user.save     = g.savepassSwt.On;
                    if (g.user.udid == null)
                    {
                        g.user.udid = "-1";
                    }

                    g = await m.SignIn(g);

                    //if (g.signIn)
                    //{
                    if (g.rememberSwt.On)
                    {
                        g.user.remember = true;

                        if (g.savepassSwt.On)
                        {
                            g.user.save = true;
                        }
                        else
                        {
                            g.user.save = false;
                            g.user.pass = null;
                            g.user.cpss = null;
                        }

                        sqlm.DeleteAll();
                        sqlm.Insert(g.user);
                    }
                    else
                    {
                        g.user.remember = false;
                        //g.user.user = null;
                        g.user.pass     = null;
                        g.user.cust     = null;
                        g.user.cpss     = null;
                        g.user.remember = false;

                        if (g.savepassSwt.On)
                        {
                            g.user.save = true;
                        }
                        else
                        {
                            g.user.save = false;
                        }

                        sqlm.DeleteAll();
                        sqlm.Insert(g.user);
                    };

                    //}
                    if (!g.signIn)
                    {
                        mth.hideProgress(p);
                        await this.DisplayAlert("Info Error", "SignIn Fail", "OK");
                    }
                    else
                    {
                        mth.hideProgress(p);



                        WelcomePage welcomep = new WelcomePage(g);


                        NavigationPage np = new NavigationPage(welcomep);

                        g.mdp.Detail = np;

                        //await g.mdp.Detail.Navigation.PushModalAsync(welcomep);

                        await Navigation.PopToRootAsync();

                        //mth.callPage(g, welcomep);
                    }
                }
                catch (Exception)
                {
                    mth.hideProgress(p);

                    throw;
                }
            }
        }