示例#1
0
        private void CreateKeyButton_Click(object sender, EventArgs e)
        {
            if (MainForm.havePassword)
            {
                using (SaveFileDialog sfd = new SaveFileDialog())
                {
                    sfd.Title  = "Create secure key";
                    sfd.Filter = "Passave Secure Key (*.psvkey)|*.psvkey";

                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        using (StreamWriter sw = new StreamWriter(sfd.FileName))
                        {
                            string hash;
                            using (MD5 md5hash = MD5.Create())
                            {
                                hash = MainForm.GetMD5Hash(md5hash, MainForm.password);
                                sw.Write(hash);

                                MainForm.password = NewPasswordTextBox.Text;
                                NewMessageBox messageBox = new NewMessageBox(CreateSecureKeySuccessfullMB, SuccessHMB);
                                messageBox.ShowDialog();
                            }
                        }
                    }
                }
            }
            else
            {
                NewMessageBox messageBox = new NewMessageBox(CreateSecureKeyWrongMB, ErrorHMB);
                messageBox.Show();
            }
        }
示例#2
0
 private void ChangeButton_Click(object sender, EventArgs e)
 {
     if (ConfirmPasswordTextBox.Text != NewPasswordTextBox.Text)
     {
         NewMessageBox messageBox = new NewMessageBox(WrongOldPasswordMB, ErrorHMB);
         messageBox.ShowDialog();
     }
     else if (!MainForm.havePassword)
     {
         MainForm.password = NewPasswordTextBox.Text;
         NewMessageBox messageBox = new NewMessageBox(PasswordSetsMB, SuccessHMB);
         messageBox.ShowDialog();
         MainForm.havePassword = true;
     }
     else if (OldPasswordTextBox.Text == MainForm.password && NewPasswordTextBox.Text == ConfirmPasswordTextBox.Text)
     {
         MainForm.password = NewPasswordTextBox.Text;
         NewMessageBox messageBox = new NewMessageBox(PasswordChangedMB, SuccessHMB);
         messageBox.ShowDialog();
         MainForm.havePassword = true;
     }
 }
示例#3
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            NewMessageBox messageBox;

            if (PasswordTextBox.Text != RepeatPasswordTextBox.Text)
            {
                messageBox = new NewMessageBox(PasswordNotEqualsMB, AttentionHMB);
                messageBox.ShowDialog();
            }
            else
            {
                if (MainForm.isSNShow || MainForm.isEmailShow || MainForm.isOtherShow)
                {
                    if (NameTextBox.Text != "" && PasswordTextBox.Text != "" && LoginTextBox.Text != "")
                    {
                        addEntry     = new Entry(NameTextBox.Text, LoginTextBox.Text, PasswordTextBox.Text, PhoneTextBox.Text, UrlTextBox.Text, NotesTextBox.Text);
                        DialogResult = DialogResult.OK;
                        Close();
                    }
                    else if (addEntry.Name == NameTextBox.Text && addEntry.Login == LoginTextBox.Text && addEntry.Password == PasswordTextBox.Text &&
                             addEntry.Phone == PhoneTextBox.Text && addEntry.URL == UrlTextBox.Text && addEntry.Notes == NotesTextBox.Text)
                    {
                        DialogResult = DialogResult.Cancel;
                    }
                    else
                    {
                        messageBox = new NewMessageBox(EmptyNameLoginMB, AttentionHMB);
                        messageBox.ShowDialog();
                    }
                }

                if (MainForm.isHomebankingShow)
                {
                    if (NameTextBox.Text == "" || CardNumberTextBox.Text == "" || DateTextBox.Text == "" || CvcTextBox.Text == "")
                    {
                        messageBox = new NewMessageBox(NameCardNumberDateCvcMB, AttentionHMB);
                        messageBox.ShowDialog();
                    }
                    else if (CvcTextBox.Text.Length != 3)
                    {
                        messageBox = new NewMessageBox(NotCorrectCvcMB, AttentionHMB);
                        messageBox.ShowDialog();
                    }
                    else if (!char.IsDigit(CvcTextBox.Text[0]) && !char.IsDigit(CvcTextBox.Text[1]) && !char.IsDigit(CvcTextBox.Text[2]))
                    {
                        messageBox = new NewMessageBox(NotCorrectCvcMB, AttentionHMB);
                        messageBox.ShowDialog();
                    }
                    else if (DateTextBox.Text.Length != 5)
                    {
                        messageBox = new NewMessageBox(NotCorrectDateMB, AttentionHMB);
                        messageBox.ShowDialog();
                    }
                    else if (!char.IsDigit(DateTextBox.Text[0]) && !char.IsDigit(DateTextBox.Text[1]) && !char.IsDigit(DateTextBox.Text[3]) && !char.IsDigit(DateTextBox.Text[4]))
                    {
                        messageBox = new NewMessageBox(NotCorrectDateMB, AttentionHMB);
                        messageBox.ShowDialog();
                    }
                    else if (addHomebankingEntry.Name == NameTextBox.Text && addHomebankingEntry.CardNumber == CardNumberTextBox.Text && addHomebankingEntry.Date == DateTextBox.Text &&
                             addHomebankingEntry.CVC == CvcTextBox.Text && addHomebankingEntry.Phone == PhoneTextBox.Text && addHomebankingEntry.Notes == NotesTextBox.Text)
                    {
                        DialogResult = DialogResult.Cancel;
                    }
                    else
                    {
                        addHomebankingEntry = new BankEntry(NameTextBox.Text, CardNumberTextBox.Text, DateTextBox.Text, CvcTextBox.Text, PhoneTextBox.Text, NotesTextBox.Text);
                        DialogResult        = DialogResult.OK;
                        Close();
                    }
                }
                if (MainForm.isLicensesShow)
                {
                    if (NameTextBox.Text != "" || KeyTextBox.Text != "")
                    {
                        addLicenseEntry = new LicenseEntry(NameTextBox.Text, KeyTextBox.Text, NotesTextBox.Text);
                        DialogResult    = DialogResult.OK;
                        Close();
                    }
                    else if (addLicenseEntry.Name == NameTextBox.Text && addLicenseEntry.Key == KeyTextBox.Text && addLicenseEntry.Notes == NotesTextBox.Text)
                    {
                        DialogResult = DialogResult.Cancel;
                    }
                    else
                    {
                        messageBox = new NewMessageBox(EmptyNameKeyMB, AttentionHMB);
                        messageBox.ShowDialog();
                    }
                }
            }
        }