예제 #1
0
        public List <Client> GetAllPartialClients()
        {
            using (OleDbConnection connection = new OleDbConnection(ConnectionString))
            {
                using (OleDbCommand sqlCommand = connection.CreateCommand())
                {
                    sqlCommand.CommandText = @"SELECT ID, OldPEID, NewPEID, ClientName, OfficeName, Standing, AddressID FROM tblClients";
                    connection.Open();

                    OleDbDataReader reader = sqlCommand.ExecuteReader();

                    List <Client> returnCollection = new List <Client>();

                    while (reader.Read())
                    {
                        int    index       = 0;
                        Client returnValue = new Client()
                        {
                            ID         = reader.GetInt32Safe(index++),
                            OldPEID    = reader.GetStringSafe(index++),
                            NewPEID    = reader.GetStringSafe(index++),
                            ClientName = reader.GetStringSafe(index++),
                            OfficeName = reader.GetStringSafe(index++),
                            Standing   = ParseStanding(reader.GetStringSafe(index++)),
                            AddressID  = reader.GetInt32Safe(index++)
                        };
                        returnCollection.Add(returnValue);
                    }

                    return(returnCollection);
                }
            }
        }
예제 #2
0
        public List <Person> GetPartialPeopleByCriteria(string criteria)
        {
            using (OleDbConnection connection = new OleDbConnection(ConnectionString))
            {
                using (OleDbCommand sqlCommand = connection.CreateCommand())
                {
                    sqlCommand.CommandText = "SELECT ID, FirstName, LastName, CurrentAssociation FROM tblPeople " + criteria;
                    connection.Open();

                    OleDbDataReader reader           = sqlCommand.ExecuteReader();
                    List <Person>   returnCollection = new List <Person>();

                    while (reader.Read())
                    {
                        int    index       = 0;
                        Person returnValue = new Person()
                        {
                            ID                 = reader.GetInt32Safe(index++),
                            FirstName          = reader.GetStringSafe(index++),
                            LastName           = reader.GetStringSafe(index++),
                            CurrentAssociation = reader.GetStringSafe(index++)
                        };
                        returnCollection.Add(returnValue);
                    }

                    return(returnCollection);
                }
            }
        }
예제 #3
0
        public List <RecordSearch> GetPartialRecordSearchesByCriteria(string criteria)
        {
            using (OleDbConnection connection = new OleDbConnection(ConnectionString))
            {
                using (OleDbCommand sqlCommand = connection.CreateCommand())
                {
                    sqlCommand.CommandText = @"SELECT ID, ICPrefix, ICYear, ICEnumeration, ICSuffix, ProjectName, Status, LastUpdated FROM tblRecordSearches " + criteria;
                    connection.Open();

                    OleDbDataReader reader = sqlCommand.ExecuteReader();

                    List <RecordSearch> returnCollection = new List <RecordSearch>();

                    while (reader.Read())
                    {
                        int          index       = 0;
                        RecordSearch returnValue = new RecordSearch()
                        {
                            ID            = reader.GetInt32Safe(index++),
                            ICTypePrefix  = reader.GetStringSafe(index++),
                            ICYear        = reader.GetStringSafe(index++),
                            ICEnumeration = reader.GetInt32Safe(index++),
                            ICSuffix      = reader.GetStringSafe(index++),
                            ProjectName   = reader.GetStringSafe(index++),
                            Status        = reader.GetStringSafe(index++),
                            LastUpdated   = reader.GetDateTimeSafe(index++)
                        };
                        returnCollection.Add(returnValue);
                    }

                    return(returnCollection);
                }
            }
        }
