void Save()
 {
     if (!string.IsNullOrEmpty(NewPassTxt.Text))
     {
         PasswordsFile file = PasswordsFile.Load(path);
         if (PasswordTxt.Text == file.MasterPassword)
         {
             if (NewPassTxt.Text == ConfirmTxt.Text)
             {
                 file.MasterPassword = NewPassTxt.Text;
                 file.Save(path);
                 Close();
             }
             else
             {
                 MessageBox.Show("Password Confirm Doesn't Match.");
             }
         }
         else
         {
             MessageBox.Show("Old Password Is Incorrect.");
         }
     }
     else
     {
         MessageBox.Show("Enter the New Password.");
     }
 }
Esempio n. 2
0
        void LoadFile(string path, bool OpenWithValidation)
        {
            PasswordsGrd.Rows.Clear();
            try
            {
                file = PasswordsFile.Load(path);
                bool passwordIsOk           = false;
                MasterPasswordInput_frm frm = new MasterPasswordInput_frm(file.MasterPassword);

                if (OpenWithValidation)
                {
                    passwordIsOk = frm.ShowDialog() == DialogResult.OK;
                }


                if ((OpenWithValidation && passwordIsOk) || OpenWithValidation == false)
                {
                    DisplayPasswords(file.Passwords);
                }
                else
                {
                    Close();
                }
            }
            catch
            {
                var result = MessageBox.Show("Faild To Open Passwords File.Do You Want To ReCreate It?", "Open Failed", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    CreateFileFrm frm2 = new CreateFileFrm(path);
                    frm2.ShowDialog();
                }
            }
        }
Esempio n. 3
0
        public Password_AE(int id, string path)
        {
            InitializeComponent();
            this.id   = id;
            this.path = path;
            //Retrive Password Details
            PasswordsFile passwordfile = PasswordsFile.Load(path);
            var           password     = passwordfile.Passwords.FirstOrDefault(x => x.ID == id);

            Passwordtxt.Text = password.password;
            UserNameTxt.Text = password.UserName;
            Linktxt.Text     = password.LNK;
            DetailsTxt.Text  = password.Details;
        }
Esempio n. 4
0
        void Save()
        {
            PasswordsFile passwordfile = PasswordsFile.Load(path);

            if (!string.IsNullOrEmpty(Passwordtxt.Text))
            {
                Password password = new Password();
                if (id != 0)
                {
                    password = passwordfile.Passwords.FirstOrDefault(x => x.ID == id);
                }
                else
                {
                    int maxid = 0;
                    if (passwordfile.Passwords == null)
                    {
                        passwordfile.Passwords = new List <Password>();
                    }
                    else if (passwordfile.Passwords.Count > 0)
                    {
                        maxid = passwordfile.Passwords.Max(x => x.ID);
                    }
                    password.ID = maxid + 1;

                    passwordfile.Passwords.Add(password);
                }
                password.password = Passwordtxt.Text;
                password.UserName = UserNameTxt.Text;
                password.LNK      = Linktxt.Text;
                password.Details  = DetailsTxt.Text;

                passwordfile.Save(path);
                Close();
            }
            else
            {
                MessageBox.Show("Please Enter Password.");
            }
        }