Пример #1
0
        private static void loadPhoneCardAndRetailAccount(Rbr_Db pDb, long pSerial, long pPin, InventoryCommandRequest pInventoryCommandRequest)
        {
            //PoneCard status = Loaded | (Activeted if Activate on load)
            //RetAcct  status = Active, date_active = pInventoryCommandRequest.DateCreated

            RetailAccountRow _retailAccountRow = createRetailAccount(pDb, pInventoryCommandRequest);

            var _phoneCardRow = new PhoneCardRow();

            //TODO: !!! setup new dates here...
            if (pInventoryCommandRequest.ActivateOnLoad)
            {
                _phoneCardRow.InventoryStatus = InventoryStatus.Activated;
                _phoneCardRow.CardStatus      = Status.Active;
                _phoneCardRow.Date_active     = pInventoryCommandRequest.DateActive;
            }
            else
            {
                _phoneCardRow.InventoryStatus   = InventoryStatus.Loaded;
                _phoneCardRow.CardStatus        = Status.Pending;
                _phoneCardRow.IsDate_activeNull = true;
            }
            _phoneCardRow.Pin            = pPin;
            _phoneCardRow.Retail_acct_id = _retailAccountRow.Retail_acct_id;
            _phoneCardRow.Serial_number  = pSerial;
            _phoneCardRow.Service_id     = pInventoryCommandRequest.ServiceId;

            _phoneCardRow.Date_loaded            = pInventoryCommandRequest.DateCreated;
            _phoneCardRow.Date_to_expire         = pInventoryCommandRequest.DateToExpire;
            _phoneCardRow.IsDate_deactivatedNull = true;
            _phoneCardRow.IsDate_archivedNull    = true;

            pDb.PhoneCardCollection.Insert(_phoneCardRow);
            TimokLogger.Instance.LogRbr(LogSeverity.Debug, "InventoryController.loadPhoneCardAndRetailAccount", string.Format("PhoneCardRow inserted, Serial={0}", _phoneCardRow.Serial_number));
        }
Пример #2
0
        /// <summary>
        /// Updates a record in the <c>PhoneCard</c> table.
        /// </summary>
        /// <param name="value">The <see cref="PhoneCardRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(PhoneCardRow value)
        {
            string sqlStr = "UPDATE [dbo].[PhoneCard] SET " +
                            "[retail_acct_id]=" + _db.CreateSqlParameterName("Retail_acct_id") + ", " +
                            "[serial_number]=" + _db.CreateSqlParameterName("Serial_number") + ", " +
                            "[status]=" + _db.CreateSqlParameterName("Status") + ", " +
                            "[inventory_status]=" + _db.CreateSqlParameterName("Inventory_status") + ", " +
                            "[date_loaded]=" + _db.CreateSqlParameterName("Date_loaded") + ", " +
                            "[date_to_expire]=" + _db.CreateSqlParameterName("Date_to_expire") + ", " +
                            "[date_active]=" + _db.CreateSqlParameterName("Date_active") + ", " +
                            "[date_deactivated]=" + _db.CreateSqlParameterName("Date_deactivated") + ", " +
                            "[date_archived]=" + _db.CreateSqlParameterName("Date_archived") +
                            " WHERE " +
                            "[service_id]=" + _db.CreateSqlParameterName("Service_id") + " AND " +
                            "[pin]=" + _db.CreateSqlParameterName("Pin");
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Retail_acct_id", value.Retail_acct_id);
            AddParameter(cmd, "Serial_number", value.Serial_number);
            AddParameter(cmd, "Status", value.Status);
            AddParameter(cmd, "Inventory_status", value.Inventory_status);
            AddParameter(cmd, "Date_loaded", value.Date_loaded);
            AddParameter(cmd, "Date_to_expire", value.Date_to_expire);
            AddParameter(cmd, "Date_active",
                         value.IsDate_activeNull ? DBNull.Value : (object)value.Date_active);
            AddParameter(cmd, "Date_deactivated",
                         value.IsDate_deactivatedNull ? DBNull.Value : (object)value.Date_deactivated);
            AddParameter(cmd, "Date_archived",
                         value.IsDate_archivedNull ? DBNull.Value : (object)value.Date_archived);
            AddParameter(cmd, "Service_id", value.Service_id);
            AddParameter(cmd, "Pin", value.Pin);
            return(0 != cmd.ExecuteNonQuery());
        }
