public ContactTableCollection FetchByQuery(Query qry)
        {
            ContactTableCollection coll = new ContactTableCollection();

            coll.LoadAndCloseReader(qry.ExecuteReader());
            return(coll);
        }
예제 #2
0
        //overloaded
        public static int getuserIds(string username, string password, string returnid)
        {
            //should we rquire password encryption here?
            //string txtPassword = wwi_security.DecryptString(password, "publiship");

            int   _account = 0;
            Query _qry1    = new Query(Tables.ContactTable).WHERE("ContactName", Comparison.Equals, username).AND("Password", Comparison.Equals, password).AND("Live", Comparison.Equals, true);
            ContactTableCollection _contact = new ContactTableCollection();

            _contact.LoadAndCloseReader(_qry1.ExecuteReader());

            if (_contact.Count != 0)
            {
                _account = returnid == "user"? (int)_contact[0].ContactID : (int)_contact[0].CompanyID;
            }
            else
            {
                Query _qry2 = new Query(Tables.EmployeesTable).WHERE("Name", Comparison.Equals, username).AND("Password", Comparison.Equals, password).AND("Live", Comparison.Equals, true);
                EmployeesTableCollection _employ = new EmployeesTableCollection();
                _employ.LoadAndCloseReader(_qry2.ExecuteReader());

                if (_employ.Count != 0)
                {
                    _account = returnid == "user"? (int)_employ[0].EmployeeID: -1;
                }
            }

            return(_account);
        }
예제 #3
0
        //end get user account

        /// <summary>
        /// derive user ids as userid#companyid for a valid login
        /// return empty string if login fails
        /// </summary>
        /// <param name="username">name of user</param>
        /// <param name="password">encrypted password</param>
        /// <returns></returns>
        public static String getuserIds(string username, string password)
        {
            //should we rquire password encryption here?
            //string txtPassword = wwi_security.DecryptString(password, "publiship");

            String _account = "";
            Query  _qry1    = new Query(Tables.ContactTable).WHERE("ContactName", Comparison.Equals, username).AND("Password", Comparison.Equals, password).AND("Live", Comparison.Equals, true);
            ContactTableCollection _contact = new ContactTableCollection();

            _contact.LoadAndCloseReader(_qry1.ExecuteReader());

            if (_contact.Count != 0)
            {
                _account = _contact[0].ContactID.ToString() + "#" + (String)_contact[0].CompanyID.ToString();
            }
            else
            {
                Query _qry2 = new Query(Tables.EmployeesTable).WHERE("Name", Comparison.Equals, username).AND("Password", Comparison.Equals, password).AND("Live", Comparison.Equals, true);
                EmployeesTableCollection _employ = new EmployeesTableCollection();
                _employ.LoadAndCloseReader(_qry2.ExecuteReader());

                if (_employ.Count != 0)
                {
                    _account = _employ[0].EmployeeID.ToString() + "#-1"; //internal users do not have a company id set to -1
                }
            }

            return(_account);
        }
예제 #4
0
        //end decrypt string

        /// <summary>
        /// derive user details from submitted email address
        /// </summary>
        /// <param name="txtmail"></param>
        /// <returns></returns>
        public static String getuserAccount(string txtmail)
        {
            txtmail = wwi_security.DecryptString(txtmail, "publiship");
            String _account = "";
            Query  _qryb    = new Query(Tables.ContactTable).WHERE("Email", Comparison.Equals, txtmail).AND("Live", Comparison.Equals, true);
            ContactTableCollection _contact = new ContactTableCollection();

            _contact.LoadAndCloseReader(_qryb.ExecuteReader());

            if (_contact.Count != 0)
            {
                _account = (String)_contact[0].ContactName + "#" + (String)_contact[0].Password;
            }
            else
            {
                Query _qry = new Query(Tables.EmployeesTable).WHERE("EmailAddress", Comparison.Equals, txtmail).AND("Live", Comparison.Equals, true);
                EmployeesTableCollection _employ = new EmployeesTableCollection();
                _employ.LoadAndCloseReader(_qry.ExecuteReader());

                if (_employ.Count != 0)
                {
                    _account = (String)_employ[0].Name + "#" + (String)_employ[0].Password;
                }
            }

            return(_account);
        }
        public ContactTableCollection FetchAll()
        {
            ContactTableCollection coll = new ContactTableCollection();
            Query qry = new Query(ContactTable.Schema);

            coll.LoadAndCloseReader(qry.ExecuteReader());
            return(coll);
        }
        public ContactTableCollection FetchByID(object ContactID)
        {
            ContactTableCollection coll = new ContactTableCollection().Where("ContactID", ContactID).Load();

            return(coll);
        }