Exemplo n.º 1
0
        private void newBalance(LineItemRow row, decimal newAmount, bool newCD)
        {
            if (newAmount < 0.0m)
            {
                newAmount = Decimal.Negate(newAmount);
                newCD     = !newCD;
            }

            newAmount = Decimal.Round(newAmount, 2);

            if (row.amount != newAmount)
            {
                row.amount = newAmount;
            }

            if (row.creditDebit != newCD)
            {
                row.creditDebit = newCD;
            }

            if (newCD == LineCD.CREDIT)
            {
                row.creditAmount = newAmount;
                row.SetdebitAmountNull();
            }
            else
            {
                row.debitAmount = newAmount;
                row.SetcreditAmountNull();
            }
        }
Exemplo n.º 2
0
        private void LineItem_TableNewRow(object sender, System.Data.DataTableNewRowEventArgs e)
        {
            int         maxTransID = 0;
            LineItemRow newLine    = e.Row as LineItemRow;

            foreach (LineItemRow row in this.LineItem)
            {
                if (row.transactionID > maxTransID)
                {
                    maxTransID = row.transactionID;
                }
            }

            if (maxTransID >= this.TransactionID)
            {
                newLine.transactionID = maxTransID + 1;
            }
            else
            {
                newLine.transactionID = this.TransactionID;
            }

            newLine.id                 = this.LineItemID++;
            newLine.description        = "";
            newLine.confirmationNumber = "";
        }
Exemplo n.º 3
0
        private void LineItem_ColumnChanged(object sender, System.Data.DataColumnChangeEventArgs e)
        {
            if (stayOut)
            {
                return;
            }
            else
            {
                stayOut = true;
            }

            LineItemRow row = e.Row as LineItemRow;

            if (e.Column == this.LineItem.creditAmountColumn)
            {
                decimal newAmount = Convert.ToDecimal(e.ProposedValue);
                newBalance(row, newAmount, LineCD.CREDIT);
            }
            else if (e.Column == this.LineItem.debitAmountColumn)
            {
                decimal newAmount = Convert.ToDecimal(e.ProposedValue);
                newBalance(row, newAmount, LineCD.DEBIT);
            }

            stayOut = false;
        }
Exemplo n.º 4
0
            private void LineItemDataTable_ColumnChanged(object sender, DataColumnChangeEventArgs e)
            {
                if (stayOut)
                {
                    return;
                }

                stayOut = true;
                LineItemRow row = e.Row as LineItemRow;

                switch (e.Column.ColumnName)
                {
                case "amount":
                    // Do not accept negative numbers in this column
                    if (row.amount < 0)
                    {
                        row.amount = decimal.Negate(row.amount);
                    }

                    // Keep only to the penny.
                    row.amount = decimal.Round(row.amount, 2);
                    break;

                case "complete":
                    string tmp = e.ProposedValue as string;
                    if (tmp.Length > 1)
                    {
                        row.complete = tmp.Substring(0, 1);
                    }
                    break;
                }

                stayOut = false;
            }
Exemplo n.º 5
0
        public void mySetEnvelopeID(LineItemRow line)
        {
            if (!line.AccountRowByFK_Line_accountID.envelopes)
            {
                line.envelopeID = SpclEnvelope.NULL;
            }

            else
            {
                int count = 0;
                int eID   = SpclEnvelope.NULL;

                foreach (EnvelopeLineRow row in this.EnvelopeLine)
                {
                    if (row.RowState != DataRowState.Deleted && row.lineItemID == line.id)
                    {
                        count++;
                        eID = row.envelopeID;
                    }
                }

                if (count > 1)
                {
                    line.envelopeID = SpclEnvelope.SPLIT;
                }
                else
                {
                    line.envelopeID = eID;
                }
            }
        }
