protected void Page_Init(System.Object sender, System.EventArgs e) { try { if (!IsPostBack) { //检测是否安装过默认字段 显示名,邮箱,消息 if (!InstallationDefault)//没有安装过进入 { UpdateModuleSetting("PowerForms_InstallationDefault", "true"); //并且里面不存在任何字段的 if (DNNGo_PowerForms_Field.FindCount(DNNGo_PowerForms_Field._.ModuleId, ModuleId) == 0) { DNNGo_PowerForms_Field.InstallField("Name", this); DNNGo_PowerForms_Field.InstallField("Email", this); DNNGo_PowerForms_Field.InstallField("Messages", this); Response.Redirect(Globals.NavigateURL()); } } } //绑定容器内的子控件 BindContainer(); } catch (Exception exc) //Module failed to load { DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc); } }
/// <summary> /// 验证字段名是否重复 /// </summary> /// <returns></returns> private String ValidationCustomFieldName(string validateId, string validateValue, string validateError) { String validateJSON = "true"; Int32 ModuleID = WebHelper.GetIntParam(Request, "ModuleID", 0); QueryParam qp = new QueryParam(); qp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.Name, validateValue, SearchType.Equal)); qp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.ModuleId, ModuleID, SearchType.Equal)); if (DNNGo_PowerForms_Field.FindCount(qp) > 0) { validateJSON = "false"; } return(validateJSON); }
/// <summary> /// 验证字段名是否重复 /// </summary> /// <returns></returns> private String ValidationFieldName(string validateId, string validateValue, string validateError) { String validateJSON = String.Empty; Int32 ModuleID = WebHelper.GetIntParam(Request, "ModuleID", 0); QueryParam qp = new QueryParam(); qp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.Name, validateValue, SearchType.Equal)); qp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.ModuleId, ModuleID, SearchType.Equal)); if (DNNGo_PowerForms_Field.FindCount(qp) > 0) { validateJSON = "{\"jsonValidateReturn\":[\"" + validateId + "\",\"" + validateError + "\",false]}";//验证不通过 } else { validateJSON = "{\"jsonValidateReturn\":[\"" + validateId + "\",\"" + validateError + "\",true]}";//验证通过 } return(validateJSON); }
/// <summary> /// 设置方案项 /// </summary> private Int32 SetDataItem(Int32 ArticleStatus, out DNNGo_PowerForms_Field fieldItem) { fieldItem = FieldItem; //权限 fieldItem.Per_AllUsers = cbPermissionsAllUsers.Checked ? 0 : 1; String textStr, idStr = String.Empty; WebHelper.GetSelected(cblPermissionsRoles, out textStr, out idStr); fieldItem.Per_Roles = idStr; if (ddlControlType.Enabled) { fieldItem.FieldType = WebHelper.GetIntParam(Request, ddlControlType.UniqueID, (Int32)EnumViewControlType.TextBox); } fieldItem.ToolTip = txtToolTip.Text; fieldItem.Alias = txtAlias.Text; fieldItem.Description = txtDescription.Text; fieldItem.Required = cbRequired.Checked ? 1 : 0; fieldItem.Options = SetItemSettings(); if (divGroup.Visible) { SettingEntity GroupControl = new SettingEntity(); GroupControl.Name = "GroupControl"; Int32 GroupID = 0; if (int.TryParse(ControlHelper.GetWebFormValue(GroupControl, this), out GroupID)) { } fieldItem.GroupID = GroupID; } fieldItem.FiledList = txtFTListCollection.Text; if (fieldItem.FieldType == (Int32)EnumViewControlType.Html || fieldItem.FieldType == (Int32)EnumViewControlType.RichTextBox) { fieldItem.DefaultValue = txtTinymceDefaultValue.Text; } else { fieldItem.DefaultValue = txtFTDefaultValue.Text; } fieldItem.Rows = WebHelper.GetIntParam(Request, txtFTRows.UniqueID, 1); fieldItem.Verification = WebHelper.GetIntParam(Request, ddlVerification.UniqueID, 0); fieldItem.Direction = WebHelper.GetIntParam(Request, rblFTDirection.UniqueID, 0); fieldItem.ListColumn = WebHelper.GetIntParam(Request, txtFTListColumn.UniqueID, 1); fieldItem.Width = WebHelper.GetIntParam(Request, txtFTWidth.UniqueID, 100); fieldItem.WidthSuffix = WebHelper.GetIntParam(Request, ddlFTWidth.UniqueID, 0); fieldItem.EqualsControl = WebHelper.GetIntParam(Request, ddlFTEqualsControl.UniqueID, 0); fieldItem.AssociatedControl = WebHelper.GetIntParam(Request, ddlFTAssociatedControl.UniqueID, 0); fieldItem.InputLength = WebHelper.GetIntParam(Request, txtFTInputLength.UniqueID, 2000); fieldItem.LastTime = xUserTime.UtcTime(); fieldItem.LastUser = UserId; fieldItem.LastIP = WebHelper.UserHost; //发布状态和时间 DateTime oTime = xUserTime.LocalTime(); string[] expectedFormats = { "G", "g", "f", "F" }; string StartDate = WebHelper.GetStringParam(Request, txtStartDate.UniqueID, oTime.ToString("MM/dd/yyyy")); string StartTime = WebHelper.GetStringParam(Request, txtStartTime.UniqueID, oTime.ToString("hh:mm tt")); if (DateTime.TryParseExact(String.Format("{0} {1}", StartDate, StartTime), "MM/dd/yyyy hh:mm tt", new CultureInfo("en-US", false), DateTimeStyles.AllowWhiteSpaces, out oTime)) { fieldItem.StartTime = oTime; } //发布状态和时间 DateTime EndTime = xUserTime.LocalTime().AddYears(10); string DisableDate = WebHelper.GetStringParam(Request, txtDisableDate.UniqueID, EndTime.ToString("MM/dd/yyyy")); string DisableTime = WebHelper.GetStringParam(Request, txtDisableTime.UniqueID, EndTime.ToString("hh:mm tt")); if (DateTime.TryParseExact(String.Format("{0} {1}", DisableDate, DisableTime), "MM/dd/yyyy hh:mm tt", new CultureInfo("en-US", false), DateTimeStyles.AllowWhiteSpaces, out EndTime)) { fieldItem.EndTime = EndTime; } if (ArticleStatus == -1)//如果没有指定状态就取控件的 { fieldItem.Status = cbStatus.Checked ? (Int32)EnumStatus.Activation : (Int32)EnumStatus.Hide; } else { fieldItem.Status = ArticleStatus; } Int32 SaveResult = 0; if (fieldItem.ID > 0) { SaveResult = fieldItem.Update(); } else { fieldItem.Name = txtName.Text; QueryParam qp = new QueryParam(); qp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.ModuleId, ModuleId, SearchType.Equal)); qp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.Name, fieldItem.Name, SearchType.Equal)); if (DNNGo_PowerForms_Field.FindCount(qp) == 0) { fieldItem.ModuleId = ModuleId; fieldItem.PortalId = PortalId; QueryParam Sqp = new QueryParam(); Sqp.ReturnFields = Sqp.Orderfld = DNNGo_PowerForms_Field._.Sort; Sqp.OrderType = 1; Sqp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.ModuleId, ModuleId, SearchType.Equal)); fieldItem.Sort = Convert.ToInt32(DNNGo_PowerForms_Field.FindScalar(Sqp)) + 2; //构造默认的验证方式 if (fieldItem.FieldType == (Int32)EnumViewControlType.DatePicker) { fieldItem.Verification = (Int32)EnumVerification.date; } else if (fieldItem.FieldType == (Int32)EnumViewControlType.FileUpload) { } else if (fieldItem.FieldType == (Int32)EnumViewControlType.TextBox_Email) { fieldItem.Verification = (Int32)EnumVerification.email; } SaveResult = fieldItem.Insert(); } else { SaveResult = -1; } } return(SaveResult); }