Ejemplo n.º 1
0
        private void InitSystem()
        {
            UserKeys.Add("root", "root");
            SimpleSqlite sqlite = new SimpleSqlite("personal", "Database");

            sqlite.QueryColumnsNumber("SimpleUI.db3", "UPS");

            if (sqlite.CreateDatabase("simpleUI.db3"))
            {
                sqlite.CreateTable("simpleUI.db3", "UPS",
                                   new Dictionary <string, string>()
                {
                    { "USER", "VARCHAR(20)" },
                    { "PASSWORD", "VARCHAR(20)" }
                });

                sqlite.InsertInto("SimpleUI.db3", "UPS", new List <string>()
                {
                    "root", "root"
                });
                sqlite.InsertInto("SimpleUI.db3", "UPS", new List <string>()
                {
                    "root2", "root2"
                });
            }
        }
Ejemplo n.º 2
0
        private bool Access(string User, string Password)
        {
            SimpleSqlite sqlite = new SimpleSqlite("personal", "Database");
            List <Dictionary <string, string> > result
                = sqlite.QueryFrom("simpleUI.db3", "UPS", new List <string>()
            {
                "*"
            }, String.Format("USER='******'", User));

            if (result == null)
            {   //数据库出错
                return(false);
            }

            if (result.Count == 0)
            {   //不存在该用户
                return(false);
            }

            string correctPassword = null;

            result[0].TryGetValue("PASSWORD", out correctPassword);
            if (correctPassword == null)
            {   //数据库出错
                return(false);
            }

            if (correctPassword != Password)
            {   //密码错误
                return(false);
            }

            return(true);
        }
Ejemplo n.º 3
0
        private void SureEvent(object sender, EventArgs e)
        {
            string user     = UserName.Text;
            string password = Password.Text;
            string twice    = TwicePassword.Text;

            //check input
            if (user.Equals("") || password.Equals("") || twice.Equals(""))
            {
                SimpleAlert.Show("错误", "请输入完整", "确定");
                return;
            }

            if (!password.Equals(twice))
            {
                SimpleAlert.Show("错误", "两次密码应该一样", "确定");
                return;
            }

            //finish
            SimpleSqlite.InsertInto("personal", "Database", "SimpleUI.db3", "UPS", new List <string>()
            {
                user, password
            });
            this.NavigationController.PopViewController(true);
        }