Exemplo n.º 1
0
        // 分页控件数据绑定
        private void SplitDataBind()
        {
            KingTop.Model.SelectParams kmsObj = new KingTop.Model.SelectParams();
            kmsObj.S1 = ModelID;
            kmsObj.I1 = 1;
            DataTable dt = fieldManage.GetList("ALL", kmsObj);

            rptModelField.DataSource = dt;
            rptModelField.DataBind();
            string fieldsName = string.Empty;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i]["IsSystemFiierd"].ToString() == "True")
                {
                    continue;
                }

                if (string.IsNullOrEmpty(fieldsName))
                {
                    fieldsName = dt.Rows[i]["Name"].ToString();
                }
                else
                {
                    fieldsName += "," + dt.Rows[i]["Name"].ToString();
                }
            }
            hidFields.Value = fieldsName;
        }
        void PageInit()
        {
            DataTable dataTableField;
            bool      isValidate;
            bool      isAdd;

            isAdd = true;

            if (TableName.Substring(0, 4) == "K_F_")
            {
                displayListVisible = "display:block;";

                foreach (ListItem item in radlBasicField.Items)
                {
                    if (item.Value == "3" || item.Value == "11" || item.Value == "12" || item.Value == "14")
                    {
                        item.Enabled = false;
                    }
                }
            }

            if (IsSub == "1")
            {
                foreach (ListItem item in radlBasicField.Items)
                {
                    if (item.Value == "14")
                    {
                        item.Enabled = false;
                    }
                }
            }

            if (this.Action.ToLower() == "edit")
            {
                isAdd      = false;
                isValidate = IsHaveRightByOperCode("Edit");  // 修改权限认证

                if (!isValidate)
                {
                    jsMessage = "errmsg=\"对不起,您没有修改模型的操作权限,请与管理员联系!\";id=\"" + ID + "\"";
                }
            }
            else
            {
                isValidate = IsHaveRightByOperCode("New");  // 添加权限认证

                if (!isValidate)
                {
                    jsMessage = "errmsg=\"对不起,您没有添加模型的操作权限,请与管理员联系!\";id=\"" + ID + "\"";
                }
            }

            fieldManage.SubModelBind(ddlSubModelName);                                 // 子模型列表绑定
            fieldManage.SubModelGroupBind(ddlSubModelGroup);                           // 子模型分组绑定
            fieldManage.ModelFieldGroupBind(ddlModelFieldGroupId);                     // 字段分组
            hdnModelID.Value = ModelID;
            fieldManage.ValidationTypeBind(radlValidationType);                        // 绑定验证规则
            dataTableField = fieldManage.DropDownDataTypeBind(ddlDropDownTable, null); // 绑定数据表
            ddlDropDownTextColumn.DataTextField  = "Name";                             // 绑定Text列
            ddlDropDownTextColumn.DataValueField = "Name";
            ddlDropDownTextColumn.DataSource     = dataTableField;
            ddlDropDownTextColumn.DataBind();

            ddlDropDownValueColumn.DataTextField  = "Name";          // 绑定Value列
            ddlDropDownValueColumn.DataValueField = "Name";
            ddlDropDownValueColumn.DataSource     = dataTableField;
            ddlDropDownValueColumn.DataBind();
            ddlDropDownTextColumn.Items.Insert(0, "请选择数据表");

            if (!isAdd) // 编辑
            {
                DataTable dtField;
                KingTop.Model.SelectParams selParam;

                selParam           = new KingTop.Model.SelectParams();
                selParam.S1        = ID;
                hdnAction.Value    = "edit";
                btnModelField.Text = "修改";
                dtField            = fieldManage.GetList("ONE", selParam);

                if (dtField != null && dtField.Rows.Count > 0)
                {
                    hdnBasicField.Value = dtField.Rows[0]["BasicField"].ToString().Trim();
                    BasicFieldInit(dtField.Rows[0]);
                    CommonFieldInit(dtField.Rows[0]);
                }
                else
                {
                    jsMessage = "errmsg=\"对不起,参数传递有误!\";id=\"" + ID + "\"";
                }
            }
            else  // 添加
            {
                hdnAction.Value = "add";
            }
        }