Пример #1
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            string el1 = usnm.Text, el2 = uspassword.Text, el3 = uscs.Text, el4 = prnr.Text;



            if (string.IsNullOrEmpty(el1) || string.IsNullOrEmpty(el2) || string.IsNullOrEmpty(el3) || string.IsNullOrEmpty(el4))
            {
                new Popup(new ErrorMessage("Fyll i alla fälten!"), this).Show();
            }
            else
            {
                for (int i = 0; i < DB.accounts.Count; i++)
                {
                    var accs = DB.accounts[i];
                    if (accs.Username == el1 || accs.Pnumber == el4)
                    {
                        new Popup(new ErrorMessage("Kontot finns Redan!"), this).Show();
                        return;
                    }
                }


                await DB.AddAccount(new Account()
                {
                    Username = el1, Password = el2, Class = el3, Pnumber = el4, isAdmin = false
                });

                new Popup(new SuccessMessage("Kontot har Lagts till "), this).Show();
            }
        }
Пример #2
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            var el1 = usnm.Text; var el2 = uspassword.Text;

            if (el1 != null && el2 != null)
            {
                if (DB.getAccountByName(el1) == null)
                {
                    await DB.AddAccount(new Account()
                    {
                        Username = el1, Password = el2, isAdmin = true
                    });

                    new Popup(new SuccessMessage("Kontot har Lagts till "), this).Show();
                }
                else
                {
                    new Popup(new ErrorMessage("Kontot finns Redan!"), this).Show();
                }
            }
            else
            {
                new Popup(new ErrorMessage("Fyll i alla fälten!"), this).Show();
            }
        }