コード例 #1
0
    public void deliverProduct(ISelectionButton button)
    {
        var index = this.selectionButtonToIndex[(SelectionButton)button];

        this.productName = this.hf.ProductKinds[index];
        this.hf.ProductRacks[index].DispenseProduct();
    }
コード例 #2
0
        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();
        }
コード例 #3
0
    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());
    }
コード例 #4
0
        // 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));
        }
コード例 #5
0
        // 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);
        }
コード例 #6
0
        // 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);
        }
コード例 #7
0
        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, "修改成功"));
        }
コード例 #8
0
        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"));
        }
コード例 #9
0
        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());
        }
コード例 #10
0
        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));
        }
コード例 #11
0
        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);
            }
        }
コード例 #12
0
ファイル: Company.cs プロジェクト: zhf/EarningsPattern
 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!");
 }
コード例 #13
0
        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));
        }
コード例 #14
0
        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);
        }
コード例 #15
0
ファイル: Product.cs プロジェクト: Suki214/LearnOOP
 public Product(decimal price, ProductKind productKind)
 {
     Price       = price;
     ProductKind = productKind;
 }
コード例 #16
0
ファイル: Product.cs プロジェクト: Suki214/LearnOOP
 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];
    }
コード例 #18
0
 public ActionResult Kindadd(ProductKind p)
 {
     p.Deleted = false;
     db.ProductKind.Add(p);
     return(Json(db.SaveChanges()));
 }
コード例 #19
0
 public Addon(string ProductID, ProductKind ProductType, string DisplayName)
 {
     this.ProductID   = ProductID;
     this.ProductType = ProductType;
     this.DisplayName = DisplayName;
 }
コード例 #20
0
 public ActionResult Kindedit(ProductKind p)
 {
     p.Deleted         = false;
     db.Entry(p).State = System.Data.Entity.EntityState.Modified;
     return(Json(db.SaveChanges()));
 }