Exemplo n.º 6
0
        private TransactionDataSet.LineItemRow myNewTransaction(LineItemRow rLine)
        {
            stayOut = true;

            TransactionDataSet.LineItemRow tLine = this.tDataSet.LineItem.NewLineItemRow();

            // Initially assume this is a single line transaction.
            tLine.id                 = rLine.id;
            tLine.transactionID      = rLine.transactionID;
            tLine.date               = rLine.date;
            tLine.typeID             = rLine.typeID;
            tLine.description        = rLine.description;
            tLine.confirmationNumber = rLine.confirmationNumber;
            tLine.complete           = rLine.complete;
            tLine.amount             = rLine.amount;
            tLine.creditDebit        = rLine.creditDebit;
            tLine.accountID          = rLine.accountID;
            tLine.oppAccountID       = rLine.oppAccountID;

            if (tLine.envelopeID != rLine.envelopeID)
            {
                this.myChangeEnvelopeID(ref tLine, rLine.envelopeID);
            }

            this.tDataSet.LineItem.AddLineItemRow(tLine);

            // if not a sigle line make the other half.
            if (rLine.accountID != rLine.oppAccountID)
            {
                TransactionDataSet.LineItemRow tOppLine = this.tDataSet.LineItem.NewLineItemRow();

                tOppLine.id                 = rLine.id + 1;
                tOppLine.transactionID      = rLine.transactionID;
                tOppLine.date               = rLine.date;
                tOppLine.typeID             = rLine.typeID;
                tOppLine.description        = rLine.description;
                tOppLine.confirmationNumber = rLine.confirmationNumber;
                tOppLine.complete           = rLine.complete;
                tOppLine.amount             = rLine.amount;
                tOppLine.creditDebit        = !rLine.creditDebit;
                tOppLine.oppAccountID       = rLine.accountID;
                tOppLine.accountID          = rLine.oppAccountID;

                if (tLine.envelopeID != rLine.envelopeID)
                {
                    this.myChangeEnvelopeID(ref tOppLine, rLine.envelopeID);
                }

                this.tDataSet.LineItem.AddLineItemRow(tOppLine);
            }

            stayOut = false;
            return(tLine);
        }
Exemplo n.º 7
0
        public void mySaveSingleLineEdits(int lineID)
        {
            LineItemRow line = this.LineItem.FindByid(lineID);

            this.tDataSet.myFillLineItemAndSubLine(line.transactionID);

            this.myForwardLineEdits(line);

            this.tDataSet.mySaveChanges();
            this.myCalcBalance();
            this.LineItem.AcceptChanges();
        }
Exemplo n.º 8
0
        private void e_Finder_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                throw new Exception("Finding Transaction error exception", e.Error);
            }

            if (stayOut)
            {
                return;
            }
            else
            {
                stayOut = true;
            }

            foreach (int lineID in e_LineErrors)
            {
                LineItemRow line = this.LineItem.FindByid(lineID);
                if (line.RowState == System.Data.DataRowState.Unchanged)
                {
                    line.lineError = true;
                    line.AcceptChanges();
                }
                else
                {
                    line.lineError = true;
                }
            }

            foreach (int lineID in e_TransactionErrors)
            {
                LineItemRow line = this.LineItem.FindByid(lineID);
                if (line.RowState == System.Data.DataRowState.Unchanged)
                {
                    line.transactionError = true;
                    line.AcceptChanges();
                }
                else
                {
                    line.transactionError = true;
                }
            }

            this.OnErrorsFound(new EventArgs());
            stayOut = false;
        }
Exemplo n.º 9
0
        private void myGetLineEdits(int transID)
        {
            stayOut = true;

            for (int index = 0; index < this.LineItem.Rows.Count; index++)
            {
                LineItemRow rLine = this.LineItem[index];
                bool        found = false;

                if (rLine.transactionID != transID)
                {
                    continue;
                }

                foreach (TransactionDataSet.LineItemRow tLine in this.tDataSet.LineItem)
                {
                    if (tLine.id == rLine.id)
                    {
                        found = true;

                        rLine.date               = tLine.date;
                        rLine.typeID             = tLine.typeID;
                        rLine.accountID          = tLine.accountID;
                        rLine.oppAccountID       = tLine.oppAccountID;
                        rLine.description        = tLine.description;
                        rLine.confirmationNumber = tLine.confirmationNumber;
                        rLine.envelopeID         = tLine.envelopeID;
                        rLine.complete           = tLine.complete;
                        rLine.amount             = tLine.amount;
                        rLine.creditDebit        = tLine.creditDebit;
                        rLine.lineError          = tLine.lineError;
                        rLine.transactionError   = this.tDataSet.TransactionError;
                    }
                }

                if (!found)
                {
                    rLine.Delete();
                    index--;
                }
            }

            stayOut = false;
        }
