Esempio n. 1
0
        //--- Begin Custom Code ---

        public bool FullNameExists(string fullName)
        {
            bool           exists;
            Database       database;
            DbCommand      dbCommand;
            GreyFoxContact c;

            c = new GreyFoxContact();
            c.ParseName(fullName);

            database  = DatabaseFactory.CreateDatabase();
            dbCommand = database.GetSqlStringCommand("SELECT COUNT(*) " +
                                                     "FROM " + tableName +
                                                     "WHERE FirstName=@FirstName " +
                                                     "	AND MiddleName=@MiddleName "+
                                                     "	AND LastName=@LastName "+
                                                     "	AND Suffix=@Suffix;");

            addParameter(database, dbCommand, "FirstName", DbType.String, c.firstName);
            addParameter(database, dbCommand, "MiddleName", DbType.String, c.middleName);
            addParameter(database, dbCommand, "LastName", DbType.String, c.lastName);
            addParameter(database, dbCommand, "Suffix", DbType.String, c.Suffix);

            exists = ((int)database.ExecuteScalar(dbCommand)) > 0;

            c = null;

            return(exists);
        }
Esempio n. 2
0
        /// <summary>
        /// An object to cache the parameterized query for full name queries.
        /// </summary>
        public GreyFoxContact FindByFullName(string fullName, bool placeHolderOnly)
        {
            StringBuilder  query;
            Database       database;
            DbCommand      dbCommand;
            IDataReader    r;
            GreyFoxContact c;

            // create a new contact to parse a name into.
            c = new GreyFoxContact(tableName);
            c.ParseName(fullName);

            query = new StringBuilder();
            query.Append("SELECT ");
            if (placeHolderOnly)
            {
                query.Append(InnerJoinFields[0]);
            }
            else
            {
                query.Append(string.Join(",", InnerJoinFields));
            }
            query.Append(" FROM ");
            query.Append(tableName);
            query.Append(" WHERE FirstName=@FirstName AND " +
                         "MiddleName=@MiddleName AND " +
                         "LastName=@LastName AND " +
                         "Suffix=@Suffix;");

            database  = DatabaseFactory.CreateDatabase();
            dbCommand = database.GetSqlStringCommand(query.ToString());

            addParameter(database, dbCommand, "FirstName", DbType.String, c.firstName);
            addParameter(database, dbCommand, "MiddleName", DbType.String, c.middleName);
            addParameter(database, dbCommand, "LastName", DbType.String, c.lastName);
            addParameter(database, dbCommand, "Suffix", DbType.String, c.Suffix);

            r = database.ExecuteReader(dbCommand);
            if (r.Read())
            {
                if (placeHolderOnly)
                {
                    c = GreyFoxContact.NewPlaceHolder(tableName, r.GetInt32(0));
                }
                else
                {
                    c = GreyFoxContactManager.ParseFromReader(tableName, r, 0, 1);
                }
            }
            return(c);
        }
Esempio n. 3
0
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        private void parseTest(string name,
                               string prefix, string first, string middle, string last, string suffix)
        {
            GreyFoxContact contact;
            bool           pass;

            contact = new GreyFoxContact();
            contact.ParseName(name);

            pass = contact.Prefix == prefix &&
                   contact.FirstName == first &&
                   contact.MiddleName == middle &&
                   contact.LastName == last &&
                   contact.Suffix == suffix;

            if (!pass)
            {
                throw new Exception("Failed name parse.");
            }
        }
Esempio n. 4
0
        public PeopleTestData()
        {
            contactA = new GreyFoxContact("TestContacts");
            contactA.ParseName("Alexander E. Smith");
            contactA.DisplayName   = "Alexander E. Smith";
            contactA.Address1      = "5555 Somewhere St.";
            contactA.City          = "Anytown";
            contactA.StateProvince = "VA";
            contactA.PostalCode    = "55555";
            contactA.Country       = "USA";
            contactA.HomePhone     = "(555)555-5555";
            contactA.WorkPhone     = "(555)555-5555";
            contactA.BirthDate     = new DateTime(1954, 3, 20);
            contactA.ContactMethod = GreyFoxContactMethod.WorkPhone;

            contactB = new GreyFoxContact("TestContacts");
            contactB.ParseName("Frank Corndog");
            contactB.DisplayName   = "Frank Corndog";
            contactB.Address1      = "5555 Somewhere St.";
            contactB.City          = "Anytown";
            contactB.StateProvince = "VA";
            contactB.PostalCode    = "55555";
            contactB.Country       = "USA";
            contactB.HomePhone     = "(555)555-5555";
            contactB.WorkPhone     = "(555)555-5555";
            contactB.BirthDate     = new DateTime(1978, 6, 14);
            contactB.ContactMethod = GreyFoxContactMethod.Email;

            contactC = new GreyFoxContact("TestContacts");
            contactC.ParseName("Professor Martin E. Shorty III");
            contactC.DisplayName   = "Professor Martin E. Shorty III";
            contactC.Address1      = "5555 Somewhere St.";
            contactC.City          = "Anytown";
            contactC.StateProvince = "VA";
            contactC.PostalCode    = "55555";
            contactC.Country       = "USA";
            contactC.HomePhone     = "(555)555-5555";
            contactC.WorkPhone     = "(555)555-5555";
            contactC.ContactMethod = GreyFoxContactMethod.Email;
            contactC.BirthDate     = new DateTime(1952, 12, 10);
        }
Esempio n. 5
0
 public void ModifyContactC()
 {
     contactC.Save();
     contactC.ParseName("Alexander E. Smithy");
     contactC.Save();
 }