private void loadData() { floatingWindow.setContextMenuStrip(dataMenu); checkSelectedItems(); LSPMDatabase database = new LSPMDatabase(Properties.Settings.Default.pwdHash); LiteCollection <LSPMData> col = database.getDBCollection(); col.EnsureIndex(x => x.lAlias); credentials = col.FindAll().ToList(); credsView.Clear(); dataMenu.Items.Clear(); foreach (LSPMData data in credentials) { bool addSeparator = false; ListViewItem a = new ListViewItem(data.lAlias); a.ImageIndex = ( int )data.lDataIcon; credsView.Items.Add(a); ToolStripMenuItem mSup = new ToolStripMenuItem(data.lAlias, icons.Images[(int)data.lDataIcon]); mSup.BackColor = Color.FromArgb(33, 33, 33); mSup.ForeColor = Color.FromArgb(100, 200, 255); mSup.Font = new System.Drawing.Font("Segoe UI Semibold", 11.25F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(0))); if (data.lUserFastAccess) { LSPMMenuItem tItem = new LSPMMenuItem("Usuario", Properties.Resources.user, data.lUser, TaskbarHandler); tItem.BackColor = Color.FromArgb(33, 33, 33); mSup.DropDownItems.Add(tItem); addSeparator = true; } if (data.lPasswordFastAccess) { LSPMMenuItem tItem = new LSPMMenuItem("Clave", Properties.Resources.key, data.lPass, TaskbarHandler); tItem.BackColor = Color.FromArgb(33, 33, 33); mSup.DropDownItems.Add(tItem); addSeparator = true; } if (data.lPasswordFastAccess || data.lUserFastAccess) { dataMenu.Items.Add(mSup); } //if ( addSeparator ) dataMenu.Items.Add( new ToolStripSeparator() ); } dataMenu.Items.Add(toolStripSeparator1); dataMenu.Items.Add(generarPass); dataMenu.Items.Add(mostrarLSPMToolStripMenuItem); dataMenu.Items.Add(salirToolStripMenuItem); }
private void deleteCredsButton_Click(object sender, EventArgs e) { string alias = credsView.SelectedItems[0].Text; if (MessageBox.Show("¿Realmente desea eliminar la información seleccionada?", "¿Eliminar?", MessageBoxButtons.OKCancel) == DialogResult.OK) { LSPMDatabase database = new LSPMDatabase(Properties.Settings.Default.pwdHash); LiteCollection <LSPMData> col = database.getDBCollection(); col.EnsureIndex(x => x.lAlias); col.Delete(x => x.lAlias.Equals(alias)); loadData(); } }
private bool validatePwd(string pwd) { bool result = false; if (LSPMDatabase.hashString(pwd) == Properties.Settings.Default.pwdHash) { result = true; } else { MessageBox.Show("La contraseña es incorrecta", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(result); }
private void clearDB() { LSPMDatabase database = new LSPMDatabase(Properties.Settings.Default.pwdHash); LiteCollection <LSPMData> col = database.getDBCollection(); col.EnsureIndex(x => x.lAlias); List <LSPMData> credentials = col.FindAll().ToList(); foreach (LSPMData data in credentials) { col.Delete(data.Id); } DialogResult = DialogResult.OK; Close(); }
public editDataForm(string alias) { InitializeComponent(); db = new LSPMDatabase(Properties.Settings.Default.pwdHash); LiteDB.LiteCollection <LSPMData> col = db.getDBCollection(); col.EnsureIndex(x => x.lAlias); editable = col.FindOne(x => x.lAlias.Equals(alias)); aliasInput.Text = editable.lAlias; userInput.Text = editable.lUser; passwordInput.Text = editable.lPass; userAccessCheck.Checked = editable.lUserFastAccess; passwordAccessCheck.Checked = editable.lPasswordFastAccess; markColor(editable.lDataIcon); }
private void startButton_Click(object sender, EventArgs e) { if (passwordInput1.Text == "" || passwordInput2.Text == "") { MessageBox.Show("La contraseña no puede estar vacía", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (passwordInput1.Text != passwordInput2.Text) { MessageBox.Show("Las contraseñas no coinciden", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { Properties.Settings.Default.pwdHash = LSPMDatabase.hashString(passwordInput1.Text); Properties.Settings.Default.Save(); LSPMDatabase ndb = new LSPMDatabase(Properties.Settings.Default.pwdHash); ndb.getDBCollection().Insert(new LSPMData("admin", "1234", "Acceso Prueba", true, true)); DialogResult = DialogResult.OK; Close(); } }
private void newDataForm_Load(object sender, EventArgs e) { db = new LSPMDatabase(Properties.Settings.Default.pwdHash); }