Пример #1
0
        public bool CreateAdmin(string login, string password)
        {
            if (string.IsNullOrWhiteSpace(login))
            {
                throw new Exception("Empty Login");
            }
            if (string.IsNullOrWhiteSpace(password))
            {
                throw new Exception("Empty Password");
            }
            string        q   = "insert into tbl_admins (login,pass) values (@L,@P)";
            SQLiteCommand cmd = Conn.CreateCommand();

            cmd.CommandText = q;
            cmd.Parameters.Add(new SQLiteParameter("L", login));
            cmd.Parameters.Add(new SQLiteParameter("P", password.MD5Hash()));
            try
            {
                SQLiteTransaction trans = Conn.BeginTransaction();
                cmd.ExecuteNonQuery();
                trans.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                KCore.ShowKError(ex.Message);
                return(false);
            }
        }
Пример #2
0
        public bool ExecuteNonQuery(SQLiteCommand cmd)
        {
            bool answer         = false;
            SQLiteTransaction t = Conn.BeginTransaction();

            try
            {
                cmd.ExecuteNonQuery();
                t.Commit();
                answer = true;
            }
            catch (SQLiteException sex)
            {
                KCore.ShowKError(sex.Message);
                t.Rollback();
            }
            catch (Exception ex)
            {
                KCore.ShowKError(ex.Message);
                t.Rollback();
            }
            return(answer);
        }