void AddItemToInventory(WorldItem request) { if (!IsOwner) { return; } Item shipped_item = ItemCatalogue.RequestItem(request.item_name); if (SharedItem.isSharedItem(shipped_item)) { if (!IsServer) { InvokeServerRpc(RPC_AddSharedItemNetwork, request.NetworkId, 1, channel: INVMANG_CHANNEL); } else { RPC_AddSharedItemNetwork(request.NetworkId, 1); } } else if (AbilityItem.isAbilityItem(shipped_item)) { shipped_item.context = this; shipped_item.menu_form = Resources.Load(shipped_item.name() + "MenuForm") as Sprite; actionSlots.ability_items[shipped_item.name()] = (AbilityItem)shipped_item; actionSlots.ChangeAbilityItem(actionSlots.ability_items.GetStackCount(), shipped_item.name()); } }
public void CreateDisbursementForApprovedRequest(ADProjectDb db, int requestId, int?collectionPointId, int quantity, int itemCatalogueId) { Employee sessionEmployee = GetEmployee(db); Disbursement disbursement = new Disbursement(); DisbursementDetail disbursementDetail = new DisbursementDetail(); CollectionPoint collectionPoint = db.CollectionPoint.Where(cp => cp.CollectionPointId == collectionPointId).SingleOrDefault(); Employee employee = sessionEmployee; DisbursementStatus disbursementStatus = db.DisbursementStatus.Where(ds => ds.Description == "PENDING").SingleOrDefault(); ItemCatalogue itemCatalogue = db.ItemCatalogue.Where(ic => ic.ItemCatalogueId == itemCatalogueId).SingleOrDefault(); Request request = db.Request.Where(r => r.RequestId == requestId).SingleOrDefault(); disbursement.CollectionPoint = collectionPoint; disbursement.Department = employee.Department; disbursement.Employee = employee; disbursement.RequestId = requestId; disbursementDetail.DisbursementStatus = disbursementStatus; disbursementDetail.DisburseQuantity = quantity; disbursementDetail.Disbursement = disbursement; disbursementDetail.ItemCatalogue = itemCatalogue; request.CollectionPoint = collectionPoint; db.Disbursement.Add(disbursement); db.DisbursementDetail.Add(disbursementDetail); db.SaveChanges(); }
public Models.Order CreateNewOrderWithSupplierWithFirstOrderDetail(ADProjectDb db, int empId, string supplier, int itemId) { Supplier selectedSupplier = GetSupplierByName(db, supplier); ItemCatalogue firstitem = GetItemCatalogue(db, itemId); // create new PO object with SupplierId and EmpId OrderStatus orderStatusDraft = db.OrderStatus.Where(x => x.OrderStatusId == 1).FirstOrDefault(); ADProject.Models.Order newOrder = new ADProject.Models.Order() { EmpId = empId, SupplierId = selectedSupplier.SupplierId, Supplier = selectedSupplier, OrderStatus = orderStatusDraft }; db.Order.Add(newOrder); //Need to save changes first so that the new order id will be generated db.SaveChanges(); // Get back the last added order, need its orderId newOrder = db.Order.OrderByDescending(o => o.OrderId).FirstOrDefault(); //Get the reordering qty var reorder = db.StockInfo.Where(x => x.ItemCatalogueId == itemId).FirstOrDefault().ReOrderQuantity; // Create and add the new orderdetail, qty is the default restock quantity OrderDetail firstOd = new OrderDetail() { OrderId = newOrder.OrderId, ItemId = itemId, ItemCatalogue = firstitem, OrderQuantity = reorder }; db.OrderDetail.Add(firstOd); newOrder.OrderDetails = new List <OrderDetail>(); newOrder.OrderDetails.Add(firstOd); db.SaveChanges(); return(newOrder); }
public void ItemCatalogue_ParseFromString() { String itemStr1 = "ID:1,Name:TestItem,Amount:1,Description:test item 1,ActiveEffect,PassiveEffect,Requirements,Icon:test.png"; String itemStr2 = "ID:2,Name:TestItem,Amount:1,Description:test item 2," + "ActiveEffect:" + ActiveEffect.TAG + ":" + PlayerCharacter.HEALTH + ":" + "10" + ":" + ActiveEffect.TAG + ":" + PlayerCharacter.THIRST + ":" + "10" + ",PassiveEffect:" + PassiveEffect.TAG + ":" + PlayerCharacter.HEALTH + ":" + "0.8" + ",Requirements:2,Icon:test.png"; String itemStr3 = "ID:3,Name:TestItem,Amount:1,Description:test item 3," + "ActiveEffect:" + ActiveEffect.TAG + ":" + PlayerCharacter.HEALTH + ":" + "10" + ":" + ActiveEffect.TAG + ":" + PlayerCharacter.THIRST + ":" + "10" + ",PassiveEffect:" + PassiveEffect.TAG + ":" + PlayerCharacter.HEALTH + ":" + "0.8" + ":" + PassiveEffect.TAG + ":" + PlayerCharacter.SANITY + ":" + "0.9" + ":" + PassiveEffect.TAG + ":" + PlayerCharacter.HUNGER + ":" + "0.8" + ":" + PassiveEffect.TAG + ":" + PlayerCharacter.THIRST + ":" + "0.8" + ",Requirements:2,Icon:test.png"; String catalogueStr = ItemCatalogue.TAG + ";" + itemStr1 + ";" + itemStr2 + ";" + itemStr3; var catalogue = new ItemCatalogue(catalogueStr); Assert.AreEqual(itemStr1, catalogue.GetItem(1).ParseToString(), "Item 1 should be in the catalogue"); Assert.AreEqual(itemStr2, catalogue.GetItem(2).ParseToString(), "Item 2 should be in the catalogue"); Assert.AreEqual(itemStr3, catalogue.GetItem(3).ParseToString(), "Item 3 should be in the catalogue"); Assert.AreEqual(null, catalogue.GetItem(4), "Item 4 should not be in the catalogue"); }
public void EquipSharedItem(string item_name) { if (!IsOwner) { return; } Item shipped_item = ItemCatalogue.RequestItem(item_name); if (SharedItem.isSharedItem(shipped_item)) { if (!IsServer) { InvokeServerRpc(RPC_EquipSharedItem, item_name, 1, channel: INVMANG_CHANNEL); } else { ulong clientId = NetworkingManager.Singleton.LocalClientId; NetworkSharedItem netItem; if (NetworkSwapSharedItem(item_name, (int)clientId, out netItem, 1)) { RPC_ClientEquipSharedItem(netItem.name); } } } }
private void Menu_EditItem_Click(object sender, RoutedEventArgs e) { ItemCatalogue items = (ItemCatalogue)Resources["itemCatalogue"]; int index = items.CurrentIndex; try { //create Window to prompt user for data. var editItemWindow = new EditItemWindow(items[index]); //if 'OK' pressed if (editItemWindow.ShowDialog() == true) { //Get data from create-window. int ID = editItemWindow.ID; string Name = editItemWindow.Name; int Price = editItemWindow.Price; //Create new item with data. Item item = new Item(ID, Name, Price); //Replace item with edited item. items[index] = item; } } catch { MessageBox.Show("Please choose an item from the catalogue to edit."); } }
// Use this for initialization public void Setup(MenuHandler mh) { utils = Utilities.Instance; im = InputManager.Instance; amazon = new ItemCatalogue(); actionSlots = gameObject.AddComponent <ActionSlots>(); cam_controller = GetComponentInChildren <CameraController>(); networkInv = new NetworkInventory(); actionSlots.mh = mh; }
private void RPC_ClientEquipSharedItem(string item_name) { if (item_name != "") { SharedItem shipped_item = (SharedItem)ItemCatalogue.RequestItem(item_name); shipped_item.context = this; shipped_item.menu_form = image; actionSlots.ChangeSharedItem(shipped_item); } }
private void RPC_ClientEquipSharedItem(string item_name) { if (item_name != "") { SharedItem shipped_item = (SharedItem)ItemCatalogue.RequestItem(item_name); shipped_item.context = this; shipped_item.menu_form = Resources.Load <Sprite>(shipped_item.name() + "MenuForm"); actionSlots.ChangeSharedItem(shipped_item); } }
public static void SeedEntities(ADProjectDb context) { List <OrderStatus> orderStatuses = new List <OrderStatus>() { new OrderStatus("PENDING"), new OrderStatus("DELIVERED") }; context.OrderStatus.AddRange(orderStatuses); context.SaveChanges(); Order order = new Order(); order.OrderDate = DateTime.Today; order.OrderStatus = orderStatuses[0]; OrderDetail orderDetail = new OrderDetail(); orderDetail.OrderQuantity = 2; orderDetail.ExpDelDate = new DateTime(2020, 1, 4); orderDetail.ActDelDate = null; order.OrderDetails = new List <OrderDetail>() { orderDetail }; Supplier supplier = new Supplier(); supplier.SupplierName = "ABC Holdings"; order.Supplier = supplier; Employee employee = context.Employee.FirstOrDefault(); order.Employee = employee; context.Order.Add(order); context.OrderDetail.Add(orderDetail); context.Supplier.Add(supplier); Category category = new Category(); category.CategoryDescription = "pencil"; ItemCatalogue itemCatalogue = new ItemCatalogue(); itemCatalogue.ItemDes = "AA pencil"; itemCatalogue.Category = category; context.Categories.Add(category); context.ItemCatalogue.Add(itemCatalogue); context.SaveChanges(); }
private void _menuItemOpenCatalogue(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog() == true) { string filename = openFileDialog.FileName.ToString(); ItemCatalogue catalogue = getItemCatalogue(); catalogue.filename = filename; } }
private void _menuItemSaveCatalogueAs(object sender, RoutedEventArgs e) { SaveFileDialog saveFileDialog = new SaveFileDialog(); if (saveFileDialog.ShowDialog() == true) { string filename = saveFileDialog.FileName.ToString(); ItemCatalogue catalogue = getItemCatalogue(); catalogue.filename = filename; } }
// Use this for initialization public override void NetworkStart() { if (!IsServer) { return; } Item item = ItemCatalogue.RequestItem(item_name); item.physical_form = Instantiate(item.physical_form); item.physical_form.transform.position = transform.position; item.physical_form.GetComponent <NetworkedObject>().Spawn(); }
// Remembers the saved item if it existed public override void RememberHeldItem() { ItemIDHeld = PlayerPrefs.GetString("GauntletsID" + SlotNumber, "None"); if (ItemIDHeld == "None") { //Debug.Log("Nothing Loaded; ID: 'None'"); SlotWeight = 0; ItemsHeld = 0; } else { ItemsHeld = PlayerPrefs.GetInt("GauntletsCount" + "" + SlotNumber, 1); string[] str = ItemIDHeld.Split('-'); ItemCatalogue cat = Resources.Load <ItemCatalogue>("Prefabs/Items/Catalogue/" + str[0]); if (cat != null) { cat = Instantiate(cat); //Debug.Log(cat.gameObject.name + " Loaded"); if (cat.FindObjectID(str[0], int.Parse(str[1])) != null) { HeldItem = Instantiate(cat.FindObjectID(str[0], int.Parse(str[1]))); } if (HeldItem != null) { //Debug.Log(HeldItem.gameObject.name + " Loaded (ID: " + HeldItem.itemID + ")"); HeldItem.transform.parent = ParentInventory.transform; HeldItem.transform.localPosition = Vector3.zero; } } if (HeldItem == null) { string Name = PlayerPrefs.GetString(ItemIDHeld); Item folderItem = Resources.Load <Item>("Prefabs/Items/" + Name + ".prefab"); if (folderItem != null) { HeldItem = Instantiate(folderItem, ParentInventory.transform); } } Destroy(cat.gameObject); if (HeldItem != null) { Durability = PlayerPrefs.GetInt("GauntletID_Durability" + SlotNumber, Durability); SetDurability(Durability); HeldItem.SetStack(ItemsHeld); ItemsHeld = HeldItem.stackCount; SetHeldItem(); HeldItem.DeactivateItem(); } } UpdateItemDisplay(); }
public void ItemCatalogue_GetRandomItem() { String itemStr1 = "ID:1,Name:TestItem,Amount:1,Description:test item 1,ActiveEffect,PassiveEffect,Requirements,Icon:test.png"; String itemStr2 = "ID:2,Name:TestItem,Amount:1,Description:test item 2," + "ActiveEffect:" + ActiveEffect.TAG + ":" + PlayerCharacter.HEALTH + ":" + "10" + ":" + ActiveEffect.TAG + ":" + PlayerCharacter.THIRST + ":" + "10" + ",PassiveEffect:" + PassiveEffect.TAG + ":" + PlayerCharacter.HEALTH + ":" + "0.8" + ",Requirements:2,Icon:test.png"; String itemStr3 = "ID:3,Name:TestItem,Amount:1,Description:test item 3," + "ActiveEffect:" + ActiveEffect.TAG + ":" + PlayerCharacter.HEALTH + ":" + "10" + ":" + ActiveEffect.TAG + ":" + PlayerCharacter.THIRST + ":" + "10" + ",PassiveEffect:" + PassiveEffect.TAG + ":" + PlayerCharacter.HEALTH + ":" + "0.8" + ":" + PassiveEffect.TAG + ":" + PlayerCharacter.SANITY + ":" + "0.9" + ":" + PassiveEffect.TAG + ":" + PlayerCharacter.HUNGER + ":" + "0.8" + ":" + PassiveEffect.TAG + ":" + PlayerCharacter.THIRST + ":" + "0.8" + ",Requirements:2,Icon:test.png"; String catalogueStr = ItemCatalogue.TAG + ";" + itemStr1 + ";" + itemStr2 + ";" + itemStr3; for (int i = 4; i <= 1000; i++) { String loopItem = "ID:" + i + ",Name:TestItem,Amount:1,Description:test item" + i + ",ActiveEffect,PassiveEffect,Requirements"; catalogueStr += ";" + loopItem; } var catalogue = new ItemCatalogue(catalogueStr); for (int i = 0; i < 10; i++) { var item1 = catalogue.GetRandomItem(); var item2 = catalogue.GetRandomItem(); Assert.AreNotSame(item1, item2, "Two randomly selected items should not be the same"); } for (int i = 0; i < 1000; i++) { var item3 = catalogue.GetRandomItem(-1, 10001); Assert.IsInstanceOfType(item3, typeof(Item)); } for (int i = 0; i < 100; i++) { var item5 = catalogue.GetRandomItem(100, 200); Assert.IsTrue(item5.GetID() >= 100 && item5.GetID() <= 200, "Random items should be in range, ID was " + item5.GetID()); } }
public void SaveRequest(ADProjectDb db, int itemCatalogueId, int quantity, bool?isUpdate, int?requestId) { using (db) { Employee employee = GetEmployee(db); RequestStatus requestStatus = db.RequestStatus.Where(rs => rs.RequestStatusDescription == StatusEnums.RequestStatusEnum.PENDING.ToString()).SingleOrDefault(); ItemCatalogue itemCatalogue = db.ItemCatalogue.Where(ic => ic.ItemCatalogueId == itemCatalogueId).SingleOrDefault(); Request request = new Request(); RequestDetail requestDetail = new RequestDetail(); //if update instead of create... isUpdate = (isUpdate == null ? false : isUpdate); if ((bool)isUpdate) { request = db.Request.Where(r => r.RequestId == requestId).SingleOrDefault(); requestDetail = db.RequestDetail.Where(rd => rd.Request.RequestId == requestId).SingleOrDefault(); } request.Department = employee.Department; request.RaisedByEmployee = employee; request.RequestDate = DateTime.Today; request.RequestStatus = requestStatus; RepresentativeService representativeService = new RepresentativeService(); CollectionPoint collectionPoint = representativeService.GetLatestCollectionPoint(db); request.CollectionPoint = collectionPoint; requestDetail.ItemCatalogue = itemCatalogue; requestDetail.Quantity = quantity; requestDetail.Request = request; if (isUpdate == false) { db.Request.Add(request); db.RequestDetail.Add(requestDetail); } db.SaveChanges(); Request lastestAddedRequest = db.Request.OrderByDescending(r => r.RequestId).FirstOrDefault(); } }
private void Menu_NewItem_Click(object sender, RoutedEventArgs e) { //create Window to prompt user for data. var createItemWindow = new NewItemWindow(); //if 'OK' pressed if (createItemWindow.ShowDialog() == true) { //Get data from create-window. int ID = createItemWindow.ID; string Name = createItemWindow.Name; int Price = createItemWindow.Price; //Create new item with data. Item item = new Item(ID, Name, Price); //Get item catalogue from XAML and add new item. ItemCatalogue items = (ItemCatalogue)Resources["itemCatalogue"]; items.NewItemCommand.Execute(item); } }
public void UnequipSharedItem(string item_name) { if (!IsOwner) { return; } Item shipped_item = ItemCatalogue.RequestItem(item_name); if (SharedItem.isSharedItem(shipped_item)) { if (!IsServer) { InvokeServerRpc(RPC_UnequipSharedItem, item_name, 1, channel: INVMANG_CHANNEL); } else { ulong clientId = NetworkingManager.Singleton.LocalClientId; bool success = networkInv.RevokeItem(item_name, (int)clientId, 1); RPC_ClientUnequipSharedItem(success ? item_name : ""); } } }
public void ItemCatalogue_CheckStringIsValid() { String itemStr1 = "ID:1,Name:TestItem,Amount:1,Description:test item 1,ActiveEffect,PassiveEffect,Requirements"; String itemStr2 = "ID:2,Name:TestItem,Amount:1,Description:test item 2,ActiveEffect,PassiveEffect,Requirements"; String itemStr3 = "ID:3,Name:TestItem,Amount:1,Description:test item 3,ActiveEffect,PassiveEffect,Requirements"; String invalidItem1 = "ID:-1,Name:TestItem,Amount:1,Description:test item -1,ActiveEffect,PassiveEffect,Requirements"; String invalidItemAmount1 = "ID:4,Name:TestItem,Amount:2,Description:test item 4,ActiveEffect,PassiveEffect,Requirements"; String expected = ItemCatalogue.TAG + ";" + itemStr1 + ";" + itemStr2 + ";" + itemStr3; String nonUniqueID = ItemCatalogue.TAG + ";" + itemStr1 + ";" + itemStr2 + ";" + itemStr3 + ";" + itemStr1; Assert.IsTrue(ItemCatalogue.IsValidItemCatalogue(ItemCatalogue.TAG), "empty catalogue should be valid"); Assert.IsTrue(ItemCatalogue.IsValidItemCatalogue(expected), "Standard catalogue should be valid"); Assert.IsFalse(ItemCatalogue.IsValidItemCatalogue(ItemCatalogue.TAG + ";"), "if an catalogue has items it should have at least one item"); Assert.IsFalse(ItemCatalogue.IsValidItemCatalogue("NotaCatalogue;" + itemStr1), "Not an catalogue should be invalid"); Assert.IsFalse(ItemCatalogue.IsValidItemCatalogue(";" + itemStr1), "No Tag should be invalid"); Assert.IsFalse(ItemCatalogue.IsValidItemCatalogue(ItemCatalogue.TAG + itemStr1), "No # should be invalid"); Assert.IsFalse(ItemCatalogue.IsValidItemCatalogue(ItemCatalogue.TAG + ";" + invalidItem1), "Invalid item means invalid catalogue"); Assert.AreEqual(ItemCatalogue.IsValidItemCatalogue(ItemCatalogue.TAG + ";" + invalidItem1), Item.IsValidItem(invalidItem1), "Invalid item should match invalid catalogue"); Assert.IsFalse(ItemCatalogue.IsValidItemCatalogue(ItemCatalogue.TAG + ";" + invalidItemAmount1), "Catalogue Items should only have amount of 1"); Assert.IsFalse(ItemCatalogue.IsValidItemCatalogue(nonUniqueID), "Each ID should be unique"); }
/// <summary> /// Scavenges a sublocation putting found items into the inventory of this PC /// </summary> /// <param name="gs">The game state to modify</param> /// <returns>List of scavenged items</returns> public List <Item> ScavangeSubLocation(GameState gs) { LocationModel lm = gs.GetLM(); PCModel pcm = gs.GetPCM(); ItemCatalogue ic = pcm.GetItemCatalogue(); List <Item> scavengedItems = new List <Item>(); if (lm.IsScavenged() || pcm.GetInventory().IsInventoryFull()) { return(scavengedItems); } List <Item> itemSelection = new List <Item>(); for (int i = 0; i < 100; i++) { itemSelection.Add(ic.GetRandomItem()); } scavengedItems = lm.Scavenge(itemSelection); foreach (Item item in scavengedItems) { pcm.ModifyInventory(item, item.GetAmount()); } return(scavengedItems); }
public void LookupPrice_WhenNoSuchItem_ThrowsException() { var sut = new ItemCatalogue(); Assert.Throws <NoSuchItemException>(() => sut.LookupPrice("No such item")); }
public void LookupPrice_WhenBread_ReturnsPrice() { var sut = new ItemCatalogue(); Assert.That(sut.LookupPrice("Bread"), Is.EqualTo(1.00m)); }
public void LookupPrice_WhenButter_ReturnsPrice() { var sut = new ItemCatalogue(); Assert.That(sut.LookupPrice("Butter"), Is.EqualTo(0.80m)); }
public void LookupPrice_WhenMilk_ReturnsPrice() { var sut = new ItemCatalogue(); Assert.That(sut.LookupPrice("Milk"), Is.EqualTo(1.15m)); }
public MainWindow() { InitializeComponent(); activeEffectsList = new BindingList <string>(); BindingSource activeSource = new BindingSource(); activeSource.DataSource = activeEffectsList; activeSelect.DataSource = activeSource; String aes = ReadFile("activeEffects.txt"); if (aes != "") { String[] aesElem = aes.Split('^'); for (int i = 1; i < aesElem.Length; i++) { activeEffectsList.Add(aesElem[i]); } } passiveEffectsList = new BindingList <string>(); BindingSource passiveSource = new BindingSource(); passiveSource.DataSource = passiveEffectsList; passiveSelect.DataSource = passiveSource; String pes = ReadFile("passiveEffects.txt"); if (pes != "") { String[] pesElem = pes.Split('^'); for (int i = 1; i < pesElem.Length; i++) { passiveEffectsList.Add(pesElem[i]); } } itemActiveList = new BindingList <string>(); BindingSource itemActiveSource = new BindingSource(); itemActiveSource.DataSource = itemActiveList; activeEffects.DataSource = itemActiveSource; itemPassiveList = new BindingList <string>(); BindingSource itemPassiveSource = new BindingSource(); itemPassiveSource.DataSource = itemPassiveList; passiveEffects.DataSource = itemPassiveSource; requirementsList = new BindingList <int>(); BindingSource requirementsSource = new BindingSource(); requirementsSource.DataSource = requirementsList; requirements.DataSource = requirementsSource; resources = new List <String>(); resources.Add(PlayerCharacter.HEALTH); resources.Add(PlayerCharacter.HUNGER); resources.Add(PlayerCharacter.THIRST); resources.Add(PlayerCharacter.SANITY); activeResource.DataSource = resources; passiveResource.DataSource = resources; eventResource.DataSource = resources; iconList = new SortedList <string, Image>(); iconFileNames = new BindingList <string>(); BindingSource fileNameSource = new BindingSource(); fileNameSource.DataSource = iconFileNames; iconSelect.DataSource = fileNameSource; DirectoryInfo dir = new DirectoryInfo(@"C:\Items\"); FileInfo[] imageFiles = dir.GetFiles("*.png"); for (int i = 0; i < imageFiles.Length; i++) { Image image = Image.FromFile(@"C:\Items\" + imageFiles[i].Name); iconList.Add(imageFiles[i].Name, image); iconFileNames.Add(imageFiles[i].Name); } itemList = new SortedList <int, Item>(); String filename = "itemCatalogue.txt"; String file = ReadFile(filename); if (ItemCatalogue.IsValidItemCatalogue(file)) { itemCatalogue = new ItemCatalogue(file); } else { itemCatalogue = new ItemCatalogue(""); } foreach (Item item in itemCatalogue.GetItems()) { itemList.Add(item.GetID(), item); } itemCatList = new BindingList <string>(); BindingSource itemCatListSource = new BindingSource(); itemCatListSource.DataSource = itemCatList; itemCatalogueList.DataSource = itemCatListSource; eventItemCatalogue.DataSource = itemCatListSource; itemResource.DataSource = itemCatListSource; foreach (Item item in itemCatalogue.GetItems()) { itemCatList.Add(String.Format("{0}:{1}", item.itemID, item.name)); } prEffectsList = new BindingList <String>(); itemEffectsList = new BindingList <string>(); BindingSource prEffectListSource = new BindingSource(); prEffectListSource.DataSource = prEffectsList; prEffectSelect.DataSource = prEffectListSource; BindingSource itemEffectListSource = new BindingSource(); itemEffectListSource.DataSource = itemEffectsList; itemEffectSelect.DataSource = itemEffectListSource; String ies = ReadFile("itemEffects.txt"); if (ies != "") { String[] iesElem = ies.Split('^'); for (int i = 1; i < iesElem.Length; i++) { itemEffectsList.Add(iesElem[i]); } } String pres = ReadFile("prEffects.txt"); if (pres != "") { String[] presElem = pres.Split('^'); for (int i = 1; i < presElem.Length; i++) { prEffectsList.Add(presElem[i]); } } sel_ItemEffectsList = new BindingList <String>(); sel_PREffectsList = new BindingList <String>(); BindingSource sel_pr = new BindingSource(); sel_pr.DataSource = sel_PREffectsList; prEffects.DataSource = sel_pr; BindingSource sel_item = new BindingSource(); sel_item.DataSource = sel_ItemEffectsList; itemEffects.DataSource = sel_item; optionsList = new BindingList <String>(); BindingSource optionsSource = new BindingSource(); optionsSource.DataSource = optionsList; options.DataSource = optionsSource; String eventFilename = "eventCatalogue.txt"; String eventfile = ReadFile(eventFilename); if (EventCatalogue.IsValidEventCatalogue(eventfile)) { eventCatalogue = new EventCatalogue(eventfile); } else { eventCatalogue = new EventCatalogue(""); } eventCat = new BindingList <String>(); foreach (Event ev in eventCatalogue.GetEvents()) { eventCat.Add(ev.GetEventID() + ":" + ev.GetEventText()); } BindingSource eventCatSource = new BindingSource(); eventCatSource.DataSource = eventCat; eventCreatorCatalogue.DataSource = eventCatSource; }
public ItemCatalogue GetItemCatalogue(ADProjectDb db, int itemId) { ItemCatalogue itemCatalogue = db.ItemCatalogue.Where(x => x.ItemCatalogueId == itemId).FirstOrDefault(); return(itemCatalogue); }
public ActionResult CreateVoucher(string itemdes, string quantity, string reason, string cost, int?categoryId, bool?isSubmit) { var db = new ADProjectDb(); //-------Eugene's change List <SelectListItem> selectListCategory = db.Categories .Select(c => new SelectListItem { Text = c.CategoryDescription, Value = c.CategoryId.ToString() }).ToList(); ViewData["selectListCategory"] = selectListCategory; //------------ List <ItemCatalogue> items = (from Item in db.ItemCatalogue select Item).ToList(); //---Eugene's change if (categoryId != null) { items = items.Where(item => item.CategoryId == categoryId).ToList(); } ViewData["itemdes"] = itemdes; if (itemdes != null) { double unitPrice = adjustmentVoucherServices.getUnitPrice(db, itemdes); ViewData["unitPrice"] = unitPrice; } //---------- ViewData["items"] = items; List <AdjustmentDetail> details = new List <AdjustmentDetail>(); List <string> des = new List <string>(); Employee currentUser = Session["employee"] as Employee; int employeeId = currentUser.EmployeeId; AdjustmentVoucher NewVoucher = adjustmentVoucherServices.CreateAdjustmentVoucher(db, employeeId); ViewData["newvoucher"] = NewVoucher; if (Session["detail"] == null) { Session["detail"] = details; Session["des"] = des; } if (Session["detail"] != null && isSubmit == true) { if (itemdes != null && quantity != null && reason != null && cost != null) { ItemCatalogue item = db.ItemCatalogue.Where(ite => ite.ItemDes == itemdes).SingleOrDefault(); AdjustmentDetail detail = new AdjustmentDetail() { ItemCatalogueId = item.ItemCatalogueId, Quantity = Convert.ToInt32(quantity), AdjustmentVoucherId = NewVoucher.AdjustmentVoucherId, Reason = reason, Cost = Convert.ToDouble(cost) }; ((List <AdjustmentDetail>)Session["detail"]).Add(detail); ((List <string>)Session["des"]).Add(itemdes); Session["details"] = Session["detail"]; NewVoucher.AdjustmentDetail = (List <AdjustmentDetail>)Session["detail"]; Session["newvoucher"] = NewVoucher; return(RedirectToAction("ViewVoucherDetail", "AdjustmentVoucher")); } return(View()); } return(View()); }
public void LookupPrice_WhenNullOrEmpty_ThrowsException(string item) { var sut = new ItemCatalogue(); Assert.Throws <ArgumentNullException>(() => sut.LookupPrice(item)); }