Example #1
0
        public string CreateAccount(double _sum, String _name)
        {
            string res = "1;1";
            var dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, dbname);
            using (var db = new SQLiteConnection(dbPath))
            {
                // Работа с БД
                var _acc = new AccountTable() { _Name = _name, CurrentMoneyAmount = _sum };
                db.Insert(_acc);
                var _change = new ChangesTable() { _DBString = "INSERT INTO AccountTable(_Name, CurrentMoneyAmount) VALUES('" + _name + "', '" + _sum + "');", _ChangesDatetime = DateTime.Now };
                db.Insert(_change);
            }

            return res;
        }
Example #2
0
        public void CreateAccountTest()
        {
            int res = 0;
            // параметры генерации
            int iterationCount = 10;
            int rand1 = 100;
            int rand2 = 10000;

            var dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "testDB.db");
            using (var db = new SQLiteConnection(dbPath))
            {
                // Работа с БД
                for (int i = 0; i != iterationCount; i++)
                {
                    Random rand = new Random();
                    var _acc = new AccountTable() { _Name = "TestAccount" + rand.Next(0, rand1).ToString(), CurrentMoneyAmount = rand.Next(0, rand2) };
                    db.Insert(_acc);
                    res++;
                }
            }
            Assert.IsTrue(res > 0, res.ToString());
        }
Example #3
0
 // устанавливаем значения из параметров
 public string ChangeAccount(int _acc_id, double _sum, String _name)
 {
     string res = "";
     var dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, dbname);
     using (var db = new SQLiteConnection(dbPath))
     {
         // Работа с БД     
         var _acc = new AccountTable() {_account_Id = _acc_id, _Name = _name, CurrentMoneyAmount = _sum };
         db.Update(_acc);
         var _change = new ChangesTable() { _DBString = "UPDATE AccountTable SET _Name='" + _name + "', CurrentMoneyAmount='" + _sum + "' WHERE _account_ID='" + _acc_id + "';", _ChangesDatetime = DateTime.Now };
         db.Insert(_change);
     }
     return res;
 }
Example #4
0
 // применяем к счету значение из параметра (меняется только значение суммы на счете, запоминаем экшн)
 public string ChangeAccount(int _acc_id, double _sum, int _cat_id)
 {
     string res = "";
     var dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, dbname);
     using (var db = new SQLiteConnection(dbPath))
     {
         // Работа с БД
         var command = db.CreateCommand("SELECT CurrentMoneyAmount from AccountTable WHERE _account_Id =" + _acc_id);
         var current_sum = command.ExecuteScalar<double>();
         var command1 = db.CreateCommand("Select _Name from AccountTable WHERE _account_Id =" + _acc_id);
         var _name = command1.ExecuteScalar<string>();
         var _acc = new AccountTable() { _account_Id = _acc_id, CurrentMoneyAmount = current_sum + _sum, _Name = _name };
         db.Update(_acc);
         var _act = new ActionTable() {AccountID = _acc_id, Money =  _sum, CategoryID = _cat_id};
         db.Insert(_act);
         // Если до этого был просто быдлокод, то теперь будет быдлокод в квадрате!!!
         var _change_acc = new ChangesTable() { _DBString = "UPDATE AccountTable SET _Name='" + _name + "', CurrentMoneyAmount='" + (current_sum + _sum) + "' WHERE _account_ID='" + _acc_id + "';", _ChangesDatetime = DateTime.Now };
         db.Insert(_change_acc);
         var _change_act = new ChangesTable() { _DBString = "INSERT INTO ActionTable(AccountID, Money, CategoryID) VALUES('" + _acc_id + "', '" + _sum + "', '" + _cat_id + "');", _ChangesDatetime = DateTime.Now };
         db.Insert(_change_act);
     }
     return res;
 }
Example #5
0
 // export Account to AccountTAble
 public AccountTable Export()
 {
     AccountTable res = new AccountTable();
     res._account_Id = Id;
     res._Name = Name;
     res.CurrentMoneyAmount = CurrentMoneyAmount;
     return res;
 }