Beispiel #1
0
        /// <summary>
        /// Updates a record in the <c>ResellAcct</c> table.
        /// </summary>
        /// <param name="value">The <see cref="ResellAcctRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(ResellAcctRow value)
        {
            string sqlStr = "UPDATE [dbo].[ResellAcct] SET " +
                            "[partner_id]=" + _db.CreateSqlParameterName("Partner_id") + ", " +
                            "[customer_acct_id]=" + _db.CreateSqlParameterName("Customer_acct_id") + ", " +
                            "[person_id]=" + _db.CreateSqlParameterName("Person_id") + ", " +
                            "[per_route]=" + _db.CreateSqlParameterName("Per_route") + ", " +
                            "[commision_type]=" + _db.CreateSqlParameterName("Commision_type") + ", " +
                            "[markup_dollar]=" + _db.CreateSqlParameterName("Markup_dollar") + ", " +
                            "[markup_percent]=" + _db.CreateSqlParameterName("Markup_percent") + ", " +
                            "[fee_per_call]=" + _db.CreateSqlParameterName("Fee_per_call") + ", " +
                            "[fee_per_minute]=" + _db.CreateSqlParameterName("Fee_per_minute") +
                            " WHERE " +
                            "[resell_acct_id]=" + _db.CreateSqlParameterName("Resell_acct_id");
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Partner_id", value.Partner_id);
            AddParameter(cmd, "Customer_acct_id", value.Customer_acct_id);
            AddParameter(cmd, "Person_id", value.Person_id);
            AddParameter(cmd, "Per_route", value.Per_route);
            AddParameter(cmd, "Commision_type", value.Commision_type);
            AddParameter(cmd, "Markup_dollar", value.Markup_dollar);
            AddParameter(cmd, "Markup_percent", value.Markup_percent);
            AddParameter(cmd, "Fee_per_call", value.Fee_per_call);
            AddParameter(cmd, "Fee_per_minute", value.Fee_per_minute);
            AddParameter(cmd, "Resell_acct_id", value.Resell_acct_id);
            return(0 != cmd.ExecuteNonQuery());
        }
Beispiel #2
0
        /// <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="ResellAcctRow"/> objects.</returns>
        protected virtual ResellAcctRow[] 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 resell_acct_idColumnIndex   = reader.GetOrdinal("resell_acct_id");
            int partner_idColumnIndex       = reader.GetOrdinal("partner_id");
            int customer_acct_idColumnIndex = reader.GetOrdinal("customer_acct_id");
            int person_idColumnIndex        = reader.GetOrdinal("person_id");
            int per_routeColumnIndex        = reader.GetOrdinal("per_route");
            int commision_typeColumnIndex   = reader.GetOrdinal("commision_type");
            int markup_dollarColumnIndex    = reader.GetOrdinal("markup_dollar");
            int markup_percentColumnIndex   = reader.GetOrdinal("markup_percent");
            int fee_per_callColumnIndex     = reader.GetOrdinal("fee_per_call");
            int fee_per_minuteColumnIndex   = reader.GetOrdinal("fee_per_minute");

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

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

                    record.Resell_acct_id   = Convert.ToInt16(reader.GetValue(resell_acct_idColumnIndex));
                    record.Partner_id       = Convert.ToInt32(reader.GetValue(partner_idColumnIndex));
                    record.Customer_acct_id = Convert.ToInt16(reader.GetValue(customer_acct_idColumnIndex));
                    record.Person_id        = Convert.ToInt32(reader.GetValue(person_idColumnIndex));
                    record.Per_route        = Convert.ToByte(reader.GetValue(per_routeColumnIndex));
                    record.Commision_type   = Convert.ToByte(reader.GetValue(commision_typeColumnIndex));
                    record.Markup_dollar    = Convert.ToDecimal(reader.GetValue(markup_dollarColumnIndex));
                    record.Markup_percent   = Convert.ToDecimal(reader.GetValue(markup_percentColumnIndex));
                    record.Fee_per_call     = Convert.ToDecimal(reader.GetValue(fee_per_callColumnIndex));
                    record.Fee_per_minute   = Convert.ToDecimal(reader.GetValue(fee_per_minuteColumnIndex));

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

            totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1;
            return((ResellAcctRow[])(recordList.ToArray(typeof(ResellAcctRow))));
        }
Beispiel #3
0
        static ResellAcctRow mapToResellAcctRow(ResellAccountDto pResellAccount)
        {
            var _resellAcctRow = new ResellAcctRow
            {
                Resell_acct_id   = pResellAccount.ResellAccountId,
                Customer_acct_id = pResellAccount.CustomerAcctId,
                Partner_id       = pResellAccount.PartnerId,
                Person_id        = pResellAccount.PersonId,
                CommisionType    = pResellAccount.CommisionType,
                Fee_per_call     = pResellAccount.FeePerCall,
                Fee_per_minute   = pResellAccount.FeePerMinute,
                Markup_dollar    = pResellAccount.MarkupDollar,
                Markup_percent   = pResellAccount.MarkupPercent,
                PerRoute         = pResellAccount.PerRoute
            };

            return(_resellAcctRow);
        }
