public ProductItem Create(ProductItem item) { string resource = "products/rfid-cache/api/"; RestRequest request = new RestRequest(resource, Method.POST) { RequestFormat = DataFormat.Json }; request.AddBody(item); return Execute<ProductItem>(request); }
public bool TryGet(string rfid, out ProductItem productItem) { try { productItem = Get(rfid); return true; } catch (Exception ex) { LogHelper.WriteLog("ProductClientApi.TryGet", ex.Message, LogHelper.Level.Error); } productItem = null; return false; }
public static ProductItem FillOne(DataRow r, IncludeToFill i) { ProductItem p = new ProductItem(); if (i.Amount) p.Amount = (int)r["Amount"]; if (i.Description) p.Description = (string)r["Description"]; if (i.Discount) p.Discount = (int)r["Discount"]; if (i.Featured) p.Featured = (bool)r["Featured"]; if (i.Id) p.Id = (int)r["Id"]; if (i.Images) p.Images = ProductImageManager.GetImagesForProduct(p.Id); if (i.Name) p.Name = (string)r["Name"]; if (i.Price) p.Price = (int)r["Price"]; if (i.ShowOnPage) p.ShowOnPage = (bool)r["ShowOnPage"]; return p; }
public bool TryCreate(ProductItem product, out ProductItem newProduct) { if (product == null) { throw new ArgumentNullException("product"); } try { newProduct = Create(product); return true; } catch (Exception ex) { LogHelper.WriteLog("ProductClientApi.TryCreate", ex.Message, LogHelper.Level.Error); } newProduct = null; return false; }
public static void WriteJSON(NewEntitiesModel context) { var productItemsCollection = new MongoHelper<ProductItem>("Products"); productItemsCollection.MongoCollection.Drop(); foreach (var product in context.Products.Include("Vendor").Include("Reports")) { int productId = product.Id; string vendorName = product.Vendor.VendorName; string productName = product.ProductName; decimal quantity = 0; decimal sum = 0; foreach (var report in product.Reports) { quantity += report.Quantity.Value; sum += report.Sum.Value; } // Console.WriteLine(productId + " : " + vendorName + " : " + productName + " : " + quantity + " : " + sum); var tempObject = new ProductItem() { ProductId = productId, ProductName = productName, VendorName = vendorName, Quantity = quantity, Sum = sum }; productItemsCollection.InsertData(tempObject); } var productList = productItemsCollection.LoadData<ProductItem>().ToJson(); var removeId = Regex.Replace(productList, "\"_id\".*?\\,", "", RegexOptions.IgnoreCase); var formatedList = Regex.Replace(removeId, ",", ",\n", RegexOptions.IgnoreCase); var removedBracesRight = Regex.Replace(formatedList, "},", "\n},", RegexOptions.IgnoreCase); var removedBracesLeft = Regex.Replace(removedBracesRight, "{", "{\n", RegexOptions.IgnoreCase); File.Delete(@"../../../GeneratedReports/report.json"); File.WriteAllText(@"../../../GeneratedReports/report.json", removedBracesLeft); Console.WriteLine("JSON report created."); }
protected abstract string GetDescription(ProductItem productItem);
public IActionResult Detail(int prdIdx) { ProductItem item = (new ProductBiz(HttpContext)).GetProductItem(prdIdx); return(View(item)); }
public Task <int> DeleteItemAsync(ProductItem item) { return(database.DeleteAsync(item)); }
private void OnSyncSupplierInfoExecuted(ProductItem input, SimpleResult result, Exception ex) { var product = AppDatabase.db.ProductItems.FindById(input.Id); if (ex == null && result.Success && !product.NeedResotreProfit) { //备份原始利润 product.原利润 = product.利润; } if (product.SyncProfitSubmited) { product.SyncProfitSubmited = false; } AppDatabase.db.ProductItems.Update(product); BindDGViewProduct(); }
public ItemDetailViewModel(ProductItem item = null) { Title = item?.Name; Item = item; }
public static void OnDownshelfing(this ProductItem product, LiteCollection <ProductItem> productItems) { product.正在下架 = true; productItems.Update(product); }
public void LoadProducts(bool isReload) { if (_saveProducts == null || isReload) { List <ProductItem> productItems = new List <ProductItem>(); var dataProvider = DataProvider.GetInstance(); List <Product> products = dataProvider.GetProductByIDStore(IDStore); foreach (Product product in products) { product.QuantityOrder = 0; ProductItem item = new ProductItem { Product = product, isHidden = false }; productItems.Add(item); } _saveProducts = new ObservableCollection <ProductItem>(productItems); List <ProductItem> items = new List <ProductItem>(); foreach (ProductItem item in _saveProducts) { if (!item.isHidden) { items.Add(item); } } Products = new ObservableCollection <ProductItem>(items); } else { List <ProductItem> filteredProducts = new List <ProductItem>(); if (currentType == -1) { foreach (ProductItem item in _saveProducts) { item.isHidden = false; filteredProducts.Add(item); } } else { foreach (ProductItem item in _saveProducts) { if (item.Product.IDType == (currentType + 1).ToString()) { item.isHidden = false; } else { item.isHidden = true; } filteredProducts.Add(item); } } List <ProductItem> items = new List <ProductItem>(); foreach (ProductItem item in _saveProducts) { if (!item.isHidden) { items.Add(item); } } Products = new ObservableCollection <ProductItem>(items); } FiltProducts(); }
private List<ItemAttributeValue> quickform2obj(ProductItem obj) { int enabled = 0; int.TryParse(DropEnabled.SelectedValue, out enabled); obj.Enabled = (enabled == 1) ? true : false; obj.TitleTranslations.Clear(); obj.DescriptionTranslations.Clear(); obj.CategoryId = int.Parse(DropCategories.SelectedValue); obj.ThreadId = CurrentId; obj.ItemDate = this.ItemDate; obj.ValidFrom = this.ValidFrom; obj.ValidTo = this.ValidTo; // product fields obj.ProductType = ProductItem.ProductTypeEnum.Simple; int set = 0; int.TryParse(DropSets.SelectedValue, out set); obj.AttributeSet = set; obj.IsDraft = false; obj.SKU = QuickTxtSKU.Text; decimal regPrice = 0m; decimal.TryParse(QuickTxtRegularPrice.Text, out regPrice); obj.RegularPrice = regPrice; decimal salePrice = 0m; decimal.TryParse(QuickTxtSalePrice.Text, out salePrice); obj.SalePrice = salePrice; decimal weight = 0m; decimal.TryParse(QuickTxtWeight.Text, out weight); obj.Weight = weight; int qty = 0; int.TryParse(QuickTxtQty.Text, out qty); obj.Availability = qty; int inStock = 0; int.TryParse(QuickDropStock.SelectedValue, out inStock); obj.InStock = (inStock == 1) ? true : false; var atts = new List<ItemAttributeValue>(); // QUI raccolo i quick attributevalue da salvare string endofname = ""; foreach (var attribute in attributes) { if (!attribute.AllowCustomValue) { DropDownList d1 = new DropDownList(); d1 = (DropDownList)QuickAttributes.FindControl("DropAttributeValuesQuick" + attribute.Name); int attributeValueId = 0; int.TryParse(d1.SelectedValue, out attributeValueId); if (attributeValueId > 0) { endofname += "-" + d1.SelectedItem.Text; var record = new ItemAttributeValue(); record.AttributeId = attribute.Id; record.AttributeValueId = attributeValueId; atts.Add(record); } } else { TextBox t1 = new TextBox(); t1 = (TextBox)QuickAttributes.FindControl("TxtCustomFieldQuick" + attribute.Name); var record = new ItemAttributeValue(); record.AttributeId = attribute.Id; record.AttributeValueId = 0; record.CustomValueString = t1.Text; atts.Add(record); } } foreach (KeyValuePair<string, string> item in Config.CultureList) { TextBox t1 = new TextBox(); t1 = (TextBox)PanelTitle.FindControl("TxtTitle" + item.Value); obj.TitleTranslations.Add(item.Key, t1.Text + endofname); } obj.Alias = TxtAlias.Text + endofname.ToLower(); obj.ItemParams = FormBuilder.GetParamsString(obj.ItemType.Params, ItemParams1); string fieldsString = FormBuilder.GetParamsString(obj.ItemType.Fields, ItemFields1); obj.LoadCustomFieldsFromString(fieldsString); PermissionsControl1.Form2obj(obj); return atts; }
private void obj2form(ProductItem obj) { LblId.Text = obj.Id.ToString(); LblOrderId.Text = obj.Ordering.ToString(); LblUpdated.Text = obj.DateUpdated.ToString() + " by " + obj.UserUpdated; LblCreated.Text = obj.DateInserted.ToString() + " by " + obj.UserInserted; ChkEnabled.Checked = obj.Enabled; TxtAlias.Text = obj.Alias; TxtCssClass.Text = obj.CssClass; Utility.SetDropByValue(DropCategories, obj.CategoryId.ToString()); foreach (KeyValuePair<string, string> item in Config.CultureList) { string sTitleTranslation = ""; TextBox t1 = new TextBox(); t1 = (TextBox)PanelTitle.FindControl("TxtTitle" + item.Value); obj.TitleTranslations.TryGetValue(item.Key, out sTitleTranslation); t1.Text = sTitleTranslation; string sDescriptionTraslation = ""; var txt2 = new Controls_ContentEditorControl(); txt2 = Utility.FindControlRecursive<Controls_ContentEditorControl>(this, "TxtDescription" + item.Value); obj.DescriptionTranslations.TryGetValue(item.Key, out sDescriptionTraslation); txt2.Text = sDescriptionTraslation; } // QUI popolo le varianti se son già salvate attributes.Clear(); for (int i = 0; i < obj.Attributes.Count; i++) { DropDownList d1 = new DropDownList(); d1 = (DropDownList)PanelAttributes.FindControl("DropAttributeValues" + obj.Attributes[i].Name); Utility.SetDropByValue(d1, obj.AttributeValues[i].Id.ToString()); } for (int i = 0; i < obj.CustomAttributes.Count; i++) { TextBox t1 = new TextBox(); t1 = (TextBox)PanelAttributes.FindControl("TxtCustomField" + obj.CustomAttributes[i].Name); t1.Text = obj.CustomAttributeValues[i]; } //product fields TxtSKU.Text = obj.SKU; TxtRegularPrice.Text = (obj.RegularPrice > 0) ? obj.RegularPrice.ToString() : "" ; TxtSalePrice.Text = (obj.SalePrice > 0) ? obj.SalePrice.ToString() : ""; TxtWeight.Text = (obj.Weight > 0) ? obj.Weight.ToString() : ""; TxtQty.Text = (obj.Availability > 0) ? obj.Availability.ToString() : ""; DropStock.SelectedValue = (obj.InStock) ? "1" : "0"; if (obj.AttributeSet > 0) { DropSets.SelectedValue = (obj.AttributeSet.ToString()); DropSets.Enabled = false; } else { DropSets.Enabled = true; } ItemParams1.ClearParams(); ItemFields1.ClearParams(); ItemParams1.LoadParams(obj); ItemFields1.LoadFields(obj); PermissionsControl1.Obj2form(obj); LitItemType.Text = obj.ItemTypeName; this.ItemDate = obj.ItemDate; this.ValidFrom = obj.ValidFrom; this.ValidTo = obj.ValidTo; int itemType = 0; int.TryParse(DropNew.SelectedValue, out itemType); if ((ProductItem.ProductTypeEnum)itemType == ProductItem.ProductTypeEnum.Configurable || obj.ProductType == ProductItem.ProductTypeEnum.Configurable) { PlhConfigurableProductPane.Visible = true; plhConfigurableProductTab.Visible = true; } else { PlhConfigurableProductPane.Visible = false; plhConfigurableProductTab.Visible = false; } }
protected void btnServiceOrderItemProduct_Click(object sender, ImageClickEventArgs e) { //search the Product in Inventory productManager = new ProductManager(this); inventoryManager = new InventoryManager(this); Product product = productManager.GetProductByName(Company.CompanyId, txtProduct.Text); litErrorMessage.Visible = false; if (product != null) { if (!String.IsNullOrEmpty(cboDeposit.SelectedValue)) if (!IsValidProductWithDeposit(product)) return; if (ucCurrFieldQuantity.IntValue == 0) { litErrorMessage.Visible = true; litErrorMessage.Text = "Quantidade não pode ser zero!"; return; } Decimal productPrice = Decimal.Zero; Inventory inventory = inventoryManager.GetProductInventory(Company.CompanyId, product.ProductId, Deposit.DepositId); if (inventory != null) productPrice = inventory.UnitPrice; ProductItem productItem = new ProductItem(product.CompanyId, product.ProductId, product.Name, ucCurrFieldQuantity.IntValue, txtDescription.Text, productPrice, Convert.ToBoolean(choProductIsApplied.Checked)); ProductItemsList.Add(productItem); BindProducts(); txtProduct.Text = String.Empty; txtDescription.Text = String.Empty; ucCurrFieldQuantity.Text = String.Empty; } }
public void Create([FromBody] ProductItem item) { bool result = _ProductItemRepo.Add(item); }
public object GetVShop(long id, bool sv = false) { //Json(ErrorResult<int>("取消失败,该订单已删除或者不属于当前用户!")); var vshopService = ServiceProvider.Instance <IVShopService> .Create; var vshop = vshopService.GetVShop(id); if (vshop == null) { return(ErrorResult <bool>("未开通微店!", code: -4)); } if (vshop.State == Entities.VShopInfo.VShopStates.Close) { return(ErrorResult <bool>("商家暂未开通微店!", code: -5)); } if (!vshop.IsOpen) { return(ErrorResult <bool>("此微店已关闭!", code: -3)); } var s = ShopApplication.GetShop(vshop.ShopId); if (null != s && s.ShopStatus == Entities.ShopInfo.ShopAuditStatus.HasExpired) { return(ErrorResult <bool>("此店铺已过期!", code: -1)); } //throw new MallApiException("此店铺已过期"); if (null != s && s.ShopStatus == Entities.ShopInfo.ShopAuditStatus.Freeze) { return(ErrorResult <bool>("此店铺已冻结!", code: -2)); } //throw new MallApiException("此店铺已冻结"); //轮播图配置只有商家微店首页配置页面可配置,现在移动端都读的这个数据 var slideImgs = ServiceProvider.Instance <ISlideAdsService> .Create.GetSlidAds(vshop.ShopId, Entities.SlideAdInfo.SlideAdType.VShopHome).ToList(); //首页商品现在只有商家配置微信首页,APP读的也是这个数据所以平台类型选的的微信端 var homeProducts = ServiceProvider.Instance <IMobileHomeProductsService> .Create.GetMobileHomeProducts(vshop.ShopId, PlatformType.WeiXin, 1, 8); #region 价格更新 //会员折扣 decimal discount = 1M; long SelfShopId = 0; if (CurrentUser != null) { discount = CurrentUser.MemberDiscount; var shopInfo = ShopApplication.GetSelfShop(); SelfShopId = shopInfo.Id; } var limit = LimitTimeApplication.GetLimitProducts(); var fight = FightGroupApplication.GetFightGroupPrice(); var products = new List <ProductItem>(); var productData = ProductManagerApplication.GetProducts(homeProducts.Models.Select(p => p.ProductId)); foreach (var item in homeProducts.Models) { var product = productData.FirstOrDefault(p => p.Id == item.ProductId); var pitem = new ProductItem(); pitem.Id = item.ProductId; pitem.ImageUrl = Core.MallIO.GetRomoteProductSizeImage(product.RelativePath, 1, (int)Mall.CommonModel.ImageSize.Size_350); pitem.Name = product.ProductName; pitem.MarketPrice = product.MarketPrice; pitem.SalePrice = product.MinSalePrice; if (item.ShopId == SelfShopId) { pitem.SalePrice = product.MinSalePrice * discount; } var isLimit = limit.Where(r => r.ProductId == item.ProductId).FirstOrDefault(); var isFight = fight.Where(r => r.ProductId == item.ProductId).FirstOrDefault(); if (isLimit != null) { pitem.SalePrice = isLimit.MinPrice; } if (isFight != null) { pitem.SalePrice = isFight.ActivePrice; } products.Add(pitem); } #endregion var banner = ServiceProvider.Instance <INavigationService> .Create.GetSellerNavigations(vshop.ShopId, Core.PlatformType.WeiXin).ToList(); var couponInfo = GetCouponList(vshop.ShopId); var SlideAds = slideImgs.ToArray().Select(item => new HomeSlideAdsModel() { ImageUrl = Core.MallIO.GetRomoteImagePath(item.ImageUrl), Url = item.Url }); var Banner = banner; var Products = products; bool favoriteShop = false; if (CurrentUser != null) { favoriteShop = ServiceProvider.Instance <IShopService> .Create.IsFavoriteShop(CurrentUser.Id, vshop.ShopId); } string followUrl = ""; //快速关注 var vshopSetting = ServiceProvider.Instance <IVShopService> .Create.GetVShopSetting(vshop.ShopId); if (vshopSetting != null) { followUrl = vshopSetting.FollowUrl; } var model = new { Id = vshop.Id, //Logo = "http://" + Url.Request.RequestUri.Host + vshop.Logo, Logo = Core.MallIO.GetRomoteImagePath(vshop.StrLogo), Name = vshop.Name, ShopId = vshop.ShopId, Favorite = favoriteShop, State = vshop.State, FollowUrl = followUrl }; // 客服 var customerServices = CustomerServiceApplication.GetMobileCustomerServiceAndMQ(vshop.ShopId); //统计访问量 if (!sv) { vshopService.LogVisit(id); //统计店铺访问人数 StatisticApplication.StatisticShopVisitUserCount(vshop.ShopId); } dynamic result = new ExpandoObject(); result.VShop = model; result.SlideImgs = SlideAds; result.Products = products; result.Banner = banner; result.Coupon = couponInfo; result.CustomerServices = customerServices; return(Json(new { result })); }
private bool saveQuickAdd() { bool res = false; LblErr.Text = RenderError(""); LblOk.Text = RenderSuccess(""); try { var o1 = new ProductItem(); //precarico i campi esistenti e nn gestiti dal form var a1 = quickform2obj(o1); var prod = new ProductItemsManager().Insert(o1); // cancello tutti i record con questo itemID man.DeleteByItemId(prod.Id); foreach (var a in a1) { a.ItemId = prod.Id; man.Insert(a); } removeFromCache(); Grid1.DataBind(); GridViewSimple.DataBind(); clearQuickForm(); LblOk.Text = RenderSuccess(Utility.GetLabel("RECORD_SAVED_MSG")); res = true; } catch (CustomException e1) { if (e1.CustomMessage == ProductItemsManager.MaxItemsException) LblErr.Text = RenderError(base.GetLabel("LblMaxItemsReached", "you have reached the maximum number of elements")); else LblErr.Text = RenderError(e1.CustomMessage); } catch (Exception e1) { LblErr.Text = RenderError(Utility.GetLabel("RECORD_ERR_MSG") + "<br />" + e1.ToString()); } finally { } return res; }
private void showProducts() { this.backgroundProductImageUploader.CancelAsync(); clearTable(); int row = productItems.Count; List <ProductModel> filteredProducts = new List <ProductModel>(); //In case when there are no if (string.IsNullOrEmpty(productsGridOptions.searchProductName)) { try { filteredProducts = productProvider.GetProducts( productsPerPageCount, productsGridOptions.PageNumber, productsGridOptions.SortColumnName, productsGridOptions.SortOrder, productsGridOptions.FilterProductTypeId).ToList(); } catch (Exception ex) { MessageBox.Show(ex.Message, Resources.ErrorMessage); return; } } else { this.productsGridOptions.PageNumber = 1; this.leftSideProductListButton.Enabled = false; try { filteredProducts = productProvider.SearchProductByName( productsGridOptions.searchProductName).ToList(); } catch (Exception ex) { MessageBox.Show(ex.Message, Resources.ErrorMessage); return; } } if (filteredProducts.Count == 0) { this.noMoreProductMessageLabel.Visible = true; this.rightSideProductListButton.Enabled = false; return; } this.noMoreProductMessageLabel.Visible = false; this.rightSideProductListButton.Enabled = true; foreach (var product in filteredProducts) { MaterialCheckBox productCheckBox = new MaterialCheckBox(); productCheckBox.Anchor = AnchorStyles.Bottom & AnchorStyles.None; this.productTableRowLabels = new Control[tableColumnCount]; foreach (var selectedProduct in selectedProducts) { if (selectedProduct.Id == product.Id) { productCheckBox.Checked = true; } } this.productTableRowLabels[0] = productCheckBox; int initialTableDataColIndex = 2; for (int i = initialTableDataColIndex; i < productTableRowLabels.Length; i++) { this.productTableRowLabels[i] = new Label(); this.productTableRowLabels[i].AutoSize = true; this.productTableRowLabels[i].Anchor = AnchorStyles.None; this.productTableRowLabels[i].Font = commonFont; this.productTableView.Controls.Add(productTableRowLabels[i], i, row); } var productItem = new ProductItem(product); productItems.Add(productItem); //Each time will be selecting an item in front of the Check box productCheckBox.CheckedChanged += (sender, e) => { var chackBox = (MaterialCheckBox)sender; if (chackBox.Checked) { if (selectedProducts.Count == 0) { selectedProductsListBox.Items.RemoveAt(0); } this.selectedProductsListBox.Items.Insert(0, productItem.ProductModel.Name); this.selectedProducts.Add(productItem.ProductModel); } else { this.selectedProducts.RemoveAll((p) => (p.Id == productItem.ProductModel.Id)); this.selectedProductsListBox.Items.Remove(productItem.ProductModel.Name); if (selectedProducts.Count == 0) { this.selectedProductsListBox.Items.Insert(0, Resources.NoProductsYetMessage); } } changePlan(productItem); }; this.productTableView.Controls.Add(productCheckBox, 0, row); this.productTableView.Controls.Add(productTableRowLabels[0], 0, row); var deleteIconLabel = new Label(); var editIconLabel = new Label(); editIconLabel.Anchor = AnchorStyles.Left; deleteIconLabel.Anchor = AnchorStyles.Left; deleteIconLabel.Width = 25; deleteIconLabel.Image = Resources.DeleteIcon; editIconLabel.Image = Resources.EditIcon; deleteIconLabel.Click += (sender, e) => { deleteProduct(productItem.ProductModel); }; editIconLabel.Click += (sender, e) => { setProductToUpdate(productItem); }; this.productTableView.Controls.Add(editIconLabel, 7, row); this.productTableView.Controls.Add(deleteIconLabel, 8, row); //Configure Label element, so that there could put the picture there productItem.PictureLabel = new Label(); productItem.PictureLabel.AutoSize = true; productItem.PictureLabel.Font = new Font("Microsoft Sans Serif", 50F); productItem.PictureLabel.Text = string.Format("{0,4}", string.Empty); productItem.PictureLabel.Anchor = AnchorStyles.None; this.productTableView.Controls.Add(productItem.PictureLabel, 1, row); //Set the text values of Label content in the correct order this.productTableRowLabels[2].Text = product.Name; this.productTableRowLabels[3].Text = product.ProductTypeModel.Name; this.productTableRowLabels[4].Text = product.Proteins.ToString(); this.productTableRowLabels[5].Text = product.Fats.ToString(); this.productTableRowLabels[6].Text = product.Carbohydrates.ToString(); row++; this.productTableView.Refresh(); } }
protected void GridRelated_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var item = new ProductItem(); item = (ProductItem)e.Row.DataItem; if (item.IsThreadRoot) lastRowDataboundRoot = e.Row; else { if (lastRowDataboundRoot != null) e.Row.RowState = lastRowDataboundRoot.RowState; //keeps same style of thread root } if (item.Id == base.CurrentId) { e.Row.Visible = false; } var pman = new ProductItemsManager(); var relatedIds = pman.GetRelatedItems(CurrentId).Select(x => x.Id); CheckBox chkRow = (CheckBox)e.Row.FindControl("chkRow"); if (relatedIds.Contains(item.Id)) { chkRow.Checked = true; } } }
public async Task AddToCartAsync(ProductItem productItem, ComboMeal comboMeal, CustomizeProduct customizeProduct, int quantity, string shoppingCartId) { await _shoppingCartRepository.AddToCartAsync(productItem, comboMeal, customizeProduct, quantity, shoppingCartId); }
protected void GridViewSimple_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var item = new ProductItem(); item = (ProductItem)e.Row.DataItem; if (item.IsThreadRoot) lastRowDataboundRoot = e.Row; else { if (lastRowDataboundRoot != null) e.Row.RowState = lastRowDataboundRoot.RowState; //keeps same style of thread root } CheckBox chkRow = (CheckBox)e.Row.FindControl("chkRow"); if (item.ThreadId == this.CurrentId) { chkRow.Checked = true; } } }
public async Task<bool> SetProductProfit(ProductItem product, Func<ProductItem, decimal> Getprofit, bool forceModify = false, bool isUserOperation = false) { try { decimal profit = Getprofit(product); SuplierInfo supplier = null; if (!string.IsNullOrEmpty(product.SupplierId)) { supplier = product.GetSuplierInfo(); } else { await CheckIfLoginRequired(); using (var wbHelper = new WBHelper(true)) { supplier = await this.InvokeTask(supplierInfo, wbHelper, product.SpuId); if (supplier == null || !supplier.profitData.Any()) { AppendText("【{0}】暂无供应商,改价操作取消。", product.ItemName); return false; } product.OnSupplierInfoUpdate(AppDatabase.db.ProductItems, supplier); } } if (supplier != null && supplier.profitData != null && supplier.profitData.Any()) { if (supplier.profitData[0].price == 0) { AppendText("【{0}】暂无供应商,改价操作取消。", product.ItemName); return false; } if (supplier.profitData[0].price == product.进价 && product.利润 == profit && !forceModify) { //价格无变化不处理 AppendText("商品【{0}】进价及利润无变化,跳过。", product.ItemName); BindDGViewProduct(); return true; } string profitString = "0.00"; profitString = profit.ToString("f2"); var oneprice = (supplier.profitData[0].price + profit).ToString("f2"); await CheckIfLoginRequired(); using (var wbHelper = new WBHelper(false)) { var save = await this.InvokeTask(supplierSave, wbHelper, supplier.profitData[0].id, product.SpuId, profitString, oneprice, product.Id, tbcpCrumbs); if (save.status != 200) { AppendText("为商品{0}设置利润时失败。错误消息:{1}", product.Id, save.msg); return false; } else { product.ModifyProfitSubmitted = true; if (isUserOperation) { //备份原始利润 product.原利润 = profit; } AppDatabase.db.ProductItems.Update(product); BindDGViewProduct(); return true; } } } else { AppendText("为商品{0}设置利润时失败,因为没有查询到供应商信息。", product.Id); return false; } } catch (Exception ex) { AppendException(ex); return false; } }
protected void Page_Load(object sender, EventArgs e) { LblOk.Text = RenderSuccess(""); LblErr.Text = RenderError(""); if (this.BaseModule.DirectEditMode) { if (base.CurrItem.Id == 0) throw new ArgumentException(); if (new ProductItemsManager(true, true).GetByKey(base.CurrItem.Id).Id == 0) throw new ArgumentException(); } QuickTxtWeight.Attributes.Add("onclick", "autosuggest(" + TxtWeight.ClientID + ", this )"); QuickTxtRegularPrice.Attributes.Add("onclick", "autosuggest(" + TxtRegularPrice.ClientID + ", this )"); QuickTxtSalePrice.Attributes.Add("onclick", "autosuggest(" + TxtSalePrice.ClientID + ", this )"); QuickTxtQty.Attributes.Add("onclick", "autosuggest(" + TxtQty.ClientID + ", this )"); if (!Page.IsPostBack) { loadDropEnabledFilter(); loadDropCategoriesFilter(PRODUCT_SECTION); // TOTO with settings loadDropsItemTypes(); loadDropSets(); loadDropProductType(); } else { string eventArg = HttpContext.Current.Request["__EVENTARGUMENT"]; if (eventArg == "items") Grid1.DataBind(); //reload params on every postback, because cannot manage dinamically fields var currentItem = new ProductItem(); if (CurrentId > 0) { currentItem = new ProductItemsManager(true, true).GetByKey(CurrentId); ItemParams1.LoadParams(currentItem); ItemFields1.LoadFields(currentItem); } else { //manually set ItemType try { currentItem.ItemTypeName = LitItemType.Text; ItemParams1.LoadParams(currentItem); ItemFields1.LoadFields(currentItem); } catch { } } } if (this.BaseModule.DirectEditMode) { DropNew.Visible = false; BtnNew.Visible = false; BtnCancel.OnClientClick = "closePopup();"; editRow(base.CurrItem.Id); } }
public static ProductItem GetProduct(SqlConnection sqlconn, string productName) { ProductItem item = new ProductItem(); SqlCommand query = new SqlCommand("proc_get_product", sqlconn); query.CommandType = CommandType.StoredProcedure; query.Parameters.Add("@productName", SqlDbType.VarChar); query.Parameters["@productName"].Value = productName; try { // Get the data var reader = query.ExecuteReader(); if (reader.Read()) { item = new ProductItem(reader.GetString(0), reader.GetString(1), reader.GetString(3), reader.GetString(4), reader.GetString(5)); } return item; } catch { return item; } }
private List<ItemAttributeValue> form2obj(ProductItem obj) { obj.Id = CurrentId; obj.Enabled = ChkEnabled.Checked; obj.TitleTranslations.Clear(); obj.DescriptionTranslations.Clear(); obj.CategoryId = int.Parse(DropCategories.SelectedValue); obj.Alias = TxtAlias.Text; obj.CssClass = TxtCssClass.Text; obj.ItemDate = this.ItemDate; obj.ValidFrom = this.ValidFrom; obj.ValidTo = this.ValidTo; // product fields // Product Type int type = 0; int.TryParse(DropNew.SelectedValue, out type); if (type > 0) { obj.ProductType = (ProductItem.ProductTypeEnum)type; } // Attribute Set int attributeSetId = 0; int.TryParse(DropSets.SelectedValue, out attributeSetId); obj.AttributeSet = attributeSetId; // Draft obj.IsDraft = false; // SKU obj.SKU = TxtSKU.Text; // Regular Price decimal regPrice = 0m; decimal.TryParse(TxtRegularPrice.Text, out regPrice); if (regPrice > 0) obj.RegularPrice = regPrice; // Sale Price decimal salePrice = 0m; decimal.TryParse(TxtSalePrice.Text, out salePrice); if(salePrice > 0) obj.SalePrice = salePrice; // Weight decimal weight = 0m; decimal.TryParse(TxtWeight.Text, out weight); if(weight > 0) obj.Weight = weight; // Qty int qty = 0; int.TryParse(TxtQty.Text, out qty); if (weight > 0) obj.Availability = qty; // Stock int inStock = 0; int.TryParse(DropStock.SelectedValue, out inStock); if (inStock > 0) obj.InStock = (inStock == 1) ? true : false; if (CurrentId == 0) obj.ItemTypeName = LitItemType.Text; foreach (KeyValuePair<string, string> item in Config.CultureList) { TextBox t1 = new TextBox(); t1 = (TextBox)PanelTitle.FindControl("TxtTitle" + item.Value); obj.TitleTranslations.Add(item.Key, t1.Text); var txt2 = new Controls_ContentEditorControl(); txt2 = Utility.FindControlRecursive<Controls_ContentEditorControl>(this, "TxtDescription" + item.Value); obj.DescriptionTranslations.Add(item.Key, txt2.Text); } foreach(GridViewRow r in GridViewSimple.Rows) { CheckBox cb = (CheckBox)r.FindControl("chkRow"); string IdString = r.Cells[5].Text; int Id = 0; int.TryParse(IdString, out Id); var p = new ProductItemsManager().GetByKey(Id); if (cb.Checked) { p.ThreadId = CurrentId; } else { if (p.ThreadId == CurrentId ) p.ThreadId = p.Id; } try { new ProductItemsManager().Update(p); } catch (Exception e1) { LblErr.Text = RenderError(Utility.GetLabel("RECORD_ERR_MSG") + "<br />" + e1.ToString()); } } foreach (GridViewRow r in GridRelated.Rows) { CheckBox cb = (CheckBox)r.FindControl("chkRow"); string IdString = r.Cells[5].Text; int Id = 0; int.TryParse(IdString, out Id); var p = new ProductItemsManager().GetByKey(Id); if (cb.Checked) { try { new ProductItemsManager().SetRelated(CurrentId, p.Id); } catch (Exception e1) { LblErr.Text = RenderError(Utility.GetLabel("RECORD_ERR_MSG") + "<br />" + e1.ToString()); } } else { try { new ProductItemsManager().DeleteRelated(CurrentId, p.Id); } catch (Exception e1) { LblErr.Text = RenderError(Utility.GetLabel("RECORD_ERR_MSG") + "<br />" + e1.ToString()); } } } var atts = new List<ItemAttributeValue>(); // Store ItemAttributeValues var set = sman.GetByKey(attributeSetId); attributes.Clear(); foreach (var attributeId in set.AttributesList) { var attribute = aman.GetByKey(attributeId); attributes.Add(attribute); } foreach (var attribute in attributes) { if (!attribute.AllowCustomValue) { DropDownList d1 = new DropDownList(); d1 = (DropDownList)PanelAttributes.FindControl("DropAttributeValues" + attribute.Name); int attributeValueId = 0; int.TryParse(d1.SelectedValue, out attributeValueId); var record = new ItemAttributeValue(); record.AttributeId = attribute.Id; record.AttributeValueId = attributeValueId; record.ItemId = CurrentId; atts.Add(record); } else { TextBox t1 = new TextBox(); t1 = (TextBox)QuickAttributes.FindControl("TxtCustomField" + attribute.Name); var record = new ItemAttributeValue(); record.AttributeId = attribute.Id; record.AttributeValueId = 0; record.CustomValueString = t1.Text; record.ItemId = CurrentId; atts.Add(record); } } obj.ItemParams = FormBuilder.GetParamsString(obj.ItemType.Params, ItemParams1); string fieldsString = FormBuilder.GetParamsString(obj.ItemType.Fields, ItemFields1); obj.LoadCustomFieldsFromString(fieldsString); PermissionsControl1.Form2obj(obj); return atts; }
public int AddProductItem(ProductItem item) { item.Id = _productId++; _productItems.Add(item.Id, item.Clone()); return(item.Id); }
public void GivenTheProductsTableIsTheFollowing(Table table) { var itemList = new List<ProductItem>(); foreach (var row in table.Rows) { var item = new ProductItem { ProductId = int.Parse(row["ProductId"]), ProductName = row["ProductName"], Price = double.Parse(row["Price"]), Quantity = int.Parse(row["Quantity"]), ExpirationDate = DateTime.Now }; itemList.Add(item); } _productRepositoryMock.Setup(pr => pr.LoadProductItemsFromStoredCartItems(It.IsAny<List<StoredCartItem>>())) .Returns(itemList); }
public void PriceForQuantity_OnInvalidEligibleUnits_ShouldThrowException() { var productItem = new ProductItem("1", "T-SHIRT", 2000); var decorator = new AddOnUnitPromo(productItem, 0, 1); }
public ProductDetailsView(ProductItem productItem) { InitializeComponent(); pvm = new ProductDetailsViewModel(productItem); this.BindingContext = pvm; }
protected abstract bool ProcessProduct(ProductItem productItem);
public bool UpdateProductItem(ProductItem item) { throw new NotImplementedException(); }
public async Task CreateProduct(ProductItem item) { _context.ProductItems.Add(item); await _context.SaveChangesAsync(); }
public int AddProductItem(ProductItem item) { throw new NotImplementedException(); }
public ActionResult Import(HttpPostedFileBase file) { DataSet ds = file.ToDataSet(); Utils.LdapAuthentication _ldap = new Utils.LdapAuthentication(string.Format("LDAP://{0}", ConfigurationManager.AppSettings["Domain"])); DataTable dt = ds.Tables[0]; if (dt.Columns.Count == 5) { dt.Columns.Add("Kết quả"); if (ds != null) { //foreach (DataTable dt2 in ds.Tables) //{ foreach (DataRow r in dt.Rows) { string importDescription = string.Empty; string error = string.Empty; string shortCode = string.Empty; string _username = string.Empty; string _stockStatusName = string.Empty; string _POno = string.Empty; string _description = string.Empty; try { shortCode = r[0].ToString(); _username = r[1].ToString(); _stockStatusName = r[2].ToString(); _POno = r[3].ToString(); _description = r[4].ToString(); var productItem = db.ProductItems.Where(p => p.ShortCode.Equals(shortCode, StringComparison.OrdinalIgnoreCase) || p.Name.Equals(shortCode, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); if (productItem == null) { importDescription = "ShortCode không tồn tại"; error = "Lỗi"; } else { var employee = new Employee(); if (_username != string.Empty) { //int empID = int.Parse(_eCode); employee = db.Employees.Where(e => (e.UserName.Equals(_username, StringComparison.OrdinalIgnoreCase) && _username != string.Empty)).FirstOrDefault(); if (employee == null) { importDescription = "Nhân viên không tồn tại"; //ImpersonatorUser imp = _ldap.Finduser(_username); //if (imp != null) //{ // Department department= null; // if (imp.Department != string.Empty && imp.Department != null) // { // department = new Department() // { // Name = imp.Department // }; // db.Departments.Add(department); // db.SaveChanges(); // } // employee = new Employee(); // employee.Code = imp.Pager; // employee.Name = imp.DisplayName; // if (department != null) employee.DepartmentId = department.Id; // employee.UserName = imp.Username; // db.Employees.Add(employee); // db.SaveChanges(); // importDescription = "Tạo mới nhân viên"; //} //else //{ // importDescription = "Nhân viên không tồn tại"; // error = "Lỗi"; //} } } var stockStatus = new StockStatus(); if (_stockStatusName != string.Empty) { stockStatus = db.StockStatuses.Where(s => s.Text.Equals(_stockStatusName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); if (stockStatus == null) { importDescription += "Không tìm thấy trạng thái kho; "; //stockStatus = new StockStatus(); //stockStatus.Text = _stockStatusName; //db.StockStatuses.Add(stockStatus); //db.SaveChanges(); } } if (error == string.Empty) { if (productItem.StockStatusId != stockStatus.Id) { StockDiary diary = new StockDiary() { Date = DateTime.Now, Note = "", Type = _stockStatusName, ProductItemId = productItem.Id }; db.StockDiaries.Add(diary); } if (employee != null && employee.Id > 0) { productItem.EmployeeId = employee.Id; productItem.StockStatusId = stockStatus.Id; } else { productItem.EmployeeId = null; productItem.StockStatusId = stockStatus.Id; } productItem.PONo = _POno; productItem.Description = _description; db.SaveChanges(); importDescription = "Thành công"; } } } catch (Exception ex) { importDescription += "Error: " + ex.Message + " Inner: " + ex.InnerException; } r[0] = shortCode; r[1] = _username; r[2] = _stockStatusName; r[3] = _POno; r[4] = _description; r[5] = importDescription; } FileExcel(dt, "ProductItem"); } } else { dt.Columns.Add("Import Status", typeof(string)); dt.Columns.Add("Import Detail", typeof(string)); //dt.Columns.Add("Description", typeof(string)); if (ds != null) { //foreach (DataTable dt2 in ds.Tables) //{ foreach (DataRow r in dt.Rows) { try { string _departmentName = string.Empty; string _categoryName = string.Empty; string _buildingName = string.Empty; string _sectionName = string.Empty; string _userCode = string.Empty, _userDisplayName = string.Empty;//, _userUserName = string.Empty _eCode = string.Empty; string _shortCode = string.Empty, _shortName = string.Empty, _productName = string.Empty, _serialNo = string.Empty; DateTime _buyDate = DateTime.MinValue; DateTime _expiryDate = DateTime.MinValue; string _stockStatusName;//, _productStatusName, _poNo = string.Empty, _cdROM = string.Empty, _remark = string.Empty; string _supplierName = string.Empty; var productItem = new ProductItem(); var category = new Category(); var product = new Product(); var dept = new Department(); var employee = new Employee(); var productStatus = new ProductStatus(); var building = new Building(); var stockStatus = new StockStatus(); var supplier = new Supplier(); string _POno = string.Empty; string _description = string.Empty; string importDescription = string.Empty; _shortCode = r[0].ToString(); _shortName = r[1].ToString(); //_buildingName = r[2].ToString(); _categoryName = r[3].ToString(); _productName = r[4].ToString(); _sectionName = r[5].ToString(); _buildingName = r[6].ToString(); _userCode = r[7].ToString(); _userDisplayName = r[8].ToString(); _departmentName = r[9].ToString(); _stockStatusName = r[10].ToString(); _serialNo = r[11].ToString(); _expiryDate = r[12] != null && r[12].ToString() != string.Empty? DateTime.Parse(r[12].ToString()) : DateTime.MinValue; _buyDate = r[13] != null && r[13].ToString() != string.Empty ? DateTime.Parse(r[13].ToString()) : DateTime.MinValue; _supplierName = r[14].ToString(); _POno = r[15].ToString(); _description = r[16].ToString(); #region check trùng dữ liệu //if (db.ProductItems.Where(p => p.ShortCode.Equals(_shortCode, StringComparison.OrdinalIgnoreCase)).FirstOrDefault() != null) //{ // importDescription = "ShortCode đã tồn tại"; //} //if (db.ProductItems.Where(p => p.Name.Equals(name, StringComparison.OrdinalIgnoreCase)).FirstOrDefault() != null) //{ // importDescription = "Name đã tồn tại"; //} //if (db.ProductItems.Where(p => p.SerialNo.Equals(serialNo, StringComparison.OrdinalIgnoreCase)).FirstOrDefault() != null) //{ // importDescription = "Số Serial No đã tồn tại"; //} #endregion if (importDescription == string.Empty) { #region kiểm tra và tạo dữ liệu từ điển if (_categoryName != string.Empty) { category = db.Categories.Where(c => c.Name.Equals(_categoryName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); if (category == null) { category = new Category(); category.Code = AutoNumberHelper.GenerateNumber(ObjectType.Category, db); category.Name = _categoryName; db.Categories.Add(category); db.SaveChanges(); } } if (_buildingName != string.Empty) { building = db.Buildings.Where(c => c.Name.Equals(_buildingName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); if (building == null) { building = new Building(); building.Code = AutoNumberHelper.GenerateNumber(ObjectType.Building, db); building.Name = _buildingName; db.Buildings.Add(building); db.SaveChanges(); } } product = db.Products.Where(p => p.Name.Equals(_productName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); if (product == null) { product = new Product(); product.Code = AutoNumberHelper.GenerateNumber(ObjectType.Product, db); product.Name = _productName; product.CategoryId = category.Id > 0 ? category.Id : (int?)null; db.Products.Add(product); db.SaveChanges(); } //if (_departmentName != string.Empty) //{ // dept = db.Departments.Where(d => d.Name.Equals(_departmentName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); // if (dept == null) // { // dept = new Department(); // dept.Name = _departmentName; // db.Departments.Add(dept); // db.SaveChanges(); // } //} if (_supplierName != string.Empty) { supplier = db.Suppliers.Where(d => d.Name.Equals(_supplierName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); if (supplier == null) { supplier = new Supplier(); supplier.Name = _supplierName; db.Suppliers.Add(supplier); db.SaveChanges(); } } if (_userDisplayName != string.Empty || _userCode != string.Empty) { //int empID = int.Parse(_eCode); employee = db.Employees.Where(e => (e.UserName.Equals(_userCode, StringComparison.OrdinalIgnoreCase) && _userCode != string.Empty)).FirstOrDefault(); if (employee == null) { importDescription += "Không tìm thấy nhân viên; "; } } //if (_productStatusName != string.Empty) //{ // productStatus = db.ProductStatuses.Where(s => s.Text.Equals(_productStatusName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); // if (productStatus == null) // { // productStatus = new ProductStatus(); // productStatus.Text = _productStatusName; // db.ProductStatuses.Add(productStatus); // db.SaveChanges(); // } //} if (_stockStatusName != string.Empty) { stockStatus = db.StockStatuses.Where(s => s.Text.Equals(_stockStatusName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); if (stockStatus == null) { importDescription += "Không tìm thấy trạng thái kho; "; //stockStatus = new StockStatus(); //stockStatus.Text = _stockStatusName; //db.StockStatuses.Add(stockStatus); //db.SaveChanges(); } } if (importDescription == string.Empty) { productItem = db.ProductItems.Where(p => p.ShortCode.Equals(_shortCode, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); if (productItem == null) { productItem = new ProductItem() { ShortCode = _shortCode, Name = _shortName, ProductId = product.Id, BuildingId = building != null && building.Id > 0 ? building.Id : (int?)null, SerialNo = _serialNo, PODate = _buyDate > DateTime.MinValue ? _buyDate : (DateTime?)null, ExpiryDate = _expiryDate > DateTime.MinValue ? _expiryDate : (DateTime?)null, ProductStatusId = productStatus != null && productStatus.Id > 0 ? productStatus.Id : (int?)null, StockStatusId = stockStatus != null && stockStatus.Id > 0 ? stockStatus.Id : (int?)null, //CDROM = _cdROM != string.Empty ? int.Parse(_cdROM) : (int?)null, EmployeeId = employee != null && employee.Id > 0 ? employee.Id : (int?)null, SupplierId = supplier != null && supplier.Id > 0 ? supplier.Id : (int?)null, PONo = _POno, Description = _description, CreatedOn = DateTime.Now }; db.ProductItems.Add(productItem); db.SaveChanges(); StockDiary diary = new StockDiary() { Date = DateTime.Now, Note = "", Type = _stockStatusName, ProductItemId = productItem.Id }; db.StockDiaries.Add(diary); db.SaveChanges(); importDescription += "Thêm mới"; } else { string oldEmployeeName = string.Empty; if (employee.Id != productItem.EmployeeId) { oldEmployeeName = (productItem.EmployeeId != null && productItem.EmployeeId > 0) ? db.Employees.Find(productItem.EmployeeId).Name : string.Empty; } string newEmployeeName = string.Empty; if (employee.Id != productItem.EmployeeId) { newEmployeeName = (employee.Id != null && employee.Id > 0) ? db.Employees.Find(employee.Id).Name : string.Empty; } if (productItem.StockStatusId != stockStatus.Id || productItem.EmployeeId != employee.Id) { StockDiary diary = new StockDiary() { Date = DateTime.Now, Note = string.Format("{0} => {1}", oldEmployeeName, newEmployeeName), Type = _stockStatusName, ProductItemId = productItem.Id }; db.StockDiaries.Add(diary); } productItem.ProductId = product.Id; productItem.Name = _shortName; productItem.BuildingId = building != null && building.Id > 0 ? building.Id : (int?)null; productItem.SerialNo = _serialNo; productItem.PODate = _buyDate > DateTime.MinValue ? _buyDate : (DateTime?)null; productItem.ProductStatusId = productStatus != null && productStatus.Id > 0 ? productStatus.Id : (int?)null; productItem.StockStatusId = stockStatus != null && stockStatus.Id > 0 ? stockStatus.Id : (int?)null; //productItem.CDROM = _cdROM != string.Empty ? int.Parse(_cdROM) : (int?)null; productItem.EmployeeId = employee != null && employee.Id > 0 ? employee.Id : (int?)null; productItem.SupplierId = supplier != null && supplier.Id > 0 ? supplier.Id : (int?)null; productItem.ExpiryDate = _expiryDate > DateTime.MinValue ? _expiryDate : (DateTime?)null; db.Entry(productItem).State = EntityState.Modified; productItem.PONo = _POno; productItem.Description = _description; db.SaveChanges(); importDescription += "Cập nhật"; } r[17] = "Thành công"; } else { r[17] = "Không thành công"; } #endregion } else { r[17] = "Không thành công"; } r[18] = importDescription; } catch (Exception ex) { r[17] = "Lỗi"; r[18] = string.Format("Message: {0} - Inner Exception: {1}", ex.Message, ex.InnerException); } } //} } //foreach (DataRow r in dt.Rows) //{ //} FileExcel(dt, "ProductItem"); } return(RedirectToAction("Index", "ProductItem")); }
public async Task CreateProduct(ProductItem item) { await _productRepository.CreateProduct(item); }
public ActionResult Confrim(Project pro) { if (ModelState.IsValid) { Order ord = unitOfWork.OrderRepository.GetByID(pro.id); pro.order = ord; pro.costs = ord.Total; IEnumerable <ApplicationUser> them = unitOfWork.UserRepository.Get().Where(s => s.RoleName.Equals(RolesConst.PROJECT_MANAGER)); foreach (ApplicationUser manager in them) { if (manager.UserName.Equals(pro.nameProjectManager)) { pro.projectManager = manager; } } pro.projectStatus = ProjectStatus.Initial; List <WorkItem> wkItems = new List <WorkItem>(); string listItems = ord.orderItemsIds; IDictionary <int, int> prItems = new Dictionary <int, int>(); string[] wkitem = listItems.Split(';'); foreach (string k in wkitem) { string[] u = k.Split(':'); if (u.Length > 1) { int key = int.Parse(u[0]); int value = int.Parse(u[1]); prItems.Add(key, value); } } foreach (KeyValuePair <int, int> kvp in prItems) { ProductItem pr = unitOfWork.ProductItemRepository.GetByID(kvp.Key); List <WorkItem> wk = Utilts.GenericTasks(pr.Categorie).ToList(); for (int i = 0; i < kvp.Value; i++) { wkItems.AddRange(wk); } } unitOfWork.ProjectRepository.Insert(pro); unitOfWork.Save(); foreach (WorkItem wk in wkItems) { wk.assignedProject = pro; wk.DueDate = DateTime.Now.AddMonths(1).Date; wk.DateCreated = DateTime.Now.Date; unitOfWork.WorkItemRepository.Insert(wk); unitOfWork.Save(); } pro.tasks = wkItems; unitOfWork.ProjectRepository.Update(pro); ord.orderStartus = OrderStatus.InProgress; unitOfWork.OrderRepository.Update(ord); Finance last = unitOfWork.FinancesRepository.Get().Last(); decimal cost = 0 - ord.Total * 0.05m; Finance fin = new Finance() { TransactionName = "salary", From = "company", To = "orderManager", itemDescription = "advance", Date = DateTime.Now, Cost = cost, Balance = last.Balance + cost }; unitOfWork.FinancesRepository.Insert(fin); unitOfWork.Save(); Finance last1 = unitOfWork.FinancesRepository.Get().Last(); Finance fin1 = new Finance() { TransactionName = "income", From = ord.customer.UserName, To = "company", itemDescription = "item_bought", Date = DateTime.Now, Cost = ord.Total, Balance = last1.Balance + ord.Total }; unitOfWork.FinancesRepository.Insert(fin1); unitOfWork.Save(); return(RedirectToAction("Index")); } return(View()); }
public async Task <ProductItem> UpdateProduct(ProductItem item) { return(await _productRepository.UpdateProduct(item)); }
public override IPaymentFactory AddItem(ProductItem item) { request.ITEMS.Add(item); return(this); }
private AddProduct(Guid cartId, ProductItem productItem) { CartId = cartId; ProductItem = productItem; }
/// <summary> /// The modify view /// </summary> /// <param name="id">The product id for modifing</param> /// <returns>修改产品的视图</returns> public ActionResult Modify(int id) { ProductItem CurrentProduct = ProductManager.GetProductByID(id); return(View(CurrentProduct)); }
/// <summary> /// Load comboboxes into form /// </summary> private void loadCmb() { cmbProductName.DataSource = ProductItem.GetProductItems(); loadIngredientCmbs(); cmbUnits.SelectedIndex = 0; }
[Authorize(Roles = "Admin,PowerUser")] public async Task <IActionResult> Edit(int id, [Bind("ProductItemId,Barcode,BrandId,StyleCode,ProductName,ItemDesc,Categorys,MRP,TaxRate,Cost,Size,Units")] ProductItem productItem) { if (id != productItem.ProductItemId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(productItem); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductItemExists(productItem.ProductItemId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["BrandId"] = new SelectList(_context.Brands, "BrandId", "BrandName", productItem.BrandId); return(PartialView(productItem)); }
/// <summary> /// Load form /// </summary> /// <param name="productItem"></param> public frmAddProductIngredients(ProductItem productItem) { this.productItem = productItem; InitializeComponent(); }
public async Task AddToCartAsync(ProductItem productItem, ComboMeal comboMeal, CustomizeProduct customizeProduct, int quantity, string shoppingCartId) { try { if (productItem != null) { var shoppingCartItem = await _context.ShoppingCartItems.SingleOrDefaultAsync( s => s.ShoppingCartId == shoppingCartId && s.ProductItemId == productItem.Id); if (shoppingCartItem == null) { shoppingCartItem = new ShoppingCartItem { ShoppingCartId = shoppingCartId, ProductItem = productItem, ComboMeal = null, CustomizeProduct = null, Quantity = quantity }; await _context.ShoppingCartItems.AddAsync(shoppingCartItem); } else { shoppingCartItem.Quantity = quantity; } } if (comboMeal != null) { var shoppingCartItem = await _context.ShoppingCartItems.SingleOrDefaultAsync( s => s.ShoppingCartId == shoppingCartId && s.ComboMealId == comboMeal.Id); if (shoppingCartItem == null) { shoppingCartItem = new ShoppingCartItem { ShoppingCartId = shoppingCartId, ProductItem = null, ComboMeal = comboMeal, CustomizeProduct = null, Quantity = quantity }; await _context.ShoppingCartItems.AddAsync(shoppingCartItem); } else { shoppingCartItem.Quantity = quantity; } } if (customizeProduct != null) { var shoppingCartItem = new ShoppingCartItem { ShoppingCartId = shoppingCartId, ProductItem = null, ComboMeal = null, CustomizeProduct = customizeProduct, Quantity = quantity }; await _context.ShoppingCartItems.AddAsync(shoppingCartItem); } await _context.SaveChangesAsync(); } catch (Exception ex) { throw ex; } }
/// <summary> /// Load form with default productItem and ingredient ID /// </summary> /// <param name="productItem"></param> /// <param name="ingredientID"></param> public frmAddProductIngredients(ProductItem productItem, long ingredientID) { this.productItem = productItem; this.ingredient = ingredientID; InitializeComponent(); }
public async Task DownProduct(ProductItem[] products) { foreach (var item in products) { await this.InvokeTask(client.ItemHub.ItemUpdateDelist, item.Id); item.AutoUpshelf = false; AppDatabase.db.ProductItems.Update(item); } }
/// <summary> /// Select default product and ingredient in form /// </summary> /// <param name="productItem"></param> /// <param name="ingredientID"></param> private void selectInForm(ProductItem productItem, long ingredientID) { selectProductInForm(productItem); selectIngredientInForm(ingredientID); }
private async Task<SimpleResult> SyncSupplierInfo(ProductItem product) { using (var helper = new WBHelper(true)) { var success = false; //查找供应商 var supplier = await this.InvokeTask(supplierInfo, helper, product.SpuId); if (supplier != null && supplier.profitData != null && supplier.profitData.Any()) { product.OnSupplierInfoUpdate(AppDatabase.db.ProductItems, supplier); success = true; } return new SimpleResult { Success = success, ProductId = product.Id }; } }
public ProductItem GetProductItem() { var item = new ProductItem(); item.Id = long.Parse(TrElement.Attribute("data-id").AttributeValue); item.SpuId = TrElement.Attribute("data-spuid").AttributeValue; item.ItemName = TrElement.FindFirst(".item-name a").InnerText(); var text = TrElement.FindFirst(".item-name").InnerText(); var index = TrElement.FindFirst(".item-name").InnerText().IndexOf("类型:"); item.ItemName = text.Substring(0, index).Trim(); item.ItemSubName = new string(text.Skip(index + 3).ToArray()).Trim(); item.Type = TrElement.FindFirst(".type").InnerText(); item.面值 = TrElement.FindFirst(".price").InnerText(); decimal price = 0; if (decimal.TryParse(TrElement.FindFirst(".buy-price em").InnerText().Trim(new char[] { ' ', '元' }), out price)) { item.进价 = price; } var onePriceElements = TrElement.Find(".one-price-text"); if (onePriceElements.Any()) { item.一口价 = decimal.Parse(TrElement.FindFirst(".one-price-text em").InnerText().Trim(new char[] { ' ', '元' })); } return item; }