protected void addSubmit_Click(object sender, EventArgs e) { //check for nulls if ((String.IsNullOrEmpty(addRoleIDTextBox.Text)) || (String.IsNullOrEmpty(addObjectTextBox.Text)) || (String.IsNullOrEmpty(addUpdateTextBox.Text)) || (String.IsNullOrEmpty(addViewTextBox.Text)) || (String.IsNullOrEmpty(addCreateTextBox.Text)) || (String.IsNullOrEmpty(addDeleteTextBox.Text))) { //return a error message errorLabel.Text = "Please enter a valid value for all fields"; errorLabel.Visible = true; } else { try { IRolePermissionRepository rolePermRepo = RepositoryFactory.Get <IRolePermissionRepository>(); RolePermission addMe = new RolePermission(); addMe.obj_create = int.Parse(addCreateTextBox.Text); addMe.obj_delete = int.Parse(addDeleteTextBox.Text); addMe.obj_update = int.Parse(addUpdateTextBox.Text); addMe.obj_view = int.Parse(addViewTextBox.Text); addMe.@object = addObjectTextBox.Text; addMe.roleID = int.Parse(addRoleIDTextBox.Text); rolePermRepo.AddRolePermission(addMe); rolePermRepo.SubmitChanges(); //return a validation message errorLabel.Text = "New Permission has been added"; errorLabel.Visible = true; //hide the panel addPanel.Visible = false; } catch (Exception) { //error message errorLabel.Text = "Database error when adding role permission"; errorLabel.Visible = true; } updateRolePermissionTable(); } }