private void ConnectionBtn_Click(object sender, EventArgs e) { con = new DBInstance(serverTxt.Text, databaseTxt.Text, usernameTxt.Text, passwordTxt.Text); if (con.Connected()) { lblWaiting.Text = "Connecting to " + con.ConnectionString().Substring(con.ConnectionString().IndexOf('=') + 1).Substring(0, con.ConnectionString().IndexOf(';') - (con.ConnectionString().IndexOf('=')) - 1); con.Disconnect(); Connection(); } else { con.Connection(); lblWaiting.Text = "Connecting to " + con.ConnectionString().Substring(con.ConnectionString().IndexOf('=') + 1).Substring(0, con.ConnectionString().IndexOf(';') - (con.ConnectionString().IndexOf('=')) - 1); con.Disconnect(); Connection(); } }
private void hotfixBtn_Click(object sender, EventArgs e) { if (!con.Connected()) { con.Connection(); } if (con.Connected()) { try { if (!LegionBox.Checked) { MySqlCommand cmd_1 = new MySqlCommand(@"INSERT INTO " + EnumDefinition.EnumType.Tables.item.ToString() + " (" + getTableColumns(EnumDefinition.EnumType.Tables.item.ToString()) + ") VALUES (@param1,2,4,@param3,@param4,@param5,1,@param2,11,0)", con.TheConnection); cmd_1.Parameters.AddWithValue("@param1", itemIDTxt.Text); cmd_1.Parameters.AddWithValue("@param2", iconFileDataIDTxt.Text); cmd_1.Parameters.AddWithValue("@param3", (int)(EnumDefinition.EnumType.MaterialWeapon)Enum.Parse(typeof(EnumDefinition.EnumType.MaterialWeapon), materialBox.Text)); cmd_1.Parameters.AddWithValue("@param4", (int)(EnumDefinition.EnumType.InventoryTypeWeapon)Enum.Parse(typeof(EnumDefinition.EnumType.InventoryTypeWeapon), inventoryTypeBox.Text)); cmd_1.Parameters.AddWithValue("@param5", (int)(EnumDefinition.EnumType.Sheath)Enum.Parse(typeof(EnumDefinition.EnumType.Sheath), objectSlotBox.Text)); MySqlCommand cmd_2 = new MySqlCommand(@"INSERT INTO " + EnumDefinition.EnumType.Tables.item_appearance.ToString() + " (" + getTableColumns(EnumDefinition.EnumType.Tables.item_appearance.ToString()) + ") VALUES (@param1,@param4,@param2,@param3,3472000,0)", con.TheConnection); cmd_2.Parameters.AddWithValue("@param1", itemID2Txt.Text); cmd_2.Parameters.AddWithValue("@param2", displayIDTxt.Text); cmd_2.Parameters.AddWithValue("@param3", iconFileDataIDTxt.Text); cmd_2.Parameters.AddWithValue("@param4", 3); MySqlCommand cmd_3 = new MySqlCommand(@"INSERT INTO " + EnumDefinition.EnumType.Tables.item_modified_appearance.ToString() + " (" + getTableColumns(EnumDefinition.EnumType.Tables.item_modified_appearance.ToString()) + ") VALUES (@param1,@param2,0,@param3,0,4,0)", con.TheConnection); cmd_3.Parameters.AddWithValue("@param1", itemID3Txt.Text); cmd_3.Parameters.AddWithValue("@param2", itemIDTxt.Text); cmd_3.Parameters.AddWithValue("@param3", itemID2Txt.Text); MySqlCommand cmd_4 = new MySqlCommand(@"INSERT INTO " + EnumDefinition.EnumType.Tables.item_sparse.ToString() + " (" + getTableColumns(EnumDefinition.EnumType.Tables.item_sparse.ToString()) + ") " + @" VALUES (@param1,-1,@param3,@param2,@param2,@param2,@param2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,150,-1,7,0,0,0,0,0,0,@param7,@param6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,110,@param5,@param4,0)", con.TheConnection); cmd_4.Parameters.AddWithValue("@param1", itemIDTxt.Text); cmd_4.Parameters.AddWithValue("@param2", itemNameTxt.Text); cmd_4.Parameters.AddWithValue("@param3", itemDescTxt.Text); cmd_4.Parameters.AddWithValue("@param4", (int)(EnumDefinition.EnumType.Quality)Enum.Parse(typeof(EnumDefinition.EnumType.Quality), qualityBox.Text)); cmd_4.Parameters.AddWithValue("@param5", (int)(EnumDefinition.EnumType.InventoryTypeWeapon)Enum.Parse(typeof(EnumDefinition.EnumType.InventoryTypeWeapon), inventoryTypeBox.Text)); cmd_4.Parameters.AddWithValue("@param6", (int)(EnumDefinition.EnumType.MaterialWeapon)Enum.Parse(typeof(EnumDefinition.EnumType.MaterialWeapon), materialBox.Text)); cmd_4.Parameters.AddWithValue("@param7", (int)(EnumDefinition.EnumType.Sheath)Enum.Parse(typeof(EnumDefinition.EnumType.Sheath), objectSlotBox.Text)); MySqlCommand cmd_5 = new MySqlCommand(@"INSERT INTO " + EnumDefinition.EnumType.Tables.item_sparse_locale.ToString() + @" VALUES (@param1,@param2,@param4,@param3,@param3,@param3,@param3,0)", con.TheConnection); cmd_5.Parameters.AddWithValue("@param1", itemIDTxt.Text); cmd_5.Parameters.AddWithValue("@param2", CultureInfo.CurrentCulture.Name.Replace("-", "")); cmd_5.Parameters.AddWithValue("@param3", itemNameTxt.Text); cmd_5.Parameters.AddWithValue("@param4", itemDescTxt.Text); MySqlCommand cmd_6 = new MySqlCommand(@"INSERT INTO " + EnumDefinition.EnumType.Tables.hotfix_data.ToString() + " (" + getTableColumns(EnumDefinition.EnumType.Tables.hotfix_data.ToString()) + ") VALUES (@param1,@param2,@param3,0)", con.TheConnection); cmd_6.Parameters.AddWithValue("@param1", hotfixDataMaxID()); cmd_6.Parameters.AddWithValue("@param2", (UInt64)(EnumDefinition.EnumType.Tables)Enum.Parse(typeof(EnumDefinition.EnumType.Tables), EnumDefinition.EnumType.Tables.item.ToString())); cmd_6.Parameters.AddWithValue("@param3", itemIDTxt.Text); MySqlCommand cmd_7 = new MySqlCommand(@"INSERT INTO " + EnumDefinition.EnumType.Tables.hotfix_data.ToString() + " (" + getTableColumns(EnumDefinition.EnumType.Tables.hotfix_data.ToString()) + ") VALUES (@param1,@param2,@param3,0)", con.TheConnection); cmd_7.Parameters.AddWithValue("@param1", hotfixDataMaxID() + 1); cmd_7.Parameters.AddWithValue("@param2", (UInt64)(EnumDefinition.EnumType.Tables)Enum.Parse(typeof(EnumDefinition.EnumType.Tables), EnumDefinition.EnumType.Tables.item_appearance.ToString())); cmd_7.Parameters.AddWithValue("@param3", itemID2Txt.Text); MySqlCommand cmd_8 = new MySqlCommand(@"INSERT INTO " + EnumDefinition.EnumType.Tables.hotfix_data.ToString() + " (" + getTableColumns(EnumDefinition.EnumType.Tables.hotfix_data.ToString()) + ") VALUES (@param1,@param2,@param3,0)", con.TheConnection); cmd_8.Parameters.AddWithValue("@param1", hotfixDataMaxID() + 2); cmd_8.Parameters.AddWithValue("@param2", (UInt64)(EnumDefinition.EnumType.Tables)Enum.Parse(typeof(EnumDefinition.EnumType.Tables), EnumDefinition.EnumType.Tables.item_modified_appearance.ToString())); cmd_8.Parameters.AddWithValue("@param3", itemID3Txt.Text); MySqlCommand cmd_9 = new MySqlCommand(@"INSERT INTO " + EnumDefinition.EnumType.Tables.hotfix_data.ToString() + " (" + getTableColumns(EnumDefinition.EnumType.Tables.hotfix_data.ToString()) + ") VALUES (@param1,@param2,@param3,0)", con.TheConnection); cmd_9.Parameters.AddWithValue("@param1", hotfixDataMaxID() + 3); cmd_9.Parameters.AddWithValue("@param2", (UInt64)(EnumDefinition.EnumType.Tables)Enum.Parse(typeof(EnumDefinition.EnumType.Tables), EnumDefinition.EnumType.Tables.item_sparse.ToString())); cmd_9.Parameters.AddWithValue("@param3", itemIDTxt.Text); if (itemIDTxt.Text != "" && iconFileDataIDTxt.Text != "" && materialBox.Text != "" && inventoryTypeBox.Text != "" && qualityBox.Text != "" && itemID2Txt.Text != "" && itemID3Txt.Text != "" && itemNameTxt.Text != "" && itemDescTxt.Text != "" && displayIDTxt.Text != "") { cmd_1.ExecuteNonQuery(); cmd_2.ExecuteNonQuery(); cmd_3.ExecuteNonQuery(); cmd_4.ExecuteNonQuery(); cmd_5.ExecuteNonQuery(); cmd_6.ExecuteNonQuery(); cmd_7.ExecuteNonQuery(); cmd_8.ExecuteNonQuery(); cmd_9.ExecuteNonQuery(); MessageBox.Show("Your weapon item has been hotfixed", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information); con.Disconnect(); } else { MessageBox.Show("You haven't filled all the cells", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); con.Disconnect(); } } else { MySqlCommand cmd_1 = new MySqlCommand(@"INSERT INTO " + EnumDefinition.EnumType.Tables.item.ToString() + " (" + getTableColumns(EnumDefinition.EnumType.Tables.item.ToString()) + ") VALUES (@param1,@param2,2,4,1,@param3,@param4,@param5,11,0)", con.TheConnection); cmd_1.Parameters.AddWithValue("@param1", itemIDTxt.Text); cmd_1.Parameters.AddWithValue("@param2", iconFileDataIDTxt.Text); cmd_1.Parameters.AddWithValue("@param3", (int)(EnumDefinition.EnumType.MaterialWeapon)Enum.Parse(typeof(EnumDefinition.EnumType.MaterialWeapon), materialBox.Text)); cmd_1.Parameters.AddWithValue("@param4", (int)(EnumDefinition.EnumType.InventoryTypeWeapon)Enum.Parse(typeof(EnumDefinition.EnumType.InventoryTypeWeapon), inventoryTypeBox.Text)); cmd_1.Parameters.AddWithValue("@param5", (int)(EnumDefinition.EnumType.Sheath)Enum.Parse(typeof(EnumDefinition.EnumType.Sheath), objectSlotBox.Text)); MySqlCommand cmd_2 = new MySqlCommand(@"INSERT INTO " + EnumDefinition.EnumType.Tables.item_appearance.ToString() + " (" + getTableColumns(EnumDefinition.EnumType.Tables.item_appearance.ToString()) + ") VALUES (@param1,@param2,@param3,3472000,@param4,0)", con.TheConnection); cmd_2.Parameters.AddWithValue("@param1", itemID2Txt.Text); cmd_2.Parameters.AddWithValue("@param2", displayIDTxt.Text); cmd_2.Parameters.AddWithValue("@param3", iconFileDataIDTxt.Text); cmd_2.Parameters.AddWithValue("@param4", 3); MySqlCommand cmd_3 = new MySqlCommand(@"INSERT INTO " + EnumDefinition.EnumType.Tables.item_modified_appearance.ToString() + " (" + getTableColumns(EnumDefinition.EnumType.Tables.item_modified_appearance.ToString()) + ") VALUES (@param1,@param3,0,0,4,@param2,0)", con.TheConnection); cmd_3.Parameters.AddWithValue("@param1", itemIDTxt.Text); cmd_3.Parameters.AddWithValue("@param2", itemID3Txt.Text); cmd_3.Parameters.AddWithValue("@param3", itemID2Txt.Text); MySqlCommand cmd_4 = new MySqlCommand(@"INSERT INTO " + EnumDefinition.EnumType.Tables.item_sparse.ToString() + " (" + getTableColumns(EnumDefinition.EnumType.Tables.item_sparse.ToString()) + ") " + @" VALUES (@param1,-1,@param2,@param2,@param2,@param2,@param3,0,8192,0,0,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,-1,930,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,@param4,@param5,110,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,@param6,@param7,0,0,0,0,0,0,6,0)", con.TheConnection); cmd_4.Parameters.AddWithValue("@param1", itemIDTxt.Text); cmd_4.Parameters.AddWithValue("@param2", itemNameTxt.Text); cmd_4.Parameters.AddWithValue("@param3", itemDescTxt.Text); cmd_4.Parameters.AddWithValue("@param4", (int)(EnumDefinition.EnumType.Quality)Enum.Parse(typeof(EnumDefinition.EnumType.Quality), qualityBox.Text)); cmd_4.Parameters.AddWithValue("@param5", (int)(EnumDefinition.EnumType.InventoryTypeWeapon)Enum.Parse(typeof(EnumDefinition.EnumType.InventoryTypeWeapon), inventoryTypeBox.Text)); cmd_4.Parameters.AddWithValue("@param6", (int)(EnumDefinition.EnumType.MaterialWeapon)Enum.Parse(typeof(EnumDefinition.EnumType.MaterialWeapon), materialBox.Text)); cmd_4.Parameters.AddWithValue("@param7", (int)(EnumDefinition.EnumType.Sheath)Enum.Parse(typeof(EnumDefinition.EnumType.Sheath), objectSlotBox.Text)); MySqlCommand cmd_5 = new MySqlCommand(@"INSERT INTO " + EnumDefinition.EnumType.Tables.item_sparse_locale.ToString() + @" VALUES (@param1,@param2,@param4,@param3,@param3,@param3,@param3,0)", con.TheConnection); cmd_5.Parameters.AddWithValue("@param1", itemIDTxt.Text); cmd_5.Parameters.AddWithValue("@param2", CultureInfo.CurrentCulture.Name.Replace("-", "")); cmd_5.Parameters.AddWithValue("@param3", itemNameTxt.Text); cmd_5.Parameters.AddWithValue("@param4", itemDescTxt.Text); MySqlCommand cmd_6 = new MySqlCommand(@"INSERT INTO " + EnumDefinition.EnumType.Tables.hotfix_data.ToString() + " (" + getTableColumns(EnumDefinition.EnumType.Tables.hotfix_data.ToString()) + ") VALUES (@param1,@param2,@param3,0)", con.TheConnection); cmd_6.Parameters.AddWithValue("@param1", hotfixDataMaxID()); cmd_6.Parameters.AddWithValue("@param2", (UInt64)(EnumDefinition.EnumType.Tables)Enum.Parse(typeof(EnumDefinition.EnumType.Tables), EnumDefinition.EnumType.Tables.item.ToString())); cmd_6.Parameters.AddWithValue("@param3", itemIDTxt.Text); MySqlCommand cmd_7 = new MySqlCommand(@"INSERT INTO " + EnumDefinition.EnumType.Tables.hotfix_data.ToString() + " (" + getTableColumns(EnumDefinition.EnumType.Tables.hotfix_data.ToString()) + ") VALUES (@param1,@param2,@param3,0)", con.TheConnection); cmd_7.Parameters.AddWithValue("@param1", hotfixDataMaxID() + 1); cmd_7.Parameters.AddWithValue("@param2", (UInt64)(EnumDefinition.EnumType.Tables)Enum.Parse(typeof(EnumDefinition.EnumType.Tables), EnumDefinition.EnumType.Tables.item_appearance.ToString())); cmd_7.Parameters.AddWithValue("@param3", itemID2Txt.Text); MySqlCommand cmd_8 = new MySqlCommand(@"INSERT INTO " + EnumDefinition.EnumType.Tables.hotfix_data.ToString() + " (" + getTableColumns(EnumDefinition.EnumType.Tables.hotfix_data.ToString()) + ") VALUES (@param1,@param2,@param3,0)", con.TheConnection); cmd_8.Parameters.AddWithValue("@param1", hotfixDataMaxID() + 2); cmd_8.Parameters.AddWithValue("@param2", (UInt64)(EnumDefinition.EnumType.Tables)Enum.Parse(typeof(EnumDefinition.EnumType.Tables), EnumDefinition.EnumType.Tables.item_modified_appearance.ToString())); cmd_8.Parameters.AddWithValue("@param3", itemID3Txt.Text); MySqlCommand cmd_9 = new MySqlCommand(@"INSERT INTO " + EnumDefinition.EnumType.Tables.hotfix_data.ToString() + " (" + getTableColumns(EnumDefinition.EnumType.Tables.hotfix_data.ToString()) + ") VALUES (@param1,@param2,@param3,0)", con.TheConnection); cmd_9.Parameters.AddWithValue("@param1", hotfixDataMaxID() + 3); cmd_9.Parameters.AddWithValue("@param2", (UInt64)(EnumDefinition.EnumType.Tables)Enum.Parse(typeof(EnumDefinition.EnumType.Tables), EnumDefinition.EnumType.Tables.item_sparse.ToString())); cmd_9.Parameters.AddWithValue("@param3", itemIDTxt.Text); if (itemIDTxt.Text != "" && iconFileDataIDTxt.Text != "" && materialBox.Text != "" && inventoryTypeBox.Text != "" && qualityBox.Text != "" && itemID2Txt.Text != "" && itemID3Txt.Text != "" && itemNameTxt.Text != "" && itemDescTxt.Text != "" && displayIDTxt.Text != "") { cmd_1.ExecuteNonQuery(); cmd_2.ExecuteNonQuery(); cmd_3.ExecuteNonQuery(); cmd_4.ExecuteNonQuery(); cmd_5.ExecuteNonQuery(); cmd_6.ExecuteNonQuery(); cmd_7.ExecuteNonQuery(); cmd_8.ExecuteNonQuery(); cmd_9.ExecuteNonQuery(); MessageBox.Show("Your weapon item has been hotfixed", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information); con.Disconnect(); } else { MessageBox.Show("You haven't filled all the cells", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); con.Disconnect(); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } else { MessageBox.Show("No Active Connection", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void SQL_Script_Generation() { if (!con.Connected()) { con.Connection(); } if (con.Connected()) { timer = new Stopwatch(); timer.Start(); sb = new StringBuilder(); if (File.Exists(pathFile)) { File.Delete(pathFile); } File.AppendAllText(pathFile, "##Script " + TableName + " du " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss\n\n")); try { MySqlCommand cmd = new MySqlCommand(@"SELECT column_name as 'Column Name' FROM information_schema.columns WHERE table_name = '" + TableName + "'", con.TheConnection); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { sb.Append(reader["Column Name"].ToString()); sb.Append(','); } tableColumns = sb.ToString().Substring(0, sb.ToString().LastIndexOf(',')); tableColumnsArray = tableColumns.Split(','); sb.Clear(); reader.Close(); cmd = new MySqlCommand("SELECT " + tableColumns + " FROM " + TableName, con.TheConnection); reader = cmd.ExecuteReader(); dt = new DataTable(); dt.Load(reader); nbRows = dt.Rows.Count; reader.Close(); cmd = new MySqlCommand("SELECT " + tableColumns + " FROM " + TableName, con.TheConnection); reader = cmd.ExecuteReader(); while (reader.Read()) { for (int i = 0; i < tableColumnsArray.Length; i++) { sb.Append(reader[tableColumnsArray[i]] + ","); } queryResult = sb.ToString().Substring(0, sb.ToString().LastIndexOf(',')); csvQuery = "INSERT INTO `" + TableName + "` (" + tableColumns + ") VALUES (" + queryResult + ");\n"; File.AppendAllText(pathFile, csvQuery); sb.Clear(); counter++; if (timer.ElapsedMilliseconds % 2 == 0) { backgroundWorker1.ReportProgress(counter * 100 / nbRows); } } reader.Close(); } catch (Exception e) { MessageBox.Show(e.Message); } } else { MessageBox.Show("No Active Connection", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }