コード例 #1
0
        public ZipGeoCode Copy()
        {
            ZipGeoCode _zipGeoCode = new ZipGeoCode();

            _zipGeoCode.ID              = _iD;
            _zipGeoCode.ZipCode         = _zipCode;
            _zipGeoCode.ZipCodeString   = _zipCodeString;
            _zipGeoCode.City            = _city;
            _zipGeoCode.State           = _state;
            _zipGeoCode.Latitude        = _latitude;
            _zipGeoCode.Longitude       = _longitude;
            _zipGeoCode.CasesAvailable  = _casesAvailable;
            _zipGeoCode.CasesMarkedSold = _casesMarkedSold;
            return(_zipGeoCode);
        }
コード例 #2
0
 static private void LoadZipGeoCodeWithDistance(ZipGeoCode objZipGeoCode, IDataReader _reader)
 {
     if (_reader.IsDBNull(0) != true)
     {
         objZipGeoCode.ID = _reader.GetInt32(0);
     }
     if (_reader.IsDBNull(1) != true)
     {
         objZipGeoCode.ZipCode = _reader.GetInt32(1);
     }
     if (_reader.IsDBNull(2) != true)
     {
         objZipGeoCode.ZipCodeString = _reader.GetString(2);
     }
     if (_reader.IsDBNull(3) != true)
     {
         objZipGeoCode.City = _reader.GetString(3);
     }
     if (_reader.IsDBNull(4) != true)
     {
         objZipGeoCode.State = _reader.GetString(4);
     }
     if (_reader.IsDBNull(5) != true)
     {
         objZipGeoCode.Latitude = _reader.GetDouble(5);
     }
     if (_reader.IsDBNull(6) != true)
     {
         objZipGeoCode.Longitude = _reader.GetDouble(6);
     }
     if (_reader.IsDBNull(7) != true)
     {
         objZipGeoCode.CasesAvailable = _reader.GetInt32(7);
     }
     if (_reader.IsDBNull(8) != true)
     {
         objZipGeoCode.CasesMarkedSold = _reader.GetInt32(8);
     }
     if (_reader.IsDBNull(9) != true)
     {
         objZipGeoCode.Distance = _reader.GetDouble(9);
     }
 }
コード例 #3
0
        static public List <ZipGeoCode> GetAll()
        {
            List <ZipGeoCode> objZipGeoCodes = new List <ZipGeoCode>();
            Database          db             = DatabaseFactory.CreateDatabase("BRGCaseMail");

            using (IDataReader reader = db.ExecuteReader(CommandType.Text, _selectViewSQL))
            {
                while (reader.Read())
                {
                    ZipGeoCode objZipGeoCode = new ZipGeoCode();
                    LoadZipGeoCode(objZipGeoCode, reader);
                    objZipGeoCode.IsModified = false;
                    objZipGeoCodes.Add(objZipGeoCode);
                }
                // always call Close when done reading.
                reader.Close();
                return(objZipGeoCodes);
            }
        }
コード例 #4
0
        static public List <ZipGeoCode> GetForZipPart(string zippart)
        {
            List <ZipGeoCode> objZipGeoCodes = new List <ZipGeoCode>();
            Database          db             = DatabaseFactory.CreateDatabase("BRGCaseMail");
            string            _query         = _selectViewSQL + " where ZipCodeString like '" + zippart + "%' order by ZipCode asc";

            using (IDataReader reader = db.ExecuteReader(CommandType.Text, _query))
            {
                while (reader.Read())
                {
                    ZipGeoCode objZipGeoCode = new ZipGeoCode();
                    LoadZipGeoCode(objZipGeoCode, reader);
                    objZipGeoCode.IsModified = false;
                    objZipGeoCodes.Add(objZipGeoCode);
                }
                // always call Close when done reading.
                reader.Close();
                return(objZipGeoCodes);
            }
        }
