/// <summary>
        /// Updates a record in the <c>RetailAccountPayment</c> table.
        /// </summary>
        /// <param name="value">The <see cref="RetailAccountPaymentRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(RetailAccountPaymentRow value)
        {
            string sqlStr = "UPDATE [dbo].[RetailAccountPayment] SET " +
                            "[previous_amount]=" + _db.CreateSqlParameterName("Previous_amount") + ", " +
                            "[payment_amount]=" + _db.CreateSqlParameterName("Payment_amount") + ", " +
                            "[previous_bonus_minutes]=" + _db.CreateSqlParameterName("Previous_bonus_minutes") + ", " +
                            "[added_bonus_minutes]=" + _db.CreateSqlParameterName("Added_bonus_minutes") + ", " +
                            "[comments]=" + _db.CreateSqlParameterName("Comments") + ", " +
                            "[person_id]=" + _db.CreateSqlParameterName("Person_id") + ", " +
                            "[balance_adjustment_reason_id]=" + _db.CreateSqlParameterName("Balance_adjustment_reason_id") + ", " +
                            "[cdr_key]=" + _db.CreateSqlParameterName("Cdr_key") +
                            " WHERE " +
                            "[retail_acct_id]=" + _db.CreateSqlParameterName("Retail_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, "Previous_bonus_minutes", value.Previous_bonus_minutes);
            AddParameter(cmd, "Added_bonus_minutes", value.Added_bonus_minutes);
            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, "Cdr_key", value.Cdr_key);
            AddParameter(cmd, "Retail_acct_id", value.Retail_acct_id);
            AddParameter(cmd, "Date_time", value.Date_time);
            return(0 != cmd.ExecuteNonQuery());
        }
        /// <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="RetailAccountPaymentRow"/> objects.</returns>
        protected virtual RetailAccountPaymentRow[] 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 retail_acct_idColumnIndex         = reader.GetOrdinal("retail_acct_id");
            int date_timeColumnIndex              = reader.GetOrdinal("date_time");
            int previous_amountColumnIndex        = reader.GetOrdinal("previous_amount");
            int payment_amountColumnIndex         = reader.GetOrdinal("payment_amount");
            int previous_bonus_minutesColumnIndex = reader.GetOrdinal("previous_bonus_minutes");
            int added_bonus_minutesColumnIndex    = reader.GetOrdinal("added_bonus_minutes");
            int commentsColumnIndex  = reader.GetOrdinal("comments");
            int person_idColumnIndex = reader.GetOrdinal("person_id");
            int balance_adjustment_reason_idColumnIndex = reader.GetOrdinal("balance_adjustment_reason_id");
            int cdr_keyColumnIndex = reader.GetOrdinal("cdr_key");

            System.Collections.ArrayList recordList = new System.Collections.ArrayList();
            int ri = -startIndex;

            while (reader.Read())
            {
                ri++;
                if (ri > 0 && ri <= length)
                {
                    RetailAccountPaymentRow record = new RetailAccountPaymentRow();
                    recordList.Add(record);

                    record.Retail_acct_id         = Convert.ToInt32(reader.GetValue(retail_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.Previous_bonus_minutes = Convert.ToInt16(reader.GetValue(previous_bonus_minutesColumnIndex));
                    record.Added_bonus_minutes    = Convert.ToInt16(reader.GetValue(added_bonus_minutesColumnIndex));
                    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));
                    record.Cdr_key = Convert.ToString(reader.GetValue(cdr_keyColumnIndex));

                    if (ri == length && 0 != totalRecordCount)
                    {
                        break;
                    }
                }
            }

            totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1;
            return((RetailAccountPaymentRow[])(recordList.ToArray(typeof(RetailAccountPaymentRow))));
        }
Exemple #3
0
        static RetailAccountPaymentDto mapToRetailAccountPayment(RetailAccountPaymentRow pRetailAccountPaymentRow, PersonDto pPerson, BalanceAdjustmentReasonDto pBalanceAdjustmentReason)
        {
            var _retailAccountPayment = new RetailAccountPaymentDto();

            _retailAccountPayment.DateTime                = pRetailAccountPaymentRow.Date_time;
            _retailAccountPayment.RetailAcctId            = pRetailAccountPaymentRow.Retail_acct_id;
            _retailAccountPayment.PreviousAmount          = pRetailAccountPaymentRow.Previous_amount;
            _retailAccountPayment.Amount                  = pRetailAccountPaymentRow.Payment_amount;
            _retailAccountPayment.PreviousBonusMinutes    = pRetailAccountPaymentRow.Previous_bonus_minutes;
            _retailAccountPayment.AddedBonusMinutes       = pRetailAccountPaymentRow.Added_bonus_minutes;
            _retailAccountPayment.Comments                = pRetailAccountPaymentRow.Comments;
            _retailAccountPayment.BalanceAdjustmentReason = pBalanceAdjustmentReason;
            _retailAccountPayment.Person                  = pPerson;
            _retailAccountPayment.CdrKey                  = pRetailAccountPaymentRow.Cdr_key;

            return(_retailAccountPayment);
        }