Пример #3
0
        PhoneCardDto mapToPhoneCard(PhoneCardRow pPhoneCardRow)
        {
            var _phoneCard = new PhoneCardDto();

            _phoneCard.Pin             = pPhoneCardRow.Pin;
            _phoneCard.SerialNumber    = pPhoneCardRow.Serial_number;
            _phoneCard.ServiceId       = pPhoneCardRow.Service_id;
            _phoneCard.InventoryStatus = pPhoneCardRow.InventoryStatus;
            _phoneCard.Status          = pPhoneCardRow.CardStatus;
            _phoneCard.RetailAcctId    = pPhoneCardRow.Retail_acct_id;

            _phoneCard.DateLoaded   = pPhoneCardRow.Date_loaded;
            _phoneCard.DateToExpire = pPhoneCardRow.Date_to_expire;

            if (pPhoneCardRow.IsDate_activeNull)
            {
                _phoneCard.DateActive = pPhoneCardRow.Date_active;
            }
            else
            {
                _phoneCard.DateActive = Configuration.Instance.Db.SqlSmallDateTimeMaxValue;
            }
            if (pPhoneCardRow.IsDate_deactivatedNull)
            {
                _phoneCard.DateDeactivated = pPhoneCardRow.Date_deactivated;
            }
            else
            {
                _phoneCard.DateDeactivated = Configuration.Instance.Db.SqlSmallDateTimeMaxValue;
            }
            if (pPhoneCardRow.IsDate_archivedNull)
            {
                _phoneCard.DateArchived = pPhoneCardRow.Date_archived;
            }
            else
            {
                _phoneCard.DateArchived = Configuration.Instance.Db.SqlSmallDateTimeMaxValue;
            }
            if (pPhoneCardRow.IsDate_first_usedNull)
            {
                _phoneCard.DateFirstUsed = pPhoneCardRow.Date_first_used;
            }
            else
            {
                _phoneCard.DateFirstUsed = Configuration.Instance.Db.SqlSmallDateTimeMaxValue;
            }
            if (pPhoneCardRow.IsDate_last_usedNull)
            {
                _phoneCard.DateLastUsed = pPhoneCardRow.Date_last_used;
            }
            else
            {
                _phoneCard.DateLastUsed = Configuration.Instance.Db.SqlSmallDateTimeMaxValue;
            }

            return(_phoneCard);
        }
