Exemple #1
0
    /// <summary>
    /// On chkSendToEmail checked event handler.
    /// </summary>
    protected void chkSendToEmail_CheckedChanged(object sender, EventArgs e)
    {
        txtFromEmail.Enabled  = chkSendToEmail.Checked;
        txtToEmail.Enabled    = chkSendToEmail.Checked;
        txtSubject.Enabled    = chkSendToEmail.Checked;
        chkAttachDocs.Enabled = chkSendToEmail.Checked;
        if (chkSendToEmail.Checked)
        {
            chkCustomLayout.Visible = true;
            if (chkCustomLayout.Checked)
            {
                pnlCustomLayout.Visible = true;
                lnkSave.OnClientClick   = "";

                // Reload HTML editor content
                BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formId);
                if (bfi != null && bfi.FormEmailTemplate != null)
                {
                    htmlEditor.ResolvedValue = bfi.FormEmailTemplate;
                }
            }
        }
        else
        {
            chkCustomLayout.Visible = false;
            pnlCustomLayout.Visible = false;

            // Add delete confirmation
            if (IsLayoutSet)
            {
                lnkSave.OnClientClick = "return ConfirmDelete();";
            }
        }
    }
Exemple #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CurrentMaster.HeaderActions.ActionPerformed += HeaderActions_ActionPerformed;

        // Get form info
        BizFormInfo formInfo = EditedObject as BizFormInfo;

        if (formInfo == null)
        {
            return;
        }

        // Get class of the form
        DataClassInfo classInfo = DataClassInfoProvider.GetDataClassInfo(formInfo.FormClassID);

        // Load mapping dialog control and initialize it
        plcMapping.Controls.Clear();
        mapControl = (CMSUserControl)Page.LoadUserControl("~/CMSModules/ContactManagement/Controls/UI/Contact/MappingDialog.ascx");
        if (mapControl != null)
        {
            mapControl.ID = "ctrlMapping";
            mapControl.SetValue("classname", classInfo.ClassName);
            mapControl.SetValue("allowoverwrite", classInfo.ClassContactOverwriteEnabled);
            plcMapping.Controls.Add(mapControl);
        }

        if (!RequestHelper.IsPostBack())
        {
            // Initialize checkbox value and mapping dialog visibility
            chkLogActivity.Checked = formInfo.FormLogActivity;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check permissions
        if (ActivityHelper.AuthorizedReadActivity(CMSContext.CurrentSiteID, true))
        {
            if (!QueryHelper.ValidateHash("hash"))
            {
                return;
            }

            int bizId = QueryHelper.GetInteger("bizid", 0);
            int recId = QueryHelper.GetInteger("recid", 0);

            if ((bizId > 0) && (recId > 0))
            {
                BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(bizId);

                if (bfi == null)
                {
                    return;
                }

                bizRecord.ItemID   = recId;
                bizRecord.SiteName = SiteInfoProvider.GetSiteName(bfi.FormSiteID);
                bizRecord.FormName = bfi.FormName;
            }

            CurrentMaster.Title.TitleText  = GetString("om.activitydetals.viewrecorddetail");
            CurrentMaster.Title.TitleImage = GetImagePath("Objects/OM_Activity/object.png");
        }
    }
    protected void btnOk_Click(object sender, EventArgs e)
    {
        // Check 'EditForm' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "EditForm"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "EditForm");
        }

        BizFormInfo form = BizFormInfoProvider.GetBizFormInfo(formId);

        if (form != null)
        {
            if (radAllUsers.Checked)
            {
                form.FormAccess = FormAccessEnum.AllBizFormUsers;
                BizFormInfoProvider.RemoveAllRolesFromForm(formId);
                form.ClearAuthorizedRoles();
                lstRoles.Items.Clear();
            }
            else
            {
                form.FormAccess = FormAccessEnum.OnlyAuthorizedRoles;
            }
            BizFormInfoProvider.SetBizFormInfo(form);

            lblInfo.Visible = true;
            lblInfo.Text    = GetString("General.Changessaved");
        }
    }
Exemple #5
0
    void layoutElem_OnAfterSave(object sender, EventArgs e)
    {
        // Log synchronization
        BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(bizFormId);

        SynchronizationHelper.LogObjectChange(bfi, TaskTypeEnum.UpdateObject);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (EditedObject == null)
        {
            RedirectToAccessDenied(GetString("general.invalidparameters"));
        }

        BizFormInfo form = EditedObject as BizFormInfo;

        if (form == null)
        {
            return;
        }

        var dci = DataClassInfoProvider.GetDataClassInfo(form.FormClassID);

        // Class exists
        if ((dci == null) || (!dci.ClassIsForm))
        {
            ShowWarning(GetString("BizFormGeneral.NotAFormClass"));
            SearchFields.Visible        = false;
            SearchFields.StopProcessing = true;
        }
        else
        {
            SearchFields.ItemID = dci.ClassID;
        }

        if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.form", "EditForm", SiteInfoProvider.GetSiteName(form.FormSiteID)))
        {
            RedirectToAccessDenied("cms.form", "EditForm");
        }
    }
    private int formId = 0; // BizForm id

    #endregion Fields

    #region Methods

    protected void Page_Load(object sender, EventArgs e)
    {
        // Check 'ReadForm' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "ReadForm"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "ReadForm");
        }

        formId = QueryHelper.GetInteger("formid", 0);
        bfi = BizFormInfoProvider.GetBizFormInfo(formId);
        EditedObject = bfi;

        if (bfi == null)
        {
            lblError.Visible = true;
            lblError.Text = GetString("general.invalidid");
            return;
        }

        // Init alternative forms listing
        listElem.FormClassID = bfi.FormClassID;
        listElem.OnEdit += listElem_OnEdit;
        listElem.OnDelete += listElem_OnDelete;

        // New item link
        string[,] actions = new string[1, 6];
        actions[0, 0] = HeaderActions.TYPE_HYPERLINK;
        actions[0, 1] = GetString("altforms.newformlink");
        actions[0, 2] = null;
        actions[0, 3] = ResolveUrl("AlternativeForms_New.aspx?formid=" + formId.ToString());
        actions[0, 4] = null;
        actions[0, 5] = GetImageUrl("Objects/CMS_AlternativeForm/add.png");
        this.CurrentMaster.HeaderActions.Actions = actions;
    }
Exemple #8
0
    /// <summary>
    /// Actions handler - saves the changes.
    /// </summary>
    protected void HeaderActions_ActionPerformed(object sender, CommandEventArgs e)
    {
        // Update the form object and its class
        BizFormInfo form = EditedObject as BizFormInfo;

        if ((form != null) && (mapControl != null))
        {
            if (plcMapping.Visible)
            {
                // Update mapping of the form class only if mapping dialog is visible
                DataClassInfo classInfo = DataClassInfoProvider.GetDataClassInfo(form.FormClassID);
                if (classInfo != null)
                {
                    classInfo.ClassContactOverwriteEnabled = ValidationHelper.GetBoolean(mapControl.GetValue("allowoverwrite"), false);
                    classInfo.ClassContactMapping          = ValidationHelper.GetString(mapControl.GetValue("mappingdefinition"), string.Empty);
                    DataClassInfoProvider.SetDataClassInfo(classInfo);
                }
            }

            // Update the form
            form.FormLogActivity = chkLogActivity.Checked;
            BizFormInfoProvider.SetBizFormInfo(form);

            // Show save information
            ShowChangesSaved();
        }
    }
