Example #1
0
        //取出飲料細節編輯的視圖
        public static BuyDMDrinkView GetDrinkDetail_EditDrink(int DetailID)
        {
            NewDrinkDB db          = new NewDrinkDB();
            var        DrinkDetail = db.CreateBuyOrder_Details.Find(DetailID);
            var        DrinkN      = db.MenuDrinks.Find(DrinkDetail.DrinkID);
            var        SizeNT      = db.SizeTables.Find(DrinkDetail.SizePID);
            var        SizeN       = db.SizeTypes.Find(SizeNT.SizeID);
            var        mySize      = DrinkSize(DrinkDetail.MenuID, DrinkDetail.DrinkID);

            foreach (var item in mySize)
            {
                if (item.Text == SizeN.SizeName && item.Value == DrinkDetail.SizePID.ToString())
                {
                    item.Selected = true;
                }
            }

            var result = new BuyDMDrinkView()
            {
                MenuID    = DrinkDetail.MenuID,
                DrinkID   = DrinkDetail.DrinkID,
                DrinkName = DrinkN.DrinkName,
                Bathus    = DrinkN.Bathus,
                SizeType  = mySize,
                SizeTypeM = DrinkDetail.SizePID.ToString(),
                Quantity  = DrinkDetail.Quantity
            };

            db.Dispose();
            return(result);
        }
Example #2
0
        //取出訂單甜度.冰度
        public static int GetSweetIceInt(BuyDMDrinkView Buy, string type)
        {
            int ID = 0;

            switch (type)
            {
            case "sweet":
                foreach (var item in Buy.SweetTypeM)
                {
                    ID = Int32.Parse(item.SweetTypeM);
                }
                break;

            case "ice":
                foreach (var item in Buy.IceTypeM)
                {
                    ID = Int32.Parse(item.IceTypeM);
                }
                break;

            default:
                break;
            }
            return(ID);
        }
Example #3
0
        //依照給的model取出1-3的配料
        public static int GetOnlyAdditemInt(BuyDMDrinkView Buy, int num)
        {
            var Tot = GetAddItemInt(Buy);
            int ID  = 0;

            switch (num)
            {
            case 1:
                for (int i = 0; i < Tot.Count; i++)
                {
                    if (i == 0)
                    {
                        ID = Tot[i];
                        break;
                    }
                }
                break;

            case 2:
                for (int i = 0; i < Tot.Count; i++)
                {
                    if (i == 1)
                    {
                        ID = Tot[i];
                        break;
                    }
                }
                break;

            case 3:
                for (int i = 0; i < Tot.Count; i++)
                {
                    if (i == 2)
                    {
                        ID = Tot[i];
                        break;
                    }
                }
                break;

            default:
                break;
            }
            return(ID);
        }
Example #4
0
        //取出購買飲料細項ViewModel
        public static BuyDMDrinkView GetBuyDMDrinkView_MenuIDdrinkID(int MenuID, int DrinkID)
        {
            NewDrinkDB db        = new NewDrinkDB();
            var        DrinkName = db.MenuDrinks.Find(DrinkID);

            var mySize = DrinkSize(MenuID, DrinkID);

            var result = new BuyDMDrinkView()
            {
                MenuID    = MenuID,
                DrinkID   = DrinkID,
                DrinkName = DrinkName.DrinkName,
                Bathus    = DrinkName.Bathus,
                SizeType  = mySize,
                Quantity  = 1
            };

            db.Dispose();
            return(result);
        }
Example #5
0
        //依照給的model取出計算小計
        public static int GetSCount(BuyDMDrinkView Buy)
        {
            NewDrinkDB db = new NewDrinkDB();
            //要SizeID
            //加料價ID
            //數量
            int SizePrice = Int32.Parse(Buy.SizeTypeM);
            var SizeP     = db.SizeTables.Find(SizePrice);
            int SCount    = SizeP.Price;
            var Add       = GetAddItemInt(Buy);

            foreach (var item in Add)
            {
                var AddPrice = db.AddItemTypePrices.Find(item);
                SCount = SCount + AddPrice.ItemPrice;
            }
            SCount = SCount * Buy.Quantity;

            db.Dispose();
            return(SCount);
        }
Example #6
0
        //取出訂單配料
        public static List <int> GetAddItemInt(BuyDMDrinkView Buy)
        {
            List <int> ID = new List <int>();

            if (Buy.AddItemType == null)
            {
                return(ID);
            }

            foreach (var item in Buy.AddItemType)
            {
                foreach (var additem in item.AddItem)
                {
                    if (additem.Selected)
                    {
                        int id = Int32.Parse(additem.Value);
                        ID.Add(id);
                    }
                }
            }
            return(ID);
        }