Ejemplo n.º 1
0
 private void createAccountButton_Click(object sender, EventArgs e)
 {
     if (usernameTX.Text != "" && passwordTX.Text != "" && userList.SelectedValue != "")
     {
         try
         {
             if (userList.SelectedIndex == 0) //Dev account
             {
                 DBConnect.SQuery("INSERT INTO account (accountID, accountName, role, password, banned, online)" +
                                  "VALUES (NULL, '" + usernameTX.Text + "', " + DEV + ", '" + passwordTX.Text + "', 0, 0)");
                 MessageBox.Show("Dev account added!");
             }
             else if (userList.SelectedIndex == 1) //Player account
             {
                 DBConnect.SQuery("INSERT INTO account (accountID, accountName, role, password, banned, online)" +
                                  "VALUES (NULL, '" + usernameTX.Text + "', " + PLAYER + ", '" + passwordTX.Text + "', 0, 0)");
                 MessageBox.Show("Player account added!");
             }
         }
         catch (InvalidExpressionException)
         {
             MessageBox.Show("Error: You might not have installed MySql, please make you have done so.", "Error");
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error: " + ex.Message, "Error");
         }
     }
 }
Ejemplo n.º 2
0
 private void delCheckedButton_Click(object sender, EventArgs e)
 {
     try
     {
         DBConnect.SQuery("DELETE FROM account WHERE accountName='" + userDataList.CurrentCell.Value + "'");
         userDataList.Rows.Remove(userDataList.CurrentRow);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 3
0
 private void createAccountButton_Click(object sender, EventArgs e)
 {
     if (usernameTX.Text != "" && passwordTX.Text != "")
     {
         DBConnect db = new DBConnect();
         try
         {
             db.SQuery("INSERT INTO account (accountName, password) VALUES ('" + usernameTX.Text + "', '" + passwordTX.Text + "')");
             MessageBox.Show("Account '" + usernameTX.Text + "' has been created. Have fun!", "Yay!");
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error: " + ex, "Error");
         }
     }
 }