public void Update(StockType entity) { var modified = StockTypes.First(st => st.Id == entity.Id); modified.Name = entity.Name; modified.Cost = entity.Cost; }
private void LoadOptions() { DataClass clsDataClass = new DataClass(); StockTypes clsStockTypes = new StockTypes(); cboStockTypes.DataTextField = "StockTypeCode"; cboStockTypes.DataValueField = "StockTypeID"; cboStockTypes.DataSource = clsDataClass.DataReaderToDataTable(clsStockTypes.List("StockTypeCode", SortOption.Ascending)).DefaultView; cboStockTypes.DataBind(); cboStockTypes.SelectedIndex = cboStockTypes.Items.Count - 1; Contacts clsContact = new Contacts(clsStockTypes.Connection, clsStockTypes.Transaction); cboSupplier.DataTextField = "ContactName"; cboSupplier.DataValueField = "ContactID"; cboSupplier.DataSource = clsDataClass.DataReaderToDataTable(clsContact.Suppliers(null, 0, "ContactName", SortOption.Ascending)).DefaultView; cboSupplier.DataBind(); Branch clsBranch = new Branch(clsStockTypes.Connection, clsStockTypes.Transaction); cboBranch.DataTextField = "BranchCode"; cboBranch.DataValueField = "BranchID"; cboBranch.DataSource = clsBranch.ListAsDataTable().DefaultView; cboBranch.DataBind(); clsStockTypes.CommitAndDispose(); cboStockTypes_SelectedIndexChanged(null, null); cboSupplier.SelectedIndex = 0; cboBranch.SelectedIndex = cboBranch.Items.IndexOf(cboBranch.Items.FindByValue(Constants.BRANCH_ID_MAIN.ToString())); NewTransaction(); }
/// <summary> /// Converts stockType to an actual prefab model /// </summary> /// <param name="stockType">StockType you're looking for</param> /// <returns>Random prefab of said stockType</returns> public GameObject GetStockTypePrefab(StockTypes stockType) { for (int c = 0; c < stockPrefabs.Length; c++) { // Collect stock pack StockData stockPrefabPack = stockPrefabs[c]; // Check if stockType matches what you're looking for if (stockPrefabPack.GetStockType() == stockType) { // Check if there's only one prefab model in the pack if (stockPrefabPack.GetPrefabs().Length == 1) { // Return the one return(stockPrefabPack.GetPrefabs()[0]); } else { // Return a random prefab in the pack return(EssentialFunctions.GetRandomFromArray(stockPrefabPack.GetPrefabs())); //return stockPrefabPack.prefabs[Random.Range(0, stockPrefabPack.prefabs.Length)]; } } } // Return nothing because it doesn't exist return(null); }
private void Update() { if (GetStockType() != _previousStockType) { // Stock changed! UpdateThumbnail(); } if (stockQuantity != _previousStockNum) { UpdateStockNum(); } billboardAnimator.SetBool(showImage, IsPlayerInDetectionRadius()); UpdateThumbnailNumCrossfade(billboardCrossfadePercentage); if (stockQuantity == 0) { Destroy(gameObject); } _previousStockType = GetStockType(); _previousStockNum = stockQuantity; }
private bool Delete() { bool boRetValue = false; string stIDs = ""; foreach (DataListItem item in lstItem.Items) { HtmlInputCheckBox chkList = (HtmlInputCheckBox)item.FindControl("chkList"); if (chkList != null) { if (chkList.Checked == true) { stIDs += chkList.Value + ","; boRetValue = true; } } } if (boRetValue) { StockTypes clsStockType = new StockTypes(); clsStockType.Delete(stIDs.Substring(0, stIDs.Length - 1)); clsStockType.CommitAndDispose(); } return(boRetValue); }
public ShelfContainer GetRandomShelvingUnit(StockTypes selectedType = StockTypes.None) { // Check if there are shelves in the map if (shelvingUnits.Count == 0) { Debug.LogWarning(!isDoneLoading ? "MapManager is not done loading!" : "There are no shelves in the map!"); return(null); } // Filter out shelves that are needed List <ShelfContainer> sortedShelfList = new List <ShelfContainer>(); if (selectedType != StockTypes.None) { for (int i = 0; i < shelvingUnits.Count; i++) { ShelfContainer currentShelf = shelvingUnits[i]; if (currentShelf.ShelfStockType == selectedType) { sortedShelfList.Add(shelvingUnits[i]); } } } else { CopyData.CopyObjectData(shelvingUnits, sortedShelfList); } if (sortedShelfList.Count == 0) { Debug.LogWarning("There are no shelves that have this type of stock: " + selectedType.ToString()); return(null); } // Filter out empty shelves List <ShelfContainer> stockedShelves = new List <ShelfContainer>(); for (int s = 0; s < sortedShelfList.Count; s++) { ShelfContainer shelf = sortedShelfList[s]; if (!shelf.IsEmpty()) { stockedShelves.Add(shelf); } } if (stockedShelves.Count == 0) { Debug.Log("All shelves of " + selectedType.ToString() + " is empty!"); return(EssentialFunctions.GetRandomFromArray(sortedShelfList));; } else { return(EssentialFunctions.GetRandomFromArray(stockedShelves)); } }
public void GetStockFromShelf(ShelfContainer shelf) { StockTypes stockType = shelf.ShelfStockType; int amount = shelf.GetStock(); if (amount != 0) { GameObject newItem = Object.Instantiate(stateMachine.mapManager.GetStockTypePrefab(stockType)) as GameObject; EquipItem(newItem.transform); } }
public Stock(int id, string name, string symbol, string isin, StockTypes stockType, bool isActive) { Guard.AgainstNull(() => name, () => symbol, () => isin); Id = id; Name = name; Symbol = symbol; Isin = isin; StockType = stockType; IsActive = isActive; Trades = new List<Trade>(); }
private void OnValidate() { // Always have at least one face available for pickup if (!allowPickupF && !allowPickupB && !allowPickupL && !allowPickupR) { allowPickupF = true; } stockAmount = Mathf.Clamp(stockAmount, 0, shelfSize); UpdatePickupPositionsArray(); _adjacentShelves.Clear(); _adjacentShelves.AddRange(GetAdjacentShelves()); // Update Stock ShelfVisual[] c = transform.GetComponentsInChildren <ShelfVisual>(); if (c.Length > 0) { UnityEditor.EditorApplication.delayCall += () => { for (int i = 0; i < c.Length; i++) { DestroyImmediate(c[i].gameObject); } }; } shelfVisual = null; shelfStockType = StockTypes.None; if (stock) { // Setup stats shelfStockType = stock.GetStockType(); GameObject newStockVisual = null; // Setup Visuals UnityEditor.EditorApplication.delayCall += () => { newStockVisual = Instantiate(stock.GetStockVisual(), transform, true); shelfVisual = newStockVisual.GetComponent <ShelfVisual>(); newStockVisual.transform.localPosition = Vector3.zero; }; } UpdateVisuals(); }
private void LoadRecord() { Int16 iID = Convert.ToInt16(Common.Decrypt(Request.QueryString["id"], Session.SessionID)); StockTypes clsStockType = new StockTypes(); StockTypesDetails clsDetails = clsStockType.Details(iID); clsStockType.CommitAndDispose(); lblStockTypeID.Text = clsDetails.StockTypeID.ToString(); txtStockTypeCode.Text = clsDetails.StockTypeCode; txtDescription.Text = clsDetails.Description; cboDirection.SelectedIndex = cboDirection.Items.IndexOf(cboDirection.Items.FindByValue(clsDetails.StockDirection.ToString("d"))); }
private void SaveRecord() { StockTypes clsStockType = new StockTypes(); StockTypesDetails clsDetails = new StockTypesDetails(); clsDetails.StockTypeID = Convert.ToInt16(lblStockTypeID.Text); clsDetails.StockTypeCode = txtStockTypeCode.Text; clsDetails.Description = txtDescription.Text; clsDetails.StockDirection = (StockDirections)Enum.Parse(typeof(StockDirections), cboDirection.SelectedItem.Value); clsStockType.Update(clsDetails); clsStockType.CommitAndDispose(); }
public void GetStockFromShelf(ShelfContainer shelf) { StockTypes stockType = shelf.ShelfStockType; int amount = shelf.GetStock(); if (amount == 0) { return; } GameObject newItem = Instantiate(mapManager.GetStockTypePrefab(stockType)); EquipItem(newItem.transform); }
ShelfContainer GetShelfDestination() { if (!stateMachine.mapManager.isDoneLoading) return GetShelfDestination(); // Get a random stock type StockTypes selectedType = GetRandomStockType(stateMachine.currentWantedProduct); stateMachine.currentWantedProduct = selectedType; // Get random shelf with wanted stocktype ShelfContainer selectedShelf = stateMachine.mapManager.GetRandomShelvingUnit(stateMachine.currentWantedProduct); return selectedShelf; }
private Int32 SaveRecord() { StockTypes clsStockType = new StockTypes(); StockTypesDetails clsDetails = new StockTypesDetails(); clsDetails.StockTypeCode = txtStockTypeCode.Text; clsDetails.Description = txtDescription.Text; clsDetails.StockDirection = (StockDirections)Enum.Parse(typeof(StockDirections), cboDirection.SelectedItem.Value); int id = clsStockType.Insert(clsDetails); clsStockType.CommitAndDispose(); return(id); }
//设置证券类型 private void SetSymbolType() { string symbolString = this.ToString(); this.StockType = StockTypes.unknow; if (Regex.IsMatch(symbolString, @"(SH.000\d{3})|(SZ.399\d{3})") == true) { this.SecurityType = SecurityTypes.Index; } else if (Regex.IsMatch(symbolString, @"(SH.60[0-8]\d{3})|(SZ.00[01256789]\d{3})") == true) { this.SecurityType = SecurityTypes.Stock; this.StockType = StockTypes.A; } else if (Regex.IsMatch(symbolString, @"(SH.90\d{4})|(SZ.20\d{4})") == true) { this.SecurityType = SecurityTypes.Stock; this.StockType = StockTypes.B; } else if (Regex.IsMatch(symbolString, @"(SZ.300\d{3})") == true) { this.SecurityType = SecurityTypes.Stock; this.StockType = StockTypes.Board2; } else if (Regex.IsMatch(symbolString, @"(SZ.4[023]\d{4})") == true) { this.SecurityType = SecurityTypes.Stock; this.StockType = StockTypes.Board3; } else if (Regex.IsMatch(symbolString, @"(SH.[012]\d{5})|(SZ.1[0123]\d{4})") == true) { this.SecurityType = SecurityTypes.Bond; } else if (Regex.IsMatch(symbolString, @"(SH.5[01]\d{4})|(SZ.184\d{3})|(SZ.1[56]\d{4})") == true) { this.SecurityType = SecurityTypes.Fund; } else if (Regex.IsMatch(symbolString, @"(SH.58\d{4})|(SZ.03\d{4})") == true) { this.SecurityType = SecurityTypes.Warrants; } else { this.SecurityType = SecurityTypes.Other; } }
public void AddStockToShelf(ShelfContainer shelf) { // Check if there is something equipped if (!stateMachine.equippedItem) { return; } // Get stock type that is equipped StockTypes equippedType = stateMachine.equippedItem.GetComponent <StockItem>().GetStockType(); int result = shelf.AddStock(equippedType); if (result == 0) { Object.Destroy(stateMachine.equippedItem); } }
StockTypes GetRandomStockType(StockTypes exclude = StockTypes.None) { if (!stateMachine.mapManager.isDoneLoading) return GetRandomStockType(exclude); List<StockTypes> productSelection = stateMachine.mapManager.GetStockTypesAvailable().ToList(); // Remove StockType.None and whatever is exluded for (int i = 0; i < productSelection.Count; i++) { if (productSelection[i] == StockTypes.None || productSelection[i] == exclude) { productSelection.RemoveAt(i); } } // Return random product in selection return productSelection[Random.Range(0, productSelection.Count)]; }
public int GetStockTypePrice(StockTypes stockType) { StockData stockToPrefabType = null; for (int i = 0; i < stockPrefabs.Length; i++) { if (stockPrefabs[i].GetStockType() == stockType) { stockToPrefabType = stockPrefabs[i]; } } if (stockToPrefabType != null) { return(stockToPrefabType.GetStockTypePrice()); } else { return(0); } }
protected void lstItem_ItemCommand(object sender, DataListCommandEventArgs e) { HtmlInputCheckBox chkList = (HtmlInputCheckBox)e.Item.FindControl("chkList"); string stParam = string.Empty; switch (e.CommandName) { case "imgItemDelete": StockTypes clsStockTypes = new StockTypes(); clsStockTypes.Delete(chkList.Value); clsStockTypes.CommitAndDispose(); LoadList(); break; case "imgItemEdit": stParam = "?task=" + Common.Encrypt("edit", Session.SessionID) + "&id=" + Common.Encrypt(chkList.Value, Session.SessionID); Response.Redirect("Default.aspx" + stParam); break; } }
public Sprite GetStockTypeThumbnail(StockTypes stockType) { StockData stockToPrefabType = null; for (int i = 0; i < stockPrefabs.Length; i++) { if (stockPrefabs[i].GetStockType() == stockType) { stockToPrefabType = stockPrefabs[i]; } } if (stockToPrefabType != null) { return(stockToPrefabType.GetThumbnail()); } else { return(null); } }
private void AddStockToShelf(ShelfContainer shelf) { // Check if there is something equipped if (!_equippedItem) { return; } int result = 0; switch (_equippedItem.tag) { case "Product": { // Get stock type that is equipped StockTypes equippedType = _equippedItem.GetComponent <StockItem>().GetStockType(); result = shelf.AddStock(equippedType); break; } case "StockCrate": { StockCrate crateComponent = _equippedItem.GetComponent <StockCrate>(); if (crateComponent) { result = shelf.AddCrate(crateComponent); } break; } } if (result == 0) { Destroy(_equippedItem); } }
public void SetStockType(StockTypes newStockType) { stockType = newStockType; }
/// <summary> /// /// </summary> /// <param name="amount">The amount of stock to add onto shelf</param> /// <param name="stockType">The stock type that is being added to the shelf</param> /// <returns>The remainder</returns> public int AddStock(int amount, StockTypes stockType) { // If this ever happens, you're actually dumb if (amount <= 0) { Debug.LogWarning("Uhhhhh... why are you adding nothing to the shelf? Tf?"); } // Check if shelf has stock already if (ShelfStockType == StockTypes.None) { // Apply new stock type ShelfStockType = stockType; } // Check if existing shelf stock doesn't match what you're adding else if (stockType != ShelfStockType) { // Stocks do not match! - do nothing Debug.Log("StockType doesn't match shelf! " + amount); return(amount); } // Fill shelves int availableShelfSpace = shelfSize - stockAmount; stockAmount += amount; if (stockAmount > shelfSize) { stockAmount = shelfSize; } int remainingStock = amount - availableShelfSpace; if (remainingStock < 0) { remainingStock = 0; } _mapManager.UpdateAvailableStockTypes(); // Add to adjacent shelves if (remainingStock > 0) { // No shelves adjacent - just return the remaining stock if (_adjacentShelves.Count == 0) { return(remainingStock); } // All adjacent shelves are full - return the remaining stock if (IsAllAdjacentShelvesFull()) { return(remainingStock); } // Add remaining stock to adjacent shelves else { ShelfContainer[] shelvesWithSpace = GetAdjacentShelvesWithSpace(); // Add all remaining stock to neighbouring shelf if (shelvesWithSpace.Length == 1) { remainingStock = shelvesWithSpace[0].AddStock(remainingStock, stockType); Debug.Log("Current Shelf Remaining: " + remainingStock); } // Evenly divide stock to all adjacent shelves including remaining else { int newRemainingStock = 0; for (int i = 0; i < remainingStock; i++) { newRemainingStock += shelvesWithSpace[i % shelvesWithSpace.Length].AddStock(stockType); } remainingStock = newRemainingStock; //int shelfQuantity = shelvesWithSpace.Length; //int shelfStockDividedQuantity = Mathf.FloorToInt(remainingStock / shelfQuantity); //int shelfStockRemaining = remainingStock % shelfQuantity; //int newRemaining = 0; //for (int i = 0; i < shelvesWithSpace.Length; i++) //{ // int amountToAdd = shelfStockDividedQuantity; // // Add remaining stock to shelves // if (i < shelfStockRemaining) // { // amountToAdd++; // } // newRemaining += shelvesWithSpace[i].AddStock(amountToAdd, stockType); //} //Debug.Log("Current Shelf Remaining: " + remainingStock + " Total Remaining Stock: " + newRemaining); } } } PushStockToaster(amount - remainingStock); return(remainingStock); }
/// <summary> /// /// </summary> /// <param name="stockType">The stock type that is being added to the shelf</param> /// <returns>The remainder</returns> public int AddStock(StockTypes stockType) { return(AddStock(1, stockType)); }
private void EmptyShelf() { stockAmount = 0; ShelfStockType = StockTypes.None; }
public TruckProduct(StockTypes _stockType, int _stockAmount) { stockType = _stockType; stockAmount = _stockAmount; }
public int Add(StockType entity) => StockTypes.Add(entity).Id;
private void LoadList() { StockTypes clsStockType = new StockTypes(); DataClass clsDataClass = new DataClass(); string SortField = "StockTypeID"; if (Request.QueryString["sortfield"] != null) { SortField = Common.Decrypt(Request.QueryString["sortfield"].ToString(), Session.SessionID); } SortOption sortoption = SortOption.Ascending; if (Request.QueryString["sortoption"] != null) { sortoption = (SortOption)Enum.Parse(typeof(SortOption), Common.Decrypt(Request.QueryString["sortoption"], Session.SessionID), true); } if (Request.QueryString["Search"] == null) { PageData.DataSource = clsStockType.ListAsDataTable(SortField, sortoption).DefaultView; } else { string SearchKey = Common.Decrypt((string)Request.QueryString["search"], Session.SessionID); PageData.DataSource = clsStockType.SearchAsDataTable(SearchKey, SortField, sortoption).DefaultView; } clsStockType.CommitAndDispose(); int iPageSize = Convert.ToInt16(Session["PageSize"]); PageData.AllowPaging = true; PageData.PageSize = iPageSize; try { PageData.CurrentPageIndex = Convert.ToInt16(cboCurrentPage.SelectedItem.Value) - 1; lstItem.DataSource = PageData; lstItem.DataBind(); } catch { PageData.CurrentPageIndex = 1; lstItem.DataSource = PageData; lstItem.DataBind(); } cboCurrentPage.Items.Clear(); for (int i = 0; i < PageData.PageCount; i++) { int iValue = i + 1; cboCurrentPage.Items.Add(new ListItem(iValue.ToString(), iValue.ToString())); if (PageData.CurrentPageIndex == i) { cboCurrentPage.Items[i].Selected = true; } else { cboCurrentPage.Items[i].Selected = false; } } lblDataCount.Text = " of " + " " + PageData.PageCount; }
public void Add(StockType entity) => StockTypes.Add(entity);
public void AddProductSold(StockTypes soldType) { productsSold.Add(soldType); }
public void Remove(StockType entity) => StockTypes.Remove(entity);