private void myChangeEnvelopeID(ref TransactionDataSet.LineItemRow lineBeingChange, int newEnvelopeID) { int envCount; int eLineID; lineBeingChange.envelopeID = newEnvelopeID; // Now update the envelopeLine If there is only one with the new envelopeID; this.tDataSet.EnvelopeLine.myEnvelopeLineCount(lineBeingChange.id, out envCount, out eLineID); if (envCount == 1 && newEnvelopeID > SpclEnvelope.NULL) { this.tDataSet.EnvelopeLine.FindByid(eLineID).envelopeID = newEnvelopeID; } else if (envCount == 1 && newEnvelopeID == SpclEnvelope.NULL) { this.tDataSet.EnvelopeLine.FindByid(eLineID).Delete(); } else if (envCount == 0 && newEnvelopeID > SpclEnvelope.NULL) { TransactionDataSet.EnvelopeLineRow eLine = this.tDataSet.EnvelopeLine.NewEnvelopeLineRow(); eLine.lineItemID = lineBeingChange.id; eLine.envelopeID = newEnvelopeID; eLine.description = lineBeingChange.description; eLine.amount = lineBeingChange.amount; this.tDataSet.EnvelopeLine.AddEnvelopeLineRow(eLine); } }
private void myChangeAccountID(ref TransactionDataSet.LineItemRow lineBeingChange, int newAccountID) { int thisSideCount = 0; // Count how many lines have the same creditDebit as the line. foreach (TransactionDataSet.LineItemRow oppLine in this.tDataSet.LineItem) { if (oppLine.creditDebit == lineBeingChange.creditDebit) { thisSideCount++; } } // If thisSide has only one line (the given line) then update the oppLines.oppAccountID with the new // accountID if (thisSideCount == 1) { foreach (TransactionDataSet.LineItemRow oppLine in this.tDataSet.LineItem) { if (oppLine.creditDebit != lineBeingChange.creditDebit) { oppLine.oppAccountID = newAccountID; } } } // Make the change to the one being changed. lineBeingChange.accountID = newAccountID; }
private void myChangeOppAccountID(ref TransactionDataSet.LineItemRow lineBeingChange, int newOppAccountID) { int oppLineCount = 0; // Count how many lines are opposite this line. foreach (TransactionDataSet.LineItemRow oppLine in this.tDataSet.LineItem) { if (oppLine.creditDebit != lineBeingChange.creditDebit) { oppLineCount++; } } // If oppLine is only one then update all the lines. The lines on the same saide as the one // getting the update get there oppAccount ids updated. Then the line opposite the one being // changed will get its accountID changed. if (oppLineCount == 1) { foreach (TransactionDataSet.LineItemRow sameSideLine in this.tDataSet.LineItem) { if (sameSideLine.creditDebit == lineBeingChange.creditDebit) { sameSideLine.oppAccountID = newOppAccountID; } else { sameSideLine.accountID = newOppAccountID; } } } }
private void myChangeCreditDebit(ref TransactionDataSet.LineItemRow lineBeingChange) { int thisSideCount = 0; int oppLineCount = 0; // Count how many lines have the same creditDebit as the line and how many lines // are opposite this line. foreach (TransactionDataSet.LineItemRow oppLine in this.tDataSet.LineItem) { if (oppLine.creditDebit == lineBeingChange.creditDebit) { thisSideCount++; } else { oppLineCount++; } } // If this is a simple transaction update both creditDebits if (thisSideCount == 1 && oppLineCount == 1) { this.tDataSet.LineItem[0].creditDebit = !this.LineItem[0].creditDebit; this.tDataSet.LineItem[1].creditDebit = !this.LineItem[1].creditDebit; } else // else just update the lineBeingchanged { lineBeingChange.creditDebit = !lineBeingChange.creditDebit; } }
//////////////////////////////////////////////////////////////////////////////////////////// // Data Grid View events //////////////////////////////////////////////////////////////////////////////////////////// private void cdDGV_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e) { CDLinesDGV lineDGV = sender as CDLinesDGV; int lineID = -1; // Defaults. Used for new lines. lineDGV.flagLineError = false; lineDGV.flagAccountError = false; // try to get the current row lineID try { lineID = Convert.ToInt32(lineDGV["lineItemIDColumn", e.RowIndex].Value); } catch { return; } TransactionDataSet.LineItemRow thisLine = this.tDataSet.LineItem.FindByid(lineID); // Set Flags if (thisLine != null) { bool thisLineUsesEnvelopes = thisLine.AccountRowByFK_Line_accountID.envelopes; lineDGV.flagLineError = thisLine.lineError; if (thisLine.accountID == SpclAccount.NULL) { lineDGV.flagAccountError = true; } //if (thisLine.envelopeID == SpclEnvelope.SPLIT || !thisLineUsesEnvelopes) // lineDGV.flagReadOnlyEnvelope = true; } }
private void myChangeAmount(ref TransactionDataSet.LineItemRow lineBeingChange, decimal newAmount) { int thisSideCount = 0; int oppLineCount = 0; int envCount; int eLineID; // Count how many lines have the sam creditDebit as the line and how many lines // are opposite this line. foreach (TransactionDataSet.LineItemRow oppLine in this.tDataSet.LineItem) { if (oppLine.creditDebit == lineBeingChange.creditDebit) { thisSideCount++; } else { oppLineCount++; } } // If this is a simple transaction update both amounts if (thisSideCount == 1 && oppLineCount == 1) { this.tDataSet.LineItem[0].amount = newAmount; this.tDataSet.LineItem[1].amount = newAmount; // Now update the envelopeLines with the new amount; this.tDataSet.EnvelopeLine.myEnvelopeLineCount(this.tDataSet.LineItem[0].id, out envCount, out eLineID); if (envCount == 1) { this.tDataSet.EnvelopeLine.FindByid(eLineID).amount = newAmount; } this.tDataSet.EnvelopeLine.myEnvelopeLineCount(this.tDataSet.LineItem[1].id, out envCount, out eLineID); if (envCount == 1) { this.tDataSet.EnvelopeLine.FindByid(eLineID).amount = newAmount; } } // else just update the lineBeingchanged else { lineBeingChange.amount = newAmount; // Now update the envelopeLines with the new amount; this.tDataSet.EnvelopeLine.myEnvelopeLineCount(lineBeingChange.id, out envCount, out eLineID); if (envCount == 1) { this.tDataSet.EnvelopeLine.FindByid(eLineID).amount = newAmount; } } }
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); }
private void changeLineMenu_Click(object sender, EventArgs e) { TransactionDataSet.LineItemRow line = this.tDataSet.LineItem.FindByid(this.CurrentLineID); if (line != null) { bool cd = line.creditDebit; line.creditDebit = !cd; } myResetValues(); }
//////////////////////////////////////////////////////////////////////////////////////////// // Data table events //////////////////////////////////////////////////////////////////////////////////////////// private void LineItem_TableNewRow(object sender, DataTableNewRowEventArgs e) { decimal debitSum; decimal creditSum; decimal difference; TransactionDataSet.LineItemRow line = e.Row as TransactionDataSet.LineItemRow; this.tDataSet.myCheckTransaction(); this.tDataSet.myGetCDSums(out creditSum, out debitSum); if (this.creditDGV.Focused) { line.creditDebit = LineCD.CREDIT; difference = debitSum - creditSum; } else if (this.debitDGV.Focused) { line.creditDebit = LineCD.DEBIT; difference = creditSum - debitSum; } else { return; } line.transactionID = this.thisTransactionID; if (difference > 0.0m) { line.amount = difference; } else { line.amount = 0.0m; } myResetValues(); }
//////////////////////////////////////////////////////////////////////////////////////////// // 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); } } }
//////////////////////////////////////////////////////////////////////////////////////////// // 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; }