Exemplo n.º 1
0
        private async void MakeNewPromoButton(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(uxTypeCombo.SelectedItem.ToString()) || String.IsNullOrEmpty(uxDescriptionBox.Text) || uxRequiredItemsList.SelectedItems.Count == 0 || uxAppliedItemsList.SelectedItems.Count == 0 || String.IsNullOrEmpty(uxPercentageBox.Text.ToString()))
            {
                ContentDialog responseAlert = new ContentDialog
                {
                    Title           = "Required fields are missing",
                    Content         = "Please make sure that all fields are filled out",
                    CloseButtonText = "Ok"
                };
                ContentDialogResult result = await responseAlert.ShowAsync();
            }
            else
            {
                List <MenuItem> required = new List <MenuItem>();
                foreach (object o in uxRequiredItemsList.SelectedItems)
                {
                    required.Add((MenuItem)o);
                }

                List <MenuItem> applied = new List <MenuItem>();
                foreach (object o in uxAppliedItemsList.SelectedItems)
                {
                    applied.Add((MenuItem)o);
                }

                var validMakeNewPromo = await MakeNewPromo.SendMakeNewPromo(uxTypeCombo.SelectedItem.ToString(), uxDescriptionBox.Text, required, applied, uxPercentageBox.Text.ToString(), uxActiveChoice.IsChecked.ToString(), uxRepeatableChoice.IsChecked.ToString());

                if (validMakeNewPromo != null)
                {
                    ContentDialog responseAlert = new ContentDialog
                    {
                        Title           = "Successful",
                        Content         = "Promotion was successfully added to the database",
                        CloseButtonText = "Ok"
                    };
                    ContentDialogResult result = await responseAlert.ShowAsync();
                }
                else
                {
                    ContentDialog responseAlert = new ContentDialog
                    {
                        Title           = "Unsuccessful",
                        Content         = "Promotion was not successfully added to the database",
                        CloseButtonText = "Ok"
                    };
                    ContentDialogResult result = await responseAlert.ShowAsync();
                }
            }
        }
Exemplo n.º 2
0
        private async void MakeNewPromoButton(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(uxDescriptionBox.Text) || uxRequiredItemsList.SelectedItems.Count == 0 || uxAppliedItemsList.SelectedItems.Count == 0 || String.IsNullOrEmpty(uxPercentageBox.Text.ToString()))
            {
                ContentDialog responseAlert = new ContentDialog
                {
                    Title           = "Required fields are missing",
                    Content         = "Please make sure that all fields are filled out",
                    CloseButtonText = "Ok"
                };
                ContentDialogResult result = await responseAlert.ShowAsync();
            }
            else
            {
                List <MenuItem> required = new List <MenuItem>();
                foreach (object o in uxRequiredItemsList.SelectedItems)
                {
                    required.Add((MenuItem)o);
                }

                List <MenuItem> applied = new List <MenuItem>();
                foreach (object o in uxAppliedItemsList.SelectedItems)
                {
                    applied.Add((MenuItem)o);
                }

                var validMakeNewPromo = await MakeNewPromo.SendMakeNewPromo("Customer", uxDescriptionBox.Text, required, applied, uxPercentageBox.Text.ToString(), uxActiveChoice.IsEnabled.ToString(), uxRepeatableChoice.IsEnabled.ToString());

                if (validMakeNewPromo != null)
                {
                    ContentDialog responseAlert = new ContentDialog
                    {
                        Title           = "Successful",
                        Content         = "Promotion was successfully added to the database",
                        CloseButtonText = "Ok"
                    };
                    ContentDialogResult result = await responseAlert.ShowAsync();

                    var writer = new ZXing.BarcodeWriter();

                    writer.Format = ZXing.BarcodeFormat.QR_CODE;

                    writer.Options = new ZXing.Common.EncodingOptions()
                    {
                        Height = 300, Width = 300, PureBarcode = true
                    };

                    QRCode.Source = writer.Write(validMakeNewPromo);

                    uxDiscountPopup.IsOpen      = false;
                    uxDiscountButton.Visibility = Visibility.Collapsed; // Remove option to bring back this screen
                }
                else
                {
                    ContentDialog responseAlert = new ContentDialog
                    {
                        Title           = "Unsuccessful",
                        Content         = "Promotion was not successfully added to the database",
                        CloseButtonText = "Ok"
                    };
                    ContentDialogResult result = await responseAlert.ShowAsync();
                }
            }
        }