コード例 #1
0
ファイル: MainClasses.cs プロジェクト: fireelf/Winuibuh
 public MoneyFlowUnitTable Export()
 {
     MoneyFlowUnitTable res = new MoneyFlowUnitTable();
     res._Account_Id = Account;
     res._Category = _Category;
     res._Count = _Count;
     res._Date = _Date;
     res._MFU_Id = Id;
     res.Comment = Comment;
     res.Date = DateTime.Now;
     return res;
 }
コード例 #2
0
ファイル: WorkerTest.cs プロジェクト: fireelf/Winuibuh
        public void AddMFUTest()
        {
            int AccId = 12345;
            int CategoryID = 1;
            double Summ = 10000.00;
            DateTime testDate = DateTime.Now;

            var dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "testDB.db");
            using (var db = new SQLiteConnection(dbPath))
            {
                // Работа с БД
                var _mfu = new MoneyFlowUnitTable()
                {
                    _Date = DateTime.Now,
                    Date = testDate,
                    _Account_Id = AccId,
                    _Category = CategoryID,
                    Comment = "",
                    _Count = Summ
                };
                db.Insert(_mfu);
                Assert.IsNotNull(_mfu, "New MoneyFLow is NULL");
            }
        }
コード例 #3
0
ファイル: Worker.cs プロジェクト: fireelf/Winuibuh
        public string ChangeMFU(int _id, int AccId, double Summ, int CategoryID, string comment, DateTime date)
        {
            string res = "";
            var dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, dbname);
            using (var db = new SQLiteConnection(dbPath))
            {
                // Работа с БД     
                var command = db.CreateCommand("Select _Account_Id from MoneyFlowUnitTable WHERE _MFU_Id =" + _id);
                var _acc_id = command.ExecuteScalar<int>();
                var command1 = db.CreateCommand("Select _Count from MoneyFlowUnitTable WHERE _MFU_Id =" + _id);
                var count = command1.ExecuteScalar<double>();
                var command2 = db.CreateCommand("Select _Category from MoneyFlowUnitTable WHERE _MFU_Id =" + _id);
                var _cat_id = command2.ExecuteScalar<int>();
                ChangeAccount(_acc_id, -count, _cat_id);

                var _mfu = new MoneyFlowUnitTable() {_MFU_Id=_id, _Date=DateTime.Now, Date = date, _Account_Id = AccId,
                 _Category = CategoryID, _Count = Summ, Comment = comment};
                ChangeAccount(AccId, Summ, CategoryID);
                db.Update(_mfu);
                var _change = new ChangesTable() { _DBString = "UPDATE MoneyFlowUnitTable SET _Date='" + DateTime.Now + "', Date='" + date + "', _Account_Id='" + AccId
                    + "',  _Category='" + CategoryID + "', _Count='" + Summ + "', Comment='" + comment + "' WHERE _MFU_Id='" + _id + "';", _ChangesDatetime = DateTime.Now };
                db.Insert(_change);
            }
            return res;
        }
コード例 #4
0
ファイル: Worker.cs プロジェクト: fireelf/Winuibuh
 /// <summary>
 /// Добавить зачисление или списание
 /// </summary>
 /// <param name="AccId">Id счета</param>
 /// <param name="Summ">Сумма (положительная при зачислении и отрицательная при списании)</param>
 /// <param name="CategoryID">Id категории</param>
 /// <returns>Возвращает строку в формате -код ошибки;доп. информация-</returns>
 public string AddMoneyFlow(int AccId, double Summ, int CategoryID, string comment, DateTime date)
 {
     var dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, dbname);
     using (var db = new SQLiteConnection(dbPath))
     {
         // Работа с БД
         var _mfu = new MoneyFlowUnitTable() {Date = date,                                                      
                                              _Account_Id = AccId, 
                                              _Category = CategoryID,   
                                              Comment = comment,
                                              _Count = Summ,
                                              _Date = DateTime.Now};
         db.Insert(_mfu);
         var _change = new ChangesTable() { _DBString = "INSERT INTO MoneyFlowUnitTable(Date, _Account_Id, _Category, Comment, _Count, _Date) VALUES('" + date + "', '" 
             + AccId + "', '" + CategoryID + "', '" + comment + "', '" + Summ + "', '" + DateTime.Now + "');", _ChangesDatetime = DateTime.Now };
         db.Insert(_change);
         ChangeAccount(AccId, Summ, CategoryID);
     }
     return "1;1";
 }