Пример #1
0
        /// <summary>
        /// Updates the specified database path.
        /// </summary>
        /// <param name="databasePath">The database path.</param>
        /// <param name="id">The identifier.</param>
        /// <param name="name">The name.</param>
        /// <param name="address">The address.</param>
        /// <param name="city">The city.</param>
        /// <param name="state">The state.</param>
        /// <param name="zip">The zip.</param>
        /// <param name="phone">The phone.</param>
        /// <param name="ccdwl">The CCDWL.</param>
        /// <param name="usePwd">if set to <c>true</c> [use password].</param>
        /// <param name="pwd">The password.</param>
        /// <param name="uid">The uid.</param>
        /// <param name="forgotWord">The forgot word.</param>
        /// <param name="forgotPhrase">The forgot phrase.</param>
        /// <param name="errOut">The error out.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public static bool Update(string databasePath, long id, string name, string address, string city, string state, string zip,
                                  string phone, string ccdwl, bool usePwd, string pwd, string uid, string forgotWord, string forgotPhrase,
                                  out string errOut)
        {
            bool bAns = false;

            errOut = @"";
            try
            {
                if (id == 0)
                {
                    bAns = Add(databasePath, name, address, city, state, zip, phone, ccdwl, usePwd, pwd, uid,
                               forgotWord, forgotPhrase, out errOut);
                }
                else
                {
                    int    iUsePassword = usePwd ? 1 : 0;
                    string sql          =
                        $"UPDATE Owner_Info set name='{name}',address='{One.Encrypt(address)}',City='{city}',State='{state}',Zip='{zip}',Phone='{phone}'" +
                        $",CCDWL='{One.Encrypt(ccdwl)}',UsePWD={iUsePassword},PWD='{One.Encrypt(pwd)}',UID='{One.Encrypt(uid)}',forgot_word='{One.Encrypt(forgotWord)}',forgot_phrase='{One.Encrypt(forgotPhrase)}'" +
                        $",sync_lastupdate=Now() where id={id}";
                    bAns = Database.Execute(databasePath, sql, out errOut);
                }
            }
            catch (Exception e)
            {
                errOut = ErrorMessage("Update", e);
            }
            return(bAns);
        }
Пример #2
0
        /// <summary>
        /// Adds the specified database path.
        /// </summary>
        /// <param name="databasePath">The database path.</param>
        /// <param name="name">The name.</param>
        /// <param name="address">The address.</param>
        /// <param name="city">The city.</param>
        /// <param name="state">The state.</param>
        /// <param name="zip">The zip.</param>
        /// <param name="phone">The phone.</param>
        /// <param name="ccdwl">The CCDWL.</param>
        /// <param name="usePwd">if set to <c>true</c> [use password].</param>
        /// <param name="pwd">The password.</param>
        /// <param name="uid">The uid.</param>
        /// <param name="forgotWord">The forgot word.</param>
        /// <param name="forgotPhrase">The forgot phrase.</param>
        /// <param name="errOut">The error out.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public static bool Add(string databasePath, string name, string address, string city, string state, string zip,
                               string phone, string ccdwl, bool usePwd, string pwd, string uid, string forgotWord, string forgotPhrase,
                               out string errOut)
        {
            bool bAns = false;

            errOut = @"";
            try
            {
                int    iUsePassword = usePwd ? 1 : 0;
                string sql          =
                    $"INSERT INTO Owner_Info(name,address,City,State,Zip,Phone,CCDWL,UsePWD,PWD,UID,forgot_word,forgot_phrase,sync_lastupdate) VALUES('" +
                    $"{name}','{One.Encrypt(address)}','{city}','{state}','{zip}','{phone}','{One.Encrypt(ccdwl)}',{iUsePassword},'{One.Encrypt(pwd)}','{One.Encrypt(uid)}','{One.Encrypt(forgotWord)}','{One.Encrypt(forgotPhrase)}',Now())";
                bAns = Database.Execute(databasePath, sql, out errOut);
            }
            catch (Exception e)
            {
                errOut = ErrorMessage("Add", e);
            }
            return(bAns);
        }