Пример #4
0
        internal RetailAccountDto GetByPIN(Rbr_Db pDb, short pServiceId, long pPIN)
        {
            PhoneCardRow _phoneCardRow = pDb.PhoneCardCollection.GetByPrimaryKey(pServiceId, pPIN);

            if (_phoneCardRow != null)
            {
                RetailAccountRow _retailAccountRow = pDb.RetailAccountCollection.GetByPrimaryKey(_phoneCardRow.Retail_acct_id);
                return(get(pDb, pServiceId, _retailAccountRow));
            }
            return(null);
        }
        public static void Update(string pSalt, RetailAccountDto pRetailAccount)
        {
            if (pRetailAccount.AccessEnabled && (pRetailAccount.Person.Salt == null || pRetailAccount.Person.Salt.Trim().Length == 0))
            {
                pRetailAccount.Person.Salt = pSalt;
            }

            using (var _db = new Rbr_Db()) {
                using (var _tx = new Transaction(_db, pSalt, pRetailAccount)) {
                    RetailAccountRow _originalRetailAccountRow = RetailAccountManager.Instance.Get(_db, pRetailAccount.RetailAcctId);
                    RetailAccountRow _retailAccountRow         = RetailAccountManager.MapToRetailAccountRow(pRetailAccount);

                    if (_originalRetailAccountRow.AccountStatus != Status.Active && _retailAccountRow.AccountStatus == Status.Active && _retailAccountRow.Date_active == Configuration.Instance.Db.SqlSmallDateTimeMaxValue)
                    {
                        _retailAccountRow.Date_active = DateTime.Today;
                    }

                    if (pRetailAccount.AccessEnabled)
                    {
                        pRetailAccount.Person.RetailAcctId = pRetailAccount.RetailAcctId;
                        PersonManager.Save(_db, pSalt, pRetailAccount.Person);
                    }
                    else
                    {
                        PersonManager.DeleteByRetailAcctId(_db, pRetailAccount.RetailAcctId);
                    }

                    RetailAccountManager.Instance.Update(_db, _retailAccountRow);

                    if (pRetailAccount.PhoneCards != null && pRetailAccount.PhoneCards.Length > 0)
                    {
                        //Update PhoneCard
                        //TODO: now works only with 1 (one) PhoneCard per RetailAcct
                        PhoneCardRow _phoneCardRow = RetailAccountManager.MapToPhoneCardRow(pRetailAccount.PhoneCards[0]);
                        _phoneCardRow.CardStatus = pRetailAccount.Status;
                        RetailAccountManager.UpdatePhoneCard(_db, _phoneCardRow);
                    }

                    if (pRetailAccount.ResidentialPSTNs != null && pRetailAccount.ResidentialPSTNs.Length > 0)
                    {
                        //Update ResidentialPSTN
                        //TODO: now works only with 1 (one) PSTN # per RetailAcct
                        ResidentialPSTNRow _residentialPSTNRow = RetailAccountManager.MapToResidentialPSTNRow(pRetailAccount.ResidentialPSTNs[0]);
                        _residentialPSTNRow.AccountStatus = pRetailAccount.Status;
                        RetailAccountManager.UpdateResidentialPSTNSubAcct(_db, _residentialPSTNRow);
                    }

                    _tx.Commit();
                }
            }
        }
Пример #6
0
        internal static PhoneCardRow[] MapToPhoneCardRows(PhoneCardDto[] pPhoneCards)
        {
            var _list = new ArrayList();

            if (pPhoneCards != null)
            {
                foreach (PhoneCardDto _phoneCard in pPhoneCards)
                {
                    PhoneCardRow _phoneCardRow = MapToPhoneCardRow(_phoneCard);
                    _list.Add(_phoneCardRow);
                }
            }
            return((PhoneCardRow[])_list.ToArray(typeof(PhoneCardRow)));
        }
