Exemple #1
0
        internal ArrayList SelectAllSubGroups(SQLiteConnection con, string TableNames, string TableName, int GroupID)
        {
            ArrayList alRet = new ArrayList();

            //Вносим в массив первый элемент - Группу "GroupID"
            AllSubGroups _allSubGroups = new AllSubGroups();

            _allSubGroups.ID   = GroupID;
            _allSubGroups.Read = false;
            alRet.Add(_allSubGroups);

            int iCount = 0; //На всязкий случае, если всё таки зациклит

            while (true)
            {
                if (SelectSubGroups(con, TableNames, TableName, alRet) == 0)
                {
                    break;
                }

                //На всязкий случае, если всё таки зациклит
                iCount++;
                if (iCount > 200)
                {
                    break;
                }
            }

            return(alRet);
        }
Exemple #2
0
        private int SelectSubGroups(SQLiteConnection con, string TableNames, string TableName, ArrayList alRet)
        {
            int iCount = 0;

            using (SQLiteCommand cmd = new SQLiteCommand("SELECT " + TableName + "ID FROM " + TableNames + " WHERE Sub=@GroupID", con))
            {
                int       forCount = alRet.Count;
                ArrayList alMas    = new ArrayList(); //Для "Read = true"
                for (int i = 0; i < forCount; i++)
                {
                    AllSubGroups _allSubGroups = (AllSubGroups)alRet[i];

                    //Если этот "GroupID" ещё не обработали
                    if (!_allSubGroups.Read)
                    {
                        cmd.Parameters.Clear();
                        SQLiteParameter parGroupID = new SQLiteParameter("@GroupID", System.Data.DbType.Int32)
                        {
                            Value = _allSubGroups.ID
                        }; cmd.Parameters.Add(parGroupID);
                        using (SQLiteDataReader dr = cmd.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                AllSubGroups _allSubGroups2 = new AllSubGroups();
                                _allSubGroups2.ID   = Convert.ToInt32(dr[TableName + "ID"].ToString());
                                _allSubGroups2.Read = false;
                                alRet.Add(_allSubGroups2);

                                iCount++;
                            }
                        }
                        alMas.Add(i);
                    }

                    /*alRet.RemoveAt(i);
                     * AllSubGroups _allSubGroups3 = new AllSubGroups();
                     * _allSubGroups3.ID = _allSubGroups3.ID;
                     * _allSubGroups3.Read = true;
                     * alRet.Add(_allSubGroups3);*/
                }

                //Ставим "Read = true"
                for (int i = 0; i < alMas.Count; i++)
                {
                    int          iMas          = Convert.ToInt32(alMas[i].ToString());
                    AllSubGroups _allSubGroups = (AllSubGroups)alRet[iMas];
                    _allSubGroups.Read = true;
                    alRet[iMas]        = _allSubGroups;
                }
            }

            return(iCount);
        }