private void btnSave_Click(object sender, EventArgs e) { var entryData = new DatabaseEntryData { Name = lblTitle.Text.Trim(), Url = txtUrl.Text.Trim(), Username = txtUsername.Text.Trim(), Password = _txtPassword.Text, Notes = txtNotes.Text }; if (_newPassword) entryData.PasswordShared = false; if (_editEntry) { var success = _databaseView.UpdateEntry(_entryId, entryData); if (!success) return; var newButton = new Templates.ButtonDisabled { Text = @"Save", Dock = DockStyle.Right, Width = _btnControl.Width }; panelSaveBtn.Controls.Remove(_btnControl); panelSaveBtn.Controls.Add(newButton); _btnControl = newButton; } else { var newEntryId = _databaseView.NewEntry(entryData, _groupId); if (newEntryId == null) return; _entryId = newEntryId.Value; _editEntry = true; var newButton = new Templates.ButtonDisabled { Text = @"Save", Dock = DockStyle.Right, Width = _btnControl.Width }; panelSaveBtn.Controls.Remove(_btnControl); panelSaveBtn.Controls.Add(newButton); _btnControl = newButton; _databaseView.UpdateControl(newEntryId.Value); } tablePasswordContainer.Controls.Remove(_txtPassword); tablePasswordContainer.Controls.Add(_lblPasswordShared); lblDelete.Visible = true; _newPassword = false; }
private void btnSave_Click(object sender, EventArgs e) { var entryData = new DatabaseEntryData { Name = lblTitle.Text.Trim(), Url = txtUrl.Text.Trim(), Username = txtUsername.Text.Trim(), Password = _txtPassword.Text, Notes = txtNotes.Text }; if (_newPassword) { entryData.PasswordShared = false; } if (_editEntry) { var success = _databaseView.UpdateEntry(_entryId, entryData); if (!success) { return; } var newButton = new Templates.ButtonDisabled { Text = @"Save", Dock = DockStyle.Right, Width = _btnControl.Width }; panelSaveBtn.Controls.Remove(_btnControl); panelSaveBtn.Controls.Add(newButton); _btnControl = newButton; } else { var newEntryId = _databaseView.NewEntry(entryData, _groupId); if (newEntryId == null) { return; } _entryId = newEntryId.Value; _editEntry = true; var newButton = new Templates.ButtonDisabled { Text = @"Save", Dock = DockStyle.Right, Width = _btnControl.Width }; panelSaveBtn.Controls.Remove(_btnControl); panelSaveBtn.Controls.Add(newButton); _btnControl = newButton; _databaseView.UpdateControl(newEntryId.Value); } tablePasswordContainer.Controls.Remove(_txtPassword); tablePasswordContainer.Controls.Add(_lblPasswordShared); lblDelete.Visible = true; _newPassword = false; }