Exemplo n.º 1
0
        public static void UpdateSavedProductsWhenClosingApp()
        {
            try
            {
                var sortedProducts = new Dictionary <string, ProductionDetailsToSave>();

                foreach (string ID in businesses.Keys)
                {
                    if (!sortedProducts.ContainsKey(ID))
                    {
                        var productionToSave = new ProductionDetailsToSave()
                        {
                            productSource = new Dictionary <string, ProductToSave>()
                        };

                        foreach (ProductItem product in businesses[ID].productSource)
                        {
                            var productDetailsToSave = new ProductToSave();

                            if (product.isEnable == true)
                            {
                                productDetailsToSave.isEnable = "TRUE";
                                productDetailsToSave.icon     = product.sortedStatusIcon;
                            }
                            else if (product.isEnable == false)
                            {
                                productDetailsToSave.isEnable = "FALSE";
                                productDetailsToSave.icon     = "";
                            }

                            var customerList = new List <CustomerToSave>();

                            foreach (Customer customer in product.customers)
                            {
                                var customerToSave = new CustomerToSave();
                                customerToSave.customer_first_name = customer.customer_first_name;
                                customerToSave.customer_last_name  = customer.customer_last_name;
                                customerToSave.customer_uid        = customer.customer_uid;
                                customerToSave.qty = customer.qty;

                                if (customer.borderColor == Color.Red)
                                {
                                    customerList.Add(customerToSave);
                                }
                            }

                            productDetailsToSave.customersSource = customerList;

                            productionToSave.productSource.Add(product.item_uid, productDetailsToSave);
                        }

                        sortedProducts.Add(ID, productionToSave);
                    }
                }

                SaveChanges(sortedProducts);
            }catch (Exception issueOnUpdateSavedProductsWhenClosingApp)
            {
                Application.Current.MainPage.DisplayAlert("Oops", issueOnUpdateSavedProductsWhenClosingApp.Message, "OK");
            }
        }
Exemplo n.º 2
0
        void NavigateToSummaryPage(System.Object sender, System.EventArgs e)
        {
            try
            {
                var sortedProducts = new Dictionary <string, ProductionDetailsToSave>();

                foreach (string ID in businesses.Keys)
                {
                    if (!sortedProducts.ContainsKey(ID))
                    {
                        var productionToSave = new ProductionDetailsToSave()
                        {
                            productSource = new Dictionary <string, ProductToSave>()
                        };

                        foreach (ProductItem product in businesses[ID].productSource)
                        {
                            var productDetailsToSave = new ProductToSave();

                            if (product.isEnable == true)
                            {
                                productDetailsToSave.isEnable = "TRUE";
                            }
                            else if (product.isEnable == false)
                            {
                                productDetailsToSave.isEnable = "FALSE";
                            }
                            productDetailsToSave.icon = product.sortedStatusIcon;

                            var customerList = new List <CustomerToSave>();

                            foreach (Customer customer in product.customers)
                            {
                                var customerToSave = new CustomerToSave();
                                customerToSave.customer_first_name = customer.customer_first_name;
                                customerToSave.customer_last_name  = customer.customer_last_name;
                                customerToSave.customer_uid        = customer.customer_uid;
                                customerToSave.qty = customer.qty;

                                if (customer.borderColor == Color.Red)
                                {
                                    customerList.Add(customerToSave);
                                }
                            }

                            productDetailsToSave.customersSource = customerList;

                            productionToSave.productSource.Add(product.item_uid, productDetailsToSave);
                        }

                        sortedProducts.Add(ID, productionToSave);
                    }
                }

                SaveChanges(sortedProducts);
                isProductionSave = "TRUE";
                Navigation.PushModalAsync(new SummaryPage());
            }
            catch (Exception issueOnNavigateToSummaryPage)
            {
                Application.Current.MainPage.DisplayAlert("Oops", issueOnNavigateToSummaryPage.Message, "OK");
            }
        }