public void addEntry(Object sender, EventArgs e)
 {
     if (Request.Cookies["username"] != null && Request.Cookies["password"] != null)
     {
         string username = Request.Cookies["username"].Value;
         string password = Request.Cookies["password"].Value;
         if (Validation.isValidPhoneNumber(username) && Validation.isValidPassword(password))
         {
             UsersDatabaseAccessor db = new UsersDatabaseAccessor(username, password);
             if (db.isLoggedIn())
             {
                 if (db.CanAdd())
                 {
                     string entryUsername = addEntryPhone.Value;
                     string entryPassword = addEntryPass.Value;
                     if (Validation.isValidPhoneNumber(entryUsername) && Validation.isValidPassword(entryPassword))
                     {
                         db.addUser(entryUsername, entryPassword);
                         Response.Redirect(Request.RawUrl);
                     }
                 }
             }
         }
     }
 }
    private void createTitle(Table table, UsersDatabaseAccessor db)
    {
        if (db.CanAdd())
        {
            int colspan = 1;
            if (db.CanDelete())
            {
                colspan++;
            }
            if (db.CanModify())
            {
                colspan += 3;
            }

            TableRow additionTitleRow = new TableRow();
            table.Controls.Add(additionTitleRow);
            additionTitleRow.Style.Add("background-color", "#7A9124");
            additionTitleRow.Style.Add("color", "white");

            TableCell additionTitleCell = new TableCell {
                ColumnSpan = colspan
            };
            additionTitleRow.Controls.Add(additionTitleCell);

            Button additionTitleButton = new Button();
            additionTitleCell.Controls.Add(additionTitleButton);
            additionTitleButton.Text          = "Adding";
            additionTitleButton.OnClientClick = "addEntry(); return false";
        }

        TableRow permissioTitlenRow = new TableRow();

        table.Controls.Add(permissioTitlenRow);
        permissioTitlenRow.Style.Add("background-color", "#7A9124");
        permissioTitlenRow.Style.Add("color", "white");
        permissioTitlenRow.Controls.Add(new TableCell());

        if (db.CanModify())
        {
            permissioTitlenRow.Controls.Add(new TableCell {
                ColumnSpan = 3, Text = "Permissions"
            });
        }

        if (db.CanDelete())
        {
            permissioTitlenRow.Controls.Add(new TableCell());
        }

        TableRow titleRow = new TableRow();

        table.Controls.Add(titleRow);
        titleRow.Style.Add("background-color", "#7A9124");
        titleRow.Style.Add("color", "white");

        titleRow.Controls.Add(new TableCell {
            Text = "Phone number"
        });

        if (db.CanModify())
        {
            titleRow.Controls.Add(new TableCell {
                Text = "Adding"
            });
            titleRow.Controls.Add(new TableCell {
                Text = "Deleting"
            });
            titleRow.Controls.Add(new TableCell {
                Text = "Managing"
            });
        }

        if (db.CanDelete())
        {
            titleRow.Controls.Add(new TableCell {
                Text = "Deletion"
            });
        }
    }