public ProductBookmarkViewModel(ProductBookmark x) : base(x) { Remarks = x.Remarks; ProductId = x.ProductId; ProductName = x.ProductName; SystemOnHand = x.SystemOnHand; PhysicalOnHand = x.PhysicalOnHand; QuantityDiff = x.QuantityDiff; CostPrice = x.CostPrice; PriceDiff = x.PriceDiff; Remarks = x.Remarks; }
public void AddProductBookmarks() { List <int> productBookmarkList = StringToIntList(Panels.instance.memberInfo.member.productBookmarks); int amount = productBookmarkList.Count; Vector2 panelSize = body.GetComponent <RectTransform>().rect.size; RectTransform content = body.GetChild(0).GetChild(0).GetComponent <RectTransform>(); float ySize = panelSize.y / productOnePageAmount; float contentYSize = panelSize.y; if (amount > productOnePageAmount) { contentYSize = ySize * amount; } content.offsetMin = new Vector2(0, 0); content.offsetMax = new Vector2(0, contentYSize); content.localPosition = new Vector2(0, -contentYSize / 2); for (int i = 0; i < amount; i++) { Transform newBookmark = Instantiate(productBookmark); newBookmark.SetParent(content); ProductBookmark bookmarkInfo = newBookmark.GetComponent <ProductBookmark>(); productBookmarks.Add(bookmarkInfo); RectTransform rectTransform = newBookmark.GetComponent <RectTransform>(); rectTransform.offsetMin = Vector2.zero; rectTransform.offsetMax = new Vector2(0, ySize); rectTransform.localPosition = new Vector2(0, contentYSize / 2 + -ySize * i - ySize / 2); int productID = productBookmarkList[i]; string sql = "SELECT * FROM product WHERE id = " + productID + ";"; MySql.Data.MySqlClient.MySqlDataReader reader = DbConnecter.instance.Reader(sql); reader.Read(); Product product = new Product(); product.id = reader.GetInt32(0); product.name = reader.GetString(1); product.barcode = reader.GetString(2); product.company = reader.GetString(3); product.category = product.koreanToCategory(reader.GetString(4)); product.ingredients = reader.GetString(5); product.imagePath = reader.GetString(6); ProductUnit productUnit = newBookmark.GetChild(0).GetComponent <ProductUnit>(); productUnit.InfoChange(product, gameObject); reader.Close(); DbConnecter.instance.CloseConnection(); bookmarkInfo.productID = product.id; } }
public void DeleteProductBookmark(int productID, ProductBookmark productBookmark) { float ratePos = 1 - body.GetChild(0).GetComponent <ScrollRect>().verticalNormalizedPosition; int amount = productBookmarks.Count; DbConnecter.instance.Connect(); List <int> intList = StringToIntList(Panels.instance.memberInfo.member.productBookmarks); int number = Mathf.FloorToInt(ratePos * amount); number = Mathf.Clamp(number - 2, 0, number); intList.Remove(productID); productBookmarks.Remove(productBookmark); Destroy(productBookmark.gameObject); SortProductBookmark(number); string bookmarks = IntListToString(intList); UpdateProductBookmark(bookmarks); DbConnecter.instance.CloseConnection(); }
void SortProductBookmark(int number) { int amount = productBookmarks.Count; Vector2 panelSize = body.GetComponent <RectTransform>().rect.size; RectTransform content = body.GetChild(0).GetChild(0).GetComponent <RectTransform>(); float ySize = panelSize.y / productOnePageAmount; float contentYSize = panelSize.y; if (amount > productOnePageAmount) { contentYSize = ySize * amount; } content.offsetMin = new Vector2(0, 0); content.offsetMax = new Vector2(0, contentYSize); content.anchoredPosition = new Vector2(0, -contentYSize / 2 + ySize * number); for (int i = 0; i < amount; i++) { ProductBookmark unit = productBookmarks[i]; RectTransform rectTransform = unit.GetComponent <RectTransform>(); rectTransform.offsetMin = Vector2.zero; rectTransform.offsetMax = new Vector2(0, ySize); rectTransform.localPosition = new Vector2(0, contentYSize / 2 + -ySize * i - ySize / 2); } }