示例#1
0
        public ActionResult UploadProducts(int id, HttpPostedFileBase[] files)
        {
            byte max     = 0;
            var  listImg = db.ImgProducts.Where(p => p.ProductsId == id).ToList();

            if (listImg.Count > 0)
            {
                max = listImg.Max(p => p.SortImg);
            }
            var listFile = files.Where(p => p != null);

            foreach (var f in listFile)
            {
                //Tạo một đối tượ
                var img = new ImgProduct();
                img.ProductsId  = id;
                img.ImgProducts = f.FileName;
                img.SortImg     = ++max;
                db.ImgProducts.Add(img);
                var path = Server.MapPath("~/ImgUI/Products/" + f.FileName);
                f.SaveAs(path);
            }
            if (listFile.Any())
            {
                db.SaveChanges();
            }
            return(RedirectToAction("UploadProducts"));
        }
        void ReleaseDesignerOutlets()
        {
            if (ImgProduct != null)
            {
                ImgProduct.Dispose();
                ImgProduct = null;
            }

            if (LblAmount != null)
            {
                LblAmount.Dispose();
                LblAmount = null;
            }

            if (LblDiscount != null)
            {
                LblDiscount.Dispose();
                LblDiscount = null;
            }

            if (LblProductName != null)
            {
                LblProductName.Dispose();
                LblProductName = null;
            }

            if (LblProductPrice != null)
            {
                LblProductPrice.Dispose();
                LblProductPrice = null;
            }

            if (VwDiscount != null)
            {
                VwDiscount.Dispose();
                VwDiscount = null;
            }
        }
        void ReleaseDesignerOutlets()
        {
            if (BtnAdd != null)
            {
                BtnAdd.Dispose();
                BtnAdd = null;
            }

            if (BtnFavorite != null)
            {
                BtnFavorite.Dispose();
                BtnFavorite = null;
            }

            if (BtnRemove != null)
            {
                BtnRemove.Dispose();
                BtnRemove = null;
            }

            if (ImgProduct != null)
            {
                ImgProduct.Dispose();
                ImgProduct = null;
            }

            if (LblAmount != null)
            {
                LblAmount.Dispose();
                LblAmount = null;
            }

            if (LblDiscount != null)
            {
                LblDiscount.Dispose();
                LblDiscount = null;
            }

            if (LblProductName != null)
            {
                LblProductName.Dispose();
                LblProductName = null;
            }

            if (LblProductPrice != null)
            {
                LblProductPrice.Dispose();
                LblProductPrice = null;
            }

            if (LblSale != null)
            {
                LblSale.Dispose();
                LblSale = null;
            }

            if (VwDiscount != null)
            {
                VwDiscount.Dispose();
                VwDiscount = null;
            }
        }
示例#4
0
        private async void SubmitProductAsync(string obj)
        {
            try
            {
                var newpro = new Product()
                {
                    Name        = ProductName,
                    Description = Description,
                    UnitPrice   = Convert.ToDecimal(Price),
                    UnitOnOrder = Convert.ToDecimal(PriceSales),
                };

                if (ImgProduct != null)
                {
                    newpro.Picture = ImgProduct.ConvertToByte();
                }

                if (SelectedCate != null)
                {
                    newpro.CategoryID = SelectedCate.CatelogyID;
                }


                if (string.IsNullOrEmpty(obj))
                {
                    //Create new category
                    var objresult = await product_Repo.Add(newpro);

                    if (objresult != null)
                    {
                        dc = new DialogContent()
                        {
                            Content = "Thêm Thành Công", Tilte = "Thông Báo"
                        };
                        dialog = new DialogOk()
                        {
                            DataContext = dc
                        };
                        DialogHost.CloseDialogCommand.Execute(null, null);
                        await DialogHost.Show(dialog, DialogHostId);

                        ListProducts = new ObservableCollection <ProductModel>(product_Repo.GetAllProductModels());
                    }
                    else
                    {
                        dc = new DialogContent()
                        {
                            Content = "Thêm Thất Bại", Tilte = "Thông Báo"
                        };
                        dialog = new DialogOk()
                        {
                            DataContext = dc
                        };
                        DialogHost.CloseDialogCommand.Execute(null, null);
                        await DialogHost.Show(dialog, DialogHostId);
                    }
                }
                else
                {
                    //update category

                    newpro.ProductID = Convert.ToInt32(ProductID);

                    if (await product_Repo.Update(newpro))
                    {
                        dc = new DialogContent()
                        {
                            Content = "Cập Nhật Thành Công", Tilte = "Thông Báo"
                        };
                        dialog = new DialogOk()
                        {
                            DataContext = dc
                        };
                        DialogHost.CloseDialogCommand.Execute(null, null);
                        await DialogHost.Show(dialog, DialogHostId);

                        ListProducts = new ObservableCollection <ProductModel>(product_Repo.GetAllProductModels());
                    }
                    else
                    {
                        dc = new DialogContent()
                        {
                            Content = "Cập Nhật Thất Bại", Tilte = "Thông Báo"
                        };
                        dialog = new DialogOk()
                        {
                            DataContext = dc
                        };
                        DialogHost.CloseDialogCommand.Execute(null, null);
                        await DialogHost.Show(dialog, DialogHostId);
                    }
                }
            }
            catch
            {
                dc.Content = "Có Lỗi";
                dc.Tilte   = "Thông Báo";
                dialog     = new DialogOk()
                {
                    DataContext = dc
                };
                DialogHost.CloseDialogCommand.Execute(null, null);
                await DialogHost.Show(dialog, DialogHostId);
            }
        }
