Example #1
0
        public void RecordInvoiceTransaction(List<transaction> transactions, projectEnums.invoiceStatus invoiceStat)
        {
            if (INV.Equals(null))
                throw new Exception("Invoice does not exists");

            using (var ctx = new accountingEntities())
            using (var ts = new TransactionScope())
            {
                //create invoice Action
                var invAction = new invoiceAction()
                {
                    invoiceID = INV.ID,
                    invoiceStatusID = (int)invoiceStat
                };
                ctx.invoiceActions.AddObject(invAction);
                ctx.SaveChanges();

                //create invoice Transactions and invoice action Transactions
                foreach (var item in transactions)
                {
                    var invActionTrans = new sysActionTransaction()
                    {
                        sysActionID = invAction.ID,
                        transactionID = item.ID
                    };
                    ctx.sysActionTransactions.AddObject(invActionTrans);

                    ctx.SaveChanges();
                }

                ts.Complete();

            }
        }
 /// <summary>
 /// Create a new invoiceAction object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 public static invoiceAction CreateinvoiceAction(global::System.Int32 id)
 {
     invoiceAction invoiceAction = new invoiceAction();
     invoiceAction.ID = id;
     return invoiceAction;
 }
Example #3
0
        public void New(invoice inv)
        {
            INV = inv;

            using (var ctx = new accountingEntities())
            using (var ts = new TransactionScope())
            {
                //Entity
                var e = new entity{entityTypeID = (int)projectEnums.entityType.invoice};
                ctx.entities.AddObject(e);

                //New Invoice
                var newInvoice = new invoice()
                {
                    currencyID = inv.currencyID,
                    ID=e.ID
                };

                //sys Action
                var sysaction = new sysAction{sysActionTypeID=(int)projectEnums.sysAction.invoice};
                ctx.sysActions.AddObject(sysaction);

                //sys Action Invoice
                var sysActionInvoice = new invoiceAction
                {
                    ID = sysaction.ID,
                    invoiceStatusID= (int)projectEnums.invoiceStatus.Generated,
                    name="Invoice Generated at "+DateTime.Now.ToLongTimeString()
                };
                ctx.invoiceActions.AddObject(sysActionInvoice);

                ctx.SaveChanges();
                ts.Complete();
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the invoiceActions EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToinvoiceActions(invoiceAction invoiceAction)
 {
     base.AddObject("invoiceActions", invoiceAction);
 }