/// <summary>
        /// Change a payment.
        /// </summary>
        /// <param name="pay"></param>
        /// <param name="amount"></param>
        /// <param name="docID"></param>
        /// <param name="ptID"></param>
        /// <param name="date">Optional, null to ignore</param>
        public void changePayment(payment pay, decimal amount, int docID, int ptID, DateTime date)
        {
            pay.payAmount = amount;
            pay.docID = docID;
            pay.ptID = ptID;
            if (date != null)
            {
                pay.payDate = date;
            }

            saveChanges();
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the payments EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTopayments(payment payment)
 {
     base.AddObject("payments", payment);
 }
 /// <summary>
 /// Create a new payment object.
 /// </summary>
 /// <param name="payID">Initial value of the payID property.</param>
 /// <param name="payAmount">Initial value of the payAmount property.</param>
 /// <param name="payDate">Initial value of the payDate property.</param>
 /// <param name="ptID">Initial value of the ptID property.</param>
 /// <param name="patID">Initial value of the patID property.</param>
 /// <param name="docID">Initial value of the docID property.</param>
 public static payment Createpayment(global::System.Int32 payID, global::System.Decimal payAmount, global::System.DateTime payDate, global::System.Int32 ptID, global::System.Int32 patID, global::System.Int32 docID)
 {
     payment payment = new payment();
     payment.payID = payID;
     payment.payAmount = payAmount;
     payment.payDate = payDate;
     payment.ptID = ptID;
     payment.patID = patID;
     payment.docID = docID;
     return payment;
 }
        public int insertPayment(decimal amount, int paymentType, int patID, int docID, DateTime date)
        {
            payment p = new payment();

            p.payAmount = amount;
            p.payVoid = false;
            p.payDate = date;
            p.ptID = paymentType;
            p.patID = patID;
            p.docID = docID;

            Context.AddTopayments(p);
            saveChanges();

            return p.payID;
        }