示例#1
0
        /// <summary>
        /// Updates a record in the <c>InventoryHistory</c> table.
        /// </summary>
        /// <param name="value">The <see cref="InventoryHistoryRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(InventoryHistoryRow value)
        {
            string sqlStr = "UPDATE [dbo].[InventoryHistory] SET " +
                            "[command]=" + _db.CreateSqlParameterName("Command") + ", " +
                            "[number_of_cards]=" + _db.CreateSqlParameterName("Number_of_cards") + ", " +
                            "[denomination]=" + _db.CreateSqlParameterName("Denomination") + ", " +
                            "[customer_acct_id]=" + _db.CreateSqlParameterName("Customer_acct_id") + ", " +
                            "[reseller_partner_id]=" + _db.CreateSqlParameterName("Reseller_partner_id") + ", " +
                            "[reseller_agent_id]=" + _db.CreateSqlParameterName("Reseller_agent_id") + ", " +
                            "[person_id]=" + _db.CreateSqlParameterName("Person_id") +
                            " WHERE " +
                            "[service_id]=" + _db.CreateSqlParameterName("Service_id") + " AND " +
                            "[batch_id]=" + _db.CreateSqlParameterName("Batch_id") + " AND " +
                            "[timestamp]=" + _db.CreateSqlParameterName("Timestamp");
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Command", value.Command);
            AddParameter(cmd, "Number_of_cards", value.Number_of_cards);
            AddParameter(cmd, "Denomination", value.Denomination);
            AddParameter(cmd, "Customer_acct_id",
                         value.IsCustomer_acct_idNull ? DBNull.Value : (object)value.Customer_acct_id);
            AddParameter(cmd, "Reseller_partner_id",
                         value.IsReseller_partner_idNull ? DBNull.Value : (object)value.Reseller_partner_id);
            AddParameter(cmd, "Reseller_agent_id",
                         value.IsReseller_agent_idNull ? DBNull.Value : (object)value.Reseller_agent_id);
            AddParameter(cmd, "Person_id", value.Person_id);
            AddParameter(cmd, "Service_id", value.Service_id);
            AddParameter(cmd, "Batch_id", value.Batch_id);
            AddParameter(cmd, "Timestamp", value.Timestamp);
            return(0 != cmd.ExecuteNonQuery());
        }
        private static void logInventoryHistory(Rbr_Db pDb, PersonDto pPerson, DateTime pTimestamp, short pServiceId, decimal pDenomination, int pBatchId, int pNumberOfCards, InventoryCommand pInventoryCommand, short pCustomerAcctId, int pResellerPartnerId, int pResellerAgentId)
        {
            var _inventoryHistoryRow = new InventoryHistoryRow();

            _inventoryHistoryRow.Service_id       = pServiceId;
            _inventoryHistoryRow.Batch_id         = pBatchId;
            _inventoryHistoryRow.Timestamp        = pTimestamp;
            _inventoryHistoryRow.InventoryCommand = pInventoryCommand;
            _inventoryHistoryRow.Number_of_cards  = pNumberOfCards;
            _inventoryHistoryRow.Denomination     = pDenomination;
            _inventoryHistoryRow.Person_id        = pPerson.PersonId;

            if (pCustomerAcctId > 0)
            {
                _inventoryHistoryRow.Customer_acct_id = pCustomerAcctId;                 //N/A FOR THIS COMMAND
            }

            if (pResellerPartnerId > 0)
            {
                _inventoryHistoryRow.Reseller_partner_id = pResellerPartnerId;                 //N/A FOR THIS COMMAND
            }

            if (pResellerAgentId > 0)
            {
                _inventoryHistoryRow.Reseller_agent_id = pResellerAgentId;                 //N/A FOR THIS COMMAND
            }

            pDb.InventoryHistoryCollection.Insert(_inventoryHistoryRow);
        }
示例#3
0
        /// <summary>
        /// Adds a new record into the <c>InventoryHistory</c> table.
        /// </summary>
        /// <param name="value">The <see cref="InventoryHistoryRow"/> object to be inserted.</param>
        public virtual void Insert(InventoryHistoryRow value)
        {
            string sqlStr = "INSERT INTO [dbo].[InventoryHistory] (" +
                            "[service_id], " +
                            "[batch_id], " +
                            "[timestamp], " +
                            "[command], " +
                            "[number_of_cards], " +
                            "[denomination], " +
                            "[customer_acct_id], " +
                            "[reseller_partner_id], " +
                            "[reseller_agent_id], " +
                            "[person_id]" +
                            ") VALUES (" +
                            _db.CreateSqlParameterName("Service_id") + ", " +
                            _db.CreateSqlParameterName("Batch_id") + ", " +
                            _db.CreateSqlParameterName("Timestamp") + ", " +
                            _db.CreateSqlParameterName("Command") + ", " +
                            _db.CreateSqlParameterName("Number_of_cards") + ", " +
                            _db.CreateSqlParameterName("Denomination") + ", " +
                            _db.CreateSqlParameterName("Customer_acct_id") + ", " +
                            _db.CreateSqlParameterName("Reseller_partner_id") + ", " +
                            _db.CreateSqlParameterName("Reseller_agent_id") + ", " +
                            _db.CreateSqlParameterName("Person_id") + ")";
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Service_id", value.Service_id);
            AddParameter(cmd, "Batch_id", value.Batch_id);
            AddParameter(cmd, "Timestamp", value.Timestamp);
            AddParameter(cmd, "Command", value.Command);
            AddParameter(cmd, "Number_of_cards", value.Number_of_cards);
            AddParameter(cmd, "Denomination", value.Denomination);
            AddParameter(cmd, "Customer_acct_id",
                         value.IsCustomer_acct_idNull ? DBNull.Value : (object)value.Customer_acct_id);
            AddParameter(cmd, "Reseller_partner_id",
                         value.IsReseller_partner_idNull ? DBNull.Value : (object)value.Reseller_partner_id);
            AddParameter(cmd, "Reseller_agent_id",
                         value.IsReseller_agent_idNull ? DBNull.Value : (object)value.Reseller_agent_id);
            AddParameter(cmd, "Person_id", value.Person_id);
            cmd.ExecuteNonQuery();
        }
