/// <summary> /// Adds a new record into the <c>CustomerAcctPayment</c> table. /// </summary> /// <param name="value">The <see cref="CustomerAcctPaymentRow"/> object to be inserted.</param> public virtual void Insert(CustomerAcctPaymentRow value) { string sqlStr = "INSERT INTO [dbo].[CustomerAcctPayment] (" + "[customer_acct_id], " + "[date_time], " + "[previous_amount], " + "[payment_amount], " + "[comments], " + "[person_id], " + "[balance_adjustment_reason_id]" + ") VALUES (" + _db.CreateSqlParameterName("Customer_acct_id") + ", " + _db.CreateSqlParameterName("Date_time") + ", " + _db.CreateSqlParameterName("Previous_amount") + ", " + _db.CreateSqlParameterName("Payment_amount") + ", " + _db.CreateSqlParameterName("Comments") + ", " + _db.CreateSqlParameterName("Person_id") + ", " + _db.CreateSqlParameterName("Balance_adjustment_reason_id") + ")"; IDbCommand cmd = _db.CreateCommand(sqlStr); AddParameter(cmd, "Customer_acct_id", value.Customer_acct_id); AddParameter(cmd, "Date_time", value.Date_time); AddParameter(cmd, "Previous_amount", value.Previous_amount); AddParameter(cmd, "Payment_amount", value.Payment_amount); AddParameter(cmd, "Comments", value.Comments); AddParameter(cmd, "Person_id", value.Person_id); AddParameter(cmd, "Balance_adjustment_reason_id", value.Balance_adjustment_reason_id); cmd.ExecuteNonQuery(); }
/// <summary> /// Converts <see cref="System.Data.DataRow"/> to <see cref="CustomerAcctPaymentRow"/>. /// </summary> /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param> /// <returns>A reference to the <see cref="CustomerAcctPaymentRow"/> object.</returns> protected virtual CustomerAcctPaymentRow MapRow(DataRow row) { CustomerAcctPaymentRow mappedObject = new CustomerAcctPaymentRow(); DataTable dataTable = row.Table; DataColumn dataColumn; // Column "Customer_acct_id" dataColumn = dataTable.Columns["Customer_acct_id"]; if (!row.IsNull(dataColumn)) { mappedObject.Customer_acct_id = (short)row[dataColumn]; } // Column "Date_time" dataColumn = dataTable.Columns["Date_time"]; if (!row.IsNull(dataColumn)) { mappedObject.Date_time = (System.DateTime)row[dataColumn]; } // Column "Previous_amount" dataColumn = dataTable.Columns["Previous_amount"]; if (!row.IsNull(dataColumn)) { mappedObject.Previous_amount = (decimal)row[dataColumn]; } // Column "Payment_amount" dataColumn = dataTable.Columns["Payment_amount"]; if (!row.IsNull(dataColumn)) { mappedObject.Payment_amount = (decimal)row[dataColumn]; } // Column "Comments" dataColumn = dataTable.Columns["Comments"]; if (!row.IsNull(dataColumn)) { mappedObject.Comments = (string)row[dataColumn]; } // Column "Person_id" dataColumn = dataTable.Columns["Person_id"]; if (!row.IsNull(dataColumn)) { mappedObject.Person_id = (int)row[dataColumn]; } // Column "Balance_adjustment_reason_id" dataColumn = dataTable.Columns["Balance_adjustment_reason_id"]; if (!row.IsNull(dataColumn)) { mappedObject.Balance_adjustment_reason_id = (int)row[dataColumn]; } return(mappedObject); }
/// <summary> /// Reads data from the provided data reader and returns /// an array of mapped objects. /// </summary> /// <param name="reader">The <see cref="System.Data.IDataReader"/> object to read data from the table.</param> /// <param name="startIndex">The index of the first record to map.</param> /// <param name="length">The number of records to map.</param> /// <param name="totalRecordCount">A reference parameter that returns the total number /// of records in the reader object if 0 was passed into the method; otherwise it returns -1.</param> /// <returns>An array of <see cref="CustomerAcctPaymentRow"/> objects.</returns> protected virtual CustomerAcctPaymentRow[] MapRecords(IDataReader reader, int startIndex, int length, ref int totalRecordCount) { if (0 > startIndex) { throw new ArgumentOutOfRangeException("startIndex", startIndex, "StartIndex cannot be less than zero."); } if (0 > length) { throw new ArgumentOutOfRangeException("length", length, "Length cannot be less than zero."); } int customer_acct_idColumnIndex = reader.GetOrdinal("customer_acct_id"); int date_timeColumnIndex = reader.GetOrdinal("date_time"); int previous_amountColumnIndex = reader.GetOrdinal("previous_amount"); int payment_amountColumnIndex = reader.GetOrdinal("payment_amount"); int commentsColumnIndex = reader.GetOrdinal("comments"); int person_idColumnIndex = reader.GetOrdinal("person_id"); int balance_adjustment_reason_idColumnIndex = reader.GetOrdinal("balance_adjustment_reason_id"); System.Collections.ArrayList recordList = new System.Collections.ArrayList(); int ri = -startIndex; while (reader.Read()) { ri++; if (ri > 0 && ri <= length) { CustomerAcctPaymentRow record = new CustomerAcctPaymentRow(); recordList.Add(record); record.Customer_acct_id = Convert.ToInt16(reader.GetValue(customer_acct_idColumnIndex)); record.Date_time = Convert.ToDateTime(reader.GetValue(date_timeColumnIndex)); record.Previous_amount = Convert.ToDecimal(reader.GetValue(previous_amountColumnIndex)); record.Payment_amount = Convert.ToDecimal(reader.GetValue(payment_amountColumnIndex)); record.Comments = Convert.ToString(reader.GetValue(commentsColumnIndex)); record.Person_id = Convert.ToInt32(reader.GetValue(person_idColumnIndex)); record.Balance_adjustment_reason_id = Convert.ToInt32(reader.GetValue(balance_adjustment_reason_idColumnIndex)); if (ri == length && 0 != totalRecordCount) { break; } } } totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1; return((CustomerAcctPaymentRow[])(recordList.ToArray(typeof(CustomerAcctPaymentRow)))); }
static CustomerAcctPaymentRow mapToCustomerAcctPaymentRow(CustomerAcctPaymentDto pCustomerAcctPayment) { var _customerAcctPaymentRow = new CustomerAcctPaymentRow { Date_time = pCustomerAcctPayment.DateTime, Customer_acct_id = pCustomerAcctPayment.CustomerAcctId, Previous_amount = pCustomerAcctPayment.PreviousAmount, Payment_amount = pCustomerAcctPayment.Amount, Comments = pCustomerAcctPayment.Comments, Balance_adjustment_reason_id = pCustomerAcctPayment.BalanceAdjustmentReasonId, Person_id = pCustomerAcctPayment.PersonId }; return(_customerAcctPaymentRow); }
/// <summary> /// Updates a record in the <c>CustomerAcctPayment</c> table. /// </summary> /// <param name="value">The <see cref="CustomerAcctPaymentRow"/> /// object used to update the table record.</param> /// <returns>true if the record was updated; otherwise, false.</returns> public virtual bool Update(CustomerAcctPaymentRow value) { string sqlStr = "UPDATE [dbo].[CustomerAcctPayment] SET " + "[previous_amount]=" + _db.CreateSqlParameterName("Previous_amount") + ", " + "[payment_amount]=" + _db.CreateSqlParameterName("Payment_amount") + ", " + "[comments]=" + _db.CreateSqlParameterName("Comments") + ", " + "[person_id]=" + _db.CreateSqlParameterName("Person_id") + ", " + "[balance_adjustment_reason_id]=" + _db.CreateSqlParameterName("Balance_adjustment_reason_id") + " WHERE " + "[customer_acct_id]=" + _db.CreateSqlParameterName("Customer_acct_id") + " AND " + "[date_time]=" + _db.CreateSqlParameterName("Date_time"); IDbCommand cmd = _db.CreateCommand(sqlStr); AddParameter(cmd, "Previous_amount", value.Previous_amount); AddParameter(cmd, "Payment_amount", value.Payment_amount); AddParameter(cmd, "Comments", value.Comments); AddParameter(cmd, "Person_id", value.Person_id); AddParameter(cmd, "Balance_adjustment_reason_id", value.Balance_adjustment_reason_id); AddParameter(cmd, "Customer_acct_id", value.Customer_acct_id); AddParameter(cmd, "Date_time", value.Date_time); return(0 != cmd.ExecuteNonQuery()); }
/// <summary> /// Deletes the specified object from the <c>CustomerAcctPayment</c> table. /// </summary> /// <param name="value">The <see cref="CustomerAcctPaymentRow"/> object to delete.</param> /// <returns>true if the record was deleted; otherwise, false.</returns> public bool Delete(CustomerAcctPaymentRow value) { return(DeleteByPrimaryKey(value.Customer_acct_id, value.Date_time)); }