Exemple #4
0
        static RetailAccountPaymentRow mapToRetailAccountPaymentRow(RetailAccountPaymentDto pRetailAccountPayment)
        {
            var _retailAccountPaymentRow = new RetailAccountPaymentRow();

            _retailAccountPaymentRow.Date_time              = pRetailAccountPayment.DateTime;
            _retailAccountPaymentRow.Retail_acct_id         = pRetailAccountPayment.RetailAcctId;
            _retailAccountPaymentRow.Previous_amount        = pRetailAccountPayment.PreviousAmount;
            _retailAccountPaymentRow.Payment_amount         = pRetailAccountPayment.Amount;
            _retailAccountPaymentRow.Previous_bonus_minutes = pRetailAccountPayment.PreviousBonusMinutes;
            _retailAccountPaymentRow.Added_bonus_minutes    = pRetailAccountPayment.AddedBonusMinutes;
            _retailAccountPaymentRow.Comments = pRetailAccountPayment.Comments;
            _retailAccountPaymentRow.Balance_adjustment_reason_id = pRetailAccountPayment.BalanceAdjustmentReasonId;
            _retailAccountPaymentRow.Person_id = pRetailAccountPayment.PersonId;
            _retailAccountPaymentRow.Cdr_key   = pRetailAccountPayment.CdrKey;

            return(_retailAccountPaymentRow);
        }
        /// <summary>
        /// Adds a new record into the <c>RetailAccountPayment</c> table.
        /// </summary>
        /// <param name="value">The <see cref="RetailAccountPaymentRow"/> object to be inserted.</param>
        public virtual void Insert(RetailAccountPaymentRow value)
        {
            string sqlStr = "INSERT INTO [dbo].[RetailAccountPayment] (" +
                            "[retail_acct_id], " +
                            "[date_time], " +
                            "[previous_amount], " +
                            "[payment_amount], " +
                            "[previous_bonus_minutes], " +
                            "[added_bonus_minutes], " +
                            "[comments], " +
                            "[person_id], " +
                            "[balance_adjustment_reason_id], " +
                            "[cdr_key]" +
                            ") VALUES (" +
                            _db.CreateSqlParameterName("Retail_acct_id") + ", " +
                            _db.CreateSqlParameterName("Date_time") + ", " +
                            _db.CreateSqlParameterName("Previous_amount") + ", " +
                            _db.CreateSqlParameterName("Payment_amount") + ", " +
                            _db.CreateSqlParameterName("Previous_bonus_minutes") + ", " +
                            _db.CreateSqlParameterName("Added_bonus_minutes") + ", " +
                            _db.CreateSqlParameterName("Comments") + ", " +
                            _db.CreateSqlParameterName("Person_id") + ", " +
                            _db.CreateSqlParameterName("Balance_adjustment_reason_id") + ", " +
                            _db.CreateSqlParameterName("Cdr_key") + ")";
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Retail_acct_id", value.Retail_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, "Previous_bonus_minutes", value.Previous_bonus_minutes);
            AddParameter(cmd, "Added_bonus_minutes", value.Added_bonus_minutes);
            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, "Cdr_key", value.Cdr_key);
            cmd.ExecuteNonQuery();
        }
        /// <summary>
        /// Converts <see cref="System.Data.DataRow"/> to <see cref="RetailAccountPaymentRow"/>.
        /// </summary>
        /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
        /// <returns>A reference to the <see cref="RetailAccountPaymentRow"/> object.</returns>
        protected virtual RetailAccountPaymentRow MapRow(DataRow row)
        {
            RetailAccountPaymentRow mappedObject = new RetailAccountPaymentRow();
            DataTable  dataTable = row.Table;
            DataColumn dataColumn;

            // Column "Retail_acct_id"
            dataColumn = dataTable.Columns["Retail_acct_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Retail_acct_id = (int)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 "Previous_bonus_minutes"
            dataColumn = dataTable.Columns["Previous_bonus_minutes"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Previous_bonus_minutes = (short)row[dataColumn];
            }
            // Column "Added_bonus_minutes"
            dataColumn = dataTable.Columns["Added_bonus_minutes"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Added_bonus_minutes = (short)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];
            }
            // Column "Cdr_key"
            dataColumn = dataTable.Columns["Cdr_key"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Cdr_key = (string)row[dataColumn];
            }
            return(mappedObject);
        }
 /// <summary>
 /// Deletes the specified object from the <c>RetailAccountPayment</c> table.
 /// </summary>
 /// <param name="value">The <see cref="RetailAccountPaymentRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(RetailAccountPaymentRow value)
 {
     return(DeleteByPrimaryKey(value.Retail_acct_id, value.Date_time));
 }