Пример #7
0
        /// <summary>
        /// Adds a new record into the <c>PhoneCard</c> table.
        /// </summary>
        /// <param name="value">The <see cref="PhoneCardRow"/> object to be inserted.</param>
        public virtual void Insert(PhoneCardRow value)
        {
            string sqlStr = "INSERT INTO [dbo].[PhoneCard] (" +
                            "[service_id], " +
                            "[pin], " +
                            "[retail_acct_id], " +
                            "[serial_number], " +
                            "[status], " +
                            "[inventory_status], " +
                            "[date_loaded], " +
                            "[date_to_expire], " +
                            "[date_active], " +
                            "[date_deactivated], " +
                            "[date_archived]" +
                            ") VALUES (" +
                            _db.CreateSqlParameterName("Service_id") + ", " +
                            _db.CreateSqlParameterName("Pin") + ", " +
                            _db.CreateSqlParameterName("Retail_acct_id") + ", " +
                            _db.CreateSqlParameterName("Serial_number") + ", " +
                            _db.CreateSqlParameterName("Status") + ", " +
                            _db.CreateSqlParameterName("Inventory_status") + ", " +
                            _db.CreateSqlParameterName("Date_loaded") + ", " +
                            _db.CreateSqlParameterName("Date_to_expire") + ", " +
                            _db.CreateSqlParameterName("Date_active") + ", " +
                            _db.CreateSqlParameterName("Date_deactivated") + ", " +
                            _db.CreateSqlParameterName("Date_archived") + ")";
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Service_id", value.Service_id);
            AddParameter(cmd, "Pin", value.Pin);
            AddParameter(cmd, "Retail_acct_id", value.Retail_acct_id);
            AddParameter(cmd, "Serial_number", value.Serial_number);
            AddParameter(cmd, "Status", value.Status);
            AddParameter(cmd, "Inventory_status", value.Inventory_status);
            AddParameter(cmd, "Date_loaded", value.Date_loaded);
            AddParameter(cmd, "Date_to_expire", value.Date_to_expire);
            AddParameter(cmd, "Date_active",
                         value.IsDate_activeNull ? DBNull.Value : (object)value.Date_active);
            AddParameter(cmd, "Date_deactivated",
                         value.IsDate_deactivatedNull ? DBNull.Value : (object)value.Date_deactivated);
            AddParameter(cmd, "Date_archived",
                         value.IsDate_archivedNull ? DBNull.Value : (object)value.Date_archived);
            cmd.ExecuteNonQuery();
        }
        static void importPhoneCardAndRetailAccount(Rbr_Db pDb, PhoneCardDto pPhoneCard, InventoryStatus pInitialInventoryStatus, PhoneCardBatch pPhoneCardBatch)
        {
            var _retailAccountRow = new RetailAccountRow();

            _retailAccountRow.AccountStatus         = Status.Active;     //NOTE
            _retailAccountRow.Start_balance         = pPhoneCardBatch.StartBalance;
            _retailAccountRow.Start_bonus_minutes   = pPhoneCardBatch.StartBonusMinutes;
            _retailAccountRow.Current_balance       = pPhoneCardBatch.StartBalance;
            _retailAccountRow.Current_bonus_minutes = pPhoneCardBatch.StartBonusMinutes;
            _retailAccountRow.Customer_acct_id      = pPhoneCardBatch.CustomerAcctId;
            _retailAccountRow.Date_created          = pPhoneCardBatch.DateCreated;   //NOTE
            _retailAccountRow.Date_active           = pPhoneCardBatch.DateCreated;   //NOTE
            _retailAccountRow.Date_to_expire        = pPhoneCardBatch.DateToExpire;
            _retailAccountRow.Date_expired          = Configuration.Instance.Db.SqlSmallDateTimeMaxValue;

            RetailAccountManager.Instance.Add(pDb, _retailAccountRow);
            pPhoneCard.RetailAcctId = _retailAccountRow.Retail_acct_id;

            var _phoneCardRow = new PhoneCardRow();

            _phoneCardRow.InventoryStatus = pInitialInventoryStatus;
            if (pInitialInventoryStatus == InventoryStatus.Activated)
            {
                _phoneCardRow.CardStatus = Status.Active;
            }
            else
            {
                _phoneCardRow.CardStatus = Status.Pending;
            }
            _phoneCardRow.Pin            = pPhoneCard.Pin;
            _phoneCardRow.Serial_number  = pPhoneCard.SerialNumber;
            _phoneCardRow.Service_id     = pPhoneCard.ServiceId;
            _phoneCardRow.Retail_acct_id = pPhoneCard.RetailAcctId;

            _phoneCardRow.Date_loaded            = pPhoneCardBatch.DateCreated;
            _phoneCardRow.Date_active            = pPhoneCardBatch.DateCreated;
            _phoneCardRow.Date_to_expire         = pPhoneCardBatch.DateToExpire;
            _phoneCardRow.IsDate_deactivatedNull = true;
            _phoneCardRow.IsDate_archivedNull    = true;

            RetailAccountManager.AddPhoneCard(pDb, _phoneCardRow);
        }
