当前位置: 首页>>代码示例>>C#>>正文


C# Transaction.Validate方法代码示例

本文整理汇总了C#中Transaction.Validate方法的典型用法代码示例。如果您正苦于以下问题:C# Transaction.Validate方法的具体用法?C# Transaction.Validate怎么用?C# Transaction.Validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Transaction的用法示例。


在下文中一共展示了Transaction.Validate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SerializeTransaction

        /// <summary>
        /// Serialize a Transaction object to an XML writer.
        /// </summary>
        /// <param name="xmlWriter">XmlWriter to serialize to.</param>
        public void SerializeTransaction( XmlWriter xmlWriter, Transaction trans )
        {
            xmlWriter.WriteStartElement( "Transaction" );

            // Write attributes
            xmlWriter.WriteAttributeString( "Id", trans.Id.ToString() );
            if( ( trans.Flags & TransactionFlags.Recurring ) != 0 )
            {
                xmlWriter.WriteAttributeString( "Recurring", "true" );
            }
            if( ( trans.Flags & TransactionFlags.Pending ) != 0 )
            {
                xmlWriter.WriteAttributeString( "Pending", "true" );
            }
            if( ( trans.Flags & TransactionFlags.Void ) != 0 )
            {
                xmlWriter.WriteAttributeString( "Void", "true" );
            }
            xmlWriter.WriteWhitespace( Environment.NewLine );

            trans.Validate();
            SerializeTransactionBody( xmlWriter, trans );

            xmlWriter.WriteEndElement(); // </Transaction>
        }
开发者ID:tkrehbiel,项目名称:UvMoney,代码行数:29,代码来源:LedgerStorageXml.cs

示例2: Merge

 /// <summary>
 /// Merges the transactions from another ledger into this ledger.
 /// </summary>
 /// <param name="newLedger">Ledger to merge transactions from.</param>
 public void Merge( Ledger newLedger )
 {
     foreach( Transaction trans in newLedger.Transactions )
     {
         Transaction newTrans = new Transaction();
         newTrans.Id = GetNextTransactionId();
         newTrans.Date = trans.Date;
         newTrans.Amount = trans.Amount;
         newTrans.Description = trans.Description;
         newTrans.Memo = trans.Memo;
         newTrans.Flags = trans.Flags;
         foreach( LineItem lineItem in trans.LineItems )
         {
             LineItem newLineItem = new LineItem();
             newLineItem.TransactionType = lineItem.TransactionType;
             newLineItem.Amount = lineItem.Amount;
             newLineItem.Memo = lineItem.Memo;
             newLineItem.Number = lineItem.Number;
             newLineItem.Account = GetAccount( lineItem.Account.AccountType, lineItem.Account.Name );
             if( lineItem.CategoryObject != null )
                 newLineItem.CategoryObject = newLineItem.Account.GetCategory( lineItem.CategoryObject.Name );
             newTrans.LineItems.Add( newLineItem );
         }
         newTrans.Validate();
         AddTransaction( newTrans );
     }
 }
开发者ID:tkrehbiel,项目名称:UvMoney,代码行数:31,代码来源:Ledger.cs

示例3: LoadTransaction


//.........这里部分代码省略.........
                            lineItemMemo = line.Substring( 1 );
                            break;
                        case '$':
                            // Split line item amount (like T above)
                            lineItemAmount = Decimal.Parse( line.Substring( 1 ) );
                            item = BuildLineItem( ledger, trans, lineItemCategory, lineItemMemo, lineItemAmount );
                            item.IsReconciled = isCleared;
                            trans.LineItems.Add( item );
                            break;

                        // Investment indicators

                        case 'Y':	// security name
                            investmentName = line.Substring( 1 );
                            break;
                        case 'I':	// price
                            investmentPrice = line.Substring( 1 );
                            break;
                        case 'Q':	// quantity (shares)
                            investmentShares = line.Substring( 1 );
                            break;
                        case 'O':	// commission
                            investmentCommission = line.Substring( 1 );
                            break;

                        default:
                            // Unrecognized - ignore
                            break;
                    }

                    lineNumber++;
                }	// while

                if( trans.LineItems.Count > 0 )
                {
                    // Transaction had splits.
                    // Add the transaction amount as the final split.
                    item = BuildLineItem( ledger, trans, transCategory, trans.Memo, -transAmount );
                    item.Number = checkNumber;
                    item.Account = account;
                    item.CategoryObject = null;
                    item.IsReconciled = isCleared;
                    trans.LineItems.Add( item );
                    // Adjust total transaction amount.
                    trans.Amount = trans.GetCreditLineItemSum();
                }
                else
                {
                    // No splits. Must create a matching debit and credit.
                    Account otherAccount;
                    Category otherCategory;
                    otherAccount = ParseAccount( ledger, transCategory, transAmount, out otherCategory );
                    if( transAmount < 0 )
                    {
                        // Withdrawal
                        item = trans.CreateLineItem( TransactionType.Credit, account, Math.Abs( transAmount ), null );
                        item.Number = checkNumber;
                        item.IsReconciled = isCleared;
                        trans.LineItems.Add( item );
                        item = trans.CreateLineItem( TransactionType.Debit, otherAccount, Math.Abs( transAmount ), otherCategory );
                        trans.LineItems.Add( item );
                    }
                    else
                    {
                        // Deposit
                        item = trans.CreateLineItem( TransactionType.Credit, otherAccount, Math.Abs( transAmount ), otherCategory );
                        trans.LineItems.Add( item );
                        item = trans.CreateLineItem( TransactionType.Debit, account, Math.Abs( transAmount ), null );
                        item.IsReconciled = isCleared;
                        trans.LineItems.Add( item );
                    }
                }

                trans.LineItems.Sort();
                trans.Validate();

                // Special case "Opening Balance" line:
                if( trans.Description == "Opening Balance" && account.GetLineItems().Count == 0 )
                {
                    // The account name is given in the category
                    account.Name = transCategory.Trim( '[', ']' );
                    account.StartingBalance = account.IsLiability ? -transAmount : transAmount;
                    account.StartingDate = trans.Date;
                }
                else
                {
                    trans.Id = ledger.GetNextTransactionId();
                    ledger.AddTransaction( trans );
                }
            }
            catch( Exception ex )
            {
                // Don't add broken transactions
                Console.WriteLine( "Error on line number " + lineNumber.ToString() );
                Console.WriteLine( ex.ToString() );
                throw;
            }

            return lineNumber;
        }
开发者ID:tkrehbiel,项目名称:UvMoney,代码行数:101,代码来源:LedgerStorageQif.cs


注:本文中的Transaction.Validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。