using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO; namespace Account_Editor { public partial class Main : Form { public string AccountName { get; set; } #region Account int AccountID = 0; string AccountPassword = ""; string AccountEmail = ""; int AccountAuthID = 0; string AccountIp = ""; int AccountCSPoints = 0; int AccountSame = 0; #endregion #region Other string AccountPasswordValue = ""; string AccountEmailValue = ""; int AccountAuthIDValue = 0; string AccountIpValue = ""; int AccountCSValue = 0; #endregion public Main() { InitializeComponent(); SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); } private void Main_Load(object sender, EventArgs e) { SetupStatistics(); SetupEdit(); } private void SetupStatistics() { try { AName.Text = AccountName; AccountID = Convert.ToInt32(Sql.Get("nEMID", "tAccounts", "sUsername", AccountName)); ID.Text = AccountID.ToString(); AccountPassword = Sql.Get("sUserPass", "tAccounts", "sUsername", AccountName); Password.Text = AccountPassword; AccountEmail = Sql.Get("sEmail", "tAccounts", "sUsername", AccountName); Email.Text = AccountEmail; AccountAuthID = Convert.ToInt32(Sql.Get("nAuthID", "tAccounts", "sUsername", AccountName)); AuthID.Text = AccountAuthID.ToString(); AccountIp = Sql.Get("sIp", "tAccounts", "sUsername", AccountName); Ip.Text = AccountIp; AccountCSPoints = Convert.ToInt32(Sql.Get("nAGPoints", "tAccounts", "sUsername", AccountName)); CSPoints.Text = AccountCSPoints.ToString(); AccountSame = Convert.ToInt32(Sql.Count("tAccounts", "sIP", AccountIp)); AccountSameIp.Text = AccountSame.ToString(); } catch (Exception Ex) { Utility.Information("There Was A Error Getting Information For " + AccountName); Utility.Information(Ex.ToString()); Close(); } } private void SetupEdit() { try { EditUsername.Text = AccountName; AccountPasswordValue = AccountPassword; EditPassword.Text = AccountPasswordValue; AccountEmailValue = AccountEmail; EditEmail.Text = AccountEmailValue; AccountAuthIDValue = AccountAuthID; EditAuthID.Value = AccountAuthIDValue; AccountIpValue = AccountIp; EditIp.Text = AccountIpValue; AccountCSValue = AccountCSPoints; EditCS.Value = AccountCSValue; } catch (Exception Ex) { Utility.Information("There Was A Error Getting Information For " + AccountName); Utility.Information(Ex.ToString()); Close(); } } private void ExecuteButton_Click(object sender, EventArgs e) { try { if (!(EditUsername.Text == AccountName)) { Sql.Update("sUsername", "tAccounts", EditUsername.Text, "sUsername", AccountName); AccountName = EditUsername.Text; } if (!(EditPassword.Text == AccountPasswordValue)) { Sql.Update("sUserPass", "tAccounts", EditPassword.Text, "sUsername", AccountName); } if (!(EditEmail.Text == AccountEmailValue)) { Sql.Update("sEmail", "tAccounts", EditEmail.Text, "sUsername", AccountName); } if (!(EditAuthID.Text == AccountAuthIDValue.ToString())) { Sql.Update("nAuthID", "tAccounts", EditAuthID.Text, "sUsername", AccountName); } if (!(EditIp.Text == AccountIpValue)) { Sql.Update("sIP", "tAccounts", EditIp.Text, "sUsername", AccountName); } if (!(EditCS.Text == AccountCSValue.ToString())) { Sql.Update("nAGPoints", "tAccounts", EditCS.Text, "sUsername", AccountName); } SetupStatistics(); SetupEdit(); MessageBox.Show(AccountName + " Information Has Been Updated"); } catch (Exception Ex) { Utility.Information(AccountName + " Was Not Updated, Please Try Again"); Utility.Information(Ex.ToString()); } } private void DeleteButton_Click(object sender, EventArgs e) { if (Utility.Question("Are You Sure You Want To Delete This Account?")) { Sql.DeleteAll("tAccounts", "sUsername", AccountName); Close(); } } private void RefreshButton_Click(object sender, EventArgs e) { SetupStatistics(); SetupEdit(); } private void BanButton_Click(object sender, EventArgs e) { if (Utility.Question("Are You Sure You Want To Ban This Account?")) { try { Sql.Ban(AccountName); Utility.Information("Account Has Been Banned"); Close(); } catch (Exception Excep) { Utility.Information("Account Could Not Be Banned"); Utility.Information(Excep.ToString()); } } } } }