Пример #9
0
        internal static PhoneCardRow MapToPhoneCardRow(PhoneCardDto pPhoneCard)
        {
            var _phoneCardRow = new PhoneCardRow();

            _phoneCardRow.InventoryStatus = pPhoneCard.InventoryStatus;
            _phoneCardRow.CardStatus      = pPhoneCard.Status;
            _phoneCardRow.Pin             = pPhoneCard.Pin;
            _phoneCardRow.Serial_number   = pPhoneCard.SerialNumber;
            _phoneCardRow.Service_id      = pPhoneCard.ServiceId;
            _phoneCardRow.Retail_acct_id  = pPhoneCard.RetailAcctId;

            _phoneCardRow.Date_loaded    = pPhoneCard.DateLoaded;
            _phoneCardRow.Date_to_expire = pPhoneCard.DateToExpire;
            if (pPhoneCard.DateActive < Configuration.Instance.Db.SqlSmallDateTimeMaxValue && pPhoneCard.DateActive > DateTime.MinValue)
            {
                _phoneCardRow.Date_active = pPhoneCard.DateActive;
            }
            if (pPhoneCard.DateDeactivated < Configuration.Instance.Db.SqlSmallDateTimeMaxValue && pPhoneCard.DateDeactivated > DateTime.MinValue)
            {
                _phoneCardRow.Date_deactivated = pPhoneCard.DateDeactivated;
            }
            if (pPhoneCard.DateArchived < Configuration.Instance.Db.SqlSmallDateTimeMaxValue && pPhoneCard.DateArchived > DateTime.MinValue)
            {
                _phoneCardRow.Date_archived = pPhoneCard.DateArchived;
            }
            if (pPhoneCard.DateFirstUsed < Configuration.Instance.Db.SqlSmallDateTimeMaxValue && pPhoneCard.DateFirstUsed > DateTime.MinValue)
            {
                _phoneCardRow.Date_first_used = pPhoneCard.DateFirstUsed;
            }
            if (pPhoneCard.DateLastUsed < Configuration.Instance.Db.SqlSmallDateTimeMaxValue && pPhoneCard.DateLastUsed > DateTime.MinValue)
            {
                _phoneCardRow.Date_last_used = pPhoneCard.DateLastUsed;
            }

            return(_phoneCardRow);
        }
        public static void Add(string pSalt, RetailAccountDto pRetailAccount)
        {
            using (var _db = new Rbr_Db()) {
                using (var _tx = new Transaction(_db, pSalt, pRetailAccount)) {
                    RetailAccountRow _retailAccountRow = RetailAccountManager.MapToRetailAccountRow(pRetailAccount);

                    //TODO: ! CONFIRM IT before implementing
                    //					CustomerAcctRow _customerAcctRow = _db.CustomerAcctCollection.GetByPrimaryKey(pRetailAccount.CustomerAcctId);
                    //					if (_customerAcctRow.BonusMinutesType == BonusMinutesType.None) {
                    //						_retailAccountRow.Current_bonus_minutes = -1;
                    //					}

                    _retailAccountRow.Date_created          = DateTime.Now;
                    _retailAccountRow.Date_expired          = Configuration.Instance.Db.SqlSmallDateTimeMaxValue;
                    _retailAccountRow.Current_balance       = _retailAccountRow.Start_balance;
                    _retailAccountRow.Current_bonus_minutes = _retailAccountRow.Start_bonus_minutes;

                    if (_retailAccountRow.AccountStatus == Status.Active)
                    {
                        _retailAccountRow.Date_active = _retailAccountRow.Date_created;
                    }
                    else
                    {
                        _retailAccountRow.Date_active = Configuration.Instance.Db.SqlSmallDateTimeMaxValue;
                    }

                    RetailAccountManager.Instance.Add(_db, _retailAccountRow);
                    pRetailAccount.RetailAcctId = _retailAccountRow.Retail_acct_id;

                    //prepare PhoneCard (s)
                    if (pRetailAccount.PhoneCards != null && pRetailAccount.PhoneCards.Length > 0)
                    {
                        //NOTE: !!! in this virsion only ONE PhoneCard p/RetailAccount allowed!!!
                        if (pRetailAccount.PhoneCards.Length > 1)
                        {
                            throw new Exception("In this virsion only ONE PhoneCard p/RetailAccount allowed!!!");
                        }
                        foreach (PhoneCardDto _phoneCard in pRetailAccount.PhoneCards)
                        {
                            long _pin = 0;
                            if (_phoneCard.SerialNumber == 0)
                            {
                                ServiceRow _serviceRow = ServiceManager.Get(_db, pRetailAccount.ServiceId);
                                long       _serialNumber;
                                generateTestSerialNumberPIN(_db, _serviceRow, out _serialNumber, out _pin);
                                _phoneCard.SerialNumber = _serialNumber;
                            }
                            if (_phoneCard.Pin == 0)
                            {
                                _phoneCard.Pin = _pin;
                            }
                            switch (pRetailAccount.Status)
                            {
                            case Status.Active:
                                _phoneCard.InventoryStatus = InventoryStatus.Activated;
                                break;

                            case Status.Pending:
                            case Status.Blocked:
                            case Status.Archived:
                            case Status.InUse:
                            default:
                                throw new ArgumentException(string.Format("Unexpected Status [{0}]", pRetailAccount.Status));
                            }
                            _phoneCard.ServiceId    = pRetailAccount.ServiceId;
                            _phoneCard.RetailAcctId = pRetailAccount.RetailAcctId;

                            _phoneCard.Status = pRetailAccount.Status;
                            //TODO: ??? set it based on RetAcct status ???
                            _phoneCard.InventoryStatus = InventoryStatus.Activated;

                            _phoneCard.DateLoaded      = _retailAccountRow.Date_created;
                            _phoneCard.DateActive      = _retailAccountRow.Date_created;
                            _phoneCard.DateToExpire    = _retailAccountRow.Date_to_expire;
                            _phoneCard.DateDeactivated = Configuration.Instance.Db.SqlSmallDateTimeMaxValue;
                            _phoneCard.DateArchived    = Configuration.Instance.Db.SqlSmallDateTimeMaxValue;
                        }
                    }

                    //prepare ResidentialPSTN (s)
                    if (pRetailAccount.ResidentialPSTNs != null && pRetailAccount.ResidentialPSTNs.Length > 0)
                    {
                        //NOTE: !!! in this virsion only ONE ResidentialPSTN p/RetailAccount allowed!!!
                        if (pRetailAccount.ResidentialPSTNs.Length > 1)
                        {
                            throw new Exception("In this virsion only ONE ResidentialPSTN p/RetailAccount allowed!!!");
                        }
                        foreach (var _residentialPSTN in pRetailAccount.ResidentialPSTNs)
                        {
                            _residentialPSTN.Status       = pRetailAccount.Status;
                            _residentialPSTN.ServiceId    = pRetailAccount.ServiceId;
                            _residentialPSTN.RetailAcctId = pRetailAccount.RetailAcctId;
                        }
                    }

                    ////prepare ResidentialVoIP (s)
                    //if (pRetailAccount.ResidentialVoIPs != null && pRetailAccount.ResidentialVoIPs.Length > 0) {
                    //  //NOTE: !!! in this virsion only ONE ResidentialVoIP p/RetailAccount allowed!!!
                    //  if (pRetailAccount.ResidentialVoIPs.Length > 1) {
                    //    throw new Exception("In this virsion only ONE ResidentialVoIP p/RetailAccount allowed!!!");
                    //  }
                    //  foreach (ResidentialVoIP _residentialVoIP in pRetailAccount.ResidentialVoIPs) {
                    //    _residentialVoIP.Status = pRetailAccount.Status;
                    //    _residentialVoIP.ServiceId = pRetailAccount.ServiceId;
                    //    _residentialVoIP.RetailAcctId = pRetailAccount.RetailAcctId;
                    //  }
                    //}

                    if (pRetailAccount.AccessEnabled)
                    {
                        pRetailAccount.Person.RetailAcctId = pRetailAccount.RetailAcctId;
                        PersonManager.Save(_db, pSalt, pRetailAccount.Person);
                    }

                    if (pRetailAccount.PhoneCards != null && pRetailAccount.PhoneCards.Length > 0)
                    {
                        //Insert PhoneCard
                        //TODO: now works only with 1 (one) card per RetailAcct
                        PhoneCardRow _phoneCardRow = RetailAccountManager.MapToPhoneCardRow(pRetailAccount.PhoneCards[0]);
                        RetailAccountManager.AddPhoneCard(_db, _phoneCardRow);
                    }

                    if (pRetailAccount.ResidentialPSTNs != null && pRetailAccount.ResidentialPSTNs.Length > 0)
                    {
                        //Insert ResidentialPSTN
                        //TODO: now works only with 1 (one) PSTN # per RetailAcct
                        ResidentialPSTNRow _residentialPSTNRow = RetailAccountManager.MapToResidentialPSTNRow(pRetailAccount.ResidentialPSTNs[0]);
                        RetailAccountManager.AddResidentialPSTNSubAcct(_db, _residentialPSTNRow);
                    }

                    _tx.Commit();
                }
            }
        }