예제 #4
0
        private static List <Binding> LoadBindingListFromDataReader(OleDbDataReader reader)
        {
            var bindings  = new List <Binding>();
            int bindingId = -1;

            try
            {
                while (reader.Read())
                {
                    var binding = new Binding();
                    binding.Id          = reader.GetInt32(reader.GetOrdinal("BindingID"));
                    bindingId           = binding.Id;
                    binding.Name_EN     = reader.GetStringSafe(reader.GetOrdinal("Naam_EN"));
                    binding.Name_NL     = reader.GetStringSafe(reader.GetOrdinal("Naam_NL"));
                    binding.Name_FR     = reader.GetStringSafe(reader.GetOrdinal("Naam_FR"));
                    binding.CreatedDttm = reader.GetNullableDateTime(reader.GetOrdinal("CreateDttm"));
                    binding.UpdatedDttm = reader.GetNullableDateTime(reader.GetOrdinal("UpdateDttm"));
                    binding.DeletedDttm = reader.GetNullableDateTime(reader.GetOrdinal("DeleteDttm"));

                    bindings.Add(binding);
                }
            }
            catch (Exception exception)
            {
                log.ErrorFormat("Error in {0} (data record with BindingID={1}, exception={2})", MethodBase.GetCurrentMethod().Name, bindingId, exception);
                throw;
            }

            return(bindings);
        }
예제 #5
0
        public RecordSearch GetPartialRecordSearchesByCriteria(int id)
        {
            using (OleDbConnection connection = new OleDbConnection(ConnectionString))
            {
                using (OleDbCommand sqlCommand = connection.CreateCommand())
                {
                    sqlCommand.CommandText = @"SELECT ID, ICPrefix, ICYear, ICEnumeration, ICSuffix, ProjectName, Status, LastUpdated FROM tblRecordSearches WHERE ID = " + id;
                    connection.Open();

                    OleDbDataReader reader = sqlCommand.ExecuteReader();

                    int          index       = 0;
                    RecordSearch returnValue = new RecordSearch()
                    {
                        ID            = reader.GetInt32Safe(index++),
                        ICTypePrefix  = reader.GetStringSafe(index++),
                        ICYear        = reader.GetStringSafe(index++),
                        ICEnumeration = reader.GetInt32Safe(index++),
                        ICSuffix      = reader.GetStringSafe(index++),
                        ProjectName   = reader.GetStringSafe(index++),
                        Status        = reader.GetStringSafe(index++),
                        LastUpdated   = reader.GetDateTimeSafe(index++)
                    };

                    return(returnValue);
                }
            }
        }
예제 #6
0
        public List <Staff> GetAllStaff()
        {
            using (OleDbConnection connection = new OleDbConnection(ConnectionString))
            {
                using (OleDbCommand sqlCommand = connection.CreateCommand())
                {
                    sqlCommand.CommandText = "SELECT ID, PersonName, IsActive FROM tblStaff";
                    connection.Open();

                    OleDbDataReader reader           = sqlCommand.ExecuteReader();
                    List <Staff>    returnCollection = new List <Staff>();

                    while (reader.Read())
                    {
                        int   index       = 0;
                        Staff returnValue = new Staff()
                        {
                            ID        = reader.GetInt32Safe(index++),
                            Name      = reader.GetStringSafe(index++),
                            IsActive  = reader.GetBooleanSafe(index++),
                            IsChanged = false
                        };
                        returnCollection.Add(returnValue);
                    }

                    return(returnCollection);
                }
            }
        }
예제 #7
0
        private static List <Author> LoadAuthorListFromDataReader(OleDbDataReader reader)
        {
            var authors  = new List <Author>();
            int authorId = -1;

            try
            {
                while (reader.Read())
                {
                    var author = new Author();
                    author.Id          = reader.GetInt32(reader.GetOrdinal("ComponistID"));
                    authorId           = author.Id;
                    author.Name        = reader.GetStringSafe(reader.GetOrdinal("Naam"));
                    author.CreatedDttm = reader.GetNullableDateTime(reader.GetOrdinal("CreateDttm"));
                    author.UpdatedDttm = reader.GetNullableDateTime(reader.GetOrdinal("UpdateDttm"));
                    author.DeletedDttm = reader.GetNullableDateTime(reader.GetOrdinal("DeleteDttm"));

                    authors.Add(author);
                }
            }
            catch (Exception exception)
            {
                log.ErrorFormat("Error in {0} (data record with ComponistID={1}, exception={2})", MethodBase.GetCurrentMethod().Name, authorId, exception);
                throw;
            }

            return(authors);
        }
