using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using SnowLight.Storage; namespace SnowLightV3.Forms { public partial class UserEdit : Form { public UserEdit() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { try { groupBox1.Enabled = true; string User; string Pass; string Mision; string Look; string HM; string Credits; string Pixeles; string IP; string respetos; string respetomascotas; User = MySqlClient.ReadString("SELECT username FROM characters WHERE username LIKE '" + textBox1.Text + "'"); Pass = MySqlClient.ReadString("SELECT password FROM accounts WHERE username LIKE '" + textBox1.Text + "'"); Mision = MySqlClient.ReadString("SELECT motto FROM characters WHERE username LIKE '" + textBox1.Text + "'"); Look = MySqlClient.ReadString("SELECT figure FROM characters WHERE username LIKE '" + textBox1.Text + "'"); HM = MySqlClient.ReadString("SELECT gender FROM characters WHERE username LIKE '" + textBox1.Text + "'"); Credits = MySqlClient.ReadString("SELECT credits_balance FROM characters WHERE username LIKE '" + textBox1.Text + "'"); Pixeles = MySqlClient.ReadString("SELECT activity_points_balance FROM characters WHERE username LIKE '" + textBox1.Text + "'"); IP = MySqlClient.ReadString("SELECT last_ip FROM characters WHERE username LIKE '" + textBox1.Text + "'"); respetos = MySqlClient.ReadString("SELECT respect_credit_humans FROM characters WHERE username LIKE '" + textBox1.Text + "'"); respetomascotas = MySqlClient.ReadString("SELECT respect_credit_pets FROM characters WHERE username LIKE '" + textBox1.Text + "'"); textBox2.Text = User; textBox3.Text = Pass; textBox4.Text = Mision; textBox5.Text = Look; if (HM == "M") { comboBox1.Text = "Hombre"; } else { comboBox1.Text = "Mujer"; } textBox6.Text = Credits; textBox7.Text = Pixeles; textBox8.Text = IP; textBox9.Text = respetos; textBox10.Text = respetomascotas; } catch (Exception) { groupBox1.Enabled = false; MessageBox.Show("Se ha introducido un usuario no existente o no se pueden cargar los datos del usuario..."); } } } private void button2_Click(object sender, EventArgs e) { using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { try { MySqlClient.ExecuteNonQuery("UPDATE characters SET username = '" + textBox2.Text + "' WHERE username LIKE '" + textBox1.Text + "'"); MySqlClient.ExecuteNonQuery("UPDATE accounts SET username = '" + textBox2.Text + "' WHERE username LIKE '" + textBox1.Text + "'"); MySqlClient.ExecuteNonQuery("UPDATE accounts SET password = '" + textBox3.Text + "' WHERE username LIKE '" + textBox2.Text + "'"); MySqlClient.ExecuteNonQuery("UPDATE characters SET motto = '" + textBox4.Text + "' WHERE username LIKE '" + textBox2.Text + "'"); MySqlClient.ExecuteNonQuery("UPDATE characters SET figure = '" + textBox5.Text + "' WHERE username LIKE '" + textBox2.Text + "'"); MySqlClient.ExecuteNonQuery("UPDATE characters SET credits_balance = '" + textBox6.Text + "' WHERE username LIKE '" + textBox2.Text + "'"); MySqlClient.ExecuteNonQuery("UPDATE characters SET activity_points_balance = '" + textBox7.Text + "' WHERE username LIKE '" + textBox2.Text + "'"); MySqlClient.ExecuteNonQuery("UPDATE characters SET last_ip = '" + textBox8.Text + "' WHERE username LIKE '" + textBox2.Text + "'"); MySqlClient.ExecuteNonQuery("UPDATE characters SET respect_credit_humans = '" + textBox9.Text + "' WHERE username LIKE '" + textBox2.Text + "'"); MySqlClient.ExecuteNonQuery("UPDATE characters SET respect_credit_pets = '" + textBox10.Text + "' WHERE username LIKE '" + textBox2.Text + "'"); textBox1.Text = textBox2.Text; if (comboBox1.Text == "Hombre") { MySqlClient.ExecuteNonQuery("UPDATE characters SET gender = 'M' WHERE username LIKE '" + textBox2.Text + "'"); } else { MySqlClient.ExecuteNonQuery("UPDATE characters SET gender = 'F' WHERE username LIKE '" + textBox2.Text + "'"); } } catch (Exception) { groupBox1.Enabled = false; MessageBox.Show("No se han podido guardar los cambios...\n¿Introdujiste algun dato erroneo?"); } } } } }