public void deliverProduct(ISelectionButton button) { var index = this.selectionButtonToIndex[(SelectionButton)button]; this.productName = this.hf.ProductKinds[index]; this.hf.ProductRacks[index].DispenseProduct(); }
public void DispenseProduct(ProductKind product) { int idx; idx = Array.IndexOf(this.hardware.ProductKinds, product); //dispenseProduct() from ProductRack ProductRack rack = this.hardware.ProductRacks[idx]; rack.DispenseProduct(); }
public void SelectionMadeHandler(object sender, EventArgs e) { var index = this.selectionButtonToIndex[(SelectionButton)sender]; this.productName = this.hf.ProductKinds[index]; this.productCost = this.hf.ProductKinds[index].Cost; this.buttonPressed = (ISelectionButton)sender; this.SelectionMade(this, new EventArgs()); }
// GET: ProductKinds/Details/5 public ActionResult Details(int?id) { Sidebar(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProductKind productKind = db.ProductKinds.Find(id); if (productKind == null) { return(HttpNotFound()); } return(View(productKind)); }
// returns the full description of the ProductKind // note that the method is private public static string GetDescription(this ProductKind productKind) { switch (productKind) { case ProductKind.Grocery: return("Products you can buy in a grocery store"); case ProductKind.FinancialInstrument: return("Products you can buy on a stock exchange"); case ProductKind.Information: return("Products you can get on the Internet"); } return(null); }
// returns a displayable short name for the ProductKind public static string GetDisplayName(this ProductKind productKind) { switch (productKind) { case ProductKind.Grocery: return("Grocery"); case ProductKind.FinancialInstrument: return("Financial Instrument"); case ProductKind.Information: return("Information"); } return(null); }
public CustomJsonResult Edit(int operater, ProductKind productKind) { var _productKind = CurrentDb.ProductKind.Where(m => m.Id == productKind.Id).FirstOrDefault(); _productKind.Name = productKind.Name; _productKind.MainImg = productKind.MainImg; _productKind.IconImg = productKind.IconImg; _productKind.Status = productKind.Status; _productKind.Description = productKind.Description; _productKind.Mender = operater; _productKind.LastUpdateTime = DateTime.Now; CurrentDb.SaveChanges(); return(new CustomJsonResult(ResultType.Success, ResultCode.Success, "修改成功")); }
public ActionResult DeleteConfirmed(int id) { var temp = db.ProductKinds.FirstOrDefault(s => s.ID == id); //防止企业用户串号修改 if (AccontData.UserType == UserType.Enterprise && temp.EnterpriseID != AccontData.EnterpriseID) { return(this.ToError("错误", "没有该操作权限", Url.Action("Index"))); } ProductKind productKind = db.ProductKinds.Find(id); db.ProductKinds.Remove(productKind); db.SaveChanges(); return(RedirectToAction("Index")); }
public void ButtonPress(Object sender, EventArgs e) { int idx = 0; //find which button was pressed foreach (var button in hardwareFacade.SelectionButtons) { if (sender.Equals(button)) { idx = Array.IndexOf(this.hardwareFacade.SelectionButtons, button); } } //find the corresponding product ProductKind product = this.hardwareFacade.ProductKinds[idx]; this.SelectionPress(product, new EventArgs()); }
public ActionResult Create(ProductKind productKind) { var tempuser = db.Users.FirstOrDefault(s => s.Id == AccontData.UserID); //防止企业用户串号修改 if (AccontData.UserType == UserType.Enterprise && tempuser.EnterpriseID != AccontData.EnterpriseID) { return(this.ToError("错误", "没有该操作权限", Url.Action("Index"))); } Sidebar(); if (ModelState.IsValid) { productKind.EnterpriseID = AccontData.EnterpriseID; db.ProductKinds.Add(productKind); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(productKind)); }
public void Button(Object sender, EventArgs e) { int idx = 0; //var product = sender; foreach (var prod in this.productList) { if (sender.Equals(prod)) { idx = Array.IndexOf(this.productList, prod); } } ProductKind product = this.productList[idx]; if (product.Cost <= this.payments.credit) { //when the Buton is selected //call Product Facade to dispense the product products.DispenseProduct(product); payments.DispenseChange(product.Cost); } }
public void CreateNewProduct(ProductKind Kind) { if (Kind < 0) return; Project p; switch (Kind) { case ProductKind.Free: p = CreateProject(ProjectKind.Small, null); break; case ProductKind.Fashionable: case ProductKind.Classic: p = CreateProject(ProjectKind.Medium, null); break; case ProductKind.Large: p = CreateProject(ProjectKind.Large, null); break; default: throw new InvalidOperationException(); } p.TargetProductKind = Kind; Debug.WriteLine("Creating a new " + Kind.ToString() + " product!"); }
public ActionResult Edit(ProductKind productKind) { var temp = db.ProductKinds.FirstOrDefault(s => s.ID == productKind.ID); //防止企业用户串号修改 if (AccontData.UserType == UserType.Enterprise && temp.EnterpriseID != AccontData.EnterpriseID) { return(this.ToError("错误", "没有该操作权限", Url.Action("Index"))); } if (ModelState.IsValid) { //productKind.EnterpriseID = AccontData.EnterpriseID; //db.Entry(productKind).State = EntityState.Modified; temp.EnterpriseID = AccontData.EnterpriseID; temp.Name = productKind.Name; temp.Sort = productKind.Sort; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(productKind)); }
public CustomJsonResult Add(int operater, ProductKind productKind) { CustomJsonResult result = new CustomJsonResult(); if (productKind.PId == 0) { return(new CustomJsonResult(ResultType.Failure, ResultCode.Failure, "请选择上级分类")); } using (TransactionScope ts = new TransactionScope()) { var existObject = CurrentDb.ProductKind.Where(m => m.Name == productKind.Name).FirstOrDefault(); if (existObject != null) { return(new CustomJsonResult(ResultType.Failure, ResultCode.Failure, "名称已存在")); } existObject = CurrentDb.ProductKind.Where(m => m.PId == productKind.PId).OrderByDescending(m => m.Id).FirstOrDefault(); if (existObject == null)//同级没有分类 { productKind.Id = productKind.PId * 10000 + 1; } else//同级已存在分类则+1 { productKind.Id = existObject.Id + 1; } productKind.Creator = operater; productKind.CreateTime = DateTime.Now; CurrentDb.ProductKind.Add(productKind); CurrentDb.SaveChanges(); ts.Complete(); result = new CustomJsonResult(ResultType.Success, ResultCode.Success, "添加成功"); } return(result); }
public Product(decimal price, ProductKind productKind) { Price = price; ProductKind = productKind; }
public Product(double price, ProductKind kind) { Price = price; Kind = kind; }
// INTERNAL PROCESSING METHODS // This method retrieves info of the selection made private void selectButtonPressed(object sender, EventArgs e) { this.selectionButtonPressed = this.selectionButtonToIndex[(SelectionButton)sender]; this.product = this.hw.ProductKinds[this.selectionButtonPressed]; }
public ActionResult Kindadd(ProductKind p) { p.Deleted = false; db.ProductKind.Add(p); return(Json(db.SaveChanges())); }
public Addon(string ProductID, ProductKind ProductType, string DisplayName) { this.ProductID = ProductID; this.ProductType = ProductType; this.DisplayName = DisplayName; }
public ActionResult Kindedit(ProductKind p) { p.Deleted = false; db.Entry(p).State = System.Data.Entity.EntityState.Modified; return(Json(db.SaveChanges())); }