Пример #11
0
 internal static void UpdatePhoneCard(Rbr_Db pDb, PhoneCardRow pPhoneCardRow)
 {
     pDb.PhoneCardCollection.Update(pPhoneCardRow);
 }
Пример #12
0
 internal static void AddPhoneCard(Rbr_Db pDb, PhoneCardRow pPhoneCardRow)
 {
     pDb.PhoneCardCollection.Insert(pPhoneCardRow);
 }
Пример #13
0
 public PhoneCard(RetailAccountRow pRetailAcctRow, PhoneCardRow pPhoneCardRow) : base(pRetailAcctRow)
 {
     phoneCardRow = pPhoneCardRow;
 }
Пример #14
0
        /// <summary>
        /// Converts <see cref="System.Data.DataRow"/> to <see cref="PhoneCardRow"/>.
        /// </summary>
        /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
        /// <returns>A reference to the <see cref="PhoneCardRow"/> object.</returns>
        protected virtual PhoneCardRow MapRow(DataRow row)
        {
            PhoneCardRow mappedObject = new PhoneCardRow();
            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 "Pin"
            dataColumn = dataTable.Columns["Pin"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Pin = (long)row[dataColumn];
            }
            // Column "Retail_acct_id"
            dataColumn = dataTable.Columns["Retail_acct_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Retail_acct_id = (int)row[dataColumn];
            }
            // Column "Serial_number"
            dataColumn = dataTable.Columns["Serial_number"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Serial_number = (long)row[dataColumn];
            }
            // Column "Status"
            dataColumn = dataTable.Columns["Status"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Status = (byte)row[dataColumn];
            }
            // Column "Inventory_status"
            dataColumn = dataTable.Columns["Inventory_status"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Inventory_status = (byte)row[dataColumn];
            }
            // Column "Date_loaded"
            dataColumn = dataTable.Columns["Date_loaded"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Date_loaded = (System.DateTime)row[dataColumn];
            }
            // Column "Date_to_expire"
            dataColumn = dataTable.Columns["Date_to_expire"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Date_to_expire = (System.DateTime)row[dataColumn];
            }
            // Column "Date_active"
            dataColumn = dataTable.Columns["Date_active"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Date_active = (System.DateTime)row[dataColumn];
            }
            // Column "Date_first_used"
            dataColumn = dataTable.Columns["Date_first_used"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Date_first_used = (System.DateTime)row[dataColumn];
            }
            // Column "Date_last_used"
            dataColumn = dataTable.Columns["Date_last_used"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Date_last_used = (System.DateTime)row[dataColumn];
            }
            // Column "Date_deactivated"
            dataColumn = dataTable.Columns["Date_deactivated"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Date_deactivated = (System.DateTime)row[dataColumn];
            }
            // Column "Date_archived"
            dataColumn = dataTable.Columns["Date_archived"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Date_archived = (System.DateTime)row[dataColumn];
            }
            return(mappedObject);
        }
