private void FillInvitationsTable()
        {
            StringBuilder sb = new StringBuilder();
            Invitations.Clear();
            using (Database db = new MySqlDatabase())
            {
                DataTable dt = db.GetInvitations(Util.UserId);
                pendingInvitationsHeader.Visible = (dt.Rows.Count > 0);
                foreach (DataRow row in dt.Rows)
                {
                    long confId = Convert.ToInt64(row["confirmation_id"]);
                    long userId = Convert.ToInt64(row["requesting_user_id"]);
                    int relType = Convert.ToInt32(row["relationtype"]);

                    UserInfo ui = db.GetUser(userId);
                    ClientInfo ci = db.GetClientInfo(userId);

                    AddInvitationsRow(Invitations, ci.GetFullName(), ui.Email, confId, relType);
                }
                Invitations.DefaultView.Sort = "name ASC";
                pendingInvitations.DataSource = Invitations;
                pendingInvitations.DataBind();
            }
        }
        private void FillInvitationsTable()
        {
            StringBuilder sb = new StringBuilder();

            using (Database db = new MySqlDatabase())
            {
                DataTable dt = db.GetInvitations(Util.UserId);

                DataTable pendingInvitationTable = dt.Clone();

                DataTable pendingManageInvitationTable = dt.Clone();

                foreach (DataRow row in dt.Rows)
                {
                    if (Convert.ToInt32(row["relationtype"]) == 0)
                        pendingInvitationTable.ImportRow(row);
                    else
                        pendingManageInvitationTable.ImportRow(row);
                }

                if (Invitations == null)
                {
                    DataTable tempDt = new DataTable("confirmations");
                    tempDt.Columns.Add("name", typeof(string));
                    tempDt.Columns.Add("email", typeof(string));
                    tempDt.Columns.Add("confirmation_id", typeof(long));
                    tempDt.Columns.Add("relation_type", typeof(int));
                    Invitations = tempDt;
                }
                Invitations.Clear();
                if (pendingInvitationTable.Rows.Count > 0)
                {
                    pendingInvitationsHeader.Visible = (dt.Rows.Count > 0);

                    foreach (DataRow row in pendingInvitationTable.Rows)
                    {
                        long confId = Convert.ToInt64(row["confirmation_id"]);
                        long userId = Convert.ToInt64(row["requesting_user_id"]);
                        relType = Convert.ToInt32(row["relationtype"]);

                        UserInfo ui = db.GetUser(userId);
                        ClientInfo ci = db.GetClientInfo(userId);
                        AddInvitationsRow(Invitations, ci.GetFullName(), ui.Email, confId, relType);
                    }
                    Invitations.DefaultView.Sort = "name ASC";
                    pendingInvitations.DataSource = Invitations;
                    pendingInvitations.DataBind();
                }
                else
                {
                    pendingInvitations.DataSource = null;
                    pendingInvitations.DataBind();
                }

                if (ManagedInvitations == null)
                {
                    DataTable tempDt = new DataTable("confirmations");
                    tempDt.Columns.Add("name", typeof(string));
                    tempDt.Columns.Add("email", typeof(string));
                    tempDt.Columns.Add("confirmation_id", typeof(long));
                    tempDt.Columns.Add("relation_type", typeof(int));
                    ManagedInvitations = tempDt;
                }
                ManagedInvitations.Clear();
                if (pendingManageInvitationTable.Rows.Count > 0)
                {
                    pendingManageInvitationsHeader.Visible = (dt.Rows.Count > 0);

                    foreach (DataRow row in pendingManageInvitationTable.Rows)
                    {
                        long confId = Convert.ToInt64(row["confirmation_id"]);
                        long userId = Convert.ToInt64(row["requesting_user_id"]);
                        relType = Convert.ToInt32(row["relationtype"]);

                        UserInfo ui = db.GetUser(userId);
                        ClientInfo ci = db.GetClientInfo(userId);
                        AddInvitationsRow(ManagedInvitations, ci.GetFullName(), ui.Email, confId, relType);
                    }
                    ManagedInvitations.DefaultView.Sort = "name ASC";
                    pendingManageInvitations.DataSource = ManagedInvitations;
                    pendingManageInvitations.DataBind();
                }
                else
                {
                    pendingManageInvitations.DataSource = null;
                    pendingManageInvitations.DataBind();
                }
            }
        }