//Hvis der klikkes på mobil nummer for at ændre det
        private void LblMobile_Click(object sender, EventArgs e)
        {
            FormTextInput inputBox = new FormTextInput("Enter new mobile: ");

            if (inputBox.DialogResult == DialogResult.OK)
            {
                //Tjekker for krav
                if (inputBox.Message.Length != 8 || inputBox.Message == "Mobile" || !inputBox.Message.All(char.IsDigit))
                {
                    Utils.Shake(Settings.FormMain);
                }
                else
                {
                    //Sæt og gem nye mobil nummer
                    Settings.CurrentUser.Mobile = inputBox.Message;
                    Settings.CurrentUser.Save();
                    UpdateInfo();
                }
            }
        }
        //Hvis der klikkes på navn for at ændre det
        private void LblName_Click(object sender, EventArgs e)
        {
            FormTextInput inputBox = new FormTextInput("Enter new name: ");

            if (inputBox.DialogResult == DialogResult.OK)
            {
                if (inputBox.Message.Length == 0 || inputBox.Message == "Full name")
                {
                    Utils.Shake(Settings.FormMain);
                }
                else
                {
                    //Sæt og gem nye navn
                    Settings.CurrentUser.Name = inputBox.Message;
                    Settings.CurrentUser.Save();
                    UpdateInfo();
                    new FormMessage("Your name has been changed!");
                }
            }
        }
        //Hvis der klikkes på email for at ændre det
        private void LblEmail_Click(object sender, EventArgs e)
        {
            FormTextInput inputBox = new FormTextInput("Enter new email: ");

            if (inputBox.DialogResult == DialogResult.OK)
            {
                //Tjekker for krav
                if (!Utils.IsValidEmail(inputBox.Message))
                {
                    Utils.Shake(Settings.FormMain);
                }
                else
                {
                    //Sæt og gem nye email
                    Settings.CurrentUser.Email = inputBox.Message;
                    Settings.CurrentUser.Save();
                    UpdateInfo();
                    new FormMessage("Your Email has been changed!");
                }
            }
        }
        private void ChangePassword(String title)
        {
            FormTextInput inputBox = new FormTextInput(title);

            if (inputBox.DialogResult == DialogResult.OK)
            {
                //Tjekker for krav
                if (inputBox.Message.Length < 8 || inputBox.Message == "Password")
                {
                    inputBox.Hide();
                    ChangePassword("Enter new password: Please try again");
                }
                else
                {
                    //Sæt og gem nye password
                    Settings.CurrentUser.Password = Utils.CalculateMD5Hash(inputBox.Message);
                    Settings.CurrentUser.Save();
                    UpdateInfo();
                    new FormMessage("Your password has been changed!");
                }
            }
        }
Beispiel #5
0
        //Bruges til at lave konto
        public void CreateAccount(String customMSG)
        {
            FormTextInput customText;

            if (customMSG != null)
            {
                customText = new FormTextInput(customMSG);
            }
            else
            {
                customText = new FormTextInput("Name of account: ");
            }
            if (customText.DialogResult == DialogResult.OK)
            {
                //Tjek om brugeren allerede har en account med det navn.
                Boolean exists = false;
                foreach (Account acc in user.Accounts)
                {
                    if (acc.Name.ToLower().Equals(customText.Message.ToLower()))
                    {
                        exists = true;
                    }
                }
                //Hvis ikke
                if (exists == false)
                {
                    //Tjekker om konto navnet er "white space"
                    if (!string.IsNullOrWhiteSpace(customText.Message))
                    {
                        if (customText.Message.Length < 20)
                        {
                            //Sætter og gemmer ny konto
                            Account newAccount = new Account(Utils.GenerateAccountNumber(), customText.Message, 0.0m, user.ID, null);
                            Settings.CurrentUser.Accounts.Add(newAccount);
                            user = Settings.CurrentUser;
                            user.Save();
                            UpdateList();
                            cmbChooseAccount.SelectedIndex = cmbChooseAccount.Items.IndexOf(newAccount.Name);
                            account = newAccount;
                            UpdateAccount();

                            Settings.PayAndTransfer.UpdateLists();
                        }
                        else
                        {
                            //Hvis navnet er for langt
                            CreateAccount("Your account name is too long!\nPlease try again!");
                        }
                    }
                    else
                    {
                        //Hvis navnet kun har "white space"
                        CreateAccount("Your account name can't\nonly contain whitespaces!\nPlease try again!");
                    }
                }
                else
                {
                    //Hvis navn allerede bruges af bruger
                    CreateAccount("You already have an account\nwith that name!\nPlease try again!");
                }
                //Hvis bruger fortryder, lukkes formen
            }
            else if (customText.DialogResult == DialogResult.Cancel)
            {
            }
        }