Пример #15
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="PhoneCardRow"/> objects.</returns>
        protected virtual PhoneCardRow[] 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 pinColumnIndex              = reader.GetOrdinal("pin");
            int retail_acct_idColumnIndex   = reader.GetOrdinal("retail_acct_id");
            int serial_numberColumnIndex    = reader.GetOrdinal("serial_number");
            int statusColumnIndex           = reader.GetOrdinal("status");
            int inventory_statusColumnIndex = reader.GetOrdinal("inventory_status");
            int date_loadedColumnIndex      = reader.GetOrdinal("date_loaded");
            int date_to_expireColumnIndex   = reader.GetOrdinal("date_to_expire");
            int date_activeColumnIndex      = reader.GetOrdinal("date_active");
            int date_first_usedColumnIndex  = reader.GetOrdinal("date_first_used");
            int date_last_usedColumnIndex   = reader.GetOrdinal("date_last_used");
            int date_deactivatedColumnIndex = reader.GetOrdinal("date_deactivated");
            int date_archivedColumnIndex    = reader.GetOrdinal("date_archived");

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

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

                    record.Service_id       = Convert.ToInt16(reader.GetValue(service_idColumnIndex));
                    record.Pin              = Convert.ToInt64(reader.GetValue(pinColumnIndex));
                    record.Retail_acct_id   = Convert.ToInt32(reader.GetValue(retail_acct_idColumnIndex));
                    record.Serial_number    = Convert.ToInt64(reader.GetValue(serial_numberColumnIndex));
                    record.Status           = Convert.ToByte(reader.GetValue(statusColumnIndex));
                    record.Inventory_status = Convert.ToByte(reader.GetValue(inventory_statusColumnIndex));
                    record.Date_loaded      = Convert.ToDateTime(reader.GetValue(date_loadedColumnIndex));
                    record.Date_to_expire   = Convert.ToDateTime(reader.GetValue(date_to_expireColumnIndex));
                    if (!reader.IsDBNull(date_activeColumnIndex))
                    {
                        record.Date_active = Convert.ToDateTime(reader.GetValue(date_activeColumnIndex));
                    }
                    if (!reader.IsDBNull(date_first_usedColumnIndex))
                    {
                        record.Date_first_used = Convert.ToDateTime(reader.GetValue(date_first_usedColumnIndex));
                    }
                    if (!reader.IsDBNull(date_last_usedColumnIndex))
                    {
                        record.Date_last_used = Convert.ToDateTime(reader.GetValue(date_last_usedColumnIndex));
                    }
                    if (!reader.IsDBNull(date_deactivatedColumnIndex))
                    {
                        record.Date_deactivated = Convert.ToDateTime(reader.GetValue(date_deactivatedColumnIndex));
                    }
                    if (!reader.IsDBNull(date_archivedColumnIndex))
                    {
                        record.Date_archived = Convert.ToDateTime(reader.GetValue(date_archivedColumnIndex));
                    }

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

            totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1;
            return((PhoneCardRow[])(recordList.ToArray(typeof(PhoneCardRow))));
        }
Пример #16
0
 /// <summary>
 /// Deletes the specified object from the <c>PhoneCard</c> table.
 /// </summary>
 /// <param name="value">The <see cref="PhoneCardRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(PhoneCardRow value)
 {
     return(DeleteByPrimaryKey(value.Service_id, value.Pin));
 }