private string cats = ""; private string[] prods; private string sql; private void getIformation() { MySQLConnection mysql = new MySQLConnection(); IniFile ini = new IniFile(Application.StartupPath + "\\Settings.ini"); mysql.connect(ini.IniReadValue("MySQL_Connection", "User"), ini.IniReadValue("MySQL_Connection", "Password"), ini.IniReadValue("MySQL_Connection", "Host")); mysql.select_db(ini.IniReadValue("MySQL_Connection", "Database")); string cat_name; string cat_id = ""; string product_id = ""; string addon_cat = ""; string sql_cats = "INSERT INTO `categories`"; string sql_prod = ""; string sql_addcat = ""; string sql_addon = ""; int addon_count = 0; int addon_failed= 0; int pos = 0; foreach (string[] line in LC) { int progress = Convert.ToInt32(pos / LC.Length * 100); Main_Form.updatePercent(progress); try { if (line[3] != "") { string[] cat = line[3].Split('/'); cat_name = cat[1]; if (cats.IndexOf(cat_name) == -1) { cats += cat_name + ","; sql_cats += "INSERT INTO `categories` SET `name`='" + cat_name + "'"; mysql.Query(sql); sql = "SELECT `id` FROM `categories` WHERE `name`='" + cat_name + "'"; mysql.Query(sql); string[][] results = mysql.getResults(); cat_id = results[0][0]; output("I Stored a Category: " + cat_name); } cats.Remove(cats.Length, 1); }else if (line[4] != "") { string product_name = line[8].Replace(" Configurable", ""); sql = "INSERT INTO `products` SET `ref`='" + line[4] + "', `name`='" + line[8] + "', `cost`='" + line[12] + "', `cat_id`='" + cat_id + "'"; mysql.Query(sql); sql = "SELECT `id` FROM `products` WHERE `ref`='" + line[4] + "' AND `name`='" + line[8] + "'AND `cost`='" + line[12] + "' AND `cat_id`='" + cat_id + "'"; string[][] results = mysql.getResults(); product_id = results[0][0]; output("I Stored a Product:" + product_name); }else if (line[4] == "" && line[5] != "") { sql = "INSERT INTO `addon_categories` SET `name`='" + line[5] + "', `product_id`='"+product_id+"'"; mysql.Query(sql); sql = "SELECT `id` FROM `addon_categories` WHERE `name`='" + line[5] + "' AND `product_id`='" + product_id + "'"; string[][] results = mysql.getResults(); addon_cat = results[0][0]; output("I found an addon category:" + line[5]); }else if (line[4] == "" && line[8] != "") { if (line[10] == "") { // free Addon if (line[6] == "") { sql = "INSERT INTO `addons` SET `name`='" + line[8] + "', `addon_cat`='" + addon_cat + "'"; mysql.Query(sql); output("I found a free addon:" + line[8]); } else { sql = "INSERT INTO `addons` SET `name`='" + line[8] + "', `addon_cat`='" + addon_cat + "', `default`='1'"; mysql.Query(sql); addon_count++; output("I found a default free addon:" + line[8]); } } else { // price editing Addon if (line[6] == "") { sql = "INSERT INTO `addons` SET `name`='" + line[8] + "', `addon_cat`='" + addon_cat + "', `cost`='" + line[10].Replace("(", "").Replace(")", "") + "'"; mysql.Query(sql); output("I found a altering addon:" + line[8]); } else { // this is default sql = "INSERT INTO `addons` SET `name`='" + line[8] + "', `addon_cat`='" + addon_cat + "', `default`='1', `cost`='" + line[10] + "'"; mysql.Query(sql); output("I found a default altering addon:" + line[8]); } } } } catch (Exception Ex) { } pos++; } }