示例#5
0
        public void Awake()
        {
            TxtBtnBuyNum.text = ProductGemModel.ProductPrice.ToString();
            ImgProduct.sprite = Resources.Load <Sprite>(ProductGemModel.ProductSprite);
            switch (ProductGemModel.ProductID)
            {
            case 1:
                ImgProduct.LocalScale(0.5f, 0.5f, 0.5f);
                break;

            case 2:
                ImgProduct.LocalScale(0.5f, 0.5f, 0.5f);
                break;

            case 3:
                ImgProduct.LocalScale(0.8f, 0.8f, 0.8f);
                break;

            default:
                ImgProduct.LocalScale(Vector3.one);
                break;
            }

            TxtProductNum.text = ProductGemModel.ProductNum.ToString();
            if (ProductGemModel.ProductBouns > 0)
            {
                TxtBonus.Show();
                TxtBonus.text = "Bonus +" + ProductGemModel.ProductBouns.ToString() + "%";
            }
            else
            {
                TxtBonus.Hide();
            }
            if (ProductGemModel.ProductPurpleSprite.Length > 0)
            {
                ImgShopLabelPurple.Show();
                TxtShopPurple.Show();
                ImgShopLabelPurple.sprite = Resources.Load <Sprite>(ProductGemModel.ProductPurpleSprite);
                TxtShopPurple.text        = ProductGemModel.ProductPurpleDesc;
            }
            else
            {
                ImgShopLabelPurple.Hide();
                TxtShopPurple.Hide();
            }

            BtnBuy.OnClickAsObservable().Subscribe(_ =>
            {
                // 打开购买界面

                // 增加钻石
                GameData.GemCount = GameData.GemCount + ProductGemModel.ProductNum;

                // 更新UI
                UIMgr.GetPanel <UIShopGemPanel>().UpdateTopStautsValue();

                // 跳转到成功界面
                UIMgr.OpenPanel <UIDataUpdateSucceedPanel>(new UIDataUpdateSucceedPanelData
                {
                    SuccessModel = new DataUpdateSuccessModel
                    {
                        StrTitle  = "购买成功",
                        StrDesc   = "成功购买 " + ProductGemModel.ProductNum + " 颗钻石!",
                        IsSucceed = true
                    }
                });
            });
        }
示例#6
0
        private void Awake()
        {
            TxtBtnBuyNum.text = ProductGoldModel.ProductGoldPrice.ToString();
            ImgProduct.sprite = Resources.Load <Sprite>(ProductGoldModel.ProductGoldSprite);
            switch (ProductGoldModel.ProductGoldID)
            {
            case 1:
                ImgProduct.LocalScale(0.5f, 0.5f, 0.5f);
                break;

            case 2:
                ImgProduct.LocalScale(0.5f, 0.5f, 0.5f);
                break;

            case 3:
                ImgProduct.LocalScale(0.8f, 0.8f, 0.8f);
                break;

            default:
                ImgProduct.LocalScale(Vector3.one);
                break;
            }

            TxtProductNum.text = ProductGoldModel.ProductGoldNum.ToString();
            if (ProductGoldModel.ProductGoldBouns > 0)
            {
                TxtBonus.Show();
                TxtBonus.text = "Bonus +" + ProductGoldModel.ProductGoldBouns.ToString() + "%";
            }
            else
            {
                TxtBonus.Hide();
            }
            if (ProductGoldModel.ProductGoldPurpleSprite.Length > 0)
            {
                ImgShopLabel.Show();
                TxtShopLabel.Show();
                ImgShopLabel.sprite = Resources.Load <Sprite>(ProductGoldModel.ProductGoldPurpleSprite);
                TxtShopLabel.text   = ProductGoldModel.ProductGoldPurpleDesc;
            }
            else
            {
                ImgShopLabel.Hide();
                TxtShopLabel.Hide();
            }

            BtnBuy.OnClickAsObservable().Subscribe(_ =>
            {
                if (GameData.GemCount >= ProductGoldModel.ProductGoldPrice)
                {
                    // 减少钻石
                    GameData.GemCount = GameData.GemCount - ProductGoldModel.ProductGoldPrice;
                    // 增加金币
                    GameData.GoldCount = GameData.GoldCount + ProductGoldModel.ProductGoldNum;
                    // 更新UI
                    UIMgr.GetPanel <UIShopGoldPanel>().UpdateTopStautsValue();
                    // 跳转到成功界面
                    UIMgr.OpenPanel <UIDataUpdateSucceedPanel>(new UIDataUpdateSucceedPanelData
                    {
                        SuccessModel = new DataUpdateSuccessModel
                        {
                            StrTitle  = "购买成功",
                            StrDesc   = "成功购买 " + ProductGoldModel.ProductGoldNum + "\n 枚金币!",
                            IsSucceed = true
                        }
                    });
                }
                else
                {
                    // 跳转到钻石不足界面
                    UIMgr.OpenPanel <UIDataUpdateSucceedPanel>(new UIDataUpdateSucceedPanelData
                    {
                        SuccessModel = new DataUpdateSuccessModel
                        {
                            StrTitle  = "购买失败",
                            StrDesc   = "钻石不足,请先购买钻石哦~",
                            IsSucceed = true
                        }
                    });
                }
            });
        }