예제 #8
0
        /// <summary>
        /// Returns an Country object from the database
        /// </summary>
        /// <param name="countryId">Id of the country to be retrieved</param>
        /// <returns>Returns an Country object populated with data</returns>
        internal static Country GetCountryById(int countryId)
        {
            Country country = null;

            try
            {
                //create and open connection
                using (OleDbConnection conn = DAL.GetConnection())
                {
                    //create command
                    OleDbCommand cmd = conn.CreateCommand();
                    cmd.CommandText = "select * from Countries where CountryID = @countryId";
                    cmd.Parameters.AddWithValue("@countryId", countryId);

                    try
                    {
                        //execute a datareader, closing the connection when all the data is read from it
                        using (OleDbDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                        {
                            while (dr.Read())
                            {
                                country            = new Country();
                                country.Id         = dr.GetInt32(dr.GetOrdinal("CountryID"));
                                country.Name       = dr.GetStringSafe(dr.GetOrdinal("Country"));
                                country.Iso2Code   = dr.GetStringSafe(dr.GetOrdinal("ISO2"));
                                country.IsEuropean = dr.GetBoolean(dr.GetOrdinal("European"));
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        throw new Exception("Error while executing the following Sql statement:\n" + cmd.ToStringExtended(), exception);
                    }
                }
            }
            catch (Exception exception)
            {
                log.Error(Utility.GetExceptionWithMethodSignatureDetails(MethodBase.GetCurrentMethod(), exception, countryId));
                throw;
            }

            return(country);
        }
예제 #9
0
        private static List <Instrument> LoadInstrumentListFromDataReader(OleDbDataReader reader)
        {
            var instruments = new List <Instrument>();

            while (reader.Read())
            {
                var instrument = new Instrument();
                instrument.Id          = reader.GetInt32(reader.GetOrdinal("InstrumentID"));
                instrument.Name_EN     = reader.GetStringSafe(reader.GetOrdinal("Naam_EN"));
                instrument.Name_NL     = reader.GetStringSafe(reader.GetOrdinal("Naam_NL"));
                instrument.Name_FR     = reader.GetStringSafe(reader.GetOrdinal("Naam_FR"));
                instrument.CreatedDttm = reader.GetNullableDateTime(reader.GetOrdinal("CreateDttm"));
                instrument.UpdatedDttm = reader.GetNullableDateTime(reader.GetOrdinal("UpdateDttm"));
                instrument.DeletedDttm = reader.GetNullableDateTime(reader.GetOrdinal("DeleteDttm"));

                instruments.Add(instrument);
            }

            return(instruments);
        }
예제 #10
0
        public Client GetClientByID(int id, bool loadAsCurrentClient = true)
        {
            using (OleDbConnection connection = new OleDbConnection(ConnectionString))
            {
                using (OleDbCommand sqlCommand = connection.CreateCommand())
                {
                    sqlCommand.CommandText = @"SELECT ID, OldPEID, NewPEID, ClientName, OfficeName, Phone, Email, Website,
                    Standing, AddressID, Notes FROM tblClients WHERE ID = ?";
                    sqlCommand.Parameters.AddWithValue("ID", id);
                    connection.Open();

                    OleDbDataReader reader = sqlCommand.ExecuteReader();
                    reader.Read();

                    if (!reader.HasRows)
                    {
                        return(new Client());
                    }

                    int    index       = 0;
                    Client returnValue = new Client()
                    {
                        ID           = reader.GetInt32Safe(index++),
                        OldPEID      = reader.GetStringSafe(index++),
                        NewPEID      = reader.GetStringSafe(index++),
                        ClientName   = reader.GetStringSafe(index++),
                        OfficeName   = reader.GetStringSafe(index++),
                        Phone        = reader.GetStringSafe(index++),
                        Email        = reader.GetStringSafe(index++),
                        Website      = reader.GetStringSafe(index++),
                        Standing     = ParseStanding(reader.GetStringSafe(index++)),
                        AddressID    = reader.GetInt32Safe(index),
                        AddressModel = _as.GetAddressByID(reader.GetInt32Safe(index++)),
                        Notes        = reader.GetStringSafe(index++)
                    };

                    if (loadAsCurrentClient)
                    {
                        CurrentClient = returnValue;
                    }
                    return(returnValue);
                }
            }
        }
예제 #11
0
        private static List <ProductCategory> LoadProductCategoryListFromDataReader(OleDbDataReader reader)
        {
            var categories = new List <ProductCategory>();

            while (reader.Read())
            {
                var category = new ProductCategory();
                category.Id              = reader.GetInt32(reader.GetOrdinal("CategoryID"));
                category.ParentId        = reader.GetNullableInt32(reader.GetOrdinal("ParentCategoryID"));
                category.Name            = reader.GetStringSafe(reader.GetOrdinal("CategoryName"));
                category.SortOrder       = reader.GetInt32(reader.GetOrdinal("Sequence"));
                category.PictureFilename = reader.GetStringSafe(reader.GetOrdinal("WS_PictureFile"));
                category.PictureUpdated  = reader.GetBoolean(reader.GetOrdinal("PictureUpdated"));
                category.TargetUrl       = reader.GetStringSafe(reader.GetOrdinal("TargetURL"));
                category.CreatedDttm     = reader.GetNullableDateTime(reader.GetOrdinal("CreateDttm"));
                category.UpdatedDttm     = reader.GetNullableDateTime(reader.GetOrdinal("UpdateDttm"));
                category.DeletedDttm     = reader.GetNullableDateTime(reader.GetOrdinal("DeleteDttm"));

                categories.Add(category);
            }

            return(categories);
        }
예제 #12
0
        public Person GetPersonByID(int id, bool loadAsCurrentClient = true)
        {
            using (OleDbConnection connection = new OleDbConnection(ConnectionString))
            {
                using (OleDbCommand sqlCommand = connection.CreateCommand())
                {
                    sqlCommand.CommandText = "SELECT ID, FirstName, LastName, CurrentAssociationID, CurrentAssociation, " +
                                             "AddressID, Phone1, Phone2, Email, DisclosureLevel, Notes" +
                                             " FROM tblPeople WHERE ID = " + id;
                    connection.Open();

                    OleDbDataReader reader = sqlCommand.ExecuteReader();
                    if (!reader.HasRows)
                    {
                        return(new Person());
                    }

                    reader.Read();

                    int    index       = 0;
                    Person returnValue = new Person()
                    {
                        ID                   = reader.GetInt32Safe(index++),
                        FirstName            = reader.GetStringSafe(index++),
                        LastName             = reader.GetStringSafe(index++),
                        CurrentAssociationID = reader.GetInt32Safe(index++),
                        CurrentAssociation   = reader.GetStringSafe(index++),
                        AddressID            = reader.GetInt32Safe(index),
                        AddressModel         = _as.GetAddressByID(reader.GetInt32(index++)),
                        Phone1               = reader.GetStringSafe(index++),
                        Phone2               = reader.GetStringSafe(index++),
                        Email                = reader.GetStringSafe(index++),
                        DisclosureLevel      = reader.GetStringSafe(index++),
                        Note                 = reader.GetStringSafe(index++)
                    };

                    if (loadAsCurrentClient)
                    {
                        CurrentPerson = returnValue;
                    }
                    return(returnValue);
                }
            }
        }
예제 #13
0
        public Fee GetFeeData(Fee returnValue)
        {
            using (OleDbConnection connection = new OleDbConnection(ConnectionString))
            {
                using (OleDbCommand sqlCommand = connection.CreateCommand())
                {
                    string fields = returnValue.GetFieldNames();

                    sqlCommand.CommandText = "SELECT " + fields + ", Adjustment, AdjustmentExplanation, IsPriority, IsEmergency, IsRapidResponse FROM tblFees WHERE ID = " + returnValue.ID;
                    connection.Open();

                    OleDbDataReader reader = sqlCommand.ExecuteReader();
                    reader.Read();

                    int index = 0;
                    foreach (ICharge charge in returnValue.Charges)
                    {
                        switch (charge.Type)
                        {
                        case "variable":
                            VariableCharge vCharge = (VariableCharge)charge;
                            vCharge.Count = reader.GetDecimalSafe(index++);
                            break;

                        case "categorical":
                            CategoricalCharge cCharge = (CategoricalCharge)charge;
                            cCharge.Count = reader.GetDecimalSafe(index++);
                            break;

                        case "boolean":
                            BooleanCharge bCharge = (BooleanCharge)charge;
                            bCharge.IsIncurred = reader.GetBooleanSafe(index++);
                            break;
                        }
                    }
                    returnValue.Adjustment            = reader.GetDecimalSafe(index++);
                    returnValue.AdjustmentExplanation = reader.GetStringSafe(index++);
                    returnValue.IsPriority            = reader.GetBooleanSafe(index++);
                    returnValue.IsEmergency           = reader.GetBooleanSafe(index++);
                    returnValue.IsRapidResponse       = reader.GetBooleanSafe(index++);

                    returnValue.CalculateProjectCost();
                    return(returnValue);
                }
            }
        }
        private static List <Manufacturer> LoadManufacturerListFromDataReader(OleDbDataReader reader)
        {
            var manufacturers = new List <Manufacturer>();

            while (reader.Read())
            {
                var manufacturer = new Manufacturer();
                manufacturer.Id          = reader.GetInt32(reader.GetOrdinal("UitgeverID"));
                manufacturer.Name        = reader.GetStringSafe(reader.GetOrdinal("Naam"));
                manufacturer.CreatedDttm = reader.GetNullableDateTime(reader.GetOrdinal("CreateDttm"));
                manufacturer.UpdatedDttm = reader.GetNullableDateTime(reader.GetOrdinal("UpdateDttm"));
                manufacturer.DeletedDttm = reader.GetNullableDateTime(reader.GetOrdinal("DeleteDttm"));

                manufacturers.Add(manufacturer);
            }

            return(manufacturers);
        }
        private static List <ProductSeries> LoadProductSeriesListFromDataReader(OleDbDataReader reader)
        {
            var productSeries = new List <ProductSeries>();

            while (reader.Read())
            {
                var series = new ProductSeries();
                series.Id          = reader.GetInt32(reader.GetOrdinal("SeriesID"));
                series.Name        = reader.GetStringSafe(reader.GetOrdinal("Naam"));
                series.CreatedDttm = reader.GetNullableDateTime(reader.GetOrdinal("CreateDttm"));
                series.UpdatedDttm = reader.GetNullableDateTime(reader.GetOrdinal("UpdateDttm"));
                series.DeletedDttm = reader.GetNullableDateTime(reader.GetOrdinal("DeleteDttm"));

                productSeries.Add(series);
            }

            return(productSeries);
        }
예제 #16
0
        private static List <Supplier> LoadSupplierListFromDataReader(OleDbDataReader reader)
        {
            var suppliers = new List <Supplier>();

            while (reader.Read())
            {
                var supplier = new Supplier();
                supplier.Id   = reader.GetInt32(reader.GetOrdinal("VerdelerID"));
                supplier.Name = reader.GetStringSafe(reader.GetOrdinal("Naam"));
                supplier.MinimumDeliveryDays = reader.GetNullableInt16(reader.GetOrdinal("WS_min_delivery_days"));
                supplier.MaximumDeliveryDays = reader.GetNullableInt16(reader.GetOrdinal("WS_max_delivery_days"));
                supplier.CreatedDttm         = reader.GetNullableDateTime(reader.GetOrdinal("CreateDttm"));
                supplier.UpdatedDttm         = reader.GetNullableDateTime(reader.GetOrdinal("UpdateDttm"));
                supplier.DeletedDttm         = reader.GetNullableDateTime(reader.GetOrdinal("DeleteDttm"));

                suppliers.Add(supplier);
            }

            return(suppliers);
        }
예제 #17
0
        public Address GetAddressByID(int id)
        {
            using (OleDbConnection connection = new OleDbConnection(ConnectionString))
            {
                using (OleDbCommand sqlCommand = connection.CreateCommand())
                {
                    sqlCommand.CommandText = "SELECT ID, AddressName, AttentionTo, Line1, Line2, City, " +
                                             "State, Zip, Notes " +
                                             "FROM tblAddresses WHERE ID = ?";
                    sqlCommand.Parameters.AddWithValue("ID", id);
                    connection.Open();

                    OleDbDataReader reader = sqlCommand.ExecuteReader();
                    reader.Read();

                    if (!reader.HasRows)
                    {
                        return(new Address());
                    }

                    int     index       = 0;
                    Address returnValue = new Address()
                    {
                        AddressID    = reader.GetInt32Safe(index++),
                        AddressName  = reader.GetStringSafe(index++),
                        AttentionTo  = reader.GetStringSafe(index++),
                        AddressLine1 = reader.GetStringSafe(index++),
                        AddressLine2 = reader.GetStringSafe(index++),
                        City         = reader.GetStringSafe(index++),
                        State        = reader.GetStringSafe(index++),
                        ZIP          = reader.GetStringSafe(index++),
                        Notes        = reader.GetStringSafe(index++)
                    };

                    return(returnValue);
                }
            }
        }
예제 #18
0
        public RecordSearch GetRecordSearchByID(int id, bool loadAsCurrentSearch = true)
        {
            using (OleDbConnection connection = new OleDbConnection(ConnectionString))
            {
                using (OleDbCommand sqlCommand = connection.CreateCommand())
                {
                    sqlCommand.CommandText = "SELECT ID, ICPrefix, ICYear, ICEnumeration, ICSuffix, " +
                                             "DateReceived, DateEntered, DateOfResponse, DateBilled, DatePaid, LastUpdated, " +
                                             "RequestorID, AdditionalRequestors, ClientID, MailingAddressID, IsMailingAddressSameAsBilling, BillingAddressID, " +
                                             "ProjectName, RecordSearchType, Status, SpecialCaseDetails, " +
                                             "MainCounty, AdditionalCounties, PLSS, Acres, LinearMiles, " +
                                             "AreResourcesInProject, Recommendation, IsReportReceived, Processor, EncryptionPassword, " +
                                             "FeeVersion, FeeID, TotalCost, " +
                                             "ProjectNumber, InvoiceNumber, CheckName, CheckNumber, IsPrePaid, IsSelected, Notes " +
                                             "FROM tblRecordSearches WHERE ID = " + id;
                    connection.Open();

                    OleDbDataReader reader = sqlCommand.ExecuteReader();
                    reader.Read();

                    int          index       = 0;
                    RecordSearch returnValue = new RecordSearch()
                    {
                        ID                     = reader.GetInt32Safe(index++), //0
                        ICTypePrefix           = reader.GetStringSafe(index++),
                        ICYear                 = reader.GetStringSafe(index++),
                        ICEnumeration          = reader.GetInt32Safe(index++),
                        ICSuffix               = reader.GetStringSafe(index++),
                        DateReceived           = reader.GetDateTimeSafe(index++), //5
                        DateEntered            = reader.GetDateTimeSafe(index++),
                        DateOfResponse         = reader.GetDateTimeSafe(index++),
                        DateBilled             = reader.GetDateTimeSafe(index++),
                        DatePaid               = reader.GetDateTimeSafe(index++),
                        LastUpdated            = reader.GetDateTimeSafe(index++), //10
                        RequestorID            = reader.GetInt32Safe(index),
                        Requestor              = _ps.GetPersonByID(reader.GetInt32Safe(index++)),
                        AdditionalRequestors   = reader.GetStringSafe(index++),
                        ClientID               = reader.GetInt32Safe(index),
                        ClientModel            = _cs.GetClientByID(reader.GetInt32Safe(index++)), //15
                        MailingAddress         = _as.GetAddressByID(reader.GetInt32Safe(index++)),
                        IsMailingSameAsBilling = reader.GetBooleanSafe(index++),
                        BillingAddress         = _as.GetAddressByID(reader.GetInt32Safe(index++)),
                        ProjectName            = reader.GetStringSafe(index++),
                        RSType                 = reader.GetStringSafe(index++), //20
                        Status                 = reader.GetStringSafe(index++),
                        SpecialDetails         = reader.GetStringSafe(index++),
                        MainCounty             = reader.GetStringSafe(index++),
                        AdditionalCounties     = ParseAdditionalCounties(reader.GetStringSafe(index++)),
                        PLSS                   = reader.GetStringSafe(index++), //25
                        Acres                  = reader.GetInt32Safe(index++),
                        LinearMiles            = reader.GetInt32Safe(index++),
                        AreResourcesInProject  = reader.GetBooleanSafe(index++),
                        Recommendation         = reader.GetStringSafe(index++),
                        IsReportReceived       = reader.GetBooleanSafe(index++), //30
                        Processor              = reader.GetStringSafe(index++),
                        EncryptionPassword     = reader.GetStringSafe(index++),
                        FeeVersion             = reader.GetStringSafe(index++),
                        FeeID                  = reader.GetInt32Safe(index++),
                        TotalFee               = reader.GetDecimalSafe(index++),
                        ProjectNumber          = reader.GetStringSafe(index++),
                        InvoiceNumber          = reader.GetStringSafe(index++),
                        CheckName              = reader.GetStringSafe(index++),
                        CheckNumber            = reader.GetStringSafe(index++),
                        IsPrePaid              = reader.GetBooleanSafe(index++),
                        IsSelected             = reader.GetBooleanSafe(index++),
                        Notes                  = reader.GetStringSafe(index++),
                    };

                    returnValue.Fee = GetFeeData(returnValue.FeeVersion, returnValue.FeeID);
                    if (returnValue.IsMailingSameAsBilling)
                    {
                        returnValue.BillingAddress = returnValue.MailingAddress;
                    }
                    if (loadAsCurrentSearch)
                    {
                        CurrentRecordSearch = returnValue;
                    }
                    return(returnValue);
                }
            }
        }
예제 #19
0
        /// <summary>
        /// Populates a list with customer objects from a data reader object
        /// </summary>
        /// <param name="reader">Data Reader containing one or more customer records</param>
        /// <returns></returns>
        private static List <Customer> LoadCustomerListFromDataReader(OleDbDataReader reader)
        {
            var customers       = new List <Customer>();
            int customerStoreId = -1;

            try
            {
                while (reader.Read())
                {
                    var customer = new Customer();
                    customer.StoreId = reader.GetNullableInt32("KlantID");
                    if (customer.StoreId != null)
                    {
                        customerStoreId = (int)customer.StoreId;
                    }
                    customer.WebshopId                 = reader.GetNullableInt32("KlantID_WS");
                    customer.LastName                  = reader.GetStringSafe(reader.GetOrdinal("Naam"));
                    customer.FirstName                 = reader.GetStringSafe(reader.GetOrdinal("Voornaam"));
                    customer.ShippingAddressStreet     = reader.GetStringSafe(reader.GetOrdinal("Straat"));
                    customer.ShippingAddressHomeNumber = reader.GetStringSafe(reader.GetOrdinal("Huisnummer"));
                    customer.ShippingAddressZip        = reader.GetStringSafe(reader.GetOrdinal("ZIP"));
                    customer.ShippingAddressCity       = reader.GetStringSafe(reader.GetOrdinal("Stad"));
                    customer.ShippingAddressState      = reader.GetStringSafe(reader.GetOrdinal("Staat"));
                    customer.ShippingAddressCountry    = reader.GetStringSafe(reader.GetOrdinal("Land"));
                    customer.Phone                   = reader.GetStringSafe(reader.GetOrdinal("Telefoon"));
                    customer.Mobile                  = reader.GetStringSafe(reader.GetOrdinal("GSM"));
                    customer.Email                   = reader.GetStringSafe(reader.GetOrdinal("Email"));
                    customer.BillingName             = reader.GetStringSafe(reader.GetOrdinal("FaktuurNaam"));
                    customer.BillingContact          = reader.GetStringSafe(reader.GetOrdinal("FaktuurContact"));
                    customer.BillingAddress1         = reader.GetStringSafe(reader.GetOrdinal("FaktuurAdres1"));
                    customer.BillingAddress2         = reader.GetStringSafe(reader.GetOrdinal("FaktuurAdres2"));
                    customer.BillingAddress3         = reader.GetStringSafe(reader.GetOrdinal("FaktuurAdres3"));
                    customer.VatNumber               = reader.GetStringSafe(reader.GetOrdinal("BTW Nummer"));
                    customer.WebshopDiscount6        = reader.GetByte(reader.GetOrdinal("WebshopDiscount_6"));
                    customer.WebshopDiscount21       = reader.GetByte(reader.GetOrdinal("WebshopDiscount_21"));
                    customer.IsTeacher               = reader.GetBoolean(reader.GetOrdinal("IsLeraarOfAcademie"));
                    customer.IsReseller              = reader.GetBoolean(reader.GetOrdinal("IsReseller"));
                    customer.Institution             = reader.GetStringSafe(reader.GetOrdinal("Academie"));
                    customer.TeachingSubjects        = reader.GetStringSafe(reader.GetOrdinal("Discipline"));
                    customer.TeacherCardNumber       = reader.GetStringSafe(reader.GetOrdinal("TeacherCardNumber"));
                    customer.TeacherCardValidFrom    = reader.GetNullableDateTime(reader.GetOrdinal("TeacherCardValidFrom"));
                    customer.TeacherCardValidTo      = reader.GetNullableDateTime(reader.GetOrdinal("TeacherCardValidTo"));
                    customer.TeacherRegistrationNote = reader.GetStringSafe(reader.GetOrdinal("TeacherRegistrationNote"));
                    customer.TeacherConfirmed        = reader.GetNullableDateTime(reader.GetOrdinal("TeacherConfirmed"));
                    customer.LastLoginDttm           = reader.GetNullableDateTime(reader.GetOrdinal("LastLoginDttm"));
                    customer.CreatedDttm             = reader.GetNullableDateTime(reader.GetOrdinal("CreateDttm"));
                    customer.UpdatedDttm             = reader.GetNullableDateTime(reader.GetOrdinal("UpdateDttm"));
                    customer.DeletedDttm             = reader.GetNullableDateTime(reader.GetOrdinal("DeleteDttm"));
                    customer.ForcePasswordReset      = reader.GetBoolean(reader.GetOrdinal("ForcePasswordReset"));
                    customer.Test = reader.GetBoolean(reader.GetOrdinal("Test"));

                    customers.Add(customer);
                }
            }
            catch (Exception exception)
            {
                log.ErrorFormat("Error in {0} (data record with KlantID={1}, exception={2})", MethodBase.GetCurrentMethod().Name, customerStoreId, exception);
                throw;
            }


            return(customers);
        }