示例#1
0
        private void UpdateEntry()
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                if (dataGridView1.CurrentRow != null)
                {
                    Entry           entryToUpdate = (Entry)dataGridView1.CurrentRow.DataBoundItem;
                    Dialog_AddEntry dae           = new Dialog_AddEntry();

                    dae.tbName.Text       = entryToUpdate.Name;
                    dae.tbUrl.Text        = entryToUpdate.Url;
                    dae.tbUsername.Text   = entryToUpdate.UserName;
                    dae.tbPwd.Text        = entryToUpdate.Password;
                    dae.tbPwd_second.Text = entryToUpdate.Password;
                    dae.btnOk.Text        = "Modifier";

                    var dialogResult = dae.ShowDialog();
                    if (dialogResult == DialogResult.OK)
                    {
                        string name     = dae.tbName.Text;
                        string username = dae.tbUsername.Text;
                        string url      = dae.UrlString;
                        string password = dae.rbtnGenerate.Checked ? dae.lblPwdGenerated.Text : dae.tbPwd.Text;

                        _entries.UpdateEntry(_dbXmlDoc, entryToUpdate, name, username, url, password);
                        dataGridView1.Refresh();
                        _saved            = false;
                        tsbtnSave.Enabled = !_saved;
                    }
                }
            }
        }
示例#2
0
        private void AddEntry()
        {
            Dialog_AddEntry dae = new Dialog_AddEntry();
            DialogResult    res = dae.ShowDialog();

            if (res == DialogResult.OK)
            {
                string name     = dae.tbName.Text;
                string username = dae.tbUsername.Text;
                string url      = dae.UrlString;
                string password = dae.rbtnGenerate.Checked ? dae.lblPwdGenerated.Text : dae.tbPwd.Text;
                Entry  newEntry = new Entry(name, username, url, password);
                _entries.AddEntry(_dbXmlDoc, newEntry);
            }
        }