コード例 #1
0
        /// <summary>
        /// 设置数据项
        /// </summary>
        private void SetDataItem()
        {
            //查询出当前字段的列表
            String jsonFields = WebHelper.GetStringParam(Request, nestable_output.UniqueID, "");

            if (!String.IsNullOrEmpty(jsonFields))
            {
                JavaScriptSerializer          json        = new JavaScriptSerializer();
                List <DNNGo_PowerForms_Field> json_fields = json.Deserialize <List <DNNGo_PowerForms_Field> >(jsonFields);
                if (json_fields != null && json_fields.Count > 0)
                {
                    List <DNNGo_PowerForms_Field> FieldLists = FieldList;

                    for (int i = 0; i < json_fields.Count; i++)
                    {
                        DNNGo_PowerForms_Field DBField = FieldLists.Find(r => r.ID == json_fields[i].ID);
                        if (DBField != null && DBField.ID > 0 && DBField.Sort != i)
                        {
                            DBField.Sort = i;
                            DBField.Update();
                        }
                    }
                }
            }
        }
コード例 #2
0
        /// <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;
                    mTips.IsPostBack = true;
                    for (int i = 0; i < Checkbox_Value_Array.Length; i++)
                    {
                        if (Int32.TryParse(Checkbox_Value_Array[i], out IDX))
                        {
                            DNNGo_PowerForms_Field Field = DNNGo_PowerForms_Field.FindByKeyForEdit(IDX);
                            if (Field != null && Field.ID > 0)
                            {
                                Field.Status = Status;
                                if (Field.Update() > 0)
                                {
                                    //操作成功
                                    mTips.LoadMessage("UpdateFieldSuccess", EnumTips.Success, this, new String[] { Field.Alias });
                                }
                                else
                                {
                                    //操作失败
                                    mTips.LoadMessage("UpdateFieldError", EnumTips.Success, this, new String[] { Field.Alias });
                                }
                            }
                        }
                    }

                    BindDataList();
                }
            }
            catch (Exception ex)
            {
                ProcessModuleLoadException(ex);
            }
        }
        /// <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);
        }