예제 #1
0
        public void Read()
        {
            string sql = "SELECT groupid, group_name FROM Groups";

            SQLiteDataReader reader;
            string result = ExecuteQuery(sql, null, out reader);

            this._alGroups.Clear();

            if (result == string.Empty)
            {
                while (reader.Read())
                {
                    GroupDetails gd = new GroupDetails();
                    gd.GroupID = int.Parse(reader["groupid"].ToString());
                    gd.GroupName = reader["group_name"].ToString();

                    this._alGroups.Add(gd);
                }
            }
            else
            {
                CloseConnection();
                System.Diagnostics.Debug.WriteLine(result);
                throw new Exception(result);
            }

            CloseConnection();
        }
예제 #2
0
        public void Read()
        {
            string sql = "SELECT groupid, group_name FROM Groups";

            SQLiteDataReader reader;
            string           result = ExecuteQuery(sql, null, out reader);

            this._alGroups.Clear();

            if (result == string.Empty)
            {
                while (reader.Read())
                {
                    GroupDetails gd = new GroupDetails();
                    gd.GroupID   = int.Parse(reader["groupid"].ToString());
                    gd.GroupName = reader["group_name"].ToString();

                    this._alGroups.Add(gd);
                }
            }
            else
            {
                CloseConnection();
                System.Diagnostics.Debug.WriteLine(result);
                throw new Exception(result);
            }

            CloseConnection();
        }
예제 #3
0
        public void GetGroupsWithServerCount()
        {
            string sql = "select * from viewGroupsWithServerCount";

            SQLiteDataReader reader;
            string           result = ExecuteQuery(sql, null, out reader);

            if (result == string.Empty)
            {
                this._alGroups.Clear();

                while (reader.Read())
                {
                    GroupDetails gd = new GroupDetails();
                    gd.GroupID     = int.Parse(reader["groupid"].ToString());
                    gd.GroupName   = reader["group_name"].ToString();
                    gd.ServerCount = int.Parse(reader["ServerCount"].ToString());

                    this._alGroups.Add(gd);
                }
            }
            else
            {
                CloseConnection();
                throw new Exception(result);
            }

            CloseConnection();
        }
예제 #4
0
        private void Update(GroupDetails group_details)
        {
            string sql = "UPDATE Groups SET groupid = @gid, group_name = @gname WHERE groupid = @gid";

            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@gid",   group_details.GroupID),
                new SQLiteParameter("@gname", group_details.GroupName)
            };

            string result = ExecuteNonQuery(sql, parameters);

            if (result == string.Empty)
            {
            }
            else
            {
                CloseConnection();
                System.Diagnostics.Debug.WriteLine(result);

                if (result.Contains("Abort due to constraint violation"))
                {
                    throw new DatabaseException(DatabaseException.ExceptionTypes.DUPLICATE_ENTRY);
                }
                else
                {
                    throw new Exception(result);
                }
            }

            CloseConnection();
        }
예제 #5
0
        private void Save(GroupDetails group_details)
        {
            string sql = "INSERT INTO Groups(groupid, group_name) VALUES((select count(Groups.groupid) from groups) + 1, @gname);";

            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@gname", group_details.GroupName)
            };

            string result = ExecuteNonQuery(sql, parameters);

            if (result == string.Empty)
            {
            }
            else
            {
                CloseConnection();
                System.Diagnostics.Debug.WriteLine(result);

                if (result.Contains("Abort due to constraint violation"))
                {
                    throw new DatabaseException(DatabaseException.ExceptionTypes.DUPLICATE_ENTRY);
                }
                else
                {
                    throw new Exception(result);
                }
            }

            CloseConnection();
        }
예제 #6
0
 public void Save(bool isNew, GroupDetails group_details)
 {
     if (isNew)
     {
         Save(group_details);
     }
     else
     {
         Update(group_details);
     }
 }
예제 #7
0
        public void GetGroupsWithServerCount()
        {
            string sql = "select * from viewGroupsWithServerCount";

            SQLiteDataReader reader;
            string result = ExecuteQuery(sql, null, out reader);

            if (result == string.Empty)
            {
                this._alGroups.Clear();

                while (reader.Read())
                {
                    GroupDetails gd = new GroupDetails();
                    gd.GroupID = int.Parse(reader["groupid"].ToString());
                    gd.GroupName = reader["group_name"].ToString();
                    gd.ServerCount = int.Parse(reader["ServerCount"].ToString());

                    this._alGroups.Add(gd);
                }
            }
            else
            {
                CloseConnection();
                throw new Exception(result);
            }

            CloseConnection();
        }
예제 #8
0
        private void Update(GroupDetails group_details)
        {
            string sql = "UPDATE Groups SET groupid = @gid, group_name = @gname WHERE groupid = @gid";
            SQLiteParameter[] parameters = {
                                               new SQLiteParameter("@gid", group_details.GroupID),
                                               new SQLiteParameter("@gname", group_details.GroupName)
                                           };

            string result = ExecuteNonQuery(sql, parameters);

            if (result == string.Empty)
            {
            }
            else
            {
                CloseConnection();
                System.Diagnostics.Debug.WriteLine(result);

                if (result.Contains("Abort due to constraint violation"))
                {
                    throw new DatabaseException(DatabaseException.ExceptionTypes.DUPLICATE_ENTRY);
                }
                else
                {
                    throw new Exception(result);
                }
            }

            CloseConnection();
        }
예제 #9
0
        private void Save(GroupDetails group_details)
        {
            string sql = "INSERT INTO Groups(groupid, group_name) VALUES((select count(Groups.groupid) from groups) + 1, @gname);";
            SQLiteParameter[] parameters = {
                                               new SQLiteParameter("@gname", group_details.GroupName)
                                           };

            string result = ExecuteNonQuery(sql, parameters);

            if (result == string.Empty)
            {
            }
            else
            {
                CloseConnection();
                System.Diagnostics.Debug.WriteLine(result);

                if (result.Contains("Abort due to constraint violation"))
                {
                    throw new DatabaseException(DatabaseException.ExceptionTypes.DUPLICATE_ENTRY);
                }
                else
                {
                    throw new Exception(result);
                }
            }

            CloseConnection();
        }
예제 #10
0
 public void Save(bool isNew, GroupDetails group_details)
 {
     if (isNew)
     {
         Save(group_details);
     }
     else
     {
         Update(group_details);
     }
 }