public static AccountBookModel CreateFromTemplate(string title, AccountBookModel template)
        {
            AccountBookModel account = new AccountBookModel(title);

            foreach (var classify in template._allIncomeBillClassifyCollection)
            {
                App.ViewModel.InsertBillClassify(classify);
                account.BillClassifies.Add(classify);
                account._allIncomeBillClassifyCollection.Add(classify);
            }

            foreach (var classify in template._allExpenditureBillClassifyCollection)
            {
                App.ViewModel.InsertBillClassify(classify);
                account.BillClassifies.Add(classify);

                account._allExpenditureBillClassifyCollection.Add(classify);
            }

            return account;
        }
Ejemplo n.º 2
0
        public void DeleteAccount(AccountBookModel accountbookForDelete)
        {
            this.AccountBookItems.Remove(accountbookForDelete);

            // delete BillClassify
            _hkDB.TableBillClassify.DeleteAllOnSubmit(accountbookForDelete.BillClassifies);

            if (accountbookForDelete.AllBills != null)
            {
                // delete DetailItems
                foreach (var bill in accountbookForDelete.AllBills)
                {
                    if (bill.DetailItems != null)
                    {
                        _hkDB.TableDetailItem.DeleteAllOnSubmit(bill.DetailItems);
                    }
                }

                // delete Bill
                _hkDB.TableBill.DeleteAllOnSubmit(accountbookForDelete.AllBills);
            }

            _hkDB.TableAccountBook.DeleteOnSubmit(accountbookForDelete);

            _hkDB.SubmitChanges();
        }