/**<summary>Saves the xml to be modified for use in Terraria.</summary>*/ public static void SaveXmlConfiguration() { try { string configPath = Path.Combine(Patcher.ExeDirectory, CoinReplacer.ConfigName); XmlDocument doc = new XmlDocument(); doc.AppendChild(doc.CreateXmlDeclaration("1.0", "UTF-8", null)); XmlElement replacer = doc.CreateElement("RupeeReplacer"); doc.AppendChild(replacer); XmlElement element = doc.CreateElement("CopperCoin"); element.SetAttribute("Color", Copper.ToString()); replacer.AppendChild(element); element = doc.CreateElement("SilverCoin"); element.SetAttribute("Color", Silver.ToString()); replacer.AppendChild(element); element = doc.CreateElement("GoldCoin"); element.SetAttribute("Color", Gold.ToString()); replacer.AppendChild(element); element = doc.CreateElement("PlatinumCoin"); element.SetAttribute("Color", Platinum.ToString()); replacer.AppendChild(element); element = doc.CreateElement("CoinGun"); element.SetAttribute("Enabled", CoinGun.ToString()); replacer.AppendChild(element); element = doc.CreateElement("LuckyCoin"); element.SetAttribute("Enabled", LuckyCoin.ToString()); replacer.AppendChild(element); element = doc.CreateElement("CoinRing"); element.SetAttribute("Enabled", CoinRing.ToString()); replacer.AppendChild(element); element = doc.CreateElement("CoinPortal"); element.SetAttribute("Enabled", CoinPortal.ToString()); replacer.AppendChild(element); doc.Save(configPath); } catch (Exception ex) { throw new Exception("Failed to save " + CoinReplacer.ConfigName, ex); } }
public void SaveMoney() { try { using (SqlConnection con = new SqlConnection(Properties.Settings.Default.DBConnection)) { string sql = "INSERT INTO tblMoney(Platinum, Gold, Electrum, Silver, Copper) "; sql += "VALUES (" + Platinum.ToString() + ", " + Gold.ToString() + ", " + Electrum.ToString() + ", " + Silver.ToString() + ", " + Copper.ToString() + ")"; SqlCommand cmd = new SqlCommand(sql, con); con.Close(); cmd.Connection.Open(); cmd.ExecuteNonQuery(); con.Close(); } } catch { } }