using System.Data;
using System.Data.SqlClient;
...
private void button1_Click(object sender, EventArgs e)
{
SqlConnection connection = new SqlConnection("server=(local);Integrated Security=SSPI; database=atum2_db_1");
try
{
if (MessageBox.Show("Are you sure that you want to reset the leaders?", "Reset the leaders", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
connection.Open();
new SqlCommand("UPDATE [atum2_db_1].[dbo].[td_InfluenceWarData] SET InflLeaderCharacterUID = 0 WHERE InfluenceType='2'", connection).ExecuteNonQuery();
new SqlCommand("UPDATE [atum2_db_1].[dbo].[td_InfluenceWarData] SET InflLeaderCharacterUID = 0 WHERE InfluenceType='4'", connection).ExecuteNonQuery();
new SqlCommand("UPDATE [atum2_db_1].[dbo].[td_InfluenceWarData] SET InflSub1LeaderCharacterUID = 0 WHERE InfluenceType='2'", connection).ExecuteNonQuery();
new SqlCommand("UPDATE [atum2_db_1].[dbo].[td_InfluenceWarData] SET InflSub1LeaderCharacterUID = 0 WHERE InfluenceType='4'", connection).ExecuteNonQuery();
new SqlCommand("UPDATE [atum2_db_1].[dbo].[td_InfluenceWarData] SET InflSub2LeaderCharacterUID = 0 WHERE InfluenceType='2'", connection).ExecuteNonQuery();
new SqlCommand("UPDATE [atum2_db_1].[dbo].[td_InfluenceWarData] SET InflSub2LeaderCharacterUID = 0 WHERE InfluenceType='4'", connection).ExecuteNonQuery();
new SqlCommand("DELETE FROM [atum2_db_1].[dbo].[td_Store] WHERE ItemNum = '7001320' OR ItemNum = '7001330'", connection).ExecuteNonQuery();
new SqlCommand("DELETE FROM [atum2_db_1].[dbo].[td_Store] WHERE ItemNum = '7001090'", connection).ExecuteNonQuery();
new SqlCommand("DELETE FROM [atum2_db_1].[dbo].[td_Store] WHERE ItemNum = '7016170'", connection).ExecuteNonQuery();
new SqlCommand("DELETE FROM [atum2_db_1].[dbo].[td_Store] WHERE ItemNum = '7001110'", connection).ExecuteNonQuery();
MessageBox.Show("The leaders have been successfully reseted!");
connection.Close();
}
}
catch (Exception exception)
{
Console.WriteLine(exception.ToString());
}
}
private void button2_Click(object sender, EventArgs e)
{
string text = this.textBox1.Text;
if (text == "")
{
MessageBox.Show("Please enter a username first!");
}
else
{
SqlConnection connection = new SqlConnection("server=(local);Integrated Security=SSPI; database=atum2_db_1");
try
{
connection.Open();
int num = 0;
SqlCommand command = new SqlCommand("SELECT InflLeaderCharacterUID FROM [atum2_db_1].[dbo].[td_InfluenceWarData] WHERE InfluenceType = '4'", connection);
int num2 = (int) command.ExecuteScalar();
SqlCommand command2 = new SqlCommand("SELECT InflLeaderCharacterUID FROM [atum2_db_1].[dbo].[td_InfluenceWarData] WHERE InfluenceType = '2'", connection);
int num3 = (int) command2.ExecuteScalar();
SqlCommand command3 = new SqlCommand("SELECT Count(*) FROM [atum2_db_1].[dbo].[td_Character] WHERE CharacterName = @CharacterName", connection);
command3.Parameters.AddWithValue("@CharacterName", text);
if (((int) command3.ExecuteScalar()) != 0)
{
SqlCommand command4 = new SqlCommand("SELECT UniqueNumber FROM [atum2_db_1].[dbo].[td_Character] WHERE CharacterName = @CharacterName", connection);
command4.Parameters.AddWithValue("@CharacterName", text);
num = (int) command4.ExecuteScalar();
if ((num2 == 0) || ((num3 == 0) && (num != 0)))
{
if (MessageBox.Show(string.Format("Are you sure that you want to set '{0}' to a leader?", text.ToUpper()), "Set a leader", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
SqlCommand command5 = new SqlCommand("SELECT InfluenceType FROM [atum2_db_1].[dbo].[td_Character] WHERE CharacterName = @CharacterName", connection);
command5.Parameters.AddWithValue("@CharacterName", text);
int num5 = (byte) command5.ExecuteScalar();
SqlCommand command6 = new SqlCommand("SELECT AccountUniqueNumber FROM [atum2_db_1].[dbo].[td_Character] WHERE CharacterName = @CharacterName", connection);
command6.Parameters.AddWithValue("@CharacterName", text);
int num6 = (int) command6.ExecuteScalar();
switch (num5)
{
case 2:
{
SqlCommand command7 = new SqlCommand("UPDATE [atum2_db_1].[dbo].[td_InfluenceWarData] SET InflLeaderCharacterUID = @UID WHERE InfluenceType='2'", connection);
command7.Parameters.AddWithValue("@UID", num);
command7.ExecuteNonQuery();
SqlCommand command8 = new SqlCommand("INSERT INTO [atum2_db_1].[dbo].[td_Store] (AccountUniqueNumber,Possess,ItemStorage,Wear,CurrentCount,ItemNum) VALUES (@AccID,@UID,'0','0','1','7001320')", connection);
command8.Parameters.AddWithValue("@AccID", num6);
command8.Parameters.AddWithValue("@UID", num);
command8.ExecuteNonQuery();
SqlCommand command9 = new SqlCommand("INSERT INTO [atum2_db_1].[dbo].[td_Store] (AccountUniqueNumber,Possess,ItemStorage,Wear,CurrentCount,ItemNum) VALUES (@AccID, @UID,'0','0','5','7001090')", connection);
command9.Parameters.AddWithValue("@AccID", num6);
command9.Parameters.AddWithValue("@UID", num);
command9.ExecuteNonQuery();
SqlCommand command10 = new SqlCommand("INSERT INTO [atum2_db_1].[dbo].[td_Store] (AccountUniqueNumber,Possess,ItemStorage,Wear,CurrentCount,ItemNum) VALUES (@AccID,@UID,'0','0','1','7016170')", connection);
command10.Parameters.AddWithValue("@AccID", num6);
command10.Parameters.AddWithValue("@UID", num);
command10.ExecuteNonQuery();
SqlCommand command11 = new SqlCommand("INSERT INTO [atum2_db_1].[dbo].[td_Store] (AccountUniqueNumber,Possess,ItemStorage,Wear,CurrentCount,ItemNum) VALUES (@AccID,@UID,'0','0','5','7001110')", connection);
command11.Parameters.AddWithValue("@AccID", num6);
command11.Parameters.AddWithValue("@UID", num);
command11.ExecuteNonQuery();
new SqlCommand("UPDATE [atum2_db_1].[dbo].[td_InfluenceWarData] SET WartimeStage = 0 WHERE InfluenceType='2'", connection).ExecuteNonQuery();
break;
}
case 4:
{
SqlCommand command13 = new SqlCommand("UPDATE [atum2_db_1].[dbo].[td_InfluenceWarData] SET InflLeaderCharacterUID = @UID WHERE InfluenceType='4'", connection);
command13.Parameters.AddWithValue("@UID", num);
command13.ExecuteNonQuery();
SqlCommand command14 = new SqlCommand("INSERT INTO [atum2_db_1].[dbo].[td_Store] (AccountUniqueNumber,Possess,ItemStorage,Wear,CurrentCount,ItemNum) VALUES (@AccID,@UID,'0','0','1','7001330')", connection);
command14.Parameters.AddWithValue("@AccID", num6);
command14.Parameters.AddWithValue("@UID", num);
command14.ExecuteNonQuery();
SqlCommand command15 = new SqlCommand("INSERT INTO [atum2_db_1].[dbo].[td_Store] (AccountUniqueNumber,Possess,ItemStorage,Wear,CurrentCount,ItemNum) VALUES (@AccID,@UID,'0','0','5','7001090')", connection);
command15.Parameters.AddWithValue("@AccID", num6);
command15.Parameters.AddWithValue("@UID", num);
command15.ExecuteNonQuery();
SqlCommand command16 = new SqlCommand("INSERT INTO [atum2_db_1].[dbo].[td_Store] (AccountUniqueNumber,Possess,ItemStorage,Wear,CurrentCount,ItemNum) VALUES (@AccID,@UID,'0','0','1','7016170')", connection);
command16.Parameters.AddWithValue("@AccID", num6);
command16.Parameters.AddWithValue("@UID", num);
command16.ExecuteNonQuery();
SqlCommand command17 = new SqlCommand("INSERT INTO [atum2_db_1].[dbo].[td_Store] (AccountUniqueNumber,Possess,ItemStorage,Wear,CurrentCount,ItemNum) VALUES (@AccID,@UID,'0','0','5','7001110')", connection);
command17.Parameters.AddWithValue("@AccID", num6);
command17.Parameters.AddWithValue("@UID", num);
command17.ExecuteNonQuery();
new SqlCommand("UPDATE [atum2_db_1].[dbo].[td_InfluenceWarData] SET WartimeStage = 0 WHERE InfluenceType='4'", connection).ExecuteNonQuery();
break;
}
}
MessageBox.Show("The character has been successfully set to a leader!");
connection.Close();
}
}
else
{
connection.Close();
MessageBox.Show("You have to reset the leaders before you can set a new one!");
}
}
else
{
connection.Close();
MessageBox.Show("The charactername you entered doesn't exsit!");
}
}
catch (Exception exception)
{
Console.WriteLine(exception.ToString());
}
}
}
private void button3_Click(object sender, EventArgs e)
{
SqlConnection connection = new SqlConnection("server=(local);Integrated Security=SSPI; database=atum2_db_1");
try
{
if (MessageBox.Show("Are you sure that you want to reset the nationpoints?", "Reset the nationpoints", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
connection.Open();
new SqlCommand("UPDATE [atum2_db_1].[dbo].[td_InfluenceWarData] SET ContributionPoint = 0 WHERE InfluenceType='2'", connection).ExecuteNonQuery();
new SqlCommand("UPDATE [atum2_db_1].[dbo].[td_InfluenceWarData] SET ContributionPoint = 0 WHERE InfluenceType='4'", connection).ExecuteNonQuery();
MessageBox.Show("The nation points have been successfully reseted!");
connection.Close();
}
}
catch (Exception exception)
{
Console.WriteLine(exception.ToString());
}
}