Exemple #9
0
    /// <summary>
    /// On chkSendToEmail checked event handler.
    /// </summary>
    protected void chkSendToEmail_CheckedChanged(object sender, EventArgs e)
    {
        txtFromEmail.Enabled  = chkSendToEmail.Checked;
        txtToEmail.Enabled    = chkSendToEmail.Checked;
        txtSubject.Enabled    = chkSendToEmail.Checked;
        chkAttachDocs.Enabled = chkSendToEmail.Checked;
        if (chkSendToEmail.Checked)
        {
            chkCustomLayout.Visible = true;
            if (chkCustomLayout.Checked)
            {
                pnlCustomLayout.Visible = true;

                // Reload HTML editor content
                BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formId);
                if (bfi != null && bfi.FormEmailTemplate != null)
                {
                    htmlEditor.ResolvedValue = bfi.FormEmailTemplate;
                }
            }
        }
        else
        {
            chkCustomLayout.Visible = false;
            pnlCustomLayout.Visible = false;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check 'ReadForm' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "ReadForm"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "ReadForm");
        }

        int altFormId = QueryHelper.GetInteger("altformid", 0);
        int formId    = QueryHelper.GetInteger("formid", 0);

        bfi          = BizFormInfoProvider.GetBizFormInfo(formId);
        EditedObject = bfi;

        if (bfi == null)
        {
            ShowError(GetString("general.invalidid"));
            altFormFieldEditor.Visible = false;
            return;
        }

        CurrentMaster.BodyClass += " FieldEditorBody";
        altFormFieldEditor.AlternativeFormID = altFormId;
        altFormFieldEditor.Mode = FieldEditorModeEnum.BizFormDefinition;
        altFormFieldEditor.DisplayedControls = FieldEditorControlsEnum.Bizforms;
        altFormFieldEditor.OnBeforeSave     += altFormFieldEditor_OnBeforeSave;
        altFormFieldEditor.OnAfterSave      += altFormFieldEditor_OnAfterSave;
    }
Exemple #11
0
    /// <summary>
    /// Click event - updates new values.
    /// </summary>
    /// <param name="sender">Sender</param>
    /// <param name="e">Params</param>
    protected void nameElem_Click(object sender, EventArgs e)
    {
        // Check 'EditForm' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "EditForm"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "EditForm");
        }

        // Code name validation
        string err = new Validator().IsIdentificator(nameElem.CodeName, GetString("general.erroridentificatorformat")).Result;

        if (err != String.Empty)
        {
            lblError.Visible = true;
            lblError.Text    = err;
            lblInfo.Visible  = false;
            return;
        }

        // Validate form id
        AlternativeFormInfo afi = AlternativeFormInfoProvider.GetAlternativeFormInfo(altFormId);

        EditedObject = afi;
        if (afi == null)
        {
            return;
        }

        // Checking for duplicate items
        DataSet ds = AlternativeFormInfoProvider.GetAlternativeForms("FormName='" + SqlHelperClass.GetSafeQueryString(nameElem.CodeName, false) +
                                                                     "' AND FormClassID=" + afi.FormClassID, null);

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            if (!((ds.Tables.Count == 1) && (ds.Tables[0].Rows.Count == 1) && (
                      ValidationHelper.GetInteger(ds.Tables[0].Rows[0]["FormID"], 0) == altFormId)))
            {
                lblError.Visible = true;
                lblError.Text    = GetString("general.codenameexists");
                lblInfo.Visible  = false;
                return;
            }
        }

        afi.FormDisplayName = nameElem.DisplayName;
        afi.FormName        = nameElem.CodeName;
        AlternativeFormInfoProvider.SetAlternativeFormInfo(afi);

        // Required to log staging task, alternative form is not binded to bizform as child
        using (CMSActionContext context = new CMSActionContext())
        {
            context.CreateVersion = false;

            // Log synchronization
            BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formId);
            SynchronizationHelper.LogObjectChange(bfi, TaskTypeEnum.UpdateObject);
        }

        URLHelper.Redirect("AlternativeForms_Edit_General.aspx?altformid=" + altFormId + "&formid=" + formId + "&saved=1");
    }
        public List <FormEntry> GetFormEntries(string formName)
        {
            List <FormEntry> entries    = new List <FormEntry>();
            BizFormInfo      formObject = BizFormInfoProvider.GetBizFormInfo(formName, SiteContext.CurrentSiteID);

            if (formObject == null)
            {
                throw new InvalidOperationException("The requested checkin form does not exist.");
            }
            // Gets the class name of the form
            DataClassInfo formClass = DataClassInfoProvider.GetDataClassInfo(formObject.FormClassID);
            string        className = formClass.ClassName;

            // Loads the form's data
            ObjectQuery <BizFormItem> data = BizFormItemProvider.GetItems(className);

            // Checks whether the form contains any records
            if (!DataHelper.DataSourceIsEmpty(data))
            {
                // Loops through the form's data records
                foreach (BizFormItem item in data)
                {
                    FormEntry entry = new FormEntry();
                    entry.ID = item.ItemID;

                    foreach (var columnName in item.ColumnNames)
                    {
                        entry.FormValues.Add(columnName.ToLower(), item.GetStringValue(columnName, ""));
                    }
                    entries.Add(entry);
                }
            }
            return(entries);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check 'ReadForm' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "ReadForm"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "ReadForm");
        }

        int altFormId = QueryHelper.GetInteger("altformid", 0);
        int formId = QueryHelper.GetInteger("formid", 0);

        bfi = BizFormInfoProvider.GetBizFormInfo(formId);
        EditedObject = bfi;

        if (bfi == null)
        {
            ShowError(GetString("general.invalidid"));
            altFormFieldEditor.Visible = false;
            return;
        }

        CurrentMaster.BodyClass += " FieldEditorBody";
        altFormFieldEditor.AlternativeFormID = altFormId;
        altFormFieldEditor.Mode = FieldEditorModeEnum.BizFormDefinition;
        altFormFieldEditor.DisplayedControls = FieldEditorControlsEnum.Bizforms;
        altFormFieldEditor.OnBeforeSave += altFormFieldEditor_OnBeforeSave;
        altFormFieldEditor.OnAfterSave += altFormFieldEditor_OnAfterSave;
    }
Exemple #14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check 'ReadForm' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "ReadForm"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "ReadForm");
        }

        formId       = QueryHelper.GetInteger("formid", 0);
        bfi          = BizFormInfoProvider.GetBizFormInfo(formId);
        EditedObject = bfi;

        if (bfi == null)
        {
            ShowError(GetString("general.invalidid"));
            return;
        }

        // Init alternative forms listing
        listElem.FormClassID = bfi.FormClassID;
        listElem.OnEdit     += listElem_OnEdit;
        listElem.OnDelete   += listElem_OnDelete;

        // New item link
        string[,] actions = new string[1, 6];
        actions[0, 0]     = HeaderActions.TYPE_HYPERLINK;
        actions[0, 1]     = GetString("altforms.newformlink");
        actions[0, 2]     = null;
        actions[0, 3]     = ResolveUrl("AlternativeForms_New.aspx?formid=" + formId.ToString());
        actions[0, 4]     = null;
        actions[0, 5]     = GetImageUrl("Objects/CMS_AlternativeForm/add.png");
        CurrentMaster.HeaderActions.Actions = actions;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        CurrentMaster.PanelContent.CssClass = string.Empty;

        // Check 'ReadForm' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "ReadForm"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "ReadForm");
        }

        bizFormId                 = QueryHelper.GetInteger("formid", 0);
        layoutElem.FormType       = CMSModules_AdminControls_Controls_Class_Layout.FORMTYPE_BIZFORM;
        layoutElem.ObjectID       = bizFormId;
        layoutElem.ObjectType     = FormObjectType.BIZFORM;
        layoutElem.ObjectCategory = MetaFileInfoProvider.OBJECT_CATEGORY_LAYOUT;
        layoutElem.IsLiveSite     = false;
        layoutElem.OnBeforeSave  += layoutElem_OnBeforeSave;
        layoutElem.OnAfterSave   += layoutElem_OnAfterSave;

        // Load CSS style sheet to editor area
        if (CMSContext.CurrentSite != null)
        {
            int cssId = CMSContext.CurrentSite.SiteDefaultEditorStylesheet;
            if (cssId == 0) // Use default site CSS if none editor CSS is specified
            {
                cssId = CMSContext.CurrentSite.SiteDefaultStylesheetID;
            }
            layoutElem.CssStyleSheetID = cssId;
        }

        BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(bizFormId);

        EditedObject = bfi;
    }