Exemplo n.º 10
0
            /////////////////////////
            //   Internal Events
            private void LineItemDataTable_TableNewRow(object sender, System.Data.DataTableNewRowEventArgs e)
            {
                stayOut = true;
                LineItemRow newRow = e.Row as LineItemRow;

                newRow.id = newLineID++;
                //newRow.transactionID = this.transactionID;
                newRow.date               = DateTime.Now.Date;
                newRow.typeID             = SpclLineType.NULL;
                newRow.accountID          = SpclAccount.NULL;
                newRow.oppAccountID       = SpclAccount.NULL;
                newRow.description        = "";
                newRow.confirmationNumber = "";
                newRow.envelopeID         = SpclEnvelope.NULL;
                newRow.complete           = LineState.PENDING;
                newRow.amount             = 0.0m;
                newRow.creditDebit        = LineCD.CREDIT;
                newRow.lineError          = false;

                stayOut = false;
            }
Exemplo n.º 11
0
        private void LineItem_TableNewRow(object sender, System.Data.DataTableNewRowEventArgs e)
        {
            stayOut = true;
            LineItemRow newLine = e.Row as LineItemRow;

            newLine.id                 = DBquery.getNewID("id", "LineItem");
            newLine.transactionID      = DBquery.getNewID("transactionID", "LineItem");
            newLine.date               = DateTime.Today;
            newLine.typeID             = SpclLineType.NULL;
            newLine.accountID          = currentAccountID;
            newLine.oppAccountID       = SpclAccount.NULL;
            newLine.description        = "";
            newLine.confirmationNumber = "";
            newLine.envelopeID         = SpclEnvelope.NULL;
            newLine.complete           = LineState.PENDING;
            newLine.amount             = 0.00m;
            newLine.creditDebit        = LineCD.CREDIT;
            newLine.lineError          = false;
            newLine.transactionError   = false;

            stayOut = false;
        }
