Beispiel #1
0
        private void ExportBtn_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "Passwords File|*.mps";
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                if (PasswordsGrd.SelectedRows.Count > 0)
                {
                    //Create New File To Export To
                    PasswordsFile newfile = new PasswordsFile();
                    newfile.Passwords = new List <Password>();
                    foreach (DataGridViewRow row in PasswordsGrd.SelectedRows)
                    {
                        Password password = new Password()
                        {
                            password = row.Cells["Password_col"].Value.ToString(),
                            UserName = row.Cells["UserName_col"].Value.ToString(),
                            LNK      = row.Cells["Link_col"].Value.ToString(),
                            Details  = row.Cells["details_col"].Value.ToString(),
                        };
                        newfile.Passwords.Add(password);
                    }
                    //Save With The Same MasterPassword Or Create New
                    var result = MessageBox.Show("Do You Want To Set Master Password?", "new MasterPassword", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        CreateFileFrm frm = new CreateFileFrm(sfd.FileName);
                        if (frm.ShowDialog() == DialogResult.OK)
                        {
                            newfile.MasterPassword = frm.Password;
                        }
                        else
                        {
                            MessageBox.Show("You Have Canceld new Password Creation.File Will Be saved With Current Master Password.");
                            newfile.MasterPassword = file.MasterPassword;
                        }
                    }
                    else
                    {
                        newfile.MasterPassword = file.MasterPassword;
                    }
                    newfile.Save(sfd.FileName);
                }
                else
                {
                    file.Save(sfd.FileName);
                }

                MessageBox.Show("passwords Was Successfully Exported");
            }
        }
 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.");
     }
 }
Beispiel #3
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.");
            }
        }
Beispiel #4
0
 void Save()
 {
     if (string.IsNullOrEmpty(PasswordTxt.Text))
     {
         MessageBox.Show("Please Enter Password.");
     }
     else
     {
         if (PasswordTxt.Text == ConfirmTxt.Text)
         {
             PasswordsFile file = new PasswordsFile();
             file.MasterPassword = PasswordTxt.Text;
             file.Save(path);
             this.DialogResult = DialogResult.OK;
             Password          = PasswordTxt.Text;
             Close();
         }
         else
         {
             MessageBox.Show("Password And Confirm Doesn't Match");
         }
     }
 }