Exemple #16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Add save action
        save = new SaveAction();
        menu.AddAction(save);

        // Register for action
        ComponentEvents.RequestEvents.RegisterForEvent(ComponentEvents.SAVE, lnkSave_Click);

        // Control initialization
        ltlConfirmDelete.Text = "<input type=\"hidden\" id=\"confirmdelete\" value=\"" + GetString("Bizform_Edit_Notificationemail.ConfirmDelete") + "\">";

        chkSendToEmail.Text = GetString("BizFormGeneral.chkSendToEmail");

        chkCustomLayout.Text = GetString("BizForm_Edit_NotificationEmail.CustomLayout");

        // Initialize HTML editor
        InitHTMLEditor();

        formInfo = EditedObject as BizFormInfo;

        if (!RequestHelper.IsPostBack())
        {
            if (formInfo != null)
            {
                // Get form class object
                formClassObj = DataClassInfoProvider.GetDataClassInfo(formInfo.FormClassID);

                // Fill list of available fields
                FillFieldsList();

                // Load email from/to address and email subject
                txtFromEmail.Text      = ValidationHelper.GetString(formInfo.FormSendFromEmail, "");
                txtToEmail.Text        = ValidationHelper.GetString(formInfo.FormSendToEmail, "");
                txtSubject.Text        = ValidationHelper.GetString(formInfo.FormEmailSubject, "");
                chkAttachDocs.Checked  = formInfo.FormEmailAttachUploadedDocs;
                chkSendToEmail.Checked = ((txtFromEmail.Text + txtToEmail.Text) != "");
                if (!chkSendToEmail.Checked)
                {
                    txtFromEmail.Enabled    = false;
                    txtToEmail.Enabled      = false;
                    txtSubject.Enabled      = false;
                    chkAttachDocs.Enabled   = false;
                    chkCustomLayout.Visible = false;
                    pnlCustomLayout.Visible = false;
                }
                else
                {
                    // Enable or disable form
                    EnableDisableForm(formInfo.FormEmailTemplate);
                }
            }
            else
            {
                // Disable form by default
                EnableDisableForm(null);
            }
        }
    }
    private object UniGrid_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        switch (sourceName.ToLowerCSafe())
        {
        case "edit":
        case "moveup":
        case "movedown":
        case "delete":
            (sender as ImageButton).Visible = AllowEdit;
            return(sender);

        case "answerenabled":
            return(UniGridFunctions.ColoredSpanYesNo(parameter));

        case "answerisopenended":
            return(String.IsNullOrEmpty(ValidationHelper.GetString(parameter, string.Empty)) ? GetString("polls.AnswerTypeStandard") : GetString("polls.AnswerTypeOpenEnded"));

        case "answerform":
            if (sender is ImageButton)
            {
                ImageButton imageButton = sender as ImageButton;
                GridViewRow gvr         = parameter as GridViewRow;

                if (!CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.Form", "ReadData"))
                {
                    imageButton.Visible = false;
                }
                else if (gvr != null)
                {
                    DataRowView drv = gvr.DataItem as DataRowView;
                    if (drv != null)
                    {
                        string formName = ValidationHelper.GetString(drv["AnswerForm"], null);
                        if (String.IsNullOrEmpty(formName))
                        {
                            imageButton.Visible = false;
                        }
                        else
                        {
                            BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formName, CMSContext.CurrentSiteID);
                            if ((bfi != null) && bizFormsAvailable)
                            {
                                imageButton.OnClientClick = "modalDialog('" + ResolveUrl("~/CMSModules/Polls/Tools/Polls_Answer_Results.aspx") + "?formid=" + bfi.FormID + "&dialogmode=1', 'AnswerForm', '1000', '700'); return false;";
                            }
                            else
                            {
                                imageButton.Visible = false;
                            }
                        }
                    }
                }
            }
            return(sender);
        }
        return(parameter);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        rfvDisplayName.Text = GetString("BizFormGeneral.rfvDisplayName");
        bfi = EditedObject as BizFormInfo;

        if ((!RequestHelper.IsPostBack()) && (bfi != null))
        {
            LoadData();
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        rfvDisplayName.Text = GetString("BizFormGeneral.rfvDisplayName");
        bfi = EditedObject as BizFormInfo;

        if ((!RequestHelper.IsPostBack()) && (bfi != null))
        {
            LoadData();
        }
    }
        public IForm Create(BizFormInfo info)
        {
            if (info == null)
            {
                return(new Form());
            }

            var autoresponder = new Autoresponder
            {
                Sender   = info.FormConfirmationSendFromEmail,
                Subject  = info.FormConfirmationEmailSubject,
                Template = info.FormConfirmationTemplate
            };

            var notification = new Notification
            {
                Sender     = info.FormSendFromEmail,
                Recipients = info.FormSendToEmail,
                Subject    = info.FormEmailSubject,
                Template   = info.FormEmailTemplate,
                AttachUploadedDocuments = info.FormEmailAttachUploadedDocs
            };

            var submissionOptions = new SubmissionOptions
            {
                DisplayText    = info.FormDisplayText,
                ClearAfterSave = info.FormClearAfterSave,
                RedirectUrl    = info.FormRedirectToUrl
            };

            var hasAutoResponder     = !String.IsNullOrWhiteSpace(autoresponder.Sender);
            var hasNotificationEmail = !String.IsNullOrWhiteSpace(notification.Sender) && !String.IsNullOrWhiteSpace(notification.Recipients);

            var form = new Form
            {
                Name              = info.FormName,
                SubmitText        = !string.IsNullOrEmpty(info.FormSubmitButtonText) ? info.FormSubmitButtonText : "Save",
                Autoresponder     = hasAutoResponder ? autoresponder : null,
                Notification      = hasNotificationEmail ? notification : null,
                SubmissionOptions = submissionOptions
            };

            foreach (var controlInfo in info.Form.GetFields(true, false))
            {
                var control = _controlFactory.Create(controlInfo);
                if (control == null)
                {
                    continue;
                }

                form.Controls.Add(control);
            }

            return(form);
        }