Exemplo n.º 12
0
        ////////////////////////////////////////////////////////////////////////////////////////////
        //   Private Duplicating a transaction
        ////////////////////////////////////////////////////////////////////////////////////////////
        private void myDuplicateTransaction(DateTime newDate)
        {
            LineItemRow temp = this.LineItem.NewLineItemRow();

            int newTransID = temp.transactionID;
            int transSize  = this.tDataSet.LineItem.Count;
            int envCount   = this.tDataSet.EnvelopeLine.Count;

            // Copy the lines from this transaction.
            for (int tIndex = 0; tIndex < transSize; tIndex++)
            {
                TransactionDataSet.LineItemRow origTLine = this.tDataSet.LineItem[tIndex];
                TransactionDataSet.LineItemRow newTLine  = this.tDataSet.LineItem.NewLineItemRow();

                newTLine.transactionID      = newTransID;
                newTLine.date               = newDate;
                newTLine.typeID             = origTLine.typeID;
                newTLine.accountID          = origTLine.accountID;
                newTLine.oppAccountID       = origTLine.oppAccountID;
                newTLine.description        = origTLine.description;
                newTLine.confirmationNumber = origTLine.confirmationNumber;
                newTLine.envelopeID         = origTLine.envelopeID;
                newTLine.complete           = LineState.PENDING;
                newTLine.amount             = origTLine.amount;
                newTLine.creditDebit        = origTLine.creditDebit;
                newTLine.lineError          = origTLine.lineError;

                this.tDataSet.LineItem.AddLineItemRow(newTLine);

                // Copy the envelopelines for this line.
                for (int envIndex = 0; envIndex < envCount; envIndex++)
                {
                    TransactionDataSet.EnvelopeLineRow origEnvRow = this.tDataSet.EnvelopeLine[envIndex];

                    if (origEnvRow.lineItemID == origTLine.id)
                    {
                        TransactionDataSet.EnvelopeLineRow newEnvRow = this.tDataSet.EnvelopeLine.NewEnvelopeLineRow();

                        newEnvRow.lineItemID  = newTLine.id;
                        newEnvRow.envelopeID  = origEnvRow.envelopeID;
                        newEnvRow.description = origEnvRow.description;
                        newEnvRow.amount      = origEnvRow.amount;

                        this.tDataSet.EnvelopeLine.AddEnvelopeLineRow(newEnvRow);
                    }
                }
            }

            // now copy back to the registry dataset
            for (int tIndex = transSize; tIndex < this.tDataSet.LineItem.Rows.Count; tIndex++)
            {
                TransactionDataSet.LineItemRow tLine = this.tDataSet.LineItem[tIndex];

                if (tLine.accountID == currentAccountID)
                {
                    LineItemRow rLine = this.LineItem.NewLineItemRow();

                    rLine.id                 = tLine.id;
                    rLine.transactionID      = tLine.transactionID;
                    rLine.date               = tLine.date;
                    rLine.typeID             = tLine.typeID;
                    rLine.accountID          = tLine.accountID;
                    rLine.oppAccountID       = tLine.oppAccountID;
                    rLine.description        = tLine.description;
                    rLine.confirmationNumber = tLine.confirmationNumber;
                    rLine.envelopeID         = tLine.envelopeID;
                    rLine.complete           = tLine.complete;
                    rLine.amount             = tLine.amount;
                    rLine.creditDebit        = tLine.creditDebit;
                    rLine.lineError          = tLine.lineError;

                    this.LineItem.AddLineItemRow(rLine);
                }
            }
        }
Exemplo n.º 13
0
        ////////////////////////////////////////////////////////////////////////////////////////////
        //   Private Forwarding line edits
        ////////////////////////////////////////////////////////////////////////////////////////////
        private void myForwardLineEdits(LineItemRow rLine)
        {
            TransactionDataSet.LineItemRow tLine = this.tDataSet.LineItem.FindByid(rLine.id);

            if (tLine == null)
            {
                tLine = this.myNewTransaction(rLine);
            }

            else
            {
                // Copy the simple items.
                if (tLine.date != rLine.date)
                {
                    tLine.date = rLine.date;
                }

                if (tLine.typeID != rLine.typeID)
                {
                    tLine.typeID = rLine.typeID;
                }

                if (tLine.description != rLine.description)
                {
                    tLine.description = rLine.description;
                }

                if (tLine.confirmationNumber != rLine.confirmationNumber)
                {
                    tLine.confirmationNumber = rLine.confirmationNumber;
                }

                if (tLine.complete != rLine.complete)
                {
                    tLine.complete = rLine.complete;
                }

                // The following affect other lines / envelopeLines
                if (tLine.oppAccountID != rLine.oppAccountID)
                {
                    this.myChangeOppAccountID(ref tLine, rLine.oppAccountID);
                }

                if (tLine.creditDebit != rLine.creditDebit)
                {
                    this.myChangeCreditDebit(ref tLine);
                }

                if (tLine.amount != rLine.amount)
                {
                    this.myChangeAmount(ref tLine, rLine.amount);
                }

                if (tLine.accountID != rLine.accountID)
                {
                    this.myChangeAccountID(ref tLine, rLine.accountID);
                }

                if (tLine.envelopeID != rLine.envelopeID)
                {
                    this.myChangeEnvelopeID(ref tLine, rLine.envelopeID);
                }
            }

            // Update the error flags
            this.tDataSet.myCheckTransaction();

            this.stayOut = true;

            rLine.transactionError = this.tDataSet.TransactionError;
            rLine.lineError        = tLine.lineError;

            this.stayOut = false;
        }