internal void UpdateLines(PaymentClasses.Payment Payment) { //Start the transaction. StartTransaction(); try { SqlCommand Cmd = GetCommand("PAY_Get_Payment_ID"); Payment.CopyTo(Cmd); Cmd.ExecuteNonQuery(); Payment.PaymentId = (int)Cmd.Parameters["@PaymentId"].Value; Cmd = GetCommand("PAY_Update_Item_AccountNumber"); for (int i = 0; i < Payment.LineItems.Count; i++) { Insert_Record(Cmd, Payment.PaymentId, Payment.LineItems[i]); } CompleteTransaction(true); } catch (SqlException e) { CompleteTransaction(false); if (e.Number != 50000) { throw; } throw new BusinessRuleException(e); } catch { CompleteTransaction(false); throw; } }
/// <summary> /// Inserts a record into the main payment table. /// </summary> /// <param name="Payment">The payment to insert.</param> /// <param name="IsNew">(bool) output parameter indicating if the record is new or already exists.</param> private int Insert_Payment(PaymentClasses.Payment Payment, out bool IsNew) { SqlCommand Cmd = GetCommand("PAY_Insert_Payment"); Payment.CopyTo(Cmd); Cmd.ExecuteNonQuery(); IsNew = (bool)Cmd.Parameters["@New"].Value; if (Cmd.Parameters["@ReceiptNumber"].Value != DBNull.Value) { Payment.ReceiptNumber = (string)Cmd.Parameters["@ReceiptNumber"].Value; } return((int)Cmd.Parameters["@PaymentId"].Value); }