Exemple #21
0
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        CurrentMaster.DisplayControlsPanel = true;

        // Check 'ReadData' permission
        if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.form", "ReadData"))
        {
            RedirectToAccessDenied("cms.form", "ReadData");
        }
        // Check 'EditData' permission
        else if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.form", "EditData"))
        {
            RedirectToAccessDenied("cms.form", "EditData");
        }

        // Get form id from url
        formId = QueryHelper.GetInteger("formid", 0);
        if (formId > 0)
        {
            // Get form record id
            formRecordId = QueryHelper.GetInteger("formrecordid", 0);

            if (!RequestHelper.IsPostBack())
            {
                chkSendNotification.Checked  = (formRecordId <= 0);
                chkSendAutoresponder.Checked = (formRecordId <= 0);
            }

            bfi          = BizFormInfoProvider.GetBizFormInfo(formId);
            EditedObject = bfi;

            if (!RequestHelper.IsPostBack())
            {
                // Get form info
                if (bfi != null)
                {
                    // Set form
                    formElem.FormName          = bfi.FormName;
                    formElem.ItemID            = formRecordId;
                    formElem.ShowPrivateFields = true;
                }
            }

            formElem.FormRedirectToUrl  = String.Empty;
            formElem.FormDisplayText    = String.Empty;
            formElem.FormClearAfterSave = false;
            // Submit image button is based on ImageButton which does not have implemented automatic registration of Save header action in UI.
            // Hide image button in UI even if path to image is configured
            formElem.ShowImageButton = false;

            formElem.OnBeforeSave += formElem_OnBeforeSave;
        }
    }
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        CurrentMaster.DisplayControlsPanel = true;

        // Check 'ReadData' permission
        if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.form", "ReadData"))
        {
            RedirectToAccessDenied("cms.form", "ReadData");
        }
        // Check 'EditData' permission
        else if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.form", "EditData"))
        {
            RedirectToAccessDenied("cms.form", "EditData");
        }

        // Get form id from url
        formId = QueryHelper.GetInteger("formid", 0);
        if (formId > 0)
        {
            // Get form record id
            formRecordId = QueryHelper.GetInteger("formrecordid", 0);

            if (!RequestHelper.IsPostBack())
            {
                chkSendNotification.Checked = (formRecordId <= 0);
                chkSendAutoresponder.Checked = (formRecordId <= 0);
            }

            bfi = BizFormInfoProvider.GetBizFormInfo(formId);
            EditedObject = bfi;

            if (!RequestHelper.IsPostBack())
            {
                // Get form info
                if (bfi != null)
                {
                    // Set form
                    formElem.FormName = bfi.FormName;
                    formElem.ItemID = formRecordId;
                    formElem.ShowPrivateFields = true;
                }
            }

            formElem.FormRedirectToUrl = String.Empty;
            formElem.FormDisplayText = String.Empty;
            formElem.FormClearAfterSave = false;
            // Submit image button is based on ImageButton which does not have implemented automatic registration of Save header action in UI.
            // Hide image button in UI even if path to image is configured
            formElem.ShowImageButton = false;

            formElem.OnBeforeSave += formElem_OnBeforeSave;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get needed IDs
        int formId = QueryHelper.GetInteger("formid", 0);
        bfi = BizFormInfoProvider.GetBizFormInfo(formId);

        altFormEdit.OnBeforeSave += (s, ea) => altFormEdit.EditedObject.FormClassID = bfi.FormClassID;
        altFormEdit.OnAfterSave += altFormEdit_OnAfterSave;

        altFormEdit.RedirectUrlAfterCreate = String.Empty;
    }
Exemple #24
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (EditedObject == null)
        {
            RedirectToAccessDenied(GetString("general.invalidparameters"));
        }

        currentUser = MembershipContext.AuthenticatedUser;

        // Register for action
        ComponentEvents.RequestEvents.RegisterForEvent(ComponentEvents.SAVE, lnkSave_Click);

        formInfo = EditedObject as BizFormInfo;

        if (formInfo != null)
        {
            // Control initialization
            ltlConfirmDelete.Text = "<input type=\"hidden\" id=\"confirmdelete\" value=\"" + GetString("Bizform_Edit_Autoresponder.ConfirmDelete") + "\">";

            drpEmailField.SelectedIndexChanged += drpEmailField_SelectedIndexChanged;

            // Init header actions
            InitHeaderActions();

            // Initialize HTML editor
            InitHTMLEditor();

            if (!RequestHelper.IsPostBack())
            {
                // Get bizform class object
                formClassObj = DataClassInfoProvider.GetDataClassInfo(formInfo.FormClassID);
                if (formClassObj != null)
                {
                    // Enable or disable form
                    EnableDisableForm(formInfo.FormConfirmationTemplate);

                    // Fill list of available fields
                    FillFieldsList();

                    // Load dropdown list with form text fields
                    InitializeEmailDropdown();

                    // Load email subject and email from address
                    txtEmailFrom.Text    = formInfo.FormConfirmationSendFromEmail;
                    txtEmailSubject.Text = formInfo.FormConfirmationEmailSubject;
                }
                else
                {
                    // Disable form by default
                    EnableDisableForm(null);
                }
            }
        }
    }
        public IForm GetForm(string formName)
        {
            BizFormInfo formObject = BizFormInfoProvider.GetBizFormInfo(formName, SiteContext.CurrentSiteID);

            if (formObject != null)
            {
                var formInfo = _formFactory.Create(formObject);
                return(formInfo);
            }

            return(null);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get needed IDs
        int formId = QueryHelper.GetInteger("formid", 0);

        bfi = BizFormInfoProvider.GetBizFormInfo(formId);

        altFormEdit.OnBeforeSave += (s, ea) => altFormEdit.EditedObject.FormClassID = bfi.FormClassID;
        altFormEdit.OnAfterSave  += altFormEdit_OnAfterSave;

        altFormEdit.RedirectUrlAfterCreate = String.Empty;
    }
Exemple #27
0
 protected void FieldEditor_OnFieldNameChanged(object sender, string oldFieldName, string newFieldName)
 {
     if (formId > 0)
     {
         BizFormInfo formObj = BizFormInfoProvider.GetBizFormInfo(formId);
         if (formObj != null)
         {
             // Rename field in layout(s)
             FormHelper.RenameFieldInFormLayout(formObj.FormClassID, oldFieldName, newFieldName);
         }
     }
 }
Exemple #28
0
    protected void Page_Init(object sender, EventArgs e)
    {
        // Get edited object
        if (UIContext.EditedObject != null)
        {
            bfi    = (BizFormInfo)UIContext.EditedObject;
            formId = bfi.FormID;
        }

        isDialog = QueryHelper.GetBoolean("dialogmode", false);
        InitHeaderActions();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get needed IDs
        int formId = QueryHelper.GetInteger("formid", 0);
        bfi = BizFormInfoProvider.GetBizFormInfo(formId);

        altFormEdit.OnBeforeSave += (s, ea) => ((AlternativeFormInfo)altFormEdit.EditedObject).FormClassID = bfi.FormClassID;
        altFormEdit.OnAfterSave += altFormEdit_OnAfterSave;

        altFormEdit.RedirectUrlAfterCreate = String.Empty;
        CurrentMaster.Title.Breadcrumbs[0, 1] += "?formid=" + bfi.FormID;
    }
Exemple #30
0
    protected void Page_Load(object sender, EventArgs e)
    {
        rfvDisplayName.Text = GetString("BizFormGeneral.rfvDisplayName");
        lblButtonText.AssociatedControlClientID = txtButtonText.TextBox.ClientID;

        bfi = EditedObject as BizFormInfo;

        if ((!RequestHelper.IsPostBack()) && (bfi != null))
        {
            LoadData();
        }
    }
