Пример #1
0
        //date_str format ddmmyyyy
        public async Task <List <FoodMini> > GetAllSumFoodByNotStatusStr(string date_str, string status1, string status2)
        {
            List <FoodMini> list2 = new List <FoodMini>();

            ProductFirebaseHelper productFirebaseHelper = new ProductFirebaseHelper();
            List <Product>        listProduct           = await productFirebaseHelper.GetAllProduct();

            var allFoods = await GetAllFood(date_str);

            if (allFoods != null && listProduct != null)
            {
                int totalQ = 0;
                for (int k = 0; k < listProduct.Count; k++)
                {
                    totalQ = 0;
                    Models.Product pro = listProduct[k];
                    for (int i = 0; i < allFoods.Count; i++)
                    {
                        FoodMini fMini = allFoods[i];
                        if (fMini.NameEn != null && fMini.NameEn.Equals(pro.NameEn))
                        {
                            totalQ = totalQ + fMini.Quantity;
                        }
                    }
                    FoodMini resultFMini = new FoodMini();
                    resultFMini.Name        = pro.Name;
                    resultFMini.NameEn      = pro.NameEn;
                    resultFMini.Quantity    = totalQ;
                    resultFMini.QuantityStr = "จำนวนทั้งหมด " + totalQ;
                    list2.Add(resultFMini);
                }
            }

            return(list2);
        }
Пример #2
0
        public async System.Threading.Tasks.Task <string> adjustRemainStockAsync(string foodName)
        {
            string alertMessage = "";

            ProductFirebaseHelper        productFirebase        = new ProductFirebaseHelper();
            MaterialFirebaseHelper       materialFirebaseHelper = new MaterialFirebaseHelper();
            MaterialDetailFirebaseHelper detailFirebaseHelper   = new MaterialDetailFirebaseHelper();
            MaterialSourceFirebaseHelper sourceFirebaseHelper   = new MaterialSourceFirebaseHelper();

            Models.Product pro = await productFirebase.GetProductByNameEn(foodName);

            if (pro != null)
            {
                Models.MaterialHeader header = await materialFirebaseHelper.GetMaterialByProductId(pro.ID.ToString());

                List <Models.MaterialDetail> listDetail = await detailFirebaseHelper.GetAllMaterialByHeader(convertObject(header.ID));

                for (int i = 0; i < listDetail.Count; i++)
                {
                    Models.MaterialDetail detail = listDetail[i];
                    Models.MaterialSource source = await sourceFirebaseHelper.GetMaterialSourceByID(convertObject(detail.MaterialID));

                    source.Quantity = source.Quantity - detail.Quantity;
                    if (source.Quantity < 0)
                    {
                        if (alertMessage.Trim().Length == 0)
                        {
                            alertMessage = "สินค่า " + foodName + " วัตุดิบ " + source.NameEn + " หมด";
                        }
                        else
                        {
                            alertMessage = alertMessage + " วัตุดิบ " + source.NameEn + " หมด";
                        }
                    }
                    else if (source.Quantity <= source.QuantityAlert)
                    {
                        if (alertMessage.Trim().Length == 0)
                        {
                            alertMessage = "สินค่า " + foodName + " วัตุดิบ " + source.NameEn + " เหลือน้อยกว่าที่กำหนดไว้" + source.QuantityAlert;
                        }
                        else
                        {
                            alertMessage = alertMessage + " วัตุดิบ " + source.NameEn + " เหลือน้อยกว่าที่กำหนดไว้ " + source.QuantityAlert;
                        }
                    }
                }
            }
            return(alertMessage);
        }