void AddAccount(DBAccountRow accountRow) { ListViewItem lvi = lvAccounts.Items.Add(accountRow.ID.ToString()); lvi.SubItems.Add(accountRow.UserName); lvi.SubItems.Add(accountRow.Password); }
private void btnCreate_Click(object sender, EventArgs e) { CreateAccountDialog dlg = new CreateAccountDialog(); if (dlg.ShowDialog() == DialogResult.OK) { // Add this account to the database DBAccountRow accountRow = Database.AddAccount(dlg.tbAccount.Text, dlg.tbPassword.Text); // Add it to the list AddAccount(accountRow); } }
static public DBAccountRow AddAccount(string accountName, string password) { string sql = string.Format("INSERT INTO accounts SET user_name=\"{0}\",password=\"{1}\"; SELECT LAST_INSERT_ID();", accountName, password); List <object[]> rows = ExecuteQuery(sql); DBAccountRow account = new DBAccountRow(-1, accountName, password); if (rows.Count > 0) { ulong id = (ulong)rows[0][0]; account.ID = (int)id; } return(account); }