private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            // make sure quantity is in correct format
            if (TextBoxRegex.GetIsValid(TextBoxQuantity) == false)
            {
                FlyoutWarmingText.Text = "Wrong numerical value!";
                FlyoutWarming.ShowAt(TextBoxQuantity);
                args.Cancel = true;
                return;
            }

            if (TextBoxRegex.GetIsValid(TextBoxCost) == false)
            {
                FlyoutWarmingText.Text = "Wrong numerical value!";
                FlyoutWarming.ShowAt(TextBoxCost);
                args.Cancel = true;
                return;
            }

            // perform real update
            TextBoxQuantity.GetBindingExpression(TextBox.TextProperty).UpdateSource();
            TextBoxCost.GetBindingExpression(TextBox.TextProperty).UpdateSource();
            DatePickerPurchaseDate.GetBindingExpression(DatePicker.DateProperty).UpdateSource();
            ComboBoxProvider.GetBindingExpression(ComboBox.SelectedValueProperty).UpdateSource();
        }
Example #2
0
        private void UpdateRangePurchases()
        {
            if (CalendarDatePickerStartDate.Date == null)
            {
                FlyoutWarmingText.Text = "Please select a date";
                FlyoutWarming.ShowAt(CalendarDatePickerStartDate);
                return;
            }
            if (CalendarDatePickerEndDate.Date == null)
            {
                FlyoutWarmingText.Text = "Please select a date";
                FlyoutWarming.ShowAt(CalendarDatePickerEndDate);
                return;
            }

            DateTimeOffset startDate = CalendarDatePickerStartDate.Date.Value;
            DateTimeOffset endDate   = CalendarDatePickerEndDate.Date.Value;

            if (startDate >= endDate)
            {
                FlyoutWarmingText.Text = "Start date must be earlier than end date";
                FlyoutWarming.ShowAt(CalendarDatePickerStartDate);
                return;
            }

            TextBlockListHeaderDate.Text = "[" +
                                           startDate.ToString("dd MMM yyyy") + " - " +
                                           endDate.ToString("dd MMM yyyy") + "]";

            // read records from DB and update item source
            this.purchases = MainModelView.Current.GetIngredientPurchase(startDate, endDate);
            this.ListViewPurchases.ItemsSource = this.purchases;
        }
        // event handlers
        private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            // make sure name and unit are not empty string
            if (string.IsNullOrWhiteSpace(TextBoxName.Text))
            {
                FlyoutWarmingText.Text = "Name cannot be empty!";
                FlyoutWarming.ShowAt(TextBoxName);
                args.Cancel = true;
                return;
            }
            if (ComboBoxCategory.SelectedIndex == -1)
            {
                FlyoutWarmingText.Text = "Category cannot be empty!";
                FlyoutWarming.ShowAt(ComboBoxCategory);
                args.Cancel = true;
                return;
            }
            if (ComboBoxUnit.SelectedIndex == -1)
            {
                FlyoutWarmingText.Text = "Unit cannot be empty!";
                FlyoutWarming.ShowAt(ComboBoxUnit);
                args.Cancel = true;
                return;
            }

            // perform real update
            TextBoxName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
            ComboBoxCategory.GetBindingExpression(ComboBox.SelectedValueProperty).UpdateSource();
            ComboBoxUnit.GetBindingExpression(ComboBox.SelectedValueProperty).UpdateSource();
            ImageThumbnail.GetBindingExpression(Image.SourceProperty).UpdateSource();
            this.ingredient.ThumbnailFilename = this.thumbnailFilename;
        }
        private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            // make sure name and unit are not empty string
            if (string.IsNullOrWhiteSpace(TextBoxName.Text))
            {
                FlyoutWarmingText.Text = "Name cannot be empty!";
                FlyoutWarming.ShowAt(TextBoxName);
                args.Cancel = true;
                return;
            }

            // perform real update
            TextBoxName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
        }
Example #5
0
        private void UpdateSingleDatePurchases()
        {
            if (CalenderViewSingleDate.SelectedDates.Count == 0)
            {
                FlyoutWarmingText.Text = "Please select a date";
                FlyoutWarming.ShowAt(CalenderViewSingleDate);
                return;
            }

            DateTimeOffset date = this.CalenderViewSingleDate.SelectedDates[0];

            TextBlockListHeaderDate.Text = $"[{date.ToString("dd MMM yyyy")}]";

            // read records from DB and update item source
            this.purchases = MainModelView.Current.GetIngredientPurchase(date);
            this.ListViewPurchases.ItemsSource = this.purchases;
        }
Example #6
0
        private void UpdateRecentPurchases()
        {
            if (ComboBoxPeriod.SelectedItem == null)
            {
                FlyoutWarmingText.Text = "Please select a Period";
                FlyoutWarming.ShowAt(ComboBoxPeriod);
                return;
            }

            string periodText = (string)(ComboBoxPeriod.SelectedItem);

            if (periodText == "All records")
            {
                TextBlockListHeaderDate.Text = "[All purchases]";
            }
            else
            {
                TextBlockListHeaderDate.Text = $"[Recent {periodText}]";
            }

            int periodInMonths = 0;

            switch (periodText)
            {
            case "1 Month": periodInMonths = 1; break;

            case "3 Months": periodInMonths = 3; break;

            case "6 Months": periodInMonths = 6; break;

            case "1 Year": periodInMonths = 12; break;

            case "All records": periodInMonths = -1; break;
            }

            // read records from DB and update item source
            this.purchases = MainModelView.Current.GetIngredientPurchase(periodInMonths);
            this.ListViewPurchases.ItemsSource = this.purchases;
        }