private void AddEntryToList(string account, decimal debit, decimal credit) { List <DebitAccountEntry> ThisDebitAccountEntryList = PageVariables.theDebitAccountEntrylist; DebitAccountEntry sameDebitAccounEntry = (from debitAccount in ThisDebitAccountEntryList where debitAccount.AccountName == account select debitAccount).SingleOrDefault(); DebitAccountEntry theDebitAccountEntry = new DebitAccountEntry(); if (sameDebitAccounEntry != null) { sameDebitAccounEntry.Debit = sameDebitAccounEntry.Debit + debit; } else { theDebitAccountEntry.AccountName = account; theDebitAccountEntry.Debit = debit; theDebitAccountEntry.Credit = credit; if (ThisDebitAccountEntryList.Count > 1) { ThisDebitAccountEntryList.Insert(ThisDebitAccountEntryList.Count - 1, theDebitAccountEntry); } else { ThisDebitAccountEntryList.Add(theDebitAccountEntry); } } gView_DebitVoucher.DataSource = ThisDebitAccountEntryList; gView_DebitVoucher.DataBind(); }
private void ResetCashAccount_CreditAmount() { PageVariables.TotalDebitAmount = 0; PageVariables.TotalDebitAmount = PageVariables.theDebitAccountEntrylist.Select(thedebitAccountEntry => thedebitAccountEntry.Debit).Sum(); DebitAccountEntry LastDebitAccount = PageVariables.theDebitAccountEntrylist.LastOrDefault(); LastDebitAccount.Credit = PageVariables.TotalDebitAmount; gView_DebitVoucher.DataSource = PageVariables.theDebitAccountEntrylist; gView_DebitVoucher.DataBind(); HighlightCashAccountRow(); }