Esempio n. 1
0
 private static void LoadDefaultPeopleGroups(TinyMoneyDataContext db)
 {
     string displayLanguage = AppSetting.Instance.DisplayLanguage;
     System.Collections.Generic.List<PeopleGroup> peopleGroups = LocalizedFileHelper.LoadDataSourceFromLocalizedFile<PeopleGroup>(displayLanguage, "DefaultPeopleGroup.xml");
     ApplicationSafetyService.TrackToRun(delegate
     {
         System.Collections.Generic.List<Guid> idsAlreadyExist = (from p in db.PeopleGroups select p.Id).ToList<System.Guid>();
         (from p in peopleGroups
          where idsAlreadyExist.Contains(p.Id)
          select p).ToList<PeopleGroup>().ForEach(delegate(PeopleGroup p)
         {
             peopleGroups.Remove(p);
         });
         if (peopleGroups.Count > 0)
         {
             db.PeopleGroups.InsertAllOnSubmit<PeopleGroup>(peopleGroups);
             db.SubmitChanges();
         }
     });
 }
        public static void BugFixingFor1_9_9(TinyMoneyDataContext db)
        {
            try
            {
                var allDatasToFix = db.BudgetMonthlyReports.Where(p => (p.Month == 11 && p.Year == 2013)
                    || (p.Month == 0 && p.Year == 2012));

                allDatasToFix.ToList<BudgetMonthlyReport>()
                    .ForEach((p) =>
                       {
                           p.Month = 12;
                           p.Year = 2012;
                       });

                db.SubmitChanges();
            }
            catch (Exception)
            {


            }
        }
        public void SaveCurrentMonthBudgetSettleReport(TinyMoneyDataContext db, System.DateTime date)
        {
            var month = date.Month;
            var year = date.Year;

            if (month == 1)
            {
                month = 12;

                year--;
            }
            else
            {
                month--;
            }

            var lastTimeReportSaved = IsolatedAppSetingsHelper.LastTimeBudgetReportSaved;

            if (lastTimeReportSaved.Month < DateTime.Now.Month
                && lastTimeReportSaved.Year <= DateTime.Now.Year)
            {
                IsolatedAppSetingsHelper.LastTimeBudgetReportSaved = DateTime.Now;

                if (db.BudgetMonthlyReports.Count<BudgetMonthlyReport>(p => ((p.Year == year) && (p.Month == month))) == 0)
                {
                    Table<BudgetProject> budgetProjects = db.BudgetProjects;
                    if (budgetProjects.Count<BudgetProject>() > 0)
                    {
                        foreach (BudgetProject project in budgetProjects)
                        {
                            BudgetMonthlyReport entity = new BudgetMonthlyReport
                            {
                                Month = month,
                                Year = year,
                                Amount = project.GetMoney().GetValueOrDefault(),
                                BudgetProjectId = project.Id,
                                ItemType = project.ItemType
                            };
                            db.BudgetMonthlyReports.InsertOnSubmit(entity);
                        }
                        db.SubmitChanges();
                    }
                }
            }
        }
 public static void LoadDefaultGroups(TinyMoneyDataContext db, System.Collections.Generic.IEnumerable<PeopleGroup> groups)
 {
     db.PeopleGroups.InsertAllOnSubmit<PeopleGroup>(groups);
     db.SubmitChanges();
 }
Esempio n. 5
0
 public static void UpdateOldData(TinyMoneyDataContext tinyMoneyDataContext)
 {
     ((System.Collections.Generic.IEnumerable<Repayment>)(from p in tinyMoneyDataContext.Repayments
                                                          where ((int?)p.RepaymentRecordType) == null
                                                          select p)).ForEach<Repayment>(delegate(Repayment p)
     {
         p.RepaymentRecordType = 0;
     });
     tinyMoneyDataContext.SubmitChanges();
 }
Esempio n. 6
0
        /// <summary>
        /// Updates the table structure at V1_9_8.
        /// </summary>
        /// <param name="dataBaseUpdater">The data base updater.</param>
        /// <param name="updater">The updater.</param>
        public static void UpdateTableStructureAtV1_9_8(TinyMoneyDataContext db, Action<Repayment> updater)
        {
            var itemsToUpdate = db.Repayments.Where(p => p.RepaymentRecordType == RepaymentType.MoneyBorrowOrLeanRepayment).ToList();

            itemsToUpdate.ForEach(p => updater((p)));

            db.SubmitChanges();
        }
Esempio n. 7
0
        public static void ResetOrders(TinyMoneyDataContext db)
        {
            try
            {
                var accounts = db.Accounts
                    .ToList();

                if (accounts.Count > 0)
                {
                    accounts.ForEach((p, i) => p.Order = i + 1);

                    db.SubmitChanges();
                }

                accounts = null;
            }
            catch (Exception)
            {
            }
        }
 public void SaveCurrentMonthBudgetSettleReport(TinyMoneyDataContext db, System.DateTime date)
 {
     BugFixingFor1_8_9();
     if (db.BudgetMonthlyReports.Count<BudgetMonthlyReport>(p => ((p.Year == date.Year) && (p.Month == (date.Month - 1)))) == 0)
     {
         Table<BudgetProject> budgetProjects = db.BudgetProjects;
         if (budgetProjects.Count<BudgetProject>() > 0)
         {
             foreach (BudgetProject project in budgetProjects)
             {
                 BudgetMonthlyReport entity = new BudgetMonthlyReport
                 {
                     Month = date.Month - 1,
                     Year = date.Year,
                     Amount = project.GetMoney().GetValueOrDefault(),
                     BudgetProjectId = project.Id,
                     ItemType = project.ItemType
                 };
                 db.BudgetMonthlyReports.InsertOnSubmit(entity);
             }
             db.SubmitChanges();
         }
     }
 }