public static DBItemCategories findCategory(int categoryID) { using(DBConnection conn = new DBConnection()) { return conn.categories.Where(c => c.ID == categoryID).FirstOrDefault(); } }
public void getItemList(int category_id) { using (DBConnection conn = new DBConnection()) { var items = from e in conn.items where e.category_ID == category_id select e; items_list.ItemsSource = items.ToList(); } }
public void setItemExc(Item item) { Dictionary<string, bool> opts = item.excellent_options.getOpts(); DBExcOpts exOpts = null; using(DBConnection conn = new DBConnection()) { exOpts = conn.excOptions.Where(c => c.ID == item.getItemType()).First(); } int index = 0; foreach(Label label in exc_opts_grid.Children.Cast<Label>()) { if (opts.ElementAt(index).Value) { if(exOpts != null) { switch(index) { case 0: label.Content = exOpts.option1; break; case 1: label.Content = exOpts.option2; break; case 2: label.Content = exOpts.option3; break; case 3: label.Content = exOpts.option4; break; case 4: label.Content = exOpts.option5; break; } } label.Visibility = Visibility.Visible; } else label.Visibility = Visibility.Hidden; index++; } }
private void showHarmoneyOptions() { if(current_category == null || current_category.ID > 11) { harm_grid.Visibility = Visibility.Hidden; no_harm_label.Visibility = Visibility.Visible; } else { int type; if (current_category.ID < 7) type = 1; else type = 2; using(DBConnection conn = new DBConnection()) { harm_opt_list.ItemsSource = conn.harmOpts.Where(h => h.type == type); } no_harm_label.Visibility = Visibility.Hidden; harm_grid.Visibility = Visibility.Visible; } }
private void showExcOptions(int type) { using (DBConnection conn = new DBConnection()) { var opts = from e in conn.excOptions where e.ID == type select new { opt1 = e.option1, opt2 = e.option2, opt3 = e.option3, opt4 = e.option4, opt5 = e.option5, opt6 = e.option6 }; var excOption = opts.First(); exc_opt1.Content = excOption.opt1; exc_opt2.Content = excOption.opt2; exc_opt3.Content = excOption.opt3; exc_opt4.Content = excOption.opt4; exc_opt5.Content = excOption.opt5; exc_opt6.Content = excOption.opt6; } }
private void showCharacters(string searchCharacter) { using (DBConnection conn = new DBConnection()) { if (account_list.SelectedItem == null) { var list = conn.characters; if (searchCharacter != null) character_list.ItemsSource = list.Where(character => character.Name.Contains(searchCharacter)); else character_list.ItemsSource = list; } else { if (searchCharacter != null) { character_list.ItemsSource = conn.characters .Where(character => character.AccountID == account_list.SelectedItem) .Where(character => character.Name.Contains(searchCharacter)); } else { character_list.ItemsSource = conn.characters .Where(character => character.AccountID == account_list.SelectedItem); } } } }
private void showAccounts(string searchAccount) { using (DBConnection conn = new DBConnection()) { var accounts = conn.accounts; if (searchAccount != null) account_list.ItemsSource = accounts.Where(account => account.memb___id.Contains(searchAccount)).Select(account => account.memb___id); else account_list.ItemsSource = accounts.Select(account => account.memb___id); } }
private void initCharacter(string characterName) { string hex; using(DBConnection conn = new DBConnection()) { currentCharacter = conn.characters.Single(c => c.Name == characterName); hex = BitConverter.ToString(currentCharacter.Inventory).Replace("-", ""); } if (hex != null) { currentInventory = new InventoryStorage(hex); initCharacterDisplay(); initInventoryDisplay(); } }
private void fillCategories() { using (DBConnection conn = new DBConnection()) { var categories = from e in conn.categories select e; items_list.ItemsSource = categories.ToList(); } }
private void displaySocketOptions() { using(DBConnection conn = new DBConnection()) { var socketOptions = conn.socketTypes; sock1_list.ItemsSource = socketOptions; } }
private void displayRefineOptions() { if (current_category == null) { ref_grid.Visibility = Visibility.Hidden; no_ref_label.Visibility = Visibility.Visible; } else { using(DBConnection conn = new DBConnection()) { var refineOpt = conn.refineOpts.Where(x => x.typeID == current_category.ID).FirstOrDefault(); if (refineOpt != null) { ref_opt_check.Content = refineOpt; if (refineOpt.option1 != null) ref_opt1.Content = "+ " + refineOpt.option1; else ref_opt1.Visibility = Visibility.Hidden; if (refineOpt.option2 != null) ref_opt2.Content = "+ " + refineOpt.option2; else ref_opt2.Visibility = Visibility.Hidden; no_ref_label.Visibility = Visibility.Hidden; ref_grid.Visibility = Visibility.Visible; } else { ref_grid.Visibility = Visibility.Hidden; no_ref_label.Visibility = Visibility.Visible; } } } }
private void displayAncientOptions() { if (current_item == null || (current_item.set1 == -1 && current_item.set2 == -1 && current_item.set3 == -1)) { anc_grid.Visibility = Visibility.Hidden; set_unavailable_label.Visibility = Visibility.Visible; } else { using(DBConnection conn = new DBConnection()) { //Set one //---------------------------------------------------------------------------------- if (current_item.set1 >= 0) { anc_set1.Content = conn.ancSets.FirstOrDefault(c => c.ID == current_item.set1); anc_set1.Visibility = Visibility.Visible; } else anc_set1.Visibility = Visibility.Hidden; //---------------------------------------------------------------------------------- //Set two //---------------------------------------------------------------------------------- if (current_item.set2 >= 0) { anc_set2.Content = conn.ancSets.FirstOrDefault(c => c.ID == current_item.set2); anc_set2.Visibility = Visibility.Visible; } else anc_set2.Visibility = Visibility.Hidden; //---------------------------------------------------------------------------------- //Set three //---------------------------------------------------------------------------------- if (current_item.set3 >= 0) { anc_set3.Content = conn.ancSets.FirstOrDefault(c => c.ID == current_item.set3); anc_set3.Visibility = Visibility.Visible; } else anc_set3.Visibility = Visibility.Hidden; //---------------------------------------------------------------------------------- } set_unavailable_label.Visibility = Visibility.Hidden; anc_grid.Visibility = Visibility.Visible; } }
public static void updateSingleItemImage(int item_id, int category_id, string path) { using (DBConnection conn = new DBConnection()) { var item = from e in conn.items where e.ID == item_id && e.category_ID == category_id select e; DBItems item_temp = item.First(); if (File.Exists("images/items/" + path)) { item_temp.image_path = path; conn.SubmitChanges(); } } }
public static void UpdateItemImages(Boolean reset) { using (DBConnection conn = new DBConnection()) { var items = from e in conn.items select e; foreach (var item in items) { if (item.image_path == null || item.image_path.Equals("default.gif") || reset) { DBItems item_temp = item; string path = calcItemImage((int)item.ID, (int)item.category_ID, 0, 0); if (path == null) continue; else { item_temp.image_path = path; conn.SubmitChanges(); } } } } }
public static DBItems findItem(int category, int index) { using(DBConnection conn = new DBConnection()) { return conn.items.Where(i => i.category_ID == category && i.ID == index).FirstOrDefault(); } }
public void saveCharacterInventory(string characterName) { string inventoryHex = getBuiltHex(); using(DBConnection conn = new DBConnection()) { try { string sql = String.Format("UPDATE Character SET Inventory={0} WHERE Name='{1}'", inventoryHex, characterName); conn.ExecuteCommand(sql); } catch(Exception e) { Debug.WriteLine("[SQL Exception] " + e.Message); } } }