/// <summary>
/// Reset stats button click event
/// </summary>
private async void ResetStatsBtn_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Are you sure you want to reset players stats?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
try
{
TaskForm.Show(this, "Reset Player Stats", "Reseting Player \"" + Player["name"] + "\"'s Stats", false);
await Task.Run(() =>
{
// Delete the players
using (StatsDatabase Driver = new StatsDatabase())
{
// Delete old player statistics
Driver.DeletePlayer(Pid, TaskForm.Progress);
// Insert a new player record
Driver.Execute(
"INSERT INTO player(id, name, country, joined, clantag, permban, isbot) VALUES(@P0, @P1, @P2, @P3, @P4, @P5, @P6)",
Pid, Player["name"], Player["country"], Player["joined"], Player["clantag"], Player["permban"], Player["isbot"]
);
}
});
// Reload player
LoadPlayer();
Notify.Show("Player Stats Reset Successfully!", "Operation Successful", AlertType.Success);
}
catch (DbConnectException Ex)
{
HttpServer.Stop();
ExceptionForm.ShowDbConnectError(Ex);
TaskForm.CloseForm();
this.Close();
return;
}
catch (Exception E)
{
// Show exception error
using (ExceptionForm Form = new ExceptionForm(E, false))
{
Form.Message = String.Format("Failed to reset player stats!{1}{1}Error: {0}", E.Message, Environment.NewLine);
Form.ShowDialog();
}
}
finally
{
// Close task form
TaskForm.CloseForm();
}
}
}