public AdminAddAccount(AdminAccountSettings set) { InitializeComponent(); cn = new SqlConnection(dbcon.MyConnection()); userset = set; }
private void BtnUpdate_Click_1(object sender, EventArgs e) { try { if (MessageBox.Show("Are you sure you want to Update this Account?", "Updating Account", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { cn.Open(); cm = new SqlCommand("UPDATE tblUsers SET name = @name, username = @username, password = @password, question = @question, answer = @answer, account = @account, dateupdated = @date WHERE username = '******'", cn); cm.Parameters.AddWithValue("@name", txtFullname.Text); cm.Parameters.AddWithValue("@username", txtUsername.Text); cm.Parameters.AddWithValue("@password", txtPassword.Text); cm.Parameters.AddWithValue("@question", cmbQuestion.Text); cm.Parameters.AddWithValue("@answer", txtAnswer.Text); cm.Parameters.AddWithValue("@account", cmbAccount.Text); cm.Parameters.AddWithValue("@date", dateTimePicker1.Value); cm.ExecuteNonQuery(); ClearData(); cn.Close(); MessageBox.Show("User Account has been Successfully Updated!", "Account Updated", MessageBoxButtons.OK, MessageBoxIcon.Information); AdminAccountSettings user = new AdminAccountSettings(); user.ShowAllAccounts(); this.Dispose(); } } catch (Exception ex) { cn.Close(); MessageBox.Show(ex.Message); } }
private void BtnUserSettings_Click(object sender, EventArgs e) { if (!AdminAdministrator.Instance.PnlContainer.Controls.ContainsKey("AdminAccountSettings")) { AdminAccountSettings user = new AdminAccountSettings(); user.Dock = DockStyle.Fill; AdminAdministrator.Instance.PnlContainer.Controls.Add(user); user.ShowAllAccounts(); } AdminAdministrator.Instance.PnlContainer.Controls["AdminAccountSettings"].BringToFront(); AdminAdministrator.Instance.BackButton.Visible = true; }