/// <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(); } }
/// <summary> /// Button OK clicked. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { string reportFields = string.Empty; bool noItemSelected = (chkListFields.SelectedIndex == -1) ? true : false; foreach (ListItem item in chkListFields.Items) { // Display all fields if (noItemSelected) { reportFields += item.Value + ";"; } // Display only selected fields else if (item.Selected) { reportFields += item.Value + ";"; } } if (!string.IsNullOrEmpty(reportFields)) { // Remove ending ';' reportFields = reportFields.TrimEnd(';'); } // Save report fields FormInfo.FormReportFields = reportFields; BizFormInfoProvider.SetBizFormInfo(FormInfo); // Close dialog window ScriptHelper.RegisterStartupScript(this, typeof(string), "Forms_SelectFields", "CloseAndRefresh();", true); }
protected void btnOk_Click(object sender, EventArgs e) { // Check 'EditForm' permission if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.form", "EditForm")) { RedirectToAccessDenied("cms.form", "EditForm"); } if (FormInfo != null) { if (radAllUsers.Checked) { FormInfo.FormAccess = FormAccessEnum.AllBizFormUsers; BizFormRoleInfoProvider.RemoveAllRolesFromForm(FormInfo.FormID); // Clear authorized roles from hashtable FormInfo.ClearAuthorizedRoles(); lstRoles.Items.Clear(); } else { FormInfo.FormAccess = FormAccessEnum.OnlyAuthorizedRoles; } BizFormInfoProvider.SetBizFormInfo(FormInfo); ShowChangesSaved(); } }
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"); } }
private void FormBuilder_OnAfterDefinitionUpdate(object sender, EventArgs e) { // Update form to log synchronization if (FormInfo != null) { BizFormInfoProvider.SetBizFormInfo(FormInfo); } }
private void FormBuilder_OnAfterDefinitionUpdate(object sender, EventArgs e) { // Update form to log synchronization if (FormInfo != null) { // Enforce Form property reload next time the data are needed FormInfo.ResetFormInfo(); BizFormInfoProvider.SetBizFormInfo(FormInfo); } }
protected void FieldEditor_OnAfterDefinitionUpdate(object sender, EventArgs e) { // Update form to log synchronization if (FormInfo != null) { BizFormInfoProvider.SetBizFormInfo(FormInfo); // State of unigrids may contain where/order by clauses no longer valid after definition update UniGrid.ResetStates(BizFormItemProvider.GetObjectType(FieldEditor.ClassName)); } }
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); } } }
/// <summary> /// Button OK clicked. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { BizFormInfo bfi = null; string reportFields = ""; bool noItemSelected = (chkListFields.SelectedIndex == -1) ? true : false; foreach (ListItem item in chkListFields.Items) { // Display all fields if (noItemSelected) { reportFields += item.Value + ";"; } // Display only selected fields else if (item.Selected) { reportFields += item.Value + ";"; } } if (reportFields != "") { // Remove ending ';' reportFields = reportFields.TrimEnd(';'); } bfi = BizFormInfoProvider.GetBizFormInfo(formId); if (bfi != null) { // Save report fields bfi.FormReportFields = reportFields; BizFormInfoProvider.SetBizFormInfo(bfi); // Close dialog window ltlScript.Text = ScriptHelper.GetScript("CloseAndRefresh();"); } }
/// <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; } }
/// <summary> /// Save data to Database. /// </summary> protected void SaveData() { // Check display name emptiness if (string.IsNullOrEmpty(txtDisplayName.Text)) { ShowError(GetString("BizFormGeneral.rfvDisplayName")); return; } bfi.FormDisplayName = txtDisplayName.Text; bfi.FormName = txtCodeName.Text; bfi.FormSubmitButtonText = txtButtonText.Text; bfi.FormSubmitButtonImage = null; if (!string.IsNullOrEmpty(txtSubmitButtonImage.Text.Trim())) { bfi.FormSubmitButtonImage = txtSubmitButtonImage.Text.Trim(); } // Set 'after submitting' behavior... bfi.FormRedirectToUrl = null; bfi.FormDisplayText = null; // ... clear form bfi.FormClearAfterSave = radClear.Checked; // ... display text if (radDisplay.Checked) { if (!string.IsNullOrEmpty(txtDisplay.Text.Trim())) { bfi.FormDisplayText = txtDisplay.Text.Trim(); } else { ShowError(GetString("BizFormGeneral.DisplayText")); return; } } else { txtDisplay.Text = string.Empty; } // ... redirect if (radRedirect.Checked) { bfi.FormRedirectToUrl = txtRedirect.Text.Trim(); } else { txtRedirect.Text = string.Empty; } BizFormInfoProvider.SetBizFormInfo(bfi); ShowChangesSaved(); // Reload header if changes were saved ScriptHelper.RefreshTabHeader(Page, bfi.FormDisplayName); }
/// <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; } string formDisplayName = txtFormDisplayName.Text.Trim(); string formName = txtFormName.Text.Trim(); string tableName = txtTableName.Text.Trim(); string errorMessage = new Validator().NotEmpty(formDisplayName, rfvFormDisplayName.ErrorMessage). NotEmpty(formName, rfvFormName.ErrorMessage). NotEmpty(tableName, rfvTableName.ErrorMessage). IsIdentifier(formName, GetString("bizform_edit.errorformnameinidentifierformat")). IsIdentifier(tableName, GetString("BizForm_Edit.ErrorFormTableNameInIdentifierFormat")).Result; if (!String.IsNullOrEmpty(errorMessage)) { ShowError(errorMessage); return; } var bizFormObj = new BizFormInfo { FormDisplayName = formDisplayName, FormName = formName, FormSiteID = SiteContext.CurrentSiteID, FormEmailAttachUploadedDocs = true, FormItems = 0, FormClearAfterSave = false, 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 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) { string tmpTableName = tableName.Substring(0, 59); int x = 1; do { tableName = tmpTableName + x; x++; } while (tm.TableExists(tableName)); } // TableName should be unique if (tm.TableExists(tableName)) { ShowError(string.Format(GetString("bizform_edit.errortableexists"), tableName)); return; } // 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) { EventLogProvider.LogException("BIZFORM_NEW", EventType.ERROR, ex); ShowError(string.Format(GetString("bizform_edit.createtableerror"), 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", EventType.ERROR, ex); } // Create the BizForm class DataClassInfo dci = BizFormInfoProvider.CreateBizFormDataClass(className, formDisplayName, tableName, primaryKey); try { // Create new bizform dataclass using (CMSActionContext context = new CMSActionContext()) { // Disable logging of tasks context.DisableLogging(); DataClassInfoProvider.SetDataClassInfo(dci); } } catch (Exception ex) { EventLogProvider.LogException("BIZFORM_NEW", EventType.ERROR, ex); ShowError(ex.Message); CleanUpOnError(tableName, tm, dci); return; } // Create new bizform bizFormObj.FormClassID = dci.ClassID; try { BizFormInfoProvider.SetBizFormInfo(bizFormObj); } catch (Exception ex) { EventLogProvider.LogException("BIZFORM_NEW", EventType.ERROR, ex); ShowError(ex.Message); CleanUpOnError(tableName, tm, dci, bizFormObj); return; } // 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); }
/// <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); } }
/// <summary> /// Save button is clicked. /// </summary> protected void lnkSave_Click(object sender, EventArgs e) { // Check 'EditForm' permission if (!currentUser.IsAuthorizedPerResource("cms.form", "EditForm")) { RedirectToAccessDenied("cms.form", "EditForm"); } // Validate form string errorMessage = new Validator().NotEmpty(txtEmailFrom.Text.Trim(), GetString("bizform_edit_autoresponder.emptyemail")).NotEmpty(txtEmailSubject.Text.Trim(), GetString("bizform_edit_autoresponder.emptysubject")).Result; // Check if from e-mail contains macro expression or e-mails separated by semicolon if (string.IsNullOrEmpty(errorMessage) && !MacroProcessor.ContainsMacro(txtEmailFrom.Text.Trim()) && !ValidationHelper.IsEmail(txtEmailFrom.Text.Trim())) { errorMessage = GetString("bizform_edit_autoresponder.emptyemail"); } if ((string.IsNullOrEmpty(errorMessage)) || (!pnlCustomLayout.Visible)) { errorMessage = String.Empty; if (formInfo != null) { // Save custom layout if (!string.IsNullOrEmpty(drpEmailField.SelectedValue)) { formInfo.FormConfirmationTemplate = htmlEditor.ResolvedValue.Trim(); formInfo.FormConfirmationEmailField = drpEmailField.SelectedValue; formInfo.FormConfirmationEmailSubject = txtEmailSubject.Text.Trim(); formInfo.FormConfirmationSendFromEmail = txtEmailFrom.Text.Trim(); try { BizFormInfoProvider.SetBizFormInfo(formInfo); ShowChangesSaved(); EnableDisableForm(formInfo.FormConfirmationTemplate); } catch (Exception ex) { errorMessage = ex.Message; } } // Delete custom layout if exists else { formInfo.FormConfirmationTemplate = null; formInfo.FormConfirmationEmailField = drpEmailField.SelectedValue; formInfo.FormConfirmationEmailSubject = string.Empty; formInfo.FormConfirmationSendFromEmail = string.Empty; // Delete all attachments MetaFileInfoProvider.DeleteFiles(formInfo.FormID, BizFormInfo.OBJECT_TYPE, ObjectAttachmentsCategories.FORMLAYOUT); try { BizFormInfoProvider.SetBizFormInfo(formInfo); if (IsLayoutSet) { ShowConfirmation(GetString("Bizform_Edit_Autoresponder.LayoutDeleted")); } else { ShowChangesSaved(); } EnableDisableForm(formInfo.FormConfirmationTemplate); } catch (Exception ex) { errorMessage = ex.Message; } } } } if (!string.IsNullOrEmpty(errorMessage)) { ShowError(errorMessage); } }
/// <summary> /// Save button is clicked. /// </summary> protected void lnkSave_Click(object sender, EventArgs e) { // Check 'EditForm' permission if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "EditForm")) { RedirectToCMSDeskAccessDenied("cms.form", "EditForm"); } string errorMessage = ""; BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formId); if (bfi != null) { if (chkSendToEmail.Checked) { // Validate form errorMessage = new Validator().NotEmpty(txtFromEmail.Text, GetString("BizFormGeneral.EmptyFromEmail")) .NotEmpty(txtToEmail.Text, GetString("BizFormGeneral.EmptyToEmail")) .NotEmpty(txtSubject.Text, GetString("BizFormGeneral.EmptyEmailSubject")).Result; // Check if to e-mail contains macro expression or e-mails separated by semicolon if (string.IsNullOrEmpty(errorMessage) && !MacroResolver.ContainsMacro(txtToEmail.Text.Trim()) && !ValidationHelper.AreEmails(txtToEmail.Text.Trim())) { errorMessage = GetString("BizFormGeneral.EmptyToEmail"); } // Check if from e-mail contains macro expression or e-mails separated by semicolon if (string.IsNullOrEmpty(errorMessage) && !MacroResolver.ContainsMacro(txtFromEmail.Text.Trim()) && !ValidationHelper.IsEmail(txtFromEmail.Text.Trim())) { errorMessage = GetString("BizFormGeneral.EmptyFromEmail"); } if (string.IsNullOrEmpty(errorMessage)) { bfi.FormSendFromEmail = txtFromEmail.Text.Trim(); bfi.FormSendToEmail = txtToEmail.Text.Trim(); bfi.FormEmailSubject = txtSubject.Text.Trim(); bfi.FormEmailAttachUploadedDocs = chkAttachDocs.Checked; if (chkCustomLayout.Checked) { bfi.FormEmailTemplate = htmlEditor.ResolvedValue.Trim(); } else { bfi.FormEmailTemplate = null; } } } else { bfi.FormSendFromEmail = null; bfi.FormSendToEmail = null; bfi.FormEmailSubject = null; bfi.FormEmailTemplate = null; txtToEmail.Text = ""; txtFromEmail.Text = ""; txtSubject.Text = ""; chkAttachDocs.Checked = true; htmlEditor.ResolvedValue = ""; } if (errorMessage == "") { try { BizFormInfoProvider.SetBizFormInfo(bfi); DisplayInfoMessage(GetString("General.ChangesSaved")); EnableDisableForm(bfi.FormEmailTemplate); } catch (Exception ex) { errorMessage = ex.Message; } } if (errorMessage != "") { DisplayErrorMessage(errorMessage); } } }
/// <summary> /// Save button is clicked. /// </summary> protected void lnkSave_Click(object sender, EventArgs e) { // Check 'EditForm' permission if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.form", "EditForm")) { RedirectToAccessDenied("cms.form", "EditForm"); } string errorMessage = null; if (formInfo != null) { if (chkSendToEmail.Checked) { // Validate form errorMessage = new Validator().NotEmpty(txtFromEmail.Text, GetString("BizFormGeneral.EmptyFromEmail")) .NotEmpty(txtToEmail.Text, GetString("BizFormGeneral.EmptyToEmail")) .NotEmpty(txtSubject.Text, GetString("BizFormGeneral.EmptyEmailSubject")).Result; // Check if to e-mail contains macro expression or e-mails separated by semicolon if (string.IsNullOrEmpty(errorMessage) && !MacroProcessor.ContainsMacro(txtToEmail.Text.Trim()) && !txtToEmail.IsValid()) { errorMessage = GetString("BizFormGeneral.EmptyToEmail"); } // Check if from e-mail contains macro expression or e-mails separated by semicolon if (string.IsNullOrEmpty(errorMessage) && !MacroProcessor.ContainsMacro(txtFromEmail.Text.Trim()) && !txtFromEmail.IsValid()) { errorMessage = GetString("BizFormGeneral.EmptyFromEmail"); } if (string.IsNullOrEmpty(errorMessage)) { formInfo.FormSendFromEmail = txtFromEmail.Text.Trim(); formInfo.FormSendToEmail = txtToEmail.Text.Trim(); formInfo.FormEmailSubject = txtSubject.Text.Trim(); formInfo.FormEmailAttachUploadedDocs = chkAttachDocs.Checked; if (chkCustomLayout.Checked) { formInfo.FormEmailTemplate = htmlEditor.ResolvedValue.Trim(); } else { formInfo.FormEmailTemplate = null; } } } else { formInfo.FormSendFromEmail = null; formInfo.FormSendToEmail = null; formInfo.FormEmailSubject = null; formInfo.FormEmailTemplate = null; txtToEmail.Text = string.Empty; txtFromEmail.Text = string.Empty; txtSubject.Text = string.Empty; chkAttachDocs.Checked = true; htmlEditor.ResolvedValue = string.Empty; } if (string.IsNullOrEmpty(errorMessage)) { try { BizFormInfoProvider.SetBizFormInfo(formInfo); ShowChangesSaved(); EnableDisableForm(formInfo.FormEmailTemplate); } catch (Exception ex) { errorMessage = ex.Message; } } if (!string.IsNullOrEmpty(errorMessage)) { ShowError(errorMessage); } } }
/// <summary> /// Save button is clicked. /// </summary> protected void lnkSave_Click(object sender, EventArgs e) { string errorMessage = null; // check 'ReadForm' permission if (!currentUser.IsAuthorizedPerResource("cms.form", "EditForm")) { RedirectToCMSDeskAccessDenied("cms.form", "EditForm"); } // Validate form errorMessage = new Validator().NotEmpty(txtEmailFrom.Text.Trim(), GetString("bizform_edit_autoresponder.emptyemail")).NotEmpty(txtEmailSubject.Text.Trim(), GetString("bizform_edit_autoresponder.emptysubject")).Result; // Check if from e-mail contains macro expression or e-mails separated by semicolon if (string.IsNullOrEmpty(errorMessage) && !MacroResolver.ContainsMacro(txtEmailFrom.Text.Trim()) && !ValidationHelper.IsEmail(txtEmailFrom.Text.Trim())) { errorMessage = GetString("bizform_edit_autoresponder.emptyemail"); } if ((string.IsNullOrEmpty(errorMessage)) || (!pnlCustomLayout.Visible)) { errorMessage = String.Empty; BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formId); if (bfi != null) { // Save custom layout if (!string.IsNullOrEmpty(drpEmailField.SelectedValue)) { bfi.FormConfirmationTemplate = htmlEditor.ResolvedValue.Trim(); bfi.FormConfirmationEmailField = drpEmailField.SelectedValue; bfi.FormConfirmationEmailSubject = txtEmailSubject.Text.Trim(); bfi.FormConfirmationSendFromEmail = txtEmailFrom.Text.Trim(); try { BizFormInfoProvider.SetBizFormInfo(bfi); DisplayInfoMessage(GetString("General.ChangesSaved")); EnableDisableForm(bfi.FormConfirmationTemplate); } catch (Exception ex) { errorMessage = ex.Message; } } // Delete custom layout if exists else { bfi.FormConfirmationTemplate = null; bfi.FormConfirmationEmailField = drpEmailField.SelectedValue; bfi.FormConfirmationEmailSubject = string.Empty; bfi.FormConfirmationSendFromEmail = string.Empty; // Delete all attachments MetaFileInfoProvider.DeleteFiles(bfi.FormID, FormObjectType.BIZFORM, MetaFileInfoProvider.OBJECT_CATEGORY_FORM_LAYOUT); try { BizFormInfoProvider.SetBizFormInfo(bfi); DisplayInfoMessage(IsLayoutSet ? GetString("Bizform_Edit_Autoresponder.LayoutDeleted") : GetString("General.ChangesSaved")); EnableDisableForm(bfi.FormConfirmationTemplate); } catch (Exception ex) { errorMessage = ex.Message; } } } } if (!string.IsNullOrEmpty(errorMessage)) { DisplayErrorMessage(errorMessage); } }