Exemplo n.º 1
0
        /// <summary>
        /// This method triggers the Pay Method
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PayBtn_Click(object sender, EventArgs e)
        {
            if (UserCache.CurrentDebtSelected == false)
            {
                MessageBox.Show("Please select one debt from the Grid.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (UserCache.CurrentDebt.Amount > UserCache.Account.Amount)
            {
                MessageBox.Show("Your debt is greater than your actual balance.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            try
            {
                SQLiteDataBase.DeleteDebt(UserCache.CurrentDebt);
                Debt.Pay(UserCache.CurrentDebt, UserCache.Account);
                MessageBox.Show("Payed!", "Process Complete!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                MessageBox.Show("Failed to save changes. Try Again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
 public FriendManager(SQLiteDataBase database)
 {
     _dataBase = database;
     //friends = new List<Friend>()
     //{
     //    new Friend()
     //    {
     //        Name = "Morten Vismark",
     //        Location = "IDK",
     //        Image =
     //            ImageSource.FromUri(
     //                new Uri("https://blog.xamarin.com/wp-content/uploads/2014/12/CircleImages-1024x611.png")),
     //        Address = "AbeKatteVej 12",
     //        FavoriteFood = "Tissemand",
     //        PhoneNumber = "12345678"
     //    },
     //    new Friend()
     //    {
     //        Name = "Tim",
     //        Location = "Secundary realm",
     //        Image =
     //            ImageSource.FromUri(
     //                new Uri("https://blog.xamarin.com/wp-content/uploads/2014/12/CircleImages-1024x611.png")),
     //        Address = "Wizard bullewand",
     //        FavoriteFood = "saltede kiks og nullermænd",
     //        PhoneNumber = "12345678"
     //    }
     //};
 }
Exemplo n.º 3
0
        public App()
        {
            InitializeComponent();

            SQLiteDataBase dataBase = new SQLiteDataBase();

            MainPage = new NavigationPage(new MainPage(dataBase));
        }
        public FriendCreatePage(SQLiteDataBase database, MainPage parent)
        {
            this._friendManager = new FriendManager(database);
            this.parent         = parent;
            InitializeComponent();


            FindLocation();
        }
Exemplo n.º 5
0
        public MainPage(SQLiteDataBase dataBase)
        {
            _friendManager = new FriendManager(dataBase);
            friends        = _friendManager.GetFriends();

            _database = dataBase;

            InitializeComponent();

            this.FriendList.ItemsSource = friends;
        }
Exemplo n.º 6
0
 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     try
     {
         JsonData.UpdateJson(UserCache.Account, Debt.TotalDebts);
         SQLiteDataBase.InsertOrUpdateDebts(Debt.Debts);
         SQLiteDataBase.InsertOrUpdateExpenses(Expense.Expenses);
         MessageBox.Show("Data saved succesfully.");
     }
     catch (Exception Ex)
     {
         MessageBox.Show(Ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         MessageBox.Show("Data may not have been saved", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 7
0
 private void RemoveBtn_Click(object sender, EventArgs e)
 {
     if (UserCache.CurrentExpenseSelected == false)
     {
         MessageBox.Show("Please select one Expense from the Grid.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     try
     {
         SQLiteDataBase.DeleteExpense(UserCache.CurrentExpense);
         Expense.Remove(UserCache.CurrentExpense, UserCache.Account);
         MessageBox.Show("Removed!", "Process Complete!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         MessageBox.Show("Failed to save changes. Try Again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 /// <summary>
 /// Connects to a database using the designated database file.
 /// </summary>
 /// <param name="dbFile">The datebase to load.</param>
 public WsoUserDatabase(string dbFile)
 {
     databaseFile = dbFile;
     database = new SQLiteDataBase(databaseFile);
 }
 /// Connects to a database using the default database file.
 /// </summary>
 public WsoUserDatabase()
 {
     databaseFile = "C:\\WSODB\\wsodb.s3db";
     database = new SQLiteDataBase(databaseFile);
 }
Exemplo n.º 10
0
        /// <summary>
        /// This event verificates if the Json is filled or not, if it's not that means that this
        /// is the first time the user opens the app. So, the Data Base is created and its tables.
        /// Therefore the UserDataForm is opened.
        ///
        /// If the Json file is filled.It just downloads the data and opens the app.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LoadForm_Shown(object sender, EventArgs e)
        {
            try
            {
                Application.DoEvents();
                Thread.Sleep(3000);
                if (JsonData.ReadJson())
                {
                    ReportLb.Text      = "Initializing DataBase...";
                    progressBar1.Value = 30;
                    Application.DoEvents();
                    Thread.Sleep(1000);
                    if (SQLiteDataBase.CreateDataBase())
                    {
                        ReportLb.Text      = "Creating tables...";
                        progressBar1.Value = 50;
                        SQLiteDataBase.CreateTables();
                        Application.DoEvents();
                        Thread.Sleep(1000);
                    }

                    ReportLb.Text      = "Welcome to SaveX!";
                    progressBar1.Value = 100;
                    Application.DoEvents();
                    Thread.Sleep(3000);
                    UserDataForm UserData = new UserDataForm();
                    UserData.Show();
                    this.Hide();
                }
                else
                {
                    ReportLb.Text = "Charging Data...";
                    JsonData User = JsonData.TakeInfo();
                    UserCache.Account.Name   = User.Name;
                    UserCache.Account.Amount = User.TotalBalance;
                    UserCache.Account.Date   = DateTime.Now;
                    UserCache.Account.Saves  = User.ActualSaves;
                    UserCache.TotalDebt      = User.ActualDebt;
                    UserCache.Currency       = User.Currency;
                    progressBar1.Value       = 30;
                    Application.DoEvents();
                    Thread.Sleep(1000);

                    ReportLb.Text = "Downloading tables...";
                    SQLiteDataBase.TakeAllDebts(Debt.Debts);
                    progressBar1.Value = 50;
                    SQLiteDataBase.TakeAllExpenses(Expense.Expenses);
                    progressBar1.Value = 80;
                    Application.DoEvents();
                    Thread.Sleep(1000);

                    progressBar1.Value = 100;
                    ReportLb.Text      = "Opening App...";
                    Application.DoEvents();
                    Thread.Sleep(2000);
                    MainForm Main = new MainForm();
                    Main.Show();
                    this.Hide();
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.ToString());
            }
        }