Exemplo n.º 1
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            try
            {
                base.OnNavigatedTo(e);
                SalesSource.Clear();

                // TODO WTS: Replace this with your actual data
                var data = await MySQLDataService.GetGridDataAsync();

                foreach (var item in data)
                {
                    SalesSource.Add(item);
                }

                dg_SortSales(SalesGrid, new DataGridColumnEventArgs(SalesGrid.Columns[1]));
            }
            catch (Exception eSales)
            {
                ContentDialog SalesDBException = new ContentDialog
                {
                    Title           = "Sales - Database Exception",
                    Content         = "Exception Message: " + eSales.Message + Environment.NewLine + "InnerException Message: " + eSales.InnerException.Message,
                    CloseButtonText = "Ok"
                };

                ContentDialogResult result = await SalesDBException.ShowAsync();
            }
        }
Exemplo n.º 2
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            SalesSource.Clear();

            // TODO WTS: Replace this with your actual data
            var data = await MySQLDataService.GetGridDataAsync();

            foreach (var item in data)
            {
                SalesSource.Add(item);
            }
        }
Exemplo n.º 3
0
        private async void MenuFlyoutItem_Delete(object sender, RoutedEventArgs e)
        {
            var row = (sender as FrameworkElement).DataContext as MBSales;
            //ContentDialog mbSalesDialog = new ContentDialog
            //{
            //    Title = "MBSales_Delete",
            //    Content = row.ToString(),
            //    CloseButtonText = "Ok"
            //};

            //ContentDialogResult result = await mbSalesDialog.ShowAsync();

            ContentDialog deleteSalesRowDialog = new ContentDialog
            {
                Title             = "Delete row permanently?",
                Content           = "Are you sure you want to delete this row from the database?" + Environment.NewLine + row.ToString(),
                PrimaryButtonText = "Delete",
                CloseButtonText   = "Cancel"
            };

            ContentDialogResult result = await deleteSalesRowDialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                MySQLDataService.deleteSales(row.SalesId);

                SalesSource.Clear();

                tbSalesAmount.Text = "0.00";
                tbNotes.Text       = "";

                var data = await MySQLDataService.GetGridDataAsync();

                foreach (var item in data)
                {
                    SalesSource.Add(item);
                }
            }
        }
Exemplo n.º 4
0
        private async void btnSubmit_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            //ContentDialog noWifiDialog = new ContentDialog
            //{
            //    Title = "No wifi connection",
            //    Content = "Check your connection and try again.",
            //    CloseButtonText = "Ok"
            //};

            //ContentDialogResult result = await noWifiDialog.ShowAsync();

            try
            {
                MBSales mbs = new MBSales();

                if (dpSalesDate.SelectedDate.HasValue)
                {
                    DateTimeOffset dto = dpSalesDate.SelectedDate.Value;
                    mbs.SalesDate = dto.DateTime;
                }

                mbs.SalesAmt   = Double.Parse(tbSalesAmount.Text);
                mbs.SalesNotes = tbNotes.Text;
                mbs.User       = "******";

                //ContentDialog mbSalesDialog = new ContentDialog
                //{
                //    Title = "MBSales",
                //    Content = mbs.ToString(),
                //    CloseButtonText = "Ok"
                //};

                //ContentDialogResult result3 = await mbSalesDialog.ShowAsync();
                MySQLDataService.insertSales(mbs);

                SalesSource.Clear();

                tbSalesAmount.Text  = "0.00";
                tbNotes.Text        = "";
                btnSubmit.IsEnabled = false;

                var data = await MySQLDataService.GetGridDataAsync();

                foreach (var item in data)
                {
                    SalesSource.Add(item);
                }

                SalesGrid.Columns[1].SortDirection = DataGridSortDirection.Ascending;

                dg_SortSales(SalesGrid, new DataGridColumnEventArgs(SalesGrid.Columns[1]));
            }
            catch (Exception ex)
            {
                ContentDialog insertExceptionDialog = new ContentDialog
                {
                    Title           = "Error inserting row in Sales table",
                    Content         = ex.Message,
                    CloseButtonText = "Ok"
                };

                ContentDialogResult result2 = await insertExceptionDialog.ShowAsync();
            }
        }