async void OnListViewItemSelected(object sender, EventArgs e)
        {
            Xamarin.Forms.ListView listView1     = (Xamarin.Forms.ListView)sender;
            Models.MaterialDetail  detail_select = (Models.MaterialDetail)listView1.SelectedItem;
            Utils utils = new Utils();

            Models.MaterialHeader header_select = await headerfirebaseHelper.GetMaterial(new Guid(detail_select.HeaderID));

            //header_select.ProductID

            if (this.materialHeader_id != header_select.ID)
            {
                ProductFirebaseHelper productbaseHelper = new ProductFirebaseHelper();

                Models.Product product_select = await productbaseHelper.GetProduct(new Guid(header_select.ProductID));

                await headerfirebaseHelper.AddMaterialHeader(utils.convertObject(product_select.Name), utils.convertObject(product_select.NameEn), utils.convertObject(product_select.ID));

                await Navigation.PushAsync(new MaterialFoodDetail(utils.convertObject(product_select.ID)));
            }
            else
            {
                ProductFirebaseHelper productbaseHelper = new ProductFirebaseHelper();
                Models.Product        product_select    = await productbaseHelper.GetProduct(new Guid(header_select.ProductID));

                await Navigation.PushAsync(new MaterialFoodDetail(header_select.ID, "Update"));
            }
        }
        async void OnListViewItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            Xamarin.Forms.ListView listView1       = (Xamarin.Forms.ListView)sender;
            Models.MaterialHeader  material_select = (Models.MaterialHeader)listView1.SelectedItem;


            await Navigation.PushAsync(new MaterialFoodAdmin(material_select.ID));
        }
        public async Task initialKeyNew()
        {
            listMatrialView.ItemsSource = await sourcefirebaseHelper.GetAllMaterialSource();

            Models.MaterialHeader header = await headerfirebaseHelper.GetMaterial(this.header_id);

            Models.Product product = await productbaseHelper.GetProduct(new Guid(header.ProductID));

            Lbl_FoodLabel.Text = product.NameEn;
        }
Exemplo n.º 4
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);
        }