protected void OnToolBarButtonClick(object sender, CommandEventArgs e)
    {
        if (e.CommandName == "delete")
        {
            try
            {
                if (Entity != null)
                    Entity.Delete();

                GoBack("~/bitrix/admin/InfotoursCategories.aspx");
            }
            catch (Exception ex)
            {
                this.errorMessageText = ex.Message;
                this.editorError = categorieEditorError.Deleting;
            }
        }
    }
    void TrySave()
    {
        if (this.editorError != categorieEditorError.None)
            return;

        if (this.entity == null)
        {
            this.editorError = categorieEditorError.IsNotFound;
            this.errorMessageText = GetMessageRaw("Message.categorieIsNotFound");
            return;
        }

        try
        {
            this.entity.name = name.Text;
            this.entity.sourceid = Int32.Parse(sourceid.Text);
            this.entity.description = description.Text;
   
            this.entity.Save();
            this.entityId = this.entity.id;
        }
        catch (Exception exc)
        {
            this.errorMessageText = exc.Message;
            this.editorError = this.entity.IsNew ? categorieEditorError.Creation : categorieEditorError.Modification;
        }
    }
    void TrySave()
    {
        if (this.editorError != categorieEditorError.None)
            return;

        if (this.entity == null)
        {
            this.editorError = categorieEditorError.IsNotFound;
            this.errorMessageText = GetMessageRaw("Message.categorieIsNotFound");
            return;
        }

        try
        {
            this.entity.name = name.Text;
            int teamId = 0;
   
            this.entity.Save();
            this.entityId = this.entity.id;
        }
        catch (Exception exc)
        {
            this.errorMessageText = exc.Message;
            this.editorError = this.entity.IsNew ? categorieEditorError.Creation : categorieEditorError.Modification;
        }
    }