Exemple #31
0
    protected void altFormEdit_OnAfterSave(object sender, EventArgs e)
    {
        // Required to log staging task, alternative form is not bound to bizform as a child
        using (CMSActionContext context = new CMSActionContext())
        {
            context.CreateVersion = false;

            // Log synchronization
            int         formId = QueryHelper.GetInteger("formid", 0);
            BizFormInfo bfi    = BizFormInfoProvider.GetBizFormInfo(formId);
            SynchronizationHelper.LogObjectChange(bfi, TaskTypeEnum.UpdateObject);
        }
    }
Exemple #32
0
    /// <summary>
    /// Custom layout checkbox checked changed.
    /// </summary>
    protected void chkCustomLayout_CheckedChanged(object sender, EventArgs e)
    {
        pnlCustomLayout.Visible = !pnlCustomLayout.Visible;

        if (chkCustomLayout.Checked)
        {
            BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formId);
            if (bfi != null && bfi.FormEmailTemplate != null)
            {
                htmlEditor.ResolvedValue = bfi.FormEmailTemplate;
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get needed IDs
        int formId = QueryHelper.GetInteger("formid", 0);

        bfi = BizFormInfoProvider.GetBizFormInfo(formId);

        altFormEdit.OnBeforeSave += (s, ea) => ((AlternativeFormInfo)altFormEdit.EditedObject).FormClassID = bfi.FormClassID;
        altFormEdit.OnAfterSave  += altFormEdit_OnAfterSave;

        altFormEdit.RedirectUrlAfterCreate     = String.Empty;
        CurrentMaster.Title.Breadcrumbs[0, 1] += "?formid=" + bfi.FormID;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check license
        LicenseHelper.CheckFeatureAndRedirect(URLHelper.GetCurrentDomain(), FeatureEnum.ContactManagement);

        // Check if current user is authorised to read either site or global contacts
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.ContactManagement", "ModifyContacts"))
        {
            RedirectToCMSDeskAccessDenied("CMS.ContactManagement", "ModifyContacts");
        }

        // Init header actions
        string[,] actions = new string[1, 11];
        actions[0, 0]     = HeaderActions.TYPE_SAVEBUTTON;
        actions[0, 1]     = GetString("General.Save");
        actions[0, 5]     = GetImageUrl("CMSModules/CMS_Content/EditMenu/save.png");
        actions[0, 6]     = "save";
        actions[0, 8]     = "true";
        CurrentMaster.HeaderActions.LinkCssClass     = "ContentSaveLinkButton";
        CurrentMaster.HeaderActions.ActionPerformed += HeaderActions_ActionPerformed;
        CurrentMaster.HeaderActions.Actions          = actions;

        // Get form info
        BizFormInfo formInfo = (BizFormInfo)EditedObject;

        if (formInfo == null)
        {
            return;
        }

        // Get class of the form
        DataClassInfo classInfo = DataClassInfoProvider.GetDataClass(formInfo.FormClassID);

        // Load mapping dialog control and initialize it
        plcMapping.Controls.Clear();
        mapControl = (CMSUserControl)Page.LoadControl("~/CMSModules/ContactManagement/Controls/UI/Contact/MappingDialog.ascx");
        if (mapControl != null)
        {
            mapControl.ID = "ctrlMapping";
            mapControl.SetValue("classname", classInfo.ClassName);
            mapControl.SetValue("allowoverwrite", classInfo.ClassContactOverwriteEnabled);
            plcMapping.Controls.Add(mapControl);
        }

        if (!RequestHelper.IsPostBack())
        {
            // Initialize checkbox value and mapping dialog visibility
            plcMapping.Visible = chkLogActivity.Checked = formInfo.FormLogActivity;
        }
    }
Exemple #35
0
 protected void FieldEditor_OnAfterDefinitionUpdate(object sender, EventArgs e)
 {
     // Update form to log synchronization
     if (formId > 0)
     {
         BizFormInfo formObj = BizFormInfoProvider.GetBizFormInfo(formId);
         if (formObj != null)
         {
             // Enforce Form property reload next time the data are needed
             formObj.ResetFormInfo();
             BizFormInfoProvider.SetBizFormInfo(formObj);
         }
     }
 }
        private void SendAcknowledgementEmail(BizFormInfo formInfo, BizFormItem item, IList <IControl> controls)
        {
            AddSpecialFormControls(formInfo, item, controls);

            EmailMessage em = new EmailMessage
            {
                EmailFormat = EmailFormatEnum.Html,
                From        = formInfo.FormConfirmationSendFromEmail,
                Recipients  = item.GetStringValue(formInfo.FormConfirmationEmailField, String.Empty),
                Subject     = formInfo.FormConfirmationEmailSubject,
                Body        = _emailParser.Parse(formInfo.FormConfirmationTemplate, controls)
            };

            EmailSender.SendEmail(em);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check 'ReadForm' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "ReadForm"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "ReadForm");
        }

        bizFormId = QueryHelper.GetInteger("formid", 0);
        layoutElem.FormType = CMSModules_AdminControls_Controls_Class_Layout.FORMTYPE_BIZFORM;
        layoutElem.ObjectID = bizFormId;
        layoutElem.OnBeforeSave += layoutElem_OnBeforeSave;
        layoutElem.OnAfterSave += layoutElem_OnAfterSave;

        // Load CSS style sheet to editor area
        if (CMSContext.CurrentSite != null)
        {
            int cssId = CMSContext.CurrentSite.SiteDefaultEditorStylesheet;
            if (cssId == 0) // Use default site CSS if none editor CSS is specified
            {
                cssId = CMSContext.CurrentSite.SiteDefaultStylesheetID;
            }
            layoutElem.CssStyleSheetID = cssId;
        }

        AttachmentTitle.TitleText = GetString("general.attachments");

        bfi = BizFormInfoProvider.GetBizFormInfo(bizFormId);
        EditedObject = bfi;
        if (!RequestHelper.IsPostBack())
        {
            if (bfi != null)
            {
                // Init file storage
                AttachmentList.SiteID = CMSContext.CurrentSiteID;
                AttachmentList.AllowPasteAttachments = true;
                AttachmentList.ObjectID = bfi.FormID;
                AttachmentList.ObjectType = FormObjectType.BIZFORM;
                AttachmentList.Category = MetaFileInfoProvider.OBJECT_CATEGORY_LAYOUT;
            }
        }
    }
    private DataSet uniGrid_OnAfterRetrieveData(DataSet ds)
    {
        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            int i = 0;
            while (i < ds.Tables[0].Rows.Count)
            {
                BizFormInfo form = new BizFormInfo(ds.Tables[0].Rows[i]);
                if (!form.IsFormAllowedForUser(currentUser, SiteContext.CurrentSiteName))
                {
                    ds.Tables[0].Rows.RemoveAt(i);
                }
                else
                {
                    i++;
                }
            }
        }

        return ds;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check 'ReadForm' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "ReadForm"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "ReadForm");
        }

        formId = QueryHelper.GetInteger("formid", 0);
        bfi = BizFormInfoProvider.GetBizFormInfo(formId);
        EditedObject = bfi;

        if (bfi == null)
        {
            lblError.Visible = true;
            lblError.Text = GetString("general.invalidid");
            return;
        }

        classId = bfi.FormClassID;

        // Init breadcrumbs
        string[,] breadcrumbs = new string[2, 3];

        // Return to list item in breadcrumbs
        breadcrumbs[0, 0] = GetString("altforms.listlink");
        breadcrumbs[0, 1] = "~/CMSModules/BizForms/Tools/AlternativeForms/AlternativeForms_List.aspx?formid=" + formId;
        breadcrumbs[0, 2] = "";
        breadcrumbs[1, 0] = GetString("altform.newbread");
        breadcrumbs[1, 1] = "";
        breadcrumbs[1, 2] = "";

        this.CurrentMaster.Title.Breadcrumbs = breadcrumbs;

        nameElem.ShowSubmitButton = true;
        nameElem.Click += new EventHandler(nameElem_Click);
    }
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        if (!BizFormInfoProvider.LicenseVersionCheck(RequestContext.CurrentDomain, FeatureEnum.BizForms, ObjectActionEnum.Insert))
        {
            ShowError(GetString("LicenseVersion.BizForm"));
            return;
        }

        DataClassInfo dci = null;
        BizFormInfo bizFormObj = null;

        string errorMessage = new Validator().NotEmpty(txtFormDisplayName.Text, rfvFormDisplayName.ErrorMessage).
            NotEmpty(txtFormName.Text, rfvFormName.ErrorMessage).
            NotEmpty(txtTableName.Text, rfvTableName.ErrorMessage).
            IsIdentifier(txtFormName.Text, GetString("bizform_edit.errorformnameinidentifierformat")).
            IsIdentifier(txtTableName.Text, GetString("BizForm_Edit.ErrorFormTableNameInIdentifierFormat")).Result;

        if (String.IsNullOrEmpty(errorMessage))
        {
            using (var tr = new CMSTransactionScope())
            {
                // Prepare the values
                string formDisplayName = txtFormDisplayName.Text.Trim();

                bizFormObj = new BizFormInfo();
                bizFormObj.FormDisplayName = formDisplayName;
                bizFormObj.FormName = txtFormName.Text.Trim();
                bizFormObj.FormSiteID = SiteContext.CurrentSiteID;
                bizFormObj.FormEmailAttachUploadedDocs = true;
                bizFormObj.FormItems = 0;
                bizFormObj.FormClearAfterSave = false;
                bizFormObj.FormLogActivity = true;

                // Ensure the code name
                bizFormObj.Generalized.EnsureCodeName();

                // Table name is combined from prefix ('BizForm_<sitename>_') and custom table name
                string safeFormName = ValidationHelper.GetIdentifier(bizFormObj.FormName);
                bizFormObj.FormName = safeFormName;

                string className = bizFormNamespace + "." + safeFormName;

                // Generate the table name
                string tableName = txtTableName.Text.Trim();
                if (String.IsNullOrEmpty(tableName) || (tableName == InfoHelper.CODENAME_AUTOMATIC))
                {
                    tableName = safeFormName;
                }
                tableName = FormTablePrefix + tableName;

                TableManager tm = new TableManager(null);

                // TableName wont be longer than 60 letters and will be unique
                if (tableName.Length > 60)
                {
                    int x = 1;

                    while (tm.TableExists(tableName.Substring(0, 59) + x.ToString()))
                    {
                        x++;
                    }

                    tableName = tableName.Substring(0, 59) + x.ToString();
                }

                // If first letter of safeFormName is digit, add "PK" to beginning
                string primaryKey = BizFormInfoProvider.GenerateFormPrimaryKeyName(bizFormObj.FormName);

                try
                {
                    // Create new table in DB
                    tm.CreateTable(tableName, primaryKey);
                }
                catch (Exception ex)
                {
                    errorMessage = ex.Message;

                    // Table with the same name already exists
                    ShowError(string.Format(GetString("bizform_edit.errortableexists"), tableName));
                    return;
                }

                // Change table owner
                try
                {
                    string owner = SqlHelper.GetDBSchema(SiteContext.CurrentSiteName);
                    if ((!String.IsNullOrEmpty(owner)) && (owner.ToLowerCSafe() != "dbo"))
                    {
                        tm.ChangeDBObjectOwner(tableName, owner);
                        tableName = owner + "." + tableName;
                    }
                }
                catch (Exception ex)
                {
                    EventLogProvider.LogException("BIZFORM_NEW", "E", ex);
                }

                // Convert default datetime to string in english format
                string defaultDateTime = DateTime.Now.ToString(CultureHelper.EnglishCulture.DateTimeFormat);

                try
                {
                    // Add FormInserted and FormUpdated columns to the table
                    tm.AddTableColumn(tableName, "FormInserted", "datetime", false, defaultDateTime);
                    tm.AddTableColumn(tableName, "FormUpdated", "datetime", false, defaultDateTime);
                }
                catch (Exception ex)
                {
                    errorMessage = ex.Message;

                    // Column wasn't added successfully
                    ShowError(errorMessage);

                    return;
                }

                // Create the BizForm class
                dci = BizFormInfoProvider.CreateBizFormDataClass(className, formDisplayName, tableName, primaryKey);

                try
                {
                    // Create new bizform dataclass
                    using (CMSActionContext context = new CMSActionContext())
                    {
                        // Disable logging of tasks
                        context.DisableLogging();

                        // Set default search settings
                        dci.ClassSearchEnabled = true;

                        DataClassInfoProvider.SetDataClassInfo(dci);

                        // Create default search settings
                        dci.ClassSearchSettings = SearchHelper.GetDefaultSearchSettings(dci);
                        dci.ClassSearchCreationDateColumn = "FormInserted";
                        DataClassInfoProvider.SetDataClassInfo(dci);
                    }
                }
                catch (Exception ex)
                {
                    errorMessage = ex.Message;

                    // Class with the same name already exists
                    ShowError(errorMessage);

                    return;
                }

                // Create new bizform
                bizFormObj.FormClassID = dci.ClassID;

                try
                {
                    // Create new bizform
                    BizFormInfoProvider.SetBizFormInfo(bizFormObj);
                }
                catch (Exception ex)
                {
                    errorMessage = ex.Message;

                    ShowError(errorMessage);

                    return;
                }

                tr.Commit();

                if (String.IsNullOrEmpty(errorMessage))
                {
                    // Redirect to Form builder tab
                    string url = UIContextHelper.GetElementUrl("CMS.Form", "Forms.Properties", false, bizFormObj.FormID);
                    url = URLHelper.AddParameterToUrl(url, "tabname", "Forms.FormBuldier");
                    URLHelper.Redirect(url);
                }
            }
        }
        else
        {
            ShowError(errorMessage);
        }
    }
 private void CleanUpOnError(string tableName, TableManager tm, DataClassInfo dci = null, BizFormInfo bizForm = null)
 {
     if (tm.TableExists(tableName))
     {
         tm.DropTable(tableName);
     }
     if ((bizForm != null) && (bizForm.FormID > 0))
     {
         BizFormInfoProvider.DeleteBizFormInfo(bizForm);
     }
     if ((dci != null) && (dci.ClassID > 0))
     {
         DataClassInfoProvider.DeleteDataClassInfo(dci);
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (EditedObject == null)
        {
            RedirectToAccessDenied(GetString("general.invalidparameters"));
        }

        currentUser = MembershipContext.AuthenticatedUser;

        // Register for action
        ComponentEvents.RequestEvents.RegisterForEvent(ComponentEvents.SAVE, lnkSave_Click);

        formInfo = EditedObject as BizFormInfo;

        if (formInfo != null)
        {
            // Control initialization
            ltlConfirmDelete.Text = "<input type=\"hidden\" id=\"confirmdelete\" value=\"" + GetString("Bizform_Edit_Autoresponder.ConfirmDelete") + "\">";

            drpEmailField.SelectedIndexChanged += drpEmailField_SelectedIndexChanged;

            // Init header actions
            InitHeaderActions();

            // Initialize HTML editor
            InitHTMLEditor();

            if (!RequestHelper.IsPostBack())
            {
                // Get bizform class object
                formClassObj = DataClassInfoProvider.GetDataClassInfo(formInfo.FormClassID);
                if (formClassObj != null)
                {
                    // Enable or disable form
                    EnableDisableForm(formInfo.FormConfirmationTemplate);

                    // Fill list of available fields
                    FillFieldsList();

                    // Load dropdown list with form text fields
                    InitializeEmailDropdown();

                    // Load email subject and email from address
                    txtEmailFrom.Text = formInfo.FormConfirmationSendFromEmail;
                    txtEmailSubject.Text = formInfo.FormConfirmationEmailSubject;
                }
                else
                {
                    // Disable form by default
                    EnableDisableForm(null);
                }
            }
        }
    }
    protected void Page_Init(object sender, EventArgs e)
    {
        // Get edited object
        if (CMSContext.EditedObject != null)
        {
            bfi = (BizFormInfo)CMSContext.EditedObject;
            formId = bfi.FormID;
        }

        isDialog = QueryHelper.GetBoolean("dialogmode", false);
        InitHeaderActions();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check 'ReadForm' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "ReadForm"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "ReadForm");
        }

        // Get form id from url
        int formId = QueryHelper.GetInteger("formid", 0);
        // Get form object
        bfi = BizFormInfoProvider.GetBizFormInfo(formId);
        EditedObject = bfi;

        rfvDisplayName.Text = GetString("BizFormGeneral.rfvDisplayName");

        if ((!RequestHelper.IsPostBack()) && (bfi != null))
        {
            LoadData();
        }
    }
