public void Setup() { _vendorCollection = new Collection <IVendorProduct <IItemInstance> >(10); _vendorCurrencies = new CurrencyCollection(); _gold = new Currency(Guid.NewGuid(), "Gold", "GOLD", 2, 999f); _silver = new Currency(Guid.NewGuid(), "Silver", "SILVER", 2, 999f); _vendor = new Vendor <IItemInstance>(new VendorConfig(), _vendorCollection, _vendorCurrencies); _customerCollection = new Collection <IItemInstance>(10); _customerCurrencies = new CurrencyCollection(); _customer = new Customer <IItemInstance>(Guid.NewGuid(), null, new CollectionGroup <IItemInstance>(new [] { new CollectionGroup <IItemInstance> .Slot(_customerCollection), }), new CurrencyCollectionGroup <ICurrency>(_customerCurrencies)); _item1 = new CollectionItemInstance(Guid.NewGuid(), new ItemDefinition(Guid.NewGuid()) { maxStackSize = 5, buyPrice = new [] { new CurrencyDecorator(_gold, 1d) }, sellPrice = new [] { new CurrencyDecorator(_gold, 0.6d) } }); _item2 = new CollectionItemInstance(Guid.NewGuid(), new ItemDefinition(Guid.NewGuid()) { maxStackSize = 5, buyPrice = new [] { new CurrencyDecorator(_gold, 2d) }, sellPrice = new [] { new CurrencyDecorator(_gold, 1.6d) } }); _product1 = ToProduct(_item1); _product1_1 = ToProduct(_item1); _product2 = ToProduct(_item2); }
//Sửa thông tin sản phẩm public void Edit_Poduct(ListViewItem lvi_products, ListView.ListViewItemCollection list_Vendors) { Product product = data_SP.Products.First(x => x.ProductID == Convert.ToInt32(lvi_products.SubItems[0].Text)); ProductCategory catagory_Product = new ProductCategory(); product.ProductName = lvi_products.SubItems[1].Text; product.ProductType = lvi_products.SubItems[2].Text == "Được bán" ? true : false; product.ProductCategoryID = data_SP.ProductCategories.First(x => x.ProductCategoryName == lvi_products.SubItems[3].Text).ProductCategoryID; product.Manufacture = lvi_products.SubItems[4].Text; data_SP.SubmitChanges(); foreach (ListViewItem i in list_Vendors) { VendorProduct vendor_Product = new VendorProduct(); int vendor_id = data_SP.Vendors.First(x => x.VendorName == i.Text).VendorID; if (data_SP.VendorProducts.FirstOrDefault(x => x.VendorID == vendor_id && x.ProductID == product.ProductID) == null) { vendor_Product.ProductID = product.ProductID; vendor_Product.VendorID = data_SP.Vendors.First(x => x.VendorName == i.Text).VendorID; data_SP.VendorProducts.InsertOnSubmit(vendor_Product); data_SP.SubmitChanges(); } } }
public ActionResult save(VendorProduct vendor, int id) { Product product = db.Products.FirstOrDefault(p => p.ID == id); VendorProduct vendorproduct = new VendorProduct(); bool claimIdentity = User.Identity is ClaimsIdentity; Vendor user = new Vendor(); List <OrderDetails> orders = new List <OrderDetails>(); if (claimIdentity) { ClaimsIdentity claimsIdentity = User.Identity as ClaimsIdentity; var userIdClaim = claimsIdentity.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier); if (userIdClaim != null) { var userIdValue = userIdClaim.Value; user = db.Vendors.Where(i => i.ID == userIdValue).FirstOrDefault(); } } vendorproduct.Product = product; vendorproduct.Price = vendor.Price; vendorproduct.Sale_price = vendor.Sale_price; vendorproduct.Quantity = vendor.Quantity; vendorproduct.Vendor = user; db.VendorProducts.Add(vendorproduct); db.SaveChanges(); return(RedirectToAction("index")); }
private void ShowTotalCost() { decimal totalCost = 0m; decimal totalRetail = 0m; foreach (JoinPlToVpToProd join in mHelper.DataSource) { totalCost += join.ExtendedCost; decimal retailPrice = join.PurLine_RetailPrice; if (join.PurLine_RetailPriceOverride > 0) { retailPrice = join.PurLine_RetailPriceOverride; } int eachQuantity = join.PurLine_QtyOrdered; if (!join.PurLine_OrderedEaches) { eachQuantity *= join.PurLine_CountInCase; } totalRetail += (eachQuantity * retailPrice); } mOrder.UnpersistedTotal = totalCost + mOrder.Freight; double freightPercent = 0.0; if (totalCost > 0m) { freightPercent = (double)(mOrder.Freight / totalCost); } lblTotalCost.Text = "Total Cost With Freight: " + mOrder.UnpersistedTotal.ToString("c") + " Total Retail: " + totalRetail.ToString("c") + " Margin: " + VendorProduct.ComputeMargin(totalRetail, totalCost, freightPercent ).ToString(VendorProduct.MarginFormat); }
public IQueryable <VendorProduct> GetVendorProducts(long vendorId, DateTime resultDate) { var products = new List <VendorProduct>(); var parameters = new Dictionary <string, object> { { "@VendorId", vendorId }, { "@ResultDate", resultDate.Date } }; var reader = MySqlHelper.ExecuteReader(_vendorConn, CommandType.Text, @"SELECT Id,VendorId,SKU,Name,Description,ShortDescription,Category,UPCCode,Quantity,Cost,ResultDate FROM vendorproducts WHERE VendorId=@VendorId and ResultDate=@ResultDate", parameters); while (reader.Read()) { var product = new VendorProduct(); product.Id = (long)reader[0]; product.VendorId = (int)reader[1]; product.SKU = reader[2].ToString(); product.Name = reader[3].ToString(); product.Description = reader[4].ToString(); product.ShortDescription = reader[5].ToString(); product.Category = reader[6].ToString(); product.UPCCode = reader[7].ToString(); product.Quantity = (int)reader[8]; product.Cost = (decimal)reader[9]; product.ResultDate = reader[10] == DBNull.Value ? default(DateTime) : (DateTime)reader[10]; products.Add(product); } return(products.AsQueryable()); }
private void addButt_Click(object sender, EventArgs e) { #region orders&items if (tabPaneMain.SelectedPage == tabOrders) { using (frmMakeOrder f = new frmMakeOrder()) { Order o = new Order(); if (f.ShowDialog(o, EditClient, EditProduct, EditVendor, IsValidOrder) == DialogResult.OK) { IsValidOrder(o, (v, q) => v.Quantity -= q); cContext.Orders.Add(o); } } return; } #endregion #region vendors&vendorsproducts if (tabPaneMain.SelectedPage == tabVendors) { if ((ucVendors as ucVendors).IsDetailsFocused()) { VendorProduct i = new VendorProduct(); Vendor v = (ucVendors as ucVendors).GetFocusedRow(); //.VendorsProducts.Add(i); if (v != null) { i.Vendor = v; v.VendorsProducts.Add(i); } //cContext.VendorsProducts.Add(i); } else { Vendor i = new Vendor(); cContext.Vendors.Add(i); } return; } #endregion #region products if (tabPaneMain.SelectedPage == tabProducts) { Product i = new Product(); cContext.Products.Add(i); return; } #endregion #region clients if (tabPaneMain.SelectedPage == tabClients) { Client i = new Client(); cContext.Clients.Add(i); return; } #endregion }
private void PopulateViewBagWithVendorIDandProductIDSelectLists(VendorProduct vendorproduct) { // vendors IList <Vendor> vendors = db.Vendors.ToList(); IEnumerable <SelectListItem> selectList_Vendors = from v in vendors select new SelectListItem { Selected = (v.ID == vendorproduct.VendorID), Text = v.Name, Value = v.ID.ToString() }; ViewBag.VendorID = selectList_Vendors; // products IList <Product> products = db.Products.ToList(); IEnumerable <SelectListItem> selectList_Products = from p in products select new SelectListItem { Selected = (p.ID == vendorproduct.ProductID), Text = p.Name, Value = p.ID.ToString() }; ViewBag.ProductID = selectList_Products; }
public ActionResult addProduct(ProductCategoryModelVM ProductCatModelVM) { // TODO: Add insert logic here if (ModelState.IsValid == true) { var cat = db.Categories.Where(c => c.ID == ProductCatModelVM.CategoryId).FirstOrDefault(); var mod = db.Models.Where(m => m.ID == ProductCatModelVM.ModelId).FirstOrDefault(); var product = new Product() { Name = ProductCatModelVM.Name, Category = cat, Model = mod, Image = ProductCatModelVM.Image, MinDescription = ProductCatModelVM.MinDescription, State = ProductCatModelVM.State, }; db.Products.Add(product); VendorProduct vp = new VendorProduct(); vp.Price = ProductCatModelVM.Price; vp.Sale_price = ProductCatModelVM.Sale_price; vp.Quantity = ProductCatModelVM.Quantity; vp.Product = product; string vid = User.Identity.GetUserId(); Vendor v = db.Vendors.Where(i => i.ID == vid).FirstOrDefault(); vp.Vendor = v; db.VendorProducts.Add(vp); db.SaveChanges(); return(RedirectToAction("GetProducts")); } else { return(View("_addProduct", ProductCatModelVM)); } }
public ActionResult Addprice(int id) { var vprice = db.Products.FirstOrDefault(v => v.ID == id); VendorProduct vendorproduct = new VendorProduct(); vendorproduct.Product = vprice; return(View(vendorproduct)); }
public ActionResult DeleteConfirmed(int id) { VendorProduct vendorProduct = db.VendorProducts.Find(id); db.VendorProducts.Remove(vendorProduct); db.SaveChanges(); return(RedirectToAction("Index")); }
private void PopulateViewBagWithVendorIDandProductIDSelectLists(VendorProductCreateViewModel vendorProductCreateViewModel) { VendorProduct vendorProduct = new VendorProduct { VendorID = vendorProductCreateViewModel.VendorID, ProductID = vendorProductCreateViewModel.ProductID }; PopulateViewBagWithVendorIDandProductIDSelectLists(vendorProduct); }
// // GET: /VendorProduct/Details/5 public ActionResult Details(int id = 0) { VendorProduct vendorproduct = db.VendorProducts.Find(id); if (vendorproduct == null) { return(HttpNotFound()); } return(View(vendorproduct)); }
private void bindingSource_AddingNew(object sender, AddingNewEventArgs e) { if (mExistingProduct != null) { VendorProduct venProd = new VendorProduct(); venProd.IsDirty = true; JoinVpToProd newJoin = new JoinVpToProd(venProd, mExistingProduct); e.NewObject = newJoin; } }
//public ActionResult GetAllProducts() //{ // List<Product> ProductList = db.Products.ToList(); // return PartialView("_AllProductsPartialView", ProductList); //} public ActionResult ShowProductDetails(int id) { VendorProduct p = db.VendorProducts.Where(i => i.ID == id).FirstOrDefault(); db.Entry(p).Reference(b => b.Product).Load(); db.Entry(p).Reference(v => v.Vendor).Load(); db.Entry(p.Product).Reference(m => m.Model).Load(); db.Entry(p.Product.Model).Reference(b => b.Brand).Load(); return(View("_ProductDetailsView", p)); }
public void VendorProductEqualityTest2() { var clone = new VendorProduct <IItemInstance>(_item1, new [] { new CurrencyDecorator(_gold, 1d), }, new [] { new CurrencyDecorator(_gold, 0.6d), }); var clone2 = new VendorProduct <IItemInstance>(_item1, _product1.buyPrice, _product1.sellPrice); Assert.AreEqual(_product1, clone); Assert.AreEqual(_product1_1, clone); Assert.AreEqual(_product1, clone2); Assert.AreEqual(_product1_1, clone2); }
public ActionResult Edit([Bind(Include = "ID,Name,VendorID")] VendorProduct vendorProduct) { if (ModelState.IsValid) { db.Entry(vendorProduct).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.VendorID = new SelectList(db.Vendors, "ID", "Name", vendorProduct.VendorID); return(View(vendorProduct)); }
public void VendorProductEqualityNegativeTest() { var clone = new VendorProduct <IItemInstance>(_item1, new [] { new CurrencyDecorator(_gold, 1.1d), }, new [] { new CurrencyDecorator(_gold, 0.6d), }); var clone2 = new VendorProduct <IItemInstance>(_item1, new [] { new CurrencyDecorator(_gold, 1d), }, new [] { new CurrencyDecorator(_gold, 0.65d), }); Assert.AreNotEqual(_product1, clone); Assert.AreNotEqual(_product1_1, clone); Assert.AreNotEqual(_product1, clone2); Assert.AreNotEqual(_product1_1, clone2); }
public ActionResult Create([Bind(Include = "ID,Name,VendorID")] VendorProduct vendorProduct) { if (ModelState.IsValid) { db.VendorProducts.Add(vendorProduct); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.VendorID = new SelectList(db.Vendors, "ID", "Name", vendorProduct.VendorID); return(View(vendorProduct)); }
// GET: Purchases/Create public ActionResult Create() { ViewBag.VendorProductID = new SelectList(db.VendorProducts, "ID", "Name"); ViewBag.VendorID = new SelectList(db.Vendors, "ID", "Name"); VendorProduct vendorproduct = new VendorProduct(); // ViewBag.Quantity = vendorproduct.Quantity; return(View()); }
// GET: VendorProducts/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } VendorProduct vendorProduct = db.VendorProducts.Find(id); if (vendorProduct == null) { return(HttpNotFound()); } return(View(vendorProduct)); }
// // GET: /VendorProduct/Edit/5 public ActionResult Edit(int id = 0) { VendorProduct vendorproduct = db.VendorProducts.Find(id); if (vendorproduct == null) { return(HttpNotFound()); } PopulateViewBagWithVendorIDandProductIDSelectLists(vendorproduct); // return view return(View(vendorproduct)); }
//Đẩy sp vào list view public bool Check_current_Ncc(string Ncc_selected, int id_sp) { int vendor_id = data_ncc.Vendors.Single(x => x.VendorName == Ncc_selected).VendorID; VendorProduct check = data_ncc.VendorProducts.SingleOrDefault(x => x.VendorID == vendor_id && x.ProductID == id_sp); if (check == null) { return(false); } else { return(true); } }
// GET: VendorProducts/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } VendorProduct vendorProduct = db.VendorProducts.Find(id); if (vendorProduct == null) { return(HttpNotFound()); } ViewBag.VendorID = new SelectList(db.Vendors, "ID", "Name", vendorProduct.VendorID); return(View(vendorProduct)); }
public ActionResult Edit(VendorProduct vendorproduct) { if (ModelState.IsValid) { db.Entry(vendorproduct).State = EntityState.Modified; // {"Violation of UNIQUE KEY constraint 'UQ_VendorProducts_VendorID_ProductID'. // Cannot insert duplicate key in object 'dbo.VendorProducts'. // The duplicate key value is (2, 2).\r\nThe statement has been terminated."} db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.VendorID = new SelectList(db.Vendors, "ID", "Name", vendorproduct.VendorID); ViewBag.ProductID = new SelectList(db.Products, "ID", "Name", vendorproduct.ProductID); return(View(vendorproduct)); }
public void Cmd_RequestSellItemToVendor(byte[] vendorGuidBytes, Guid vendorGuid, byte[] itemGuidBytes, Guid itemGuid, ushort amount) { logger.LogVerbose($"[Server] Client requested to sell item {itemGuid} {amount}x to vendor {vendorGuid} with ViewID {bridge.photonView.ViewID}", bridge); INetworkItemInstance item; INetworkVendor <IItemInstance> vendor; var error = inputValidator.ValidateSellItemToVendor(bridge.photonView, vendorGuidBytes, vendorGuid, itemGuidBytes, itemGuid, amount, out vendor, out item).error; if (error == null) { var product = new VendorProduct <IItemInstance>(item, item.itemDefinition.buyPrice, item.itemDefinition.sellPrice); error = vendor.Server_SellToVendor(new Customer <IItemInstance>(Guid.NewGuid(), bridge.player, bridge.inventoryPlayer.itemCollectionGroup, bridge.inventoryPlayer.currencyCollectionGroup), product, amount).error; } HandleError(error); }
public async Task <IActionResult> GetVendorProductByVendorId(int VendorId) { VendorProduct Items = new VendorProduct(); try { Items = await _context.VendorProduct.Where(q => q.VendorId == VendorId).FirstOrDefaultAsync(); } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); return(BadRequest($"Ocurrio un error:{ex.Message}")); } return(await Task.Run(() => Ok(Items))); }
public JsonResult _CreateEisSKUAndUpdateLinks(string eisSupplierSKU) { var product = _vendorProductService.GetVendorProduct(eisSupplierSKU); if (product == null) { return(Json(new { Error = "Unable to find vendor product." }, JsonRequestBehavior.AllowGet)); } var vendorProduct = new VendorProduct(); CopyObject.CopyFields(product, vendorProduct); _vendorProductService.AddLinkAndCreateEisProductIfNoMatchWithUPC(vendorProduct); return(Json(new { Success = "Vendor product links have been successfully updated." }, JsonRequestBehavior.AllowGet)); }
public void Cmd_RequestSellItemToVendor(RequestSellItemToVendorMessage data) { logger.LogVerbose($"[Server] Client requested to sell item {data.itemGuid} {data.amount}x to vendor {data.vendorGuid} with netID {bridge.netId}", bridge); INetworkItemInstance item; INetworkVendor <IItemInstance> vendor; var error = inputValidator.ValidateSellItemToVendor(bridge.identity, data, out vendor, out item).error; if (error == null) { var product = new VendorProduct <IItemInstance>(item, item.itemDefinition.buyPrice, item.itemDefinition.sellPrice); error = vendor.Server_SellToVendor(new Customer <IItemInstance>(Guid.NewGuid(), bridge.player, bridge.inventoryPlayer.itemCollectionGroup, bridge.inventoryPlayer.currencyCollectionGroup), product, data.amount).error; } HandleError(error); }
public override void OnEnter() { var vendorWrapper = (ItemVendorWrapper)vendor.Value; var customerWrapper = (ItemVendorCustomerWrapper)customer.Value; var item = ((ItemInstanceWrapper)itemInstance.Value).item; var product = new VendorProduct <IItemInstance>(item, item.itemDefinition.buyPrice, item.itemDefinition.sellPrice); var sold = vendorWrapper.vendor.SellToVendor(customerWrapper.customer, product, amount.Value); if (sold.error != null) { LogWarning(sold.error.ToString()); } Finish(); }
public string GetVendorProductSKU(VendorProduct product) { if (!string.IsNullOrEmpty(product.EisSupplierSKU)) { return(product.EisSupplierSKU); } // NEED TO CREATE NEW DB CONTEXT SINCE THIS METHOD IS SHARED TO CONSOLE SERVICES // get the EisSupplierSKU by its supplier SKU and vendorId using (var context = new EisInventoryContext()) { var result = context.vendorproducts .FirstOrDefault(x => x.SupplierSKU == product.SupplierSKU && x.VendorId == product.VendorId); return(result == null ? null : result.EisSupplierSKU); } }