public System.Collections.Generic.List<GroupByCreateTimeAccountItemViewModel> GetGroupedRelatedItems(AccountItem itemCompareTo, bool searchingOnlyCurrentMonthData = true, System.Action<AccountItem> itemAdded = null) { System.Collections.Generic.List<GroupByCreateTimeAccountItemViewModel> list = new System.Collections.Generic.List<GroupByCreateTimeAccountItemViewModel>(); IOrderedEnumerable<AccountItem> source = from p in this.GetRelatedItems(itemCompareTo, searchingOnlyCurrentMonthData) orderby p.CreateTime descending select p; if (itemAdded == null) { itemAdded = delegate(AccountItem ai) { }; } var dates = (from p in source select p.CreateTime.Date).Distinct<System.DateTime>(); foreach (var item in dates) { GroupByCreateTimeAccountItemViewModel agvm = new GroupByCreateTimeAccountItemViewModel(item); source.Where(p => p.CreateTime.Date == item.Date).ToList<AccountItem>().ForEach(delegate(AccountItem x) { agvm.Add(x); itemAdded(x); }); list.Add(agvm); } return list; }
/// <summary> /// Recovers the item processor. /// </summary> /// <param name="item">The item.</param> public static void RecoverItemProcessor(AccountItem item, TallySchedule taskInfo) { if (DataRecoverProcessor != null) { DataRecoverProcessor(item, taskInfo); } }
public override bool ParseScheduleDataToXmlNode(XElement scheduleDataEntry) { AccountItem data = new AccountItem { AccountId = scheduleDataEntry.Attribute("fromAccountId").Value.ToGuid() }; if (data.AccountId == System.Guid.Empty) { return false; } data.CategoryId = scheduleDataEntry.TryGet<string, XAttribute>(p => p.Attribute("categoryId"), p => p.Value).ToGuid(); if (data.CategoryId == System.Guid.Empty) { return false; } data.CreateTime = System.DateTime.Now; data.Description = scheduleDataEntry.TryGet<string, XAttribute>(p => p.Attribute("notes"), p => p.Value); data.Id = System.Guid.NewGuid(); data.IsClaim = new bool?(scheduleDataEntry.TryGet<string, XAttribute>(p => p.Attribute("isClaim"), p => p.Value).ToBoolean(false)); data.Money = scheduleDataEntry.TryGet<string, XAttribute>(p => p.Attribute("amount"), p => p.Value).ToDecimal(); data.State = AccountItemState.Active; data.Type = (ItemType)scheduleDataEntry.TryGet<string, XAttribute>(p => p.Attribute("itemType"), p => p.Value).ToInt32(); data.AutoTokenId = scheduleDataEntry.TryGet<string, XAttribute>(p => p.Attribute("autoTokenId"), p => p.Value).ToGuid(); this.OnHandlerDataParsed(data); return true; }
public void BindEditingData(AccountItem accountItem) { this.UpdateAccountItemInfo(accountItem); this.associatedAccountItem = accountItem; this.AccountItemTypeAndCategoryInfo.Style = (Style)base.Resources["PhoneTextNormalStyle"]; this.SetScheduledItemNameFromDetailsInfo(accountItem); }
protected void OnItemAdding(AccountItem accountItem) { TinyMoneyManager.ViewModels.ItemAdding itemAdding = this.ItemAdding; if (itemAdding != null) { itemAdding(accountItem); } }
public void AddItem(AccountItem item) { this.AccountBookDataContext.AccountItems.InsertOnSubmit(item); this.AccountBookDataContext.SubmitChanges(); switch (item.Type) { case ItemType.Expense: this.FindGroup(this.ExpenseItems, item.CreateTime.Date).Add(item); return; case ItemType.Income: this.FindGroup(this.IncomeItems, item.CreateTime.Date).Add(item); return; } }
void EditExpenseOrIncomeSchedule_Loaded(object sender, RoutedEventArgs e) { if (!this.hasInitializedBinding) { this.action = this.GetNavigatingParameter("action", null); this.InitializedApplicationBar(); if (ViewModelLocator.AccountViewModel.Accounts.Count == 0) { ViewModelLocator.AccountViewModel.QuickLoadData(); } hasInitializedBinding = true; if (this.action == "edit") { System.Guid id = this.GetNavigatingParameter("id", null).ToGuid(); this.scheduleDataInfo = this.scheduleManagerViewModel.Tasks.FirstOrDefault<TallySchedule>(p => p.Id == id); this.scheduleManagerViewModel.Current = this.scheduleDataInfo; this.taskType = this.scheduleDataInfo.ActionHandlerType; if (this.taskType == RecordActionType.CreateTranscationRecord) { this.associatedAccountItem = this.scheduleManagerViewModel.ReBuildAccountItem(this.scheduleDataInfo); if (this.associatedAccountItem != null) { this.associatedAccountItem.PropertyChanged += associatedAccountItem_PropertyChanged; } } else { this.assoicatedTransferingItem = this.scheduleManagerViewModel.ReBuildTransferingItem(this.scheduleDataInfo); } this.BindingDataToEdit(); } else { this.scheduleDataInfo = new TallySchedule(); } } }
public System.Collections.Generic.IEnumerable<AccountItem> GetRelatedItems(AccountItem itemCompareTo, bool searchingOnlyCurrentMonth = true) { System.Func<AccountItem, Boolean> predicate = null; System.Collections.Generic.IEnumerable<AccountItem> source = from p in this.AccountBookDataContext.AccountItems where ((((int)p.Type) == ((int)itemCompareTo.Type)) && (p.CategoryId == itemCompareTo.CategoryId)) && (p.Id != itemCompareTo.Id) select p; System.DateTime createTime = itemCompareTo.CreateTime; int year = createTime.Year; int month = createTime.Month; int day = createTime.Day; if (!searchingOnlyCurrentMonth) { return source; } if (predicate == null) { predicate = p => (p.CreateTime.Date.Year == year) && (p.CreateTime.Date.Month == month); } return source.Where<AccountItem>(predicate); }
public override bool ProcessingExecute(TallySchedule scheduleData) { AccountItem entity = new AccountItem { Account = scheduleData.FromAccount, AccountId = scheduleData.FromAccountId, CategoryId = scheduleData.CategoryId, CreateTime = System.DateTime.Now.Date, Description = scheduleData.Notes, IsClaim = new bool?((scheduleData.RecordType == ItemType.Income) ? false : scheduleData.IsClaim), Money = scheduleData.Money, State = AccountItemState.Active, Type = scheduleData.RecordType, AutoTokenId = scheduleData.Id }; Account account = entity.Account; decimal num = (entity.Type == ItemType.Expense) ? -entity.Money : entity.Money; decimal? balance = account.Balance; decimal num2 = num; account.Balance = balance.HasValue ? new decimal?(balance.GetValueOrDefault() + num2) : null; base.DataContext.AccountItems.InsertOnSubmit(entity); base.DataContext.SubmitChanges(); return true; }
private void StatisticsInfoButton_Click(object sender, RoutedEventArgs e) { SearchingScope scope = (SearchingScope)System.Enum.Parse(typeof(SearchingScope), (sender as HyperlinkButton).Tag.ToString(), true); SummaryDetails details2 = new SummaryDetails(); AccountItem item = new AccountItem { Category = this.current }; details2.Tag = item; SummaryDetails details = details2; DetailsCondition condition2 = new DetailsCondition { ChartGroupMode = ChartGroupMode.ByCategoryName, SearchingScope = scope, GroupCategoryMode = this.current.IsParent ? CategorySortType.ByParentCategory : CategorySortType.ByChildCategory }; DetailsCondition searchingCondition = condition2; StatsticSummaryItemsViewer.Show(details, searchingCondition, this); }
private void detach_ToDo(AccountItem toDo) { this.OnNotifyPropertyChanging("AccountItem"); toDo.Category = null; }
public void RebuildPicture(AccountItem data, Guid[] pictureIds) { if (pictureIds != null && pictureIds.Length > 0) { var pics = this.AccountBookDataContext.PictureInfos.Where(p => pictureIds.Contains(p.PictureId) && p.AttachedId == data.AutoTokenId) .AsEnumerable(); data.PicturesOutOfDatabase = pics.ToList(); } }
private void SaveAndStay_Click(object sender, System.EventArgs e) { ToastPrompt prompt = new ToastPrompt { MillisecondsUntilHidden = 0x3e8, Title = "" }; if (this.DoSaveBudget()) { prompt.Message = AppResources.OperationSuccessfullyMessage; if (this.actionType == PageActionType.Add) { this.DescriptionTextBox.Text = string.Empty; } prompt.Show(); currentEditObject = new AccountItem(); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { this.EnsureEnablePinToStart(); MainPage.ShowOpactityZeroTrayBlack(); base.OnNavigatedTo(e); if (!this.isDataNavigated) { this.totalDaysOfThisMonth = System.DateTime.Now.GetCountDaysOfMonth(); this.SetControlLocalizedString(); this.AccountName.ItemsSource = ViewModelLocator.AccountViewModel.Accounts; if (base.NavigationContext.QueryString.ContainsKey("action")) { string str = base.NavigationContext.QueryString["action"]; if (!ViewModelLocator.AccountViewModel.IsDataLoaded) { ViewModelLocator.AccountViewModel.QuickLoadData(); } if (!this.hasNavied) { if ((str == "Edit") || (IsSelectionMode && (accountItemForSchedule != null))) { this.actionType = PageActionType.Edit; this.CategoryType.BorderThickness = new Thickness(0.0, 0.0, 0.0, 0.0); this.initializeEditingMode(); base.DataContext = currentEditObject; } else { if (base.NavigationContext.QueryString.ContainsKey("categoryType")) { int num = int.Parse(base.NavigationContext.QueryString["categoryType"]); this.CategoryType.SelectedIndex = num; } this.actionType = PageActionType.Add; if (str != "preEdit") { currentEditObject = new AccountItem(); } base.DataContext = currentEditObject; this.InitializeAddData(); if (str == "preEdit") { this.BindData(currentEditObject); } } if (str == "selection") { string source = e.GetNavigatingParameter("title", null); this.NewOrEditPage.Text = source.IsNullOrEmpty() ? AppResources.CreateAccountItemForSchedule.ToUpperInvariant() : source; } this.SetControls(); this.hasNavied = true; } } this.isFromList = this.GetNavigatingParameter("isFromList", null).ToBoolean(false); this.fromMainPage = this.GetNavigatingParameter("FromMainPlus", null).ToBoolean(false); if (this.FromStartScreen) { ApplicationBarMenuItem item = new ApplicationBarMenuItem { Text = LocalizedStrings.GetLanguageInfoByKey("GoToMainPage") }; this.toMainPageButton = item; this.toMainPageButton.Click += new System.EventHandler(this.toMainPageButton_Click); base.ApplicationBar.MenuItems.Add(this.toMainPageButton); } } }
private void BindData(AccountItem item) { this.CategoryType.SelectedIndex = (item.Type == ItemType.Expense) ? 0 : 1; this.CategoryNameButton.DataContext = item.NameInfo; this.tempCategory = item.Category; if (item.Type == ItemType.Expense) { this.IsClaim.IsChecked = new bool?(item.IsClaim.GetValueOrDefault()); } this.MoneyCurrency.Text = item.Account.CurrencyType.GetCurrentString(); this.TotalMoneyBox.Text = item.Money.ToMoneyF2(); object obj2 = this.AccountName.Items.FirstOrDefault<object>(p => ((Account)p).Id == item.Account.Id); this.AccountName.SelectedItem = obj2; this.CreateDate.Value = new System.DateTime?(item.CreateTime); this.CreateTime.Value = item.CreateTime; this.DescriptionTextBox.Text = item.Description; }
public void HandleAccountItemAdding(AccountItem accountItem) { ViewModelLocator.AccountItemViewModel.AddItem(accountItem); ViewModelLocator.AccountViewModel.WithdrawlOrDeposit(accountItem.Account, (accountItem.Type == ItemType.Expense) ? -accountItem.Money : accountItem.Money); ViewModelLocator.MainPageViewModel.IsSummaryListLoaded = false; }
private void RecoverPeoples(AccountItem accountItem, TallySchedule taskInfo) { if (taskInfo.Peoples != null && taskInfo.Peoples.Length > 0) { var ids = taskInfo.Peoples; var originalData = AccountBookDataContext.PeopleAssociationDatas .Where(p => ids.Contains(p.PeopleId) && p.AttachedId == accountItem.AutoTokenId) .ToList() .Select(p => new PeopleAssociationData() { PeopleId = p.PeopleId, Comments = p.Comments, AttachedId = accountItem.Id, CreateAt = DateTime.Now }).ToList(); foreach (var pic in originalData) { AccountBookDataContext.PeopleAssociationDatas.InsertOnSubmit(pic); } } }
private void DeleteItemWithMessagBox(AccountItem item) { if (this.AlertConfirm(AppResources.DeleteAccountItemMessage, null, null) == MessageBoxResult.OK) { DeleteAccountItem(item); } }
private bool InCurrentMonth(AccountItem accountItem) { return accountItem.CreateTime.AtSameYearMonth(currentEditObject.CreateTime); }
private void GoToEditBudgetItem(AccountItem itemForEdit) { NewOrEditAccountItemPage.currentEditObject = itemForEdit; this.NavigateTo("/Pages/NewOrEditAccountItemPage.xaml?action={0}&id={1}&isFromList=true", new object[] { PageActionType.Edit, itemForEdit.Id }); }
public static void RegisterSelectionMode(AccountItem accountItem, System.Action<AccountItem> afterCreated) { if (!IsSelectionMode) { IsSelectionMode = true; } accountItemForSchedule = accountItem; currentEditObject = accountItemForSchedule; AfterCreated = afterCreated; }
/// <summary> /// Recovers the picutres. /// </summary> /// <param name="accountItem">The account item.</param> /// <param name="taskInfo">The task info.</param> private void RecoverPicutres(AccountItem accountItem, TallySchedule taskInfo) { if (taskInfo.Pictures != null && taskInfo.Pictures.Length > 0) { var ids = taskInfo.Pictures; var originalPictures = AccountBookDataContext.PictureInfos .Where(p => ids.Contains(p.PictureId) && p.Tag == PictureInfo.ScheduledAccountItemsTag) .ToList() .Select(p => new PictureInfo() { PictureId = p.PictureId, AttachedId = accountItem.Id, Comments = p.Comments, CreateAt = DateTime.Now, FullPath = p.FullPath, FileName = p.FileName, Tag = PictureInfo.AccountItemsTag }).ToList(); ViewModelLocator.PicturesViewModel.SavePicturesFrom(originalPictures, PictureInfo.ScheduledAccountItemsTag); foreach (var pic in originalPictures) { //accountItem.Pictures.Add(pic); AccountBookDataContext.PictureInfos.InsertOnSubmit(pic); //accountItem.Pictures.Add(pic); } } }
public AccountItem ReBuildAccountItem(TallySchedule scheduleDataInfo) { var data = new AccountItem { Account = scheduleDataInfo.FromAccount, AccountId = scheduleDataInfo.FromAccountId, AutoTokenId = scheduleDataInfo.Id, Category = scheduleDataInfo.AssociatedCategory, CategoryId = scheduleDataInfo.CategoryId, Description = scheduleDataInfo.Notes, IsClaim = new bool?(scheduleDataInfo.IsClaim), Money = scheduleDataInfo.Money, State = AccountItemState.Active, Type = scheduleDataInfo.RecordType, IsInDeattchedFromDatabaseMode = true, }; RebuildPicture(data, scheduleDataInfo.Pictures); RebuildPeople(data, scheduleDataInfo.Peoples); return data; }
public void HandleAccountItemDeleting(AccountItem accountItem) { try { if (accountItem != null) { this.HandleAccountItemEditing(accountItem, accountItem.Account, accountItem.Money, -accountItem.Money); ViewModelLocator.PicturesViewModel.DeletePictures(accountItem.Pictures); ViewModelLocator.AccountItemViewModel.RemoveItem(accountItem); ViewModelLocator.AccountItemViewModel.SubmitChanges(); } } catch (ChangeConflictException exception) { throw exception; } }
public void RebuildPeople(AccountItem data, Guid[] peopleAssociationIds) { if (peopleAssociationIds != null && peopleAssociationIds.Length > 0) { var peoples = this.AccountBookDataContext.PeopleAssociationDatas.Where(p => peopleAssociationIds.Contains(p.PeopleId) && p.AttachedId == data.AutoTokenId) .AsEnumerable(); data.PeoplesOutOfDatabase = peoples.ToList(); } }
/// <summary> /// Handles the account item editing. /// </summary> /// <param name="currentEditObject">The current edit object.</param> /// <param name="oldAccount">The old account.</param> /// <param name="oldMoney">The old money.</param> /// <param name="oldBalance">The old balance.</param> public void HandleAccountItemEditing(AccountItem currentEditObject, Account oldAccount, decimal oldMoney, decimal oldBalance) { if (oldAccount == null) { return; } if (oldAccount.Id == currentEditObject.Account.Id) { if (oldBalance != 0.0M) { oldBalance = (currentEditObject.Type == ItemType.Expense) ? -oldBalance : oldBalance; this.WithdrawlOrDeposit(currentEditObject.Account, oldBalance); } } else { decimal amount = oldMoney; if (currentEditObject.Type == ItemType.Expense) { this.WithdrawlOrDeposit(oldAccount, amount); this.WithdrawlOrDeposit(currentEditObject.Account, -amount); } else if (currentEditObject.Type == ItemType.Income) { this.WithdrawlOrDeposit(oldAccount, -amount); this.WithdrawlOrDeposit(currentEditObject.Account, amount); } } ViewModelLocator.AccountItemViewModel.Update(currentEditObject); ViewModelLocator.MainPageViewModel.IsSummaryListLoaded = false; }
private void LoadStasticsInfo(Category category) { int count = 0; DetailsCondition dc = new DetailsCondition { SearchingScope = SearchingScope.CurrentMonth }; decimal val = ViewModelLocator.CategoryViewModel.CountStatistic(category, dc, delegate(int p) { count = p; }); AccountItem ai = new AccountItem { SecondInfo = this.currentMonthName, ThirdInfo = AppResources.StatisticsInfoFormatterForCategory.FormatWith(new object[] { count, string.Empty, "{0}{1}".FormatWith(new object[] { this.symbol, val.ToMoneyF2() }) }) }; count = 0; DetailsCondition condition2 = new DetailsCondition { SearchingScope = SearchingScope.LastMonth }; val = ViewModelLocator.CategoryViewModel.CountStatistic(category, condition2, delegate(int p) { count = p; }); AccountItem lastMonthai = new AccountItem { SecondInfo = this.lastMonthName, ThirdInfo = AppResources.StatisticsInfoFormatterForCategory.FormatWith(new object[] { count, string.Empty, "{0}{1}".FormatWith(new object[] { this.symbol, val.ToMoneyF2() }) }) }; base.Dispatcher.BeginInvoke(delegate { this.CurrentMonthStaticsInfoPanel.DataContext = ai; this.LastMonthStaticsInfoPanel.DataContext = lastMonthai; this.hasLoadStatisticsInfo = true; this.WorkDone(); }); BudgetItem budgetItem = new BudgetItem { AssociatedCategory = category, BudgetType = category.CategoryType }; DetailsCondition detailsCondition = new DetailsCondition { SearchingScope = SearchingScope.CurrentMonth }; decimal monthlyBudgetAmount = ViewModelLocator.BudgetProjectViewModel.GetBudgetAmountForCategory(budgetItem, detailsCondition); base.Dispatcher.BeginInvoke(delegate { this.BudgetBlock.Text = "{0}{1}".FormatWith(new object[] { this.symbol, monthlyBudgetAmount.ToMoneyF2() }); }); }
public System.Collections.Generic.List<GroupByCreateTimeAccountItemViewModel> LoadAssociatedItemsForAccount( Account itemCompareToCurrent, ObservableCollection<GroupByCreateTimeAccountItemViewModel> out_container) { HasLoadAssociatedItemsForCurrentViewAccount = true; var container = new List<GroupByCreateTimeAccountItemViewModel>(); int recordCount = 0; var eachCount = 0; Action<int, string> showRecordTips = (count, name) => { recordCount += count; Deployment.Current.Dispatcher.BeginInvoke(() => { mangoProgressIndicator.GlobalIndicator.Instance.BusyForWork(AppResources.NowLoadingFormatter.FormatWith(AppResources.RecordCountTipsFormatter.FormatWith(count, name))); }); }; if (searchingConditionForAssociatedItemsForCurrentViewAccount.DataType == AssociatedItemType.All || searchingConditionForAssociatedItemsForCurrentViewAccount.DataType == AssociatedItemType.Transcations) { var accountItemsData = ViewModelLocator.AccountItemViewModel .AccountBookDataContext.AccountItems.Where(p => p.AccountId == itemCompareToCurrent.Id); if (searchingConditionForAssociatedItemsForCurrentViewAccount.SearchingScope != SearchingScope.All) { accountItemsData = accountItemsData.Where(p => p.CreateTime.Date >= searchingConditionForAssociatedItemsForCurrentViewAccount.StartDate.Value.Date && p.CreateTime.Date <= searchingConditionForAssociatedItemsForCurrentViewAccount.EndDate.Value.Date); } accountItemsData = accountItemsData.OrderByDescending(p => p.Type) .OrderByDescending(p => p.CreateTime.Date); eachCount = accountItemsData.Count(); showRecordTips(eachCount, AppResources.SelectAccountItemsLabel); var dates = accountItemsData.Select(p => p.CreateTime.Date).Distinct().ToList(); foreach (var item in dates) { var agvm = new GroupByCreateTimeAccountItemViewModel(item); accountItemsData.Where(p => p.CreateTime.Date == item.Date) .ForEach(x => { var cx = new AccountItem(); cx.Account = x.Account; cx.Money = x.Money; cx.CreateTime = x.CreateTime; cx.Category = x.Category; cx.CategoryId = x.CategoryId; cx.Description = x.Description; cx.Id = x.Id; cx.State = x.State; cx.Type = x.Type; cx.TypeInfo = LocalizedStrings.GetLanguageInfoByKey(x.Type.ToString()); if (x.Type == ItemType.Expense) cx.Money = -x.Money; cx.SecondInfo = x.NameInfo; cx.PageNameGetter = PictureInfo.AccountItemsTag; cx.ThirdInfo = x.Description; agvm.Add(cx); //OnItemAdding(x); }); container.Add(agvm); } } if (searchingConditionForAssociatedItemsForCurrentViewAccount.DataType == AssociatedItemType.All || searchingConditionForAssociatedItemsForCurrentViewAccount.DataType == AssociatedItemType.TransferingAccount) { // load Transfering list. var transfering = ViewModelLocator.TransferingHistoryViewModel .AccountBookDataContext.TransferingItems.Where(p => (p.ToAccountId == itemCompareToCurrent.Id || p.FromAccountId == itemCompareToCurrent.Id) ); if (searchingConditionForAssociatedItemsForCurrentViewAccount.SearchingScope != SearchingScope.All) { transfering = transfering.Where(p => p.TransferingDate.Date >= searchingConditionForAssociatedItemsForCurrentViewAccount.StartDate.Value.Date && p.TransferingDate.Date <= searchingConditionForAssociatedItemsForCurrentViewAccount.EndDate.Value.Date); } transfering = transfering.OrderByDescending(p => p.TransferingDate.Date); eachCount = transfering.Count(); var exchange = AppResources.TransferingAccount; showRecordTips(eachCount, exchange); var dates = transfering.Select(p => p.TransferingDate.Date).Distinct().ToList(); foreach (var item in dates) { var agvm = container.FirstOrDefault(p => p.Key.Date == item.Date); bool hasToAdd = false; if (agvm == null) { hasToAdd = true; agvm = new GroupByCreateTimeAccountItemViewModel(item); } transfering.Where(p => p.TransferingDate.Date == item.Date) .ForEach(x => { var warp = new AccountItem(); warp.Account = itemCompareToCurrent; warp.TypeInfo = exchange; bool isOut = x.FromAccountId == itemCompareToCurrent.Id; warp.Money = isOut ? -x.Amount : x.Amount; var key = isOut ? (AppResources.RolloutToSomeAccountName.FormatWith(x.ToAccountName)) : (AppResources.TransferFromAccountName.FormatWith(x.FromAccountName)); warp.SecondInfo = key; warp.ThirdInfo = x.Notes; agvm.Add(warp); }); if (hasToAdd) container.Add(agvm); } } if (searchingConditionForAssociatedItemsForCurrentViewAccount.DataType == AssociatedItemType.All || searchingConditionForAssociatedItemsForCurrentViewAccount.DataType == AssociatedItemType.BorrowAndLean) { // load Transfering list. var borrowLoans = ViewModelLocator.BorrowLeanViewModel .AccountBookDataContext.Repayments.Where(p => (p.FromAccountId == itemCompareToCurrent.Id && p.RepaymentRecordType == RepaymentType.MoneyBorrowOrLeanRepayment)); if (searchingConditionForAssociatedItemsForCurrentViewAccount.SearchingScope != SearchingScope.All) { //borrowLoans = borrowLoans.Where(p => p.ExecuteDate.Value.Date >= searchingConditionForAssociatedItemsForCurrentViewAccount.StartDate.Value.Date // && ((DateTime)p.ExecuteDate).Date <= searchingConditionForAssociatedItemsForCurrentViewAccount.EndDate.Value.Date); } borrowLoans = borrowLoans.OrderByDescending(p => ((DateTime)p.ExecuteDate).Date); eachCount = borrowLoans.Count(); var borrowLoanName = AppResources.BorrowAndLean; showRecordTips(eachCount, borrowLoanName); var dates = borrowLoans.Select(p => p.ExecuteDate.Value.Date).Distinct().ToList(); foreach (var item in dates) { var agvm = container.FirstOrDefault(p => p.Key.Date == item.Date); bool hasToAdd = false; if (agvm == null) { hasToAdd = true; agvm = new GroupByCreateTimeAccountItemViewModel(item); } borrowLoans.Where(p => ((DateTime)p.ExecuteDate).Date == item.Date) .ForEach(x => { var warp = new AccountItem(); warp.Account = itemCompareToCurrent; warp.Id = x.Id; warp.TypeInfo = borrowLoanName; bool isOut = x.BorrowOrLean == LeanType.LoanOut || x.BorrowOrLean == LeanType.Repayment; warp.Money = isOut ? -x.Amount : x.Amount; var key = x.BorrowLoanInfoWithoutAmountInfo; warp.SecondInfo = key; warp.PageNameGetter = x.IsRepaymentOrReceieve ? "RepaymentsTableForReceieveOrPayBack" : "Repayments"; warp.ThirdInfo = x.Notes; agvm.Add(warp); }); if (hasToAdd) container.Add(agvm); } } Deployment.Current.Dispatcher.BeginInvoke(() => { container.OrderByDescending(p => p.Key).ToList() .ForEach(out_container.Add); }); return container; }
private string BuildGroupByMode(AccountItem ai, DuringMode mode) { var result = string.Empty; if (mode == DuringMode.ByMonth) { result = string.Format("{0}/{1}", ai.CreateTime.Year, ai.CreateTime.Month); } else if (mode == DuringMode.ByYear) { result = ai.CreateTime.Year.ToString(); } return result; }
/// <summary> /// Handles the account item adding for task. /// </summary> /// <param name="accountItem">The account item.</param> /// <param name="taskInfo">The task info.</param> public void HandleAccountItemAddingForTask(AccountItem accountItem, TallySchedule taskInfo) { if (taskInfo != null) { if (!taskInfo.PeopleIds.IsNullOrEmpty()) { // RecoverPeoples(accountItem, taskInfo); } if (!taskInfo.PictureIds.IsNullOrEmpty()) { // RecoverPicutres(accountItem, taskInfo); } } ViewModelLocator.AccountItemViewModel.AddItem(accountItem); ViewModelLocator.AccountViewModel.WithdrawlOrDeposit(accountItem.Account, (accountItem.Type == ItemType.Expense) ? -accountItem.Money : accountItem.Money); }