Exemple #45
0
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        DataClassInfo dci = null;
        BizFormInfo bizFormObj = null;

        string errorMessage = new Validator().NotEmpty(txtFormDisplayName.Text, rfvFormDisplayName.ErrorMessage).
                                               NotEmpty(txtFormName.Text, rfvFormName.ErrorMessage).
                                               NotEmpty(txtTableName.Text, rfvTableName.ErrorMessage).
                                               IsIdentificator(txtFormName.Text, GetString("BizForm_Edit.ErrorFormNameInIdentificatorFormat")).
                                               IsIdentificator(txtTableName.Text, GetString("BizForm_Edit.ErrorFormTableNameInIdentificatorFormat")).Result;
        if (String.IsNullOrEmpty(errorMessage))
        {
            string formCodeName = txtFormName.Text.Trim();

            // Form name must be unique
            BizFormInfo testObj = BizFormInfoProvider.GetBizFormInfo(formCodeName, CMSContext.CurrentSiteName);

            // If formName value is unique...
            if (testObj == null)
            {
                string primaryKey = formCodeName + "ID";
                string formDisplayName = txtFormDisplayName.Text.Trim();
                string className = bizFormNamespace + "." + formCodeName;
                // Table name is combined from prefix ('BizForm_<sitename>_') and custom table name
                string tableName = FormTablePrefix + txtTableName.Text.Trim();

                if (!BizFormInfoProvider.LicenseVersionCheck(URLHelper.GetCurrentDomain(), FeatureEnum.BizForms, VersionActionEnum.Insert))
                {
                    lblError.Visible = true;
                    lblError.Text = GetString("LicenseVersion.BizForm");
                }

                if (!lblError.Visible)
                {
                    try
                    {
                        // Create new table in DB
                        TableManager.CreateTable(tableName, primaryKey);
                    }
                    catch (Exception ex)
                    {
                        errorMessage = ex.Message;

                        // Table with the same name already exists
                        lblError.Visible = true;
                        lblError.Text = string.Format(GetString("bizform_edit.errortableexists"), tableName);
                    }

                    if (String.IsNullOrEmpty(errorMessage))
                    {
                        // Change table owner
                        try
                        {
                            string owner = SqlHelperClass.GetDBSchema(CMSContext.CurrentSiteName);
                            if ((!String.IsNullOrEmpty(owner)) && (owner.ToLower() != "dbo"))
                            {
                                TableManager.ChangeDBObjectOwner(tableName, owner);
                                tableName = owner + "." + tableName;
                            }
                        }
                        catch (Exception ex)
                        {
                            EventLogProvider.LogException("BIZFORM_NEW", "E", ex);
                        }

                        // Convert default datetime to string in english format
                        string defaultDateTime = DateTime.Now.ToString(CultureHelper.EnglishCulture.DateTimeFormat);

                        try
                        {
                            // Add FormInserted and FormUpdated columns to the table
                            TableManager.AddTableColumn(tableName, "FormInserted", "datetime", false, defaultDateTime);
                            TableManager.AddTableColumn(tableName, "FormUpdated", "datetime", false, defaultDateTime);
                        }
                        catch (Exception ex)
                        {
                            errorMessage = ex.Message;

                            // Column wasnt added successfuly
                            lblError.Visible = true;
                            lblError.Text = errorMessage;

                            // Delete created table
                            TableManager.DropTable(tableName);
                        }
                    }

                    if (String.IsNullOrEmpty(errorMessage))
                    {
                        dci = BizFormInfoProvider.CreateBizFormDataClass(className, formDisplayName, tableName, primaryKey);

                        try
                        {
                            // Create new bizform dataclass
                            using (CMSActionContext context = new CMSActionContext())
                            {
                                // Disable logging of tasks
                                context.DisableLogging();

                                DataClassInfoProvider.SetDataClass(dci);
                            }
                        }
                        catch (Exception ex)
                        {
                            errorMessage = ex.Message;

                            // Class with the same name already exists
                            lblError.Visible = true;
                            lblError.Text = errorMessage;

                            // Delete created table
                            TableManager.DropTable(tableName);
                        }
                    }

                    if (String.IsNullOrEmpty(errorMessage))
                    {
                        // Create new bizform
                        bizFormObj = new BizFormInfo();
                        bizFormObj.FormDisplayName = formDisplayName;
                        bizFormObj.FormName = formCodeName;
                        bizFormObj.FormClassID = dci.ClassID;
                        bizFormObj.FormSiteID = CMSContext.CurrentSiteID;
                        bizFormObj.FormEmailAttachUploadedDocs = true;
                        bizFormObj.FormItems = 0;
                        bizFormObj.FormClearAfterSave = false;
                        bizFormObj.FormLogActivity = true;

                        try
                        {
                            // Create new bizform
                            BizFormInfoProvider.SetBizFormInfo(bizFormObj);

                            // Generate basic queries
                            SqlGenerator.GenerateQuery(className, "selectall", SqlOperationTypeEnum.SelectAll, false);
                            SqlGenerator.GenerateQuery(className, "delete", SqlOperationTypeEnum.DeleteQuery, false);
                            SqlGenerator.GenerateQuery(className, "insert", SqlOperationTypeEnum.InsertQuery, true);
                            SqlGenerator.GenerateQuery(className, "update", SqlOperationTypeEnum.UpdateQuery, false);
                            SqlGenerator.GenerateQuery(className, "select", SqlOperationTypeEnum.SelectQuery, false);
                        }
                        catch (Exception ex)
                        {
                            errorMessage = ex.Message;

                            lblError.Visible = true;
                            lblError.Text = errorMessage;

                            // Delete created class (includes deleting its table)
                            if (dci != null)
                            {
                                using (CMSActionContext context = new CMSActionContext())
                                {
                                    // Disable logging of tasks
                                    context.DisableLogging();

                                    DataClassInfoProvider.DeleteDataClass(dci);
                                }
                            }
                        }

                        if (String.IsNullOrEmpty(errorMessage))
                        {
                            // Redirect to edit dialog
                            URLHelper.Redirect(string.Format("BizForm_Frameset.aspx?formId={0}&newform=1", bizFormObj.FormID));
                        }
                    }
                }
            }
            else
            {
                lblError.Visible = true;
                lblError.Text = GetString("BizForm_Edit.FormNameExists");
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text = errorMessage;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        int formId = 0;
        int formRecordId = 0;

        // Check 'ReadData' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "ReadData"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "ReadData");
        }
        // Check 'EditData' permission
        else if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "EditData"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "EditData");
        }

        // Get form id from url
        formId = QueryHelper.GetInteger("formid", 0);

        if (formId > 0)
        {
            // Get form record id
            formRecordId = QueryHelper.GetInteger("formrecordid", 0);

            string currentRecord = "";

            // Edit record
            if (formRecordId > 0)
            {
                currentRecord = GetString("BizForm_Edit_EditRecord.EditRecord");
                if (!RequestHelper.IsPostBack())
                {
                    chkSendNotification.Checked = false;
                    chkSendAutoresponder.Checked = false;
                }
            }
            // New record
            else
            {
                currentRecord = GetString("BizForm_Edit_EditRecord.NewRecord");
                if (!RequestHelper.IsPostBack())
                {
                    chkSendNotification.Checked = true;
                    chkSendAutoresponder.Checked = true;
                }
            }

            // Initializes page title
            string[,] breadcrumbs = new string[2, 3];
            breadcrumbs[0, 0] = GetString("BizForm_Edit_EditRecord.Data");
            breadcrumbs[0, 1] = "~/CMSModules/BizForms/Tools/BizForm_Edit_Data.aspx?formid=" + formId;
            breadcrumbs[0, 2] = "";
            breadcrumbs[1, 0] = currentRecord;
            breadcrumbs[1, 1] = "";
            breadcrumbs[1, 2] = "";

            CurrentMaster.Title.Breadcrumbs = breadcrumbs;

            bfi = BizFormInfoProvider.GetBizFormInfo(formId);
            EditedObject = bfi;

            if (!RequestHelper.IsPostBack())
            {
                // Get form info
                if (bfi != null)
                {
                    // Set form
                    formElem.FormName = bfi.FormName;
                    formElem.ItemID = formRecordId;
                    formElem.ShowPrivateFields = true;
                }
            }

            formElem.OnBeforeSave += formElem_OnBeforeSave;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Add save action
        save = new SaveAction(Page);
        menu.AddAction(save);

        // Register for action
        ComponentEvents.RequestEvents.RegisterForEvent(ComponentEvents.SAVE, lnkSave_Click);

        // Control initialization
        ltlConfirmDelete.Text = "<input type=\"hidden\" id=\"confirmdelete\" value=\"" + GetString("Bizform_Edit_Notificationemail.ConfirmDelete") + "\">";

        chkSendToEmail.Text = GetString("BizFormGeneral.chkSendToEmail");

        chkCustomLayout.Text = GetString("BizForm_Edit_NotificationEmail.CustomLayout");

        // Initialize HTML editor
        InitHTMLEditor();

        formInfo = EditedObject as BizFormInfo;

        if (!RequestHelper.IsPostBack())
        {
            if (formInfo!= null)
            {
                // Get form class object
                formClassObj = DataClassInfoProvider.GetDataClassInfo(formInfo.FormClassID);

                // Fill list of available fields
                FillFieldsList();

                // Load email from/to address and email subject
                txtFromEmail.Text = ValidationHelper.GetString(formInfo.FormSendFromEmail, "");
                txtToEmail.Text = ValidationHelper.GetString(formInfo.FormSendToEmail, "");
                txtSubject.Text = ValidationHelper.GetString(formInfo.FormEmailSubject, "");
                chkAttachDocs.Checked = formInfo.FormEmailAttachUploadedDocs;
                chkSendToEmail.Checked = ((txtFromEmail.Text + txtToEmail.Text) != "");
                if (!chkSendToEmail.Checked)
                {
                    txtFromEmail.Enabled = false;
                    txtToEmail.Enabled = false;
                    txtSubject.Enabled = false;
                    chkAttachDocs.Enabled = false;
                    chkCustomLayout.Visible = false;
                    pnlCustomLayout.Visible = false;
                }
                else
                {
                    // Enable or disable form
                    EnableDisableForm(formInfo.FormEmailTemplate);
                }
            }
            else
            {
                // Disable form by default
                EnableDisableForm(null);
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check 'ReadData' permission
        CheckPermissions("ReadData");

        // Get form ID from url
        formId = QueryHelper.GetInteger("formid", 0);

        // Register scripts
        ScriptHelper.RegisterDialogScript(this);
        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "SelectFields", ScriptHelper.GetScript("function SelectFields() { modalDialog('" +
            ResolveUrl("~/CMSModules/BizForms/Tools/BizForm_Edit_Data_SelectFields.aspx") + "?formid=" + formId + "'  ,'BizFormFields', 500, 500); }"));
        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "Edit", ScriptHelper.GetScript(
           "function EditRecord(formId, recordId) { " +
           "  document.location.replace('BizForm_Edit_EditRecord.aspx?formID=' + formId + '&formRecordID=' + recordId); } "
           ));

        // Prepare header actions
        string[,] actions = new string[2, 6];
        // New record link
        actions[0, 0] = HeaderActions.TYPE_HYPERLINK;
        actions[0, 1] = GetString("bizform_edit_data.newrecord");
        actions[0, 2] = null;
        actions[0, 3] = ResolveUrl("BizForm_Edit_EditRecord.aspx?formid=" + formId.ToString());
        actions[0, 4] = null;
        actions[0, 5] = GetImageUrl("CMSModules/CMS_Form/newrecord.png");
        // Select fields link
        actions[1, 0] = HeaderActions.TYPE_HYPERLINK;
        actions[1, 1] = GetString("bizform_edit_data.selectdisplayedfields");
        actions[1, 2] = null;
        actions[1, 3] = "javascript:SelectFields();";
        actions[1, 4] = null;
        actions[1, 5] = GetImageUrl("CMSModules/CMS_Form/selectfields16.png");

        CurrentMaster.HeaderActions.Actions = actions;

        // Initialize unigrid
        gridData.OnExternalDataBound += gridData_OnExternalDataBound;
        gridData.OnLoadColumns += gridData_OnLoadColumns;
        gridData.OnAction += gridData_OnAction;

        // Get BizFormInfo object
        bfi = BizFormInfoProvider.GetBizFormInfo(formId);
        EditedObject = bfi;

        if (bfi != null)
        {
            dci = DataClassInfoProvider.GetDataClass(bfi.FormClassID);
            if (dci != null)
            {
                className = dci.ClassName;

                // Set alternative form and data container
                gridData.ObjectType = BizFormItemProvider.GetObjectType(className);
                gridData.FilterFormName = className + "." + "filter";
                gridData.FilterFormData = bfi;

                // Get primary column name
                gridData.OrderBy = primaryColumn = GetPrimaryColumn(FormInfo, bfi.FormName);
            }
        }
    }