示例#4
0
        /// <summary>
        /// Converts <see cref="System.Data.DataRow"/> to <see cref="InventoryHistoryRow"/>.
        /// </summary>
        /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
        /// <returns>A reference to the <see cref="InventoryHistoryRow"/> object.</returns>
        protected virtual InventoryHistoryRow MapRow(DataRow row)
        {
            InventoryHistoryRow mappedObject = new InventoryHistoryRow();
            DataTable           dataTable    = row.Table;
            DataColumn          dataColumn;

            // Column "Service_id"
            dataColumn = dataTable.Columns["Service_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Service_id = (short)row[dataColumn];
            }
            // Column "Batch_id"
            dataColumn = dataTable.Columns["Batch_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Batch_id = (int)row[dataColumn];
            }
            // Column "Timestamp"
            dataColumn = dataTable.Columns["Timestamp"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Timestamp = (System.DateTime)row[dataColumn];
            }
            // Column "Command"
            dataColumn = dataTable.Columns["Command"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Command = (byte)row[dataColumn];
            }
            // Column "Number_of_cards"
            dataColumn = dataTable.Columns["Number_of_cards"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Number_of_cards = (int)row[dataColumn];
            }
            // Column "Denomination"
            dataColumn = dataTable.Columns["Denomination"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Denomination = (decimal)row[dataColumn];
            }
            // Column "Customer_acct_id"
            dataColumn = dataTable.Columns["Customer_acct_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Customer_acct_id = (short)row[dataColumn];
            }
            // Column "Reseller_partner_id"
            dataColumn = dataTable.Columns["Reseller_partner_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Reseller_partner_id = (int)row[dataColumn];
            }
            // Column "Reseller_agent_id"
            dataColumn = dataTable.Columns["Reseller_agent_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Reseller_agent_id = (int)row[dataColumn];
            }
            // Column "Person_id"
            dataColumn = dataTable.Columns["Person_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Person_id = (int)row[dataColumn];
            }
            return(mappedObject);
        }
示例#5
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="InventoryHistoryRow"/> objects.</returns>
        protected virtual InventoryHistoryRow[] 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 service_idColumnIndex          = reader.GetOrdinal("service_id");
            int batch_idColumnIndex            = reader.GetOrdinal("batch_id");
            int timestampColumnIndex           = reader.GetOrdinal("timestamp");
            int commandColumnIndex             = reader.GetOrdinal("command");
            int number_of_cardsColumnIndex     = reader.GetOrdinal("number_of_cards");
            int denominationColumnIndex        = reader.GetOrdinal("denomination");
            int customer_acct_idColumnIndex    = reader.GetOrdinal("customer_acct_id");
            int reseller_partner_idColumnIndex = reader.GetOrdinal("reseller_partner_id");
            int reseller_agent_idColumnIndex   = reader.GetOrdinal("reseller_agent_id");
            int person_idColumnIndex           = reader.GetOrdinal("person_id");

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

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

                    record.Service_id      = Convert.ToInt16(reader.GetValue(service_idColumnIndex));
                    record.Batch_id        = Convert.ToInt32(reader.GetValue(batch_idColumnIndex));
                    record.Timestamp       = Convert.ToDateTime(reader.GetValue(timestampColumnIndex));
                    record.Command         = Convert.ToByte(reader.GetValue(commandColumnIndex));
                    record.Number_of_cards = Convert.ToInt32(reader.GetValue(number_of_cardsColumnIndex));
                    record.Denomination    = Convert.ToDecimal(reader.GetValue(denominationColumnIndex));
                    if (!reader.IsDBNull(customer_acct_idColumnIndex))
                    {
                        record.Customer_acct_id = Convert.ToInt16(reader.GetValue(customer_acct_idColumnIndex));
                    }
                    if (!reader.IsDBNull(reseller_partner_idColumnIndex))
                    {
                        record.Reseller_partner_id = Convert.ToInt32(reader.GetValue(reseller_partner_idColumnIndex));
                    }
                    if (!reader.IsDBNull(reseller_agent_idColumnIndex))
                    {
                        record.Reseller_agent_id = Convert.ToInt32(reader.GetValue(reseller_agent_idColumnIndex));
                    }
                    record.Person_id = Convert.ToInt32(reader.GetValue(person_idColumnIndex));

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

            totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1;
            return((InventoryHistoryRow[])(recordList.ToArray(typeof(InventoryHistoryRow))));
        }
示例#6
0
 /// <summary>
 /// Deletes the specified object from the <c>InventoryHistory</c> table.
 /// </summary>
 /// <param name="value">The <see cref="InventoryHistoryRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(InventoryHistoryRow value)
 {
     return(DeleteByPrimaryKey(value.Service_id, value.Batch_id, value.Timestamp));
 }