private void Start() { if (instance == null) { instance = this; DontDestroyOnLoad(this.gameObject); } else { Destroy(this.gameObject); } BoxComponent = BoxInventory.GetComponent <InventoryManager>(); SaveInvenstr = ""; SaveEquipstr = ""; itemoffsetList = new List <Item>(); itemoffsetList = LoadJsonFile <List <Item> >(Application.dataPath + "/SaveData", "Offset"); for (int i = 0; i < itemoffsetList.Count; ++i) { itemoffsetList[i].Print(); GameObject obj = CreateItemObject(itemoffsetList[i]); BoxComponent.AddItem(obj); } }
// ------------------------------------------------------------- public void Open(BoxInventory inv) { if (inv != activeContainer) { Close(); } activeContainer = inv; type = activeContainer.type; containerInventory = activeContainer.boxInventory; // MoveModal(); ResizeModal(); ShowItem(); // isOpen = true; menuObject.SetActive(true); // if (containerInventory.Count <= 0) { MakeCollapsable(); } if (containerInventory.Count > 0) { breakDownButtonObject.SetActive(false); } }
public ActionResult DeleteConfirmed(int id) { BoxInventory box = service.GetBoxById(id); service.DeleteBox(box); return(RedirectToAction("Index")); }
private void ButtonDeleteInventory_Click(object sender, EventArgs e) { if ((dataGridViewFlowers.SelectedRows.Count <= 0)) { MessageBox.Show("Please select the inventory to delete"); return; } var selectedInventory = dataGridViewFlowers.SelectedRows .OfType <DataGridViewRow>() .ToList(); using (RosePurchaseManagementEntities context = new RosePurchaseManagementEntities()) { var inven = (SupplierInventory)selectedInventory.Select(x => x).FirstOrDefault().DataBoundItem; var selectedBoxId = context.Boxes.Where(b => b.BoxID == inven.BoxID).Select(i => i.BoxID).FirstOrDefault(); Inventory inventory = context.Inventories.Where(z => z.InventoryID == inven.InventoryID).FirstOrDefault(); BoxInventory boxInventory = context.BoxInventories.Where(b => (b.BoxID == selectedBoxId) && (b.InventoryID == inven.InventoryID)).FirstOrDefault(); context.BoxInventories.Remove(boxInventory); context.SaveChanges(); context.Inventories.Remove(inventory); context.SaveChanges(); } GetSupplierInventory(); }
public ActionResult Edit(BoxInventory box) { if (ModelState.IsValid) { service.SaveEdits(box); return(RedirectToAction("Index")); } return(View(box)); }
public ActionResult Create(BoxInventory box) { if (ModelState.IsValid) { service.AddBox(box); return(RedirectToAction("Index")); } return(View("Index")); }
//refresh slot sprite public void Refresh() { if (inventory.getBoxInventory() != null && inventory.getBoxInventory().lstSlots.IndexOf(this.gameObject) >= 0) { BoxInventory box = inventory.getBoxInventory(); int x = box.lstSlots.IndexOf(this.gameObject); box.lstObj[x].set(itemInSlot); } transform.GetChild(0).GetComponent <Image>().sprite = null; transform.GetChild(0).GetComponent <Image>().sprite = itemInSlot.getSprite(); }
public void SaveEdits(BoxInventory toSave) { int idChange = toSave.Id; BoxInventory changed = null; Boolean duplicate = false; if (toSave.InventoryCount == 0) { return; } if (toSave.Weight == 0) { return; } if (toSave.Volume == 0) { return; } if (toSave.Weight < 0) { toSave.Weight = Math.Abs(toSave.Weight); } if (toSave.Volume < 0) { toSave.Volume = Math.Abs(toSave.Volume); } if (toSave.Cost < 0) { toSave.Cost = Math.Abs(toSave.Cost); } dbContext.Entry(toSave).State = EntityState.Modified; foreach (BoxInventory box in dbContext.Boxes) { if (toSave.Weight == box.Weight && toSave.Volume == box.Volume && toSave.Cost == box.Cost && (toSave.CanHoldLiquid == box.CanHoldLiquid) && toSave.Id != box.Id) { box.InventoryCount += toSave.InventoryCount; duplicate = true; } } foreach (BoxInventory box in dbContext.Boxes) { if (toSave.Id == box.Id) { changed = box; } } if (duplicate) { dbContext.Boxes.Remove(changed); } dbContext.SaveChanges(); }
public void AddBox(BoxInventory toAdd) { Boolean duplicate = false; if (toAdd.InventoryCount == 0) { return; } if (toAdd.Weight == 0) { return; } if (toAdd.Volume == 0) { return; } if (toAdd.Weight < 0) { toAdd.Weight = Math.Abs(toAdd.Weight); } if (toAdd.Volume < 0) { toAdd.Volume = Math.Abs(toAdd.Volume); } if (toAdd.Cost < 0) { toAdd.Cost = Math.Abs(toAdd.Cost); } foreach (BoxInventory box in dbContext.Boxes) { if (toAdd.Weight == box.Weight && toAdd.Volume == box.Volume && toAdd.Cost == box.Cost && (toAdd.CanHoldLiquid == box.CanHoldLiquid)) { box.InventoryCount += toAdd.InventoryCount; duplicate = true; } } if (!duplicate) { dbContext.Boxes.Add(toAdd); } dbContext.SaveChanges(); }
private void ButtonUpdateInventory_Click(object sender, EventArgs e) { var selectedInventory = dataGridViewFlowers.SelectedRows .OfType <DataGridViewRow>() .ToArray(); if (dataGridViewFlowers.SelectedRows.Count != 0) { var inven = (SupplierInventory)selectedInventory.Select(x => x).FirstOrDefault().DataBoundItem; Inventory invent = new Inventory(); BoxInventory boxinventory = new BoxInventory(); using (RosePurchaseManagementEntities context = new RosePurchaseManagementEntities()) { //select the item from the listbox String selectedFarm = listBoxFarms.SelectedItem.ToString(); String selectedRose = comboBoxRoses.Text; //get the roseId for the selected roses var farmId = context.Inventories.Include("Farm").Where(f => f.Farm.FarmName == selectedFarm).FirstOrDefault(); var roseSizeId = context.RoseSizes.Include("Rose").Where(r => r.Rose.RoseName == selectedRose).FirstOrDefault(); invent.FarmID = farmId.FarmID; invent.RoseSizeID = roseSizeId.RoseSizeID; invent.Price_per_stem = float.Parse(textBoxPrice.Text); boxinventory.Quantity = int.Parse(textBoxQuantity.Text); context.SaveChanges(); Controller <RosePurchaseManagementEntities, Inventory> .UpdateEntity(invent); Controller <RosePurchaseManagementEntities, BoxInventory> .UpdateEntity(boxinventory); } GetSupplierInventory(); } }
public void SaveEdits(BoxInventory toSave) { repository.SaveEdits(toSave); }
public void AddBox(BoxInventory toAdd) { repository.AddBox(toAdd); }
public void setBoxInventory(BoxInventory newBox) { newBoxInventory = newBox; }
private void ButtonAddInventory_Click(object sender, EventArgs e) { Inventory invent = new Inventory(); BoxInventory boxinventory = new BoxInventory(); if (listBoxFarms.SelectedIndex < 0) { MessageBox.Show("A farm must be selected. "); return; } if (textBoxQuantity.Text == "") { MessageBox.Show("Quantity must be inserted."); return; } if (comboBoxRoses.Text == "") { MessageBox.Show("Rose name must be inserted.."); return; } if (textBoxPrice.Text == "") { MessageBox.Show("Price must be inserted."); return; } using (RosePurchaseManagementEntities context = new RosePurchaseManagementEntities()) { //select the item from the listbox String selectedFarm = listBoxFarms.SelectedItem.ToString(); String selectedRose = comboBoxRoses.Text; //get the roseId and farmid for the selected roses and farms var farmId = context.Inventories.Include("Farm").Where(f => f.Farm.FarmName == selectedFarm).FirstOrDefault(); var roseSizeId = context.RoseSizes.Include("Rose").Where(r => r.Rose.RoseName == selectedRose).FirstOrDefault(); invent.FarmID = farmId.FarmID; invent.RoseSizeID = roseSizeId.RoseSizeID; invent.Price_per_stem = float.Parse(textBoxPrice.Text); boxinventory.Quantity = int.Parse(textBoxPrice.Text); } // add inventory to the list using controller if (Controller <RosePurchaseManagementEntities, Inventory> .AddEntity(invent) == null || Controller <RosePurchaseManagementEntities, BoxInventory> .AddEntity(boxinventory) == null) { MessageBox.Show("Cannot add order to database"); return; } //display GetSupplierInventory(); //clear selected farms listBoxFarms.ClearSelected(); //empty string comboBoxRoses.Text = ""; textBoxPrice.Text = ""; textBoxQuantity.Text = ""; using (RosePurchaseManagementEntities context = new RosePurchaseManagementEntities()) { // String selectedRose = comboBoxRoses.Text; String selectedFarm = listBoxFarms.SelectedItem.ToString(); var farmID = context.Inventories.Include("Farm").Where(f => f.Farm.FarmName == selectedFarm).FirstOrDefault(); // var roseSizeId = context.RoseSizes.Include("Rose").Where(r => r.Rose.RoseName == selectedRose).FirstOrDefault(); invent.FarmID = listBoxFarms.SelectedIndex + 1; invent.Price_per_stem = float.Parse(textBoxPrice.Text); // invent.RoseSizeID = roseSizeId.RoseSizeID; boxinventory.Quantity = int.Parse(textBoxQuantity.Text); Controller <RosePurchaseManagementEntities, BoxInventory> .AddEntity(boxinventory); } if (Controller <RosePurchaseManagementEntities, Inventory> .AddEntity(invent) == null) { MessageBox.Show("Cannot add to database"); return; } GetSupplierInventory(); }
/*--------------------------------------------------------------// // LoadSaveData - loads up the loot data // //--------------------------------------------------------------*/ void LoadSavedData() { storedData = Interface.GetMod().DataFileSystem.ReadObject<StoredData>("HeliControlData"); //Create a default data file if there was none: if (storedData == null) { PrintWarning("No Lootdrop Data!! Creating new file..."); storedData = new StoredData(); BoxInventory inv; inv = new BoxInventory("rifle.ak", 1); inv.lootBoxContents.Add(new ItemDef("ammo.rifle.hv", 128)); storedData.HeliInventoryLists.Add(inv); inv = new BoxInventory("rifle.bolt", 1); inv.lootBoxContents.Add(new ItemDef("ammo.rifle.hv", 128)); storedData.HeliInventoryLists.Add(inv); inv = new BoxInventory("explosive.timed", 3); inv.lootBoxContents.Add(new ItemDef("ammo.rocket.hv", 3)); storedData.HeliInventoryLists.Add(inv); SaveData(); } }
public void mouseMovement() { //If mouse in the slot and left click and left shift and the slot is not locked or null if (isStay() && Input.GetMouseButtonDown(0) && Input.GetKey("left shift") && itemInSlot.id != "locked" && itemInSlot.id != "null") { //if the slot is on the main inventory and a box is open if (inventory.slotsLst.IndexOf(this.gameObject) >= 0 && inventory.getBoxInventory() != null) { //Place this slot to the first null object find inventory.oldMoveSlot(this.gameObject); BoxInventory box = inventory.getBoxInventory(); int index = -1; for (int i = 0; i < box.lstObj.Count; i++) { if (box.lstObj[i].id == "null" && index == -1) { index = i; inventory.newMoveSlot(box.lstSlots[i]); } } } //if the slot is on the box and a box is open else if (inventory.getBoxInventory() != null && inventory.getBoxInventory().lstSlots.IndexOf(this.gameObject) >= 0) { //Place this slot to the first null object find inventory.oldMoveSlot(this.gameObject); int index = -1; for (int i = 0; i < inventory.slotsLst.Count; i++) { if (inventory.slotsLst[i].GetComponent <Slot>().itemInSlot.id == "null" && index == -1) { index = i; inventory.newMoveSlot(inventory.slotsLst[i]); } } } else if (inventory.getBoxInventory() == null && inventory.slotsLst.IndexOf(this.gameObject) >= 0) { //Place this slot to the first null object find inventory.oldMoveSlot(this.gameObject); int index = -1; for (int i = 0; i < inventory.handSlotLst.Count; i++) { if (inventory.handSlotLst[i].GetComponent <Slot>().itemInSlot.id == "null" && index == -1) { index = i; inventory.newMoveSlot(inventory.handSlotLst[i]); } } } else if (inventory.getBoxInventory() == null && inventory.handSlotLst.IndexOf(this.gameObject) >= 0) { //Place this slot to the first null object find inventory.oldMoveSlot(this.gameObject); int index = -1; for (int i = 0; i < inventory.slotsLst.Count; i++) { if (inventory.slotsLst[i].GetComponent <Slot>().itemInSlot.id == "null" && index == -1) { index = i; inventory.newMoveSlot(inventory.slotsLst[i]); } } } needToDelete = true; deleteStats(); } else if (isStay() && Input.GetMouseButtonDown(0) && itemInSlot.id != "locked" && itemInSlot.id != "null") { slotFollow = Instantiate(objMouseFollow, this.transform.parent.parent.parent); slotFollow.transform.localScale = this.transform.parent.localScale; slotFollow.transform.GetChild(0).GetComponent <Image>().sprite = itemInSlot.getSprite(); diff = new Vector3(this.transform.position.x - Input.mousePosition.x, this.transform.position.y - Input.mousePosition.y, 0); inventory.oldMoveSlot(this.gameObject); } else if (isStay() && Input.GetMouseButtonDown(0) && (itemInSlot.id == "locked" || itemInSlot.id == "null")) { inventory.resetSaveSlot(); } if (Input.GetMouseButtonUp(0) && itemInSlot.id != "locked") { if (isStay()) { inventory.newMoveSlot(this.gameObject); } Destroy(slotFollow); slotFollow = null; } if (slotFollow != null) { float s = this.transform.parent.localScale.x; slotFollow.transform.position = new Vector3(diff.x + Input.mousePosition.x, diff.y + Input.mousePosition.y, 0); } }
public ActionResult Edit(int id) { BoxInventory box = service.GetBoxById(id); return(View(box)); }
public void DeleteBox(BoxInventory toDelete) { repository.DeleteBox(toDelete); }
public void DeleteBox(BoxInventory toDelete) { dbContext.Boxes.Remove(toDelete); dbContext.SaveChanges(); }