public void UpdateUnit(Unit u)
 {
     using (MySqlConnection conn = new MySqlConnection(this.ConnectionString))
     {
         conn.Open();
         string commandText = "UPDATE Kunden SET CLASSNAME = ?, IMAGE = ?, NAME = ?, TYPE = ?, PRICE = ?, BUILDTIME = ?, UPGRADELEVEL = ?, FACTORY = ?, SCRIPT = ? WHERE id = ?";
         MySqlCommand cmd = new MySqlCommand(commandText, conn);
         cmd.Parameters.AddWithValue("?", u.Classname);
         cmd.Parameters.AddWithValue("?", u.Image);
         cmd.Parameters.AddWithValue("?", u.Name);
         cmd.Parameters.AddWithValue("?", u.Type);
         cmd.Parameters.AddWithValue("?", u.Price);
         cmd.Parameters.AddWithValue("?", u.BuildTime);
         cmd.Parameters.AddWithValue("?", u.UpgradeLevel);
         cmd.Parameters.AddWithValue("?", u.Factory);
         cmd.Parameters.AddWithValue("?", u.Script);
         ExecutionErrorHandler(cmd);
     }
 }
 public void InsertUnit(Unit u)
 {
     using (MySqlConnection conn = new MySqlConnection(this.ConnectionString))
     {
         conn.Open();
         string commandText = "INSERT INTO Units(CLASSNAME, IMAGE, NAME, TYPE, PRICE, BUILDTIME, UPGRADELEVEL, FACTORY, SCRIPT, SIDE) VALUES (?classname, ?image, ?name, ?type, ?price, ?buildtime, ?upgradelevel , ?factory, ?script, ?side)";
         MySqlCommand cmd = new MySqlCommand(commandText, conn);
         cmd.Parameters.AddWithValue("?classname", u.Classname);
         cmd.Parameters.AddWithValue("?image", u.Image);
         cmd.Parameters.AddWithValue("?name", u.Name);
         cmd.Parameters.AddWithValue("?type", u.Type);
         cmd.Parameters.AddWithValue("?price", u.Price);
         cmd.Parameters.AddWithValue("?buildtime", u.BuildTime);
         cmd.Parameters.AddWithValue("?upgradelevel", u.UpgradeLevel);
         cmd.Parameters.AddWithValue("?factory", u.Factory);
         cmd.Parameters.AddWithValue("?script", u.Script);
         cmd.Parameters.AddWithValue("?side", u.Side);
         ExecutionErrorHandler(cmd);
     }
 }
 public void InsertInBothTables(Gear g, Unit u)
 {
     InsertGear(g);
     InsertUnit(u);
 }
 internal void LoadUnit(string filename, object type, object side)
 {
     using (FileStream fs = new FileStream(filename, FileMode.Open))
     {
         String str;
         Unit u;
         StreamReader sr = new StreamReader(fs);
         List<String> myLines = new List<String>();
         while ((str = sr.ReadLine()) != null)
         {
             if (!myLines.Contains(str))
             {
                 myLines.Add(str);
             }
         }
         foreach (String s in myLines)
         {
             u = new Unit(s, "", "",(UnitType)type, 1000, 10, 1, (FactoryType)type, "", (Side)side);
             this.InsertUnit(u);
         }
     }
 }