Esempio n. 1
0
        /// <summary>
        /// Constructor for the Application object.
        /// </summary>
        public App()
        {
            // Global handler for uncaught exceptions.
            UnhandledException += Application_UnhandledException;

            // Standard XAML initialization
            InitializeComponent();

            // Phone-specific initialization
            InitializePhoneApplication();

            // Language display initialization
            InitializeLanguage();

            // Show graphics profiling information while debugging.
            if (Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are handed off to GPU with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;

                // Prevent the screen from turning off while under the debugger by disabling
                // the application's idle detection.
                // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
                // and consume battery power when the user is not using the phone.
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }

            // Specify the local database connection string.
            string DBConnectionString = "Data Source=isostore:/ReceiptDatabase.sdf";

            // Create the database if it does not exist.
            using (ReceiptDatabase db = new ReceiptDatabase(DBConnectionString))
            {
                // Create the local database.
                if (db.DatabaseExists() == false)
                {
                    db.CreateDatabase();
                    db.categories.InsertOnSubmit(new ActivityCategory { Name = "Personal" });
                    db.categories.InsertOnSubmit(new ActivityCategory { Name = "Income" });
                    db.categories.InsertOnSubmit(new ActivityCategory { Name = "Fun" });
                    db.categories.InsertOnSubmit(new ActivityCategory { Name = "Food" });
                    db.categories.InsertOnSubmit(new ActivityCategory { Name = "Transportation" });

                    // Save categories to the database.
                    db.SubmitChanges();
                }
            }
        }
Esempio n. 2
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Name.Text) || string.IsNullOrWhiteSpace(Name.Text) ||
                string.IsNullOrEmpty(Amount.Text) || string.IsNullOrWhiteSpace(Amount.Text))
            {
                MessageBox.Show("Something is missing...", "", MessageBoxButton.OK);
            }
            else
            {
                string DBConnectionString = "Data Source=isostore:/ReceiptDatabase.sdf";

                // Add entry to database with user input
                using (ReceiptDatabase db = new ReceiptDatabase(DBConnectionString))
                {
                    // Prepopulate the categories.

                    db.entries.InsertOnSubmit(new ReceiptEntry
                    {
                        EntryName     = Name.Text,
                        EntryPrice    = float.Parse(Amount.Text),
                        EntryCategory = new ActivityCategory {
                            Name = CategoryPicker.SelectedItem.ToString()
                        },
                        EntryDate = DateTime.Parse(Date.Value.ToString())
                    });

                    // Save categories to the database.
                    db.SubmitChanges();
                }

                // Load database update
                MainPage.viewModel.LoadEntriesFromDatabase();

                if (NavigationService.CanGoBack)
                {
                    NavigationService.GoBack();
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Constructor for the Application object.
        /// </summary>
        public App()
        {
            // Global handler for uncaught exceptions.
            UnhandledException += Application_UnhandledException;

            // Standard XAML initialization
            InitializeComponent();

            // Phone-specific initialization
            InitializePhoneApplication();

            // Language display initialization
            InitializeLanguage();

            // Show graphics profiling information while debugging.
            if (Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are handed off to GPU with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;

                // Prevent the screen from turning off while under the debugger by disabling
                // the application's idle detection.
                // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
                // and consume battery power when the user is not using the phone.
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }

            // Specify the local database connection string.
            string DBConnectionString = "Data Source=isostore:/ReceiptDatabase.sdf";

            // Create the database if it does not exist.
            using (ReceiptDatabase db = new ReceiptDatabase(DBConnectionString))
            {
                // Create the local database.
                if (db.DatabaseExists() == false)
                {
                    db.CreateDatabase();
                    db.categories.InsertOnSubmit(new ActivityCategory {
                        Name = "Personal"
                    });
                    db.categories.InsertOnSubmit(new ActivityCategory {
                        Name = "Income"
                    });
                    db.categories.InsertOnSubmit(new ActivityCategory {
                        Name = "Fun"
                    });
                    db.categories.InsertOnSubmit(new ActivityCategory {
                        Name = "Food"
                    });
                    db.categories.InsertOnSubmit(new ActivityCategory {
                        Name = "Transportation"
                    });

                    // Save categories to the database.
                    db.SubmitChanges();
                }
            }
        }
Esempio n. 4
0
 // Write changes in the data context to the database.
 public void SaveChangesToDB()
 {
     receiptDatabase.SubmitChanges();
 }
Esempio n. 5
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Name.Text) || string.IsNullOrWhiteSpace(Name.Text) ||
                string.IsNullOrEmpty(Amount.Text) || string.IsNullOrWhiteSpace(Amount.Text))
            {
                MessageBox.Show("Something is missing...", "", MessageBoxButton.OK);
            }
            else
            {
                string DBConnectionString = "Data Source=isostore:/ReceiptDatabase.sdf";

                // Add entry to database with user input
                using (ReceiptDatabase db = new ReceiptDatabase(DBConnectionString))
                {

                    // Prepopulate the categories.

                    db.entries.InsertOnSubmit(new ReceiptEntry
                        {
                            EntryName = Name.Text,
                            EntryPrice = float.Parse(Amount.Text),
                            EntryCategory = new ActivityCategory { Name = CategoryPicker.SelectedItem.ToString() },
                            EntryDate = DateTime.Parse(Date.Value.ToString())
                        });

                    // Save categories to the database.
                    db.SubmitChanges();
                }

                // Load database update
                MainPage.viewModel.LoadEntriesFromDatabase();

                if (NavigationService.CanGoBack)
                    NavigationService.GoBack();
            }
        }