Beispiel #4
0
        /// <summary>
        /// Adds a new record into the <c>ResellAcct</c> table.
        /// </summary>
        /// <param name="value">The <see cref="ResellAcctRow"/> object to be inserted.</param>
        public virtual void Insert(ResellAcctRow value)
        {
            string sqlStr = "INSERT INTO [dbo].[ResellAcct] (" +
                            "[resell_acct_id], " +
                            "[partner_id], " +
                            "[customer_acct_id], " +
                            "[person_id], " +
                            "[per_route], " +
                            "[commision_type], " +
                            "[markup_dollar], " +
                            "[markup_percent], " +
                            "[fee_per_call], " +
                            "[fee_per_minute]" +
                            ") VALUES (" +
                            _db.CreateSqlParameterName("Resell_acct_id") + ", " +
                            _db.CreateSqlParameterName("Partner_id") + ", " +
                            _db.CreateSqlParameterName("Customer_acct_id") + ", " +
                            _db.CreateSqlParameterName("Person_id") + ", " +
                            _db.CreateSqlParameterName("Per_route") + ", " +
                            _db.CreateSqlParameterName("Commision_type") + ", " +
                            _db.CreateSqlParameterName("Markup_dollar") + ", " +
                            _db.CreateSqlParameterName("Markup_percent") + ", " +
                            _db.CreateSqlParameterName("Fee_per_call") + ", " +
                            _db.CreateSqlParameterName("Fee_per_minute") + ")";
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Resell_acct_id", value.Resell_acct_id);
            AddParameter(cmd, "Partner_id", value.Partner_id);
            AddParameter(cmd, "Customer_acct_id", value.Customer_acct_id);
            AddParameter(cmd, "Person_id", value.Person_id);
            AddParameter(cmd, "Per_route", value.Per_route);
            AddParameter(cmd, "Commision_type", value.Commision_type);
            AddParameter(cmd, "Markup_dollar", value.Markup_dollar);
            AddParameter(cmd, "Markup_percent", value.Markup_percent);
            AddParameter(cmd, "Fee_per_call", value.Fee_per_call);
            AddParameter(cmd, "Fee_per_minute", value.Fee_per_minute);
            cmd.ExecuteNonQuery();
        }
Beispiel #5
0
        /// <summary>
        /// Converts <see cref="System.Data.DataRow"/> to <see cref="ResellAcctRow"/>.
        /// </summary>
        /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
        /// <returns>A reference to the <see cref="ResellAcctRow"/> object.</returns>
        protected virtual ResellAcctRow MapRow(DataRow row)
        {
            ResellAcctRow mappedObject = new ResellAcctRow();
            DataTable     dataTable    = row.Table;
            DataColumn    dataColumn;

            // Column "Resell_acct_id"
            dataColumn = dataTable.Columns["Resell_acct_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Resell_acct_id = (short)row[dataColumn];
            }
            // Column "Partner_id"
            dataColumn = dataTable.Columns["Partner_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Partner_id = (int)row[dataColumn];
            }
            // Column "Customer_acct_id"
            dataColumn = dataTable.Columns["Customer_acct_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Customer_acct_id = (short)row[dataColumn];
            }
            // Column "Person_id"
            dataColumn = dataTable.Columns["Person_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Person_id = (int)row[dataColumn];
            }
            // Column "Per_route"
            dataColumn = dataTable.Columns["Per_route"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Per_route = (byte)row[dataColumn];
            }
            // Column "Commision_type"
            dataColumn = dataTable.Columns["Commision_type"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Commision_type = (byte)row[dataColumn];
            }
            // Column "Markup_dollar"
            dataColumn = dataTable.Columns["Markup_dollar"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Markup_dollar = (decimal)row[dataColumn];
            }
            // Column "Markup_percent"
            dataColumn = dataTable.Columns["Markup_percent"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Markup_percent = (decimal)row[dataColumn];
            }
            // Column "Fee_per_call"
            dataColumn = dataTable.Columns["Fee_per_call"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Fee_per_call = (decimal)row[dataColumn];
            }
            // Column "Fee_per_minute"
            dataColumn = dataTable.Columns["Fee_per_minute"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Fee_per_minute = (decimal)row[dataColumn];
            }
            return(mappedObject);
        }
Beispiel #6
0
 /// <summary>
 /// Deletes the specified object from the <c>ResellAcct</c> table.
 /// </summary>
 /// <param name="value">The <see cref="ResellAcctRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(ResellAcctRow value)
 {
     return(DeleteByPrimaryKey(value.Resell_acct_id));
 }