コード例 #5
0
        static public List <ZipGeoCode> GetForDealer(int DealerID)
        {
            List <ZipGeoCode> objZipGeoCodes = new List <ZipGeoCode>();
            Database          db             = DatabaseFactory.CreateDatabase("BRGCaseMail");
            string            _query         = _selectViewSQL + " where ID in (select ZipGeoCodeID from DealerZipCode where DealerID = " + DealerID + ") ";

            using (IDataReader reader = db.ExecuteReader(CommandType.Text, _query))
            {
                while (reader.Read())
                {
                    ZipGeoCode objZipGeoCode = new ZipGeoCode();
                    LoadZipGeoCode(objZipGeoCode, reader);
                    objZipGeoCode.IsModified = false;
                    objZipGeoCodes.Add(objZipGeoCode);
                }
                // always call Close when done reading.
                reader.Close();
                return(objZipGeoCodes);
            }
        }
コード例 #6
0
        static public ZipGeoCode GetByID(int ID)
        {
            ZipGeoCode objZipGeoCode = new ZipGeoCode();
            string     query         = _selectViewSQL + " where ID = " + ID;
            Database   db            = DatabaseFactory.CreateDatabase("BRGCaseMail");

            using (IDataReader reader = db.ExecuteReader(CommandType.Text, query))
            {
                if (reader.Read())
                {
                    LoadZipGeoCode(objZipGeoCode, reader);
                    // always call Close when done reading.
                    reader.Close();
                    objZipGeoCode.IsModified = false;
                    return(objZipGeoCode);
                }
                else
                {
                    return(null);
                }
            }
        }
コード例 #7
0
        static public List <ZipGeoCode> GetForState(string state, float latitude, float longitude, float distance)
        {
            List <ZipGeoCode> objZipGeoCodes = new List <ZipGeoCode>();
            Database          db             = DatabaseFactory.CreateDatabase("BRGCaseMail");
            string            _query         = "Select ID, ZipCode, ZipCodeString, City, State, Latitude, Longitude, CasesAvailable, CasesMarkedSold, dbo.DistanceBetween(" + latitude + ", " + longitude + ", Latitude, Longitude) as Distance from ZipGeoCode ";

            _query += " where State = '" + state + "' and ";
            _query += " dbo.DistanceBetween(" + latitude + ", " + longitude + ", Latitude, Longitude) <  " + distance + " order by ZipCode asc ";
            using (IDataReader reader = db.ExecuteReader(CommandType.Text, _query))
            {
                while (reader.Read())
                {
                    ZipGeoCode objZipGeoCode = new ZipGeoCode();
                    LoadZipGeoCodeWithDistance(objZipGeoCode, reader);
                    objZipGeoCode.IsModified = false;
                    objZipGeoCodes.Add(objZipGeoCode);
                }
                // always call Close when done reading.
                reader.Close();
                return(objZipGeoCodes);
            }
        }
コード例 #8
0
        static public List <ZipGeoCode> GetInsideRadius(Dealer dealer)
        {
            List <ZipGeoCode> objZipGeoCodes = new List <ZipGeoCode>();
            Database          db             = DatabaseFactory.CreateDatabase("BRGCaseMail");
            string            _query         = _selectViewSQL + " where  ";

            _query += " ( dbo.DistanceBetween(" + dealer.Latitude + ", " + dealer.Longitude + ", Latitude, Longitude) <=  " + dealer.MaxDistance + ")";

            using (IDataReader reader = db.ExecuteReader(CommandType.Text, _query))
            {
                while (reader.Read())
                {
                    ZipGeoCode objZipGeoCode = new ZipGeoCode();
                    LoadZipGeoCode(objZipGeoCode, reader);
                    objZipGeoCode.IsModified = false;
                    objZipGeoCodes.Add(objZipGeoCode);
                }
                // always call Close when done reading.
                reader.Close();
                return(objZipGeoCodes);
            }
        }