public void fillInventory() { InventoryEntries ie; List <ShopInv> shopinvs = new List <ShopInv>(); ShopInv temp; int place = 0; int iminql = 0; int imaxql = 0; Random r = new Random(); string like = ""; SqlWrapper Sql = new SqlWrapper(); DataTable dt = Sql.ReadDT("SELECT * from vendortemplate where HASH='" + HASH + "'"); foreach (DataRow row in dt.Rows) { temp = new ShopInv(); temp.HASH = (string)row["ShopInvHash"]; temp.minQL = (Int32)row["minQL"]; temp.maxQL = (Int32)row["maxQL"]; shopinvs.Add(temp); if (like != "") { like += "OR "; } like += "HASH LIKE '%" + temp.HASH + "%' "; } if (like != "") { Inventory.Clear(); dt = Sql.ReadDT("SELECT * from shopinventorytemplates where " + like); string thishash; foreach (DataRow row in dt.Rows) { thishash = (string)row["Hash"]; foreach (ShopInv si in shopinvs) { if (si.HASH == thishash) { iminql = (Int32)row["minql"]; imaxql = (Int32)row["maxql"]; // Dont add Items that are not between si.minQL and si.maxQL if ((iminql <= si.maxQL) && (imaxql >= si.minQL)) { ie = new InventoryEntries(); ie.Container = 104; ie.Placement = place++; ie.Item.lowID = (Int32)row["lowid"]; ie.Item.highID = (Int32)row["highid"]; ie.Item.multiplecount = (Int32)row["multiplecount"]; ie.Item.Nothing = 0; ie.Item.Quality = Math.Min(Math.Max(Convert.ToInt32(r.Next(si.minQL, si.maxQL)), iminql), imaxql); Inventory.Add(ie); } } } } } }
public void fillInventory() { InventoryEntries ie; List<ShopInv> shopinvs = new List<ShopInv>(); ShopInv temp; int place = 0; int iminql = 0; int imaxql = 0; Random r = new Random(); string like = ""; SqlWrapper Sql = new SqlWrapper(); DataTable dt = Sql.ReadDT("SELECT * from vendortemplate where HASH='" + HASH + "'"); foreach (DataRow row in dt.Rows) { temp = new ShopInv(); temp.HASH = (string)row["ShopInvHash"]; temp.minQL = (Int32)row["minQL"]; temp.maxQL = (Int32)row["maxQL"]; shopinvs.Add(temp); if (like != "") { like += "OR "; } like += "HASH LIKE '%" + temp.HASH + "%' "; } if (like != "") { Inventory.Clear(); dt = Sql.ReadDT("SELECT * from shopinventorytemplates where " + like); string thishash; foreach (DataRow row in dt.Rows) { thishash = (string)row["Hash"]; foreach (ShopInv si in shopinvs) { if (si.HASH == thishash) { iminql = (Int32)row["minql"]; imaxql = (Int32)row["maxql"]; // Dont add Items that are not between si.minQL and si.maxQL if ((iminql <= si.maxQL) && (imaxql >= si.minQL)) { ie = new InventoryEntries(); ie.Container = 104; ie.Placement = place++; ie.Item.lowID = (Int32)row["lowid"]; ie.Item.highID = (Int32)row["highid"]; ie.Item.multiplecount = (Int32)row["multiplecount"]; ie.Item.Nothing = 0; ie.Item.Quality = Math.Min(Math.Max(Convert.ToInt32(r.Next(si.minQL, si.maxQL)), iminql), imaxql); Inventory.Add(ie); } } } } } }
public void FillInventory() { List<ShopInv> shopinvs = new List<ShopInv>(); int place = 0; Random r = new Random(); string like = ""; SqlWrapper sqlWrapper = new SqlWrapper(); DataTable dt = sqlWrapper.ReadDatatable("SELECT * from vendortemplate where HASH='" + this.Hash + "'"); foreach (DataRow row in dt.Rows) { ShopInv shopInventory = new ShopInv { Hash = (string)row["ShopInvHash"], MinQl = (Int32)row["minQL"], MaxQl = (Int32)row["maxQL"] }; shopinvs.Add(shopInventory); if (like != "") { like += "OR "; } like += "HASH LIKE '%" + shopInventory.Hash + "%' "; } if (like != "") { this.Inventory.Clear(); dt = sqlWrapper.ReadDatatable("SELECT * from shopinventorytemplates where " + like + "and active = 1"); foreach (DataRow row in dt.Rows) { string thisHash = (string)row["Hash"]; foreach (ShopInv si in shopinvs) { if (si.Hash == thisHash) { int minQl = (Int32)row["minql"]; int maxQl = (Int32)row["maxql"]; // Dont add Items that are not between si.minQL and si.maxQL if ((minQl <= si.MaxQl) && (maxQl >= si.MinQl)) { InventoryEntries inventoryEntry = new InventoryEntries { Container = 104, Placement = place++, Item = { LowID = (Int32)row["lowid"], HighID = (Int32)row["highid"], MultipleCount = (Int32)row["multiplecount"], Nothing = 0, Quality = Math.Min( Math.Max(Convert.ToInt32(r.Next(si.MinQl, si.MaxQl)), minQl), maxQl) } }; this.Inventory.Add(inventoryEntry); } } } } } }
public void FillInventory() { List <ShopInv> shopinvs = new List <ShopInv>(); int place = 0; Random r = new Random(); string like = ""; SqlWrapper sqlWrapper = new SqlWrapper(); DataTable dt = sqlWrapper.ReadDatatable("SELECT * from vendortemplate where HASH='" + this.Hash + "'"); foreach (DataRow row in dt.Rows) { ShopInv shopInventory = new ShopInv { Hash = (string)row["ShopInvHash"], MinQl = (Int32)row["minQL"], MaxQl = (Int32)row["maxQL"] }; shopinvs.Add(shopInventory); if (like != "") { like += "OR "; } like += "HASH LIKE '%" + shopInventory.Hash + "%' "; } if (like != "") { this.Inventory.Clear(); dt = sqlWrapper.ReadDatatable("SELECT * from shopinventorytemplates where " + like + "and active = 1"); foreach (DataRow row in dt.Rows) { string thisHash = (string)row["Hash"]; foreach (ShopInv si in shopinvs) { if (si.Hash == thisHash) { int minQl = (Int32)row["minql"]; int maxQl = (Int32)row["maxql"]; // Dont add Items that are not between si.minQL and si.maxQL if ((minQl <= si.MaxQl) && (maxQl >= si.MinQl)) { InventoryEntries inventoryEntry = new InventoryEntries { Container = 104, Placement = place++, Item = { LowID = (Int32)row["lowid"], HighID = (Int32)row["highid"], MultipleCount = (Int32)row["multiplecount"], Nothing = 0, Quality = Math.Min( Math.Max(Convert.ToInt32(r.Next(si.MinQl, si.MaxQl)), minQl), maxQl) } }; this.Inventory.Add(inventoryEntry); } } } } } }