/// <summary> /// 字段绑定事件 /// </summary> protected void RepeaterFields_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { DNNGo_PowerForms_Field FieldItem = e.Item.DataItem as DNNGo_PowerForms_Field; if (FieldItem != null && FieldItem.ID > 0) { Literal liFieldType = e.Item.FindControl("liFieldType") as Literal; liFieldType.Text = EnumHelper.GetEnumTextVal(FieldItem.FieldType, typeof(EnumViewControlType)); Literal liName = e.Item.FindControl("liName") as Literal; liName.Text = WebHelper.leftx(FieldItem.Name, 30, "..."); if (FieldItem.GroupID > 0) { DNNGo_PowerForms_Group Group = DNNGo_PowerForms_Group.FindByKeyForEdit(FieldItem.GroupID); if (Group != null && Group.ID > 0) { Literal liGroup = e.Item.FindControl("liGroup") as Literal; liGroup.Text = WebHelper.leftx(Group.Name, 20, "..."); } } } } }
/// <Description> /// 绑定树分类 /// </Description> private void BindTreeGroups(DNNGo_PowerForms_Field Article) { List <Int32> SelectList = new List <Int32>(); //绑定所有分类到页面 QueryParam qp = new QueryParam(); qp.Orderfld = DNNGo_PowerForms_Group._.Sort; qp.OrderType = 0; int RecordCount = 0; qp.Where.Add(new SearchParam(DNNGo_PowerForms_Group._.ModuleId, ModuleId, SearchType.Equal)); List <DNNGo_PowerForms_Group> lst = DNNGo_PowerForms_Group.FindAll(qp, out RecordCount); StringBuilder GroupListContent = new StringBuilder(); foreach (var Group in lst) { GroupListContent.AppendFormat("{0}:{1}", Group.Name, Group.ID).AppendLine(); } //拼接顶级分类的方法 ControlHelper ctl = new ControlHelper(this); SettingEntity GroupControl = new SettingEntity(); GroupControl.Name = "GroupControl"; GroupControl.Alias = "GroupControl"; GroupControl.ControlType = EnumViewControlType.RadioButtonList.ToString(); GroupControl.DefaultValue = Article.GroupID.ToString(); GroupControl.ListContent = GroupListContent.ToString(); PHGroups.Controls.Add((Control)ctl.ViewControl(GroupControl)); }
protected void lbSort_Click(object sender, EventArgs e) { LinkButton ImgbutSort = (LinkButton)sender; if (ImgbutSort != null) { //查出当前要排序的字段 DNNGo_PowerForms_Group objC = DNNGo_PowerForms_Group.FindByKeyForEdit(ImgbutSort.CommandArgument); mTips.IsPostBack = true;//回发时就要触发 if (ImgbutSort.ToolTip == "up") { DNNGo_PowerForms_Group.MoveField(objC, EnumMoveType.Up, ModuleId); //字段上移成功 mTips.LoadMessage("UpMoveGroupSuccess", EnumTips.Success, this, new String[] { "" }); } else { DNNGo_PowerForms_Group.MoveField(objC, EnumMoveType.Down, ModuleId); //字段下移成功 mTips.LoadMessage("DownMoveGroupSuccess", EnumTips.Success, this, new String[] { "" }); } //绑定一下 BindDataList(); } }
/// <summary> /// 列表行绑定 /// </summary> protected void gvArticleList_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { //还原出数据 DNNGo_PowerForms_Group Categorie = e.Row.DataItem as DNNGo_PowerForms_Group; //移动分类按钮 LinkButton lbSortUp = e.Row.FindControl("lbSortUp") as LinkButton; LinkButton lbSortDown = e.Row.FindControl("lbSortDown") as LinkButton; LinkButton lbMobileSortUp = e.Row.FindControl("lbMobileSortUp") as LinkButton; LinkButton lbMobileSortDown = e.Row.FindControl("lbMobileSortDown") as LinkButton; lbSortUp.CommandArgument = lbSortDown.CommandArgument = lbMobileSortUp.CommandArgument = lbMobileSortDown.CommandArgument = Categorie.ID.ToString(); //编辑按钮 HyperLink hlMobileEdit = e.Row.FindControl("hlMobileEdit") as HyperLink; HyperLink hlEdit = e.Row.FindControl("hlEdit") as HyperLink; hlMobileEdit.NavigateUrl = hlEdit.NavigateUrl = xUrl("ID", Categorie.ID.ToString(), "Groups"); //删除按钮 LinkButton btnRemove = e.Row.FindControl("btnRemove") as LinkButton; LinkButton btnMobileRemove = e.Row.FindControl("btnMobileRemove") as LinkButton; btnRemove.CommandArgument = btnMobileRemove.CommandArgument = Categorie.ID.ToString(); btnRemove.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');"); btnMobileRemove.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');"); } }
/// <summary> /// 自定义字段转XML实体 /// </summary> /// <param name="fieldItem"></param> /// <returns></returns> public DNNGo_PowerForms_Field XmlToEntity(FieldEntity fieldItem) { DNNGo_PowerForms_Field fileEntity = new DNNGo_PowerForms_Field(); fileEntity.Name = fieldItem.Name; fileEntity.Alias = fieldItem.Alias; fileEntity.DefaultValue = fieldItem.DefaultValue; fileEntity.Description = fieldItem.Description; fileEntity.Direction = fieldItem.Direction; fileEntity.FieldType = fieldItem.FieldType; fileEntity.FiledList = fieldItem.FiledList; fileEntity.Required = fieldItem.Required; fileEntity.Rows = fieldItem.Rows; fileEntity.Sort = fieldItem.Sort; fileEntity.Status = fieldItem.Status; fileEntity.ToolTip = fieldItem.ToolTip; fileEntity.Verification = fieldItem.Verification; fileEntity.Width = fieldItem.Width; fileEntity.WidthSuffix = fieldItem.WidthSuffix; fileEntity.ListColumn = fieldItem.ListColumn; fileEntity.Options = fieldItem.Options; fileEntity.StartTime = fieldItem.StartTime; fileEntity.EndTime = fieldItem.EndTime; fileEntity.Per_AllUsers = fieldItem.Per_AllUsers; fileEntity.Per_Roles = fieldItem.Per_Roles; if (!String.IsNullOrEmpty(fieldItem.Group)) { DNNGo_PowerForms_Group GroupItem = DNNGo_PowerForms_Group.FindByName(fieldItem.Group, ModuleID); if (!(GroupItem != null && GroupItem.ID > 0)) { GroupItem = new DNNGo_PowerForms_Group(); GroupItem.Name = fieldItem.Group; GroupItem.Status = fileEntity.Status; GroupItem.Sort = fileEntity.Sort; GroupItem.LastIP = WebHelper.UserHost; GroupItem.LastTime = DateTime.Now; GroupItem.LastUser = UserId; GroupItem.ModuleId = ModuleID; GroupItem.PortalId = portalInfo.PortalID; GroupItem.Insert(); } fileEntity.GroupID = GroupItem.ID; } fileEntity.ModuleId = ModuleID; fileEntity.PortalId = portalInfo.PortalID; return(fileEntity); }
protected void cmdUpdate_Click(object sender, EventArgs e) { try { DNNGo_PowerForms_Group item = DNNGo_PowerForms_Group.FindByKeyForEdit(TagID); item.Description = txtContentText.Text; item.Name = txtName.Text; if (divOptions.Visible) { item.Options = SetItemSettings(); } item.LastUser = UserId; item.LastTime = xUserTime.UtcTime(); item.LastIP = WebHelper.UserHost; if (item.ID > 0) { } else { item.ModuleId = ModuleId; item.PortalId = PortalId; item.Status = (Int32)EnumStatus.Activation; } int Resultitem = 0; if (item.ID > 0) { Resultitem = item.Update(); } else { Resultitem = item.Insert(); } if (Resultitem > 0) { mTips.LoadMessage("SaveGroupSuccess", EnumTips.Success, this, new String[] { item.Name }); } else { //保存失败 mTips.LoadMessage("SaveGroupError", EnumTips.Success, this, new String[] { item.Name }); } Response.Redirect(xUrl("Groups"), false); } catch (Exception ex) { ProcessModuleLoadException(ex); } }
/// <summary> /// 绑定数据项到前台 /// </summary> public void BindDataItem(EffectDB EffectDB, String ErrorMessage) { //防止重复提交之用 //SubmitButton.Attributes["onclick"] = Page.GetPostBackEventReference(this.SubmitButton) ; Hashtable Puts = new Hashtable(); TemplateFormat xf = new TemplateFormat(this); xf.CtlButton = SubmitButton; //读取需要载入的参数 Puts.Add("FieldList", FieldList); //读取需要载入的分组 List <DNNGo_PowerForms_Group> GroupList = new List <DNNGo_PowerForms_Group>(); if (Setting_EffectDB.Group) { GroupList = DNNGo_PowerForms_Group.FindAllByView(ModuleId); if (GroupList.Count == 0) { DNNGo_PowerForms_Group defultGroup = new DNNGo_PowerForms_Group(); defultGroup.ID = 0; defultGroup.Name = "Default Group"; GroupList.Add(defultGroup); } } Puts.Add("GroupList", GroupList); Puts.Add("EffectName", Settings_EffectName); Puts.Add("ThemeName", Settings_EffectThemeName); Puts.Add("ErrorMessage", ErrorMessage); Puts.Add("captchaErrorMessage", ErrorMessage); //判断表单版本,用来判断是否控制每个人只能填写一次 Puts.Add("DisplayForm", DisplayForm()); if (!String.IsNullOrEmpty(iFrame) && iFrame.IndexOf("iFrame", StringComparison.CurrentCultureIgnoreCase) >= 0) { liContent.Text = HttpUtility.HtmlDecode(ViewTemplate(EffectDB, "iFrame.html", Puts, xf)); } else { liContent.Text = HttpUtility.HtmlDecode(ViewTemplate(EffectDB, "Effect.html", Puts, xf)); } }
/// <summary> /// 创建下拉列表by 分组 /// </summary> /// <param name="FieldItem"></param> /// <param name="ControlName"></param> /// <param name="ControlID"></param> /// <returns></returns> public String ViewCreateDropDownListByGroup(SettingEntity FieldItem, String ControlName, String ControlID) { //构造国家数据 StringBuilder sb = new StringBuilder(FieldItem.ListContent); List <DNNGo_PowerForms_Group> Groups = DNNGo_PowerForms_Group.FindAllByModuleID(ModuleId); if (Groups != null && Groups.Count > 0) { foreach (DNNGo_PowerForms_Group info in Groups) { if (info != null && !String.IsNullOrEmpty(info.Name)) { sb.AppendFormat("|{0}", info.Name); } } FieldItem.ListContent = sb.ToString(); } return(ViewCreateDropDownList(FieldItem, ControlName, ControlID)); }
protected void cmdDeleteCategory_Click(object sender, EventArgs e) { try { DNNGo_PowerForms_Group item = DNNGo_PowerForms_Group.FindByKeyForEdit(TagID); if (item.ID > 0 && item.Delete() > 0) { mTips.LoadMessage("DeleteGroupSuccess", EnumTips.Success, this, new String[] { item.Name }); } else { mTips.LoadMessage("DeleteGroupError", EnumTips.Success, this, new String[] { item.Name }); } Response.Redirect(xUrl("Groups"), false); } catch (Exception ex) { ProcessModuleLoadException(ex); } }
/// <summary> /// 自定义字段转XML实体 /// </summary> /// <param name="fieldItem"></param> /// <returns></returns> public FieldEntity EntityToXml(DNNGo_PowerForms_Field fieldItem) { FieldEntity filexml = new FieldEntity(); filexml.Name = fieldItem.Name; filexml.Alias = fieldItem.Alias; filexml.DefaultValue = fieldItem.DefaultValue; filexml.Description = fieldItem.Description; filexml.Direction = fieldItem.Direction; filexml.FieldType = fieldItem.FieldType; filexml.FiledList = fieldItem.FiledList; filexml.Required = fieldItem.Required; filexml.Rows = fieldItem.Rows; filexml.Sort = fieldItem.Sort; filexml.Status = fieldItem.Status; filexml.ToolTip = fieldItem.ToolTip; filexml.Verification = fieldItem.Verification; filexml.Width = fieldItem.Width; filexml.WidthSuffix = fieldItem.WidthSuffix; filexml.ListColumn = fieldItem.ListColumn; filexml.Options = fieldItem.Options; filexml.StartTime = fieldItem.StartTime; filexml.EndTime = fieldItem.EndTime; filexml.Per_AllUsers = fieldItem.Per_AllUsers; filexml.Per_Roles = fieldItem.Per_Roles; if (fieldItem.GroupID > 0) { DNNGo_PowerForms_Group Group = DNNGo_PowerForms_Group.FindByID(fieldItem.GroupID); if (Group != null && Group.ID > 0) { filexml.Group = Group.Name; } } return(filexml); }
/// <summary> /// 状态应用按钮事件 /// </summary> protected void btnApply_Click(object sender, EventArgs e) { try { Int32 Status = WebHelper.GetIntParam(Request, ddlStatus.UniqueID, -1); if (Status >= 0) { string Checkbox_Value = WebHelper.GetStringParam(Request, "Checkbox", ""); string[] Checkbox_Value_Array = Checkbox_Value.Split(','); Int32 IDX = 0; for (int i = 0; i < Checkbox_Value_Array.Length; i++) { if (Int32.TryParse(Checkbox_Value_Array[i], out IDX)) { DNNGo_PowerForms_Group item = DNNGo_PowerForms_Group.FindByKeyForEdit(IDX); if (item != null && item.ID > 0) { mTips.IsPostBack = true; if (item.Delete() > 0) { //mTips.LoadMessage("DeleteCategorySuccess", EnumTips.Success, this, new String[] { item.ContentText }); } else { //mTips.LoadMessage("DeleteCategoryError", EnumTips.Success, this, new String[] { item.ContentText }); } } } } BindDataList(); } } catch (Exception ex) { ProcessModuleLoadException(ex); } }
/// <summary> /// 列表上的项删除事件 /// </summary> protected void btnRemove_Click(object sender, EventArgs e) { try { LinkButton btnRemove = (LinkButton)sender; DNNGo_PowerForms_Group item = DNNGo_PowerForms_Group.FindByKeyForEdit(btnRemove.CommandArgument); mTips.IsPostBack = true; if (item.ID > 0 && item.Delete() > 0) { mTips.LoadMessage("DeleteGroupSuccess", EnumTips.Success, this, new String[] { item.Name }); } else { mTips.LoadMessage("DeleteGroupError", EnumTips.Success, this, new String[] { item.Name }); } BindDataList(); } catch (Exception ex) { ProcessModuleLoadException(ex); } }
/// <summary> /// 绑定左边项 /// </summary> private void BindDataItem() { if (TagID > 0) { cmdDelete.Visible = true; cmdDelete.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');"); DNNGo_PowerForms_Group item = DNNGo_PowerForms_Group.FindByKeyForEdit(TagID); txtName.Text = item.Name; txtContentText.Text = item.Description; } else { //新增界面 cmdDelete.Visible = false; txtName.Text = ""; txtContentText.Text = ""; } }
/// <summary> /// 绑定右边列表 /// </summary> private void BindDataList() { QueryParam qp = new QueryParam(); qp.PageSize = 10; qp.PageIndex = PageIndex; qp.Orderfld = Orderfld; qp.OrderType = OrderType; int RecordCount = 0; //查询的方法 qp.Where = BindSearch(); List <DNNGo_PowerForms_Group> lst = DNNGo_PowerForms_Group.FindAll(qp, out RecordCount); qp.RecordCount = RecordCount; RecordPages = qp.Pages; lblRecordCount.Text = String.Format("{0} {2} / {1} {3}", RecordCount, RecordPages, ViewResourceText("Title_Items", "Items"), ViewResourceText("Title_Pages", "Pages")); gvArticleList.DataSource = lst; gvArticleList.DataBind(); }
/// <summary> /// 提交表单信息到数据库 /// </summary> public void SubmitFormToDB() { DNNGo_PowerForms_Content SubmitContent = new DNNGo_PowerForms_Content(); //读取需要载入的参数 List <DNNGo_PowerForms_ContentItem> ContentList = new List <DNNGo_PowerForms_ContentItem>(); Boolean SubmitValue = false; if (FieldList != null && FieldList.Count > 0) { foreach (DNNGo_PowerForms_Field fieldItem in FieldList) { DNNGo_PowerForms_ContentItem ContentItem = new DNNGo_PowerForms_ContentItem(); ContentItem.FieldID = fieldItem.ID; ContentItem.FieldName = fieldItem.Name; ContentItem.FieldAlias = fieldItem.Alias; ContentItem.Sort = fieldItem.Sort; ContentItem.ContentValue = GetWebFormValue(fieldItem); ContentItem.Group = DNNGo_PowerForms_Group.FindNameByKeyForEdit(fieldItem.GroupID); if (!String.IsNullOrEmpty(ContentItem.ContentValue)) { SubmitValue = true; } ContentList.Add(ContentItem); } } //是否添加额外跟踪属性 if (Settings_ExtraTracking) { ContentList.AddRange(GetExtraTracking()); } if (SubmitValue) { //判断是否需要隐藏IP String UserHost = WebHelper.UserHost; Boolean HideIp = Settings["PowerForms_HideIp"] != null?Convert.ToBoolean(Settings["PowerForms_HideIp"]) : false; if (HideIp) { UserHost = Common.HideIpAddress(UserHost); } SubmitContent.VerifyString = WebHelper.GetStringParam(Request, hfVerifyString.UniqueID, ""); SubmitContent.LastIP = UserHost; SubmitContent.LastTime = xUserTime.LocalTime(); SubmitContent.LastUser = UserId; SubmitContent.ModuleId = ModuleId; SubmitContent.PortalId = PortalId; SubmitContent.CultureInfo = System.Globalization.CultureInfo.CurrentCulture.Name; SubmitContent.FormVersion = ViewSettingT <String>("PowerForms_FormVersion", ""); //默认是当前登录用户的邮箱 if (UserId > 0 && UserInfo != null && !String.IsNullOrEmpty(UserInfo.Email) && Mail.IsValidEmailAddress(UserInfo.Email, Null.NullInteger)) { SubmitContent.UserName = UserInfo.Username; SubmitContent.Email = UserInfo.Email; } if (!String.IsNullOrEmpty(Settings_SubmitUserEmail)) { //如果没有填写邮箱时 DNNGo_PowerForms_ContentItem EmailItem = ContentList.Find(r1 => r1.FieldName == Settings_SubmitUserEmail); //if (EmailItem != null && !String.IsNullOrEmpty(EmailItem.ContentValue) && Mail.IsValidEmailAddress(EmailItem.ContentValue, Null.NullInteger)) if (EmailItem != null && !String.IsNullOrEmpty(EmailItem.ContentValue)) { SubmitContent.Email = EmailItem.ContentValue; } } //如果没有填写姓名时 DNNGo_PowerForms_Field DisplayNameField = FieldList.Find(r => r.FieldType == (Int32)EnumViewControlType.TextBox_DisplayName); if (DisplayNameField != null && DisplayNameField.ID > 0) { DNNGo_PowerForms_ContentItem DisplayNameItem = ContentList.Find(r1 => r1.FieldName == DisplayNameField.Name); if (DisplayNameItem != null && !String.IsNullOrEmpty(DisplayNameItem.ContentValue)) { SubmitContent.UserName = DisplayNameItem.ContentValue; } } //序列化收集到的提交值列表 if (ContentList != null && ContentList.Count > 0) { SubmitContent.ContentValue = Common.Serialize <List <DNNGo_PowerForms_ContentItem> >(ContentList); } SubmitContent.Status = (Int32)EnumStatus.Activation; //是否需要保存记录 Boolean SaveRecords = ViewSettingT <bool>("PowerForms_SaveRecords", true); //不保存记录 或 保存记录 if (!SaveRecords || (SaveRecords && SubmitContent.Insert() > 0)) { //提交成功发邮件的方法 SendMail(SubmitContent, ContentList, FieldList); //推送数据到第三方URL Boolean Push_Enable = Settings["PowerForms_Push_Enable"] != null && !string.IsNullOrEmpty(Settings["PowerForms_Push_Enable"].ToString()) ? Convert.ToBoolean(Settings["PowerForms_Push_Enable"]) : false; if (Push_Enable) { PushForm push = new PushForm(this); push.ContentList = ContentList; push.SubmitContent = SubmitContent; push.Push(); } if (iFrame.IndexOf("iFrame", StringComparison.CurrentCultureIgnoreCase) >= 0) { if (!String.IsNullOrEmpty(Settings_RedirectPage)) { Response.Write(String.Format("<script> window.parent.location = '{0}';</script>", RedirectPage(SubmitContent))); } else { //提交成功跳转的页面 Response.Redirect(RedirectPage(SubmitContent)); } } else { //提交成功跳转的页面 Response.Redirect(RedirectPage(SubmitContent)); } } else { //新增表单失败 } } else { //提交的内容是空的,没任何信息 } }
/// <summary> /// 列表行绑定 /// </summary> protected void gvFieldList_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { //还原出数据 DNNGo_PowerForms_Field Fielditem = e.Row.DataItem as DNNGo_PowerForms_Field; if (Fielditem != null && Fielditem.ID > 0) { #region "编辑&删除按钮" HyperLink hlEdit = e.Row.FindControl("hlEdit") as HyperLink; HyperLink hlMobileEdit = e.Row.FindControl("hlMobileEdit") as HyperLink; LinkButton btnRemove = e.Row.FindControl("btnRemove") as LinkButton; LinkButton btnMobileRemove = e.Row.FindControl("btnMobileRemove") as LinkButton; //设置按钮的CommandArgument btnRemove.CommandArgument = btnMobileRemove.CommandArgument = Fielditem.ID.ToString(); //设置删除按钮的提示 //if (Field.Status == (Int32)EnumFieldStatus.Recycle) //{ btnRemove.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');"); btnMobileRemove.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');"); //} //else //{ // btnRemove.Attributes.Add("onClick", "javascript:return confirm('" + ViewResourceText("DeleteRecycleItem", "Are you sure to move it to recycle bin?") + "');"); // btnMobileRemove.Attributes.Add("onClick", "javascript:return confirm('" + ViewResourceText("DeleteRecycleItem", "Are you sure to move it to recycle bin?") + "');"); //} hlEdit.NavigateUrl = hlMobileEdit.NavigateUrl = xUrl("FieldID", Fielditem.ID.ToString(), "AddNewField"); #endregion #region "移动分类按钮" LinkButton lbSortUp = e.Row.FindControl("lbSortUp") as LinkButton; LinkButton lbSortDown = e.Row.FindControl("lbSortDown") as LinkButton; LinkButton lbMobileSortUp = e.Row.FindControl("lbMobileSortUp") as LinkButton; LinkButton lbMobileSortDown = e.Row.FindControl("lbMobileSortDown") as LinkButton; lbSortUp.CommandArgument = lbSortDown.CommandArgument = lbMobileSortUp.CommandArgument = lbMobileSortDown.CommandArgument = Fielditem.ID.ToString(); #endregion e.Row.Cells[4].Text = EnumHelper.GetEnumTextVal(Fielditem.FieldType, typeof(EnumViewControlType)); //获取用户名称 DotNetNuke.Entities.Users.UserInfo uInfo = new DotNetNuke.Entities.Users.UserController().GetUser(PortalId, Fielditem.LastUser); e.Row.Cells[7].Text = uInfo != null && uInfo.UserID > 0 ? uInfo.Username:"******"; e.Row.Cells[8].Text = EnumHelper.GetEnumTextVal(Fielditem.Status, typeof(EnumStatus)); if (Fielditem.GroupID > 0) { DNNGo_PowerForms_Group Group = DNNGo_PowerForms_Group.FindByKeyForEdit(Fielditem.GroupID); if (Group != null && Group.ID > 0) { e.Row.Cells[3].Text = Group.Name; } else { e.Row.Cells[3].Text = String.Empty; } } else { e.Row.Cells[3].Text = String.Empty; } } } }