//修改时绑定字段 private void BindControlsValue() { ContentModelEntity model = ModelHelper.GetContentModelByName(ModelName); if (model != null) { string[] tempName = model.Name.Split(new char[] { '.' }); this.GroupDropDownList.SelectedValue = tempName[0].Trim(); this.ModelNameTextBox.Text = tempName[1]; this.ModelStateDropDownList.SelectedValue = model.State.ToString(); this.ModelLabelTextBox.Text = model.Label; this.ModelNameTextBox.Enabled = false; this.DescriptionTextBox.Text = model.Description; //tedyding 2010-10-15 ModelInfo mi = ModelHelper.GetModelInfoByName(ModelName); if (mi != null) { this.AuthorityTypeCheckBox.Checked = mi.AuthorityType; this.ddlRelationModelName.SelectedValue = mi.RelationModelName; } if (!string.IsNullOrEmpty(mi.Parameters)) { string[] p = mi.Parameters.Split(':'); if (p[0] == "role" && p.Length > 1) { this.RoleTextBox.Text = p[1]; } } GroupDropDownList.Enabled = false; } }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(ModelName)) { We7.Model.Core.ContentModel cm = ModelHelper.GetContentModelByName(ModelName); FormTitleLiteral.Text = cm.Label + "录入表单自定义"; FormDesciptionLiteral.Text = cm.Description; //显示更新到会员中心复选框 if (cm.Type == ModelType.ARTICLE) { string panel = RequestHelper.Get <string>("panel", "edit"); if (panel.ToLower() == "edit") { copyControls.Visible = true; } else { copyControls.Visible = false; } } else { copyControls.Visible = false; } } }
/// <summary> /// Form Submit /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SubmitButton_Click(object sender, EventArgs e) { if (!CheckInput()) { return; } string defaultModelName = RequestHelper.Get <string>("modelname"); if (String.IsNullOrEmpty(defaultModelName)) { defaultModelName = GetDefaultModelName(); } //获取默认的模型 ModelInfo modelInfo = ModelHelper.GetModelInfoByName(defaultModelName); ContentModelEntity model = new ContentModelEntity(); model.Name = string.Format("{0}.{1}", GroupDropDownList.Enabled ? Request[GroupDropDownList.UniqueID] : GroupDropDownList.SelectedValue, ModelNameTextBox.Text.Trim()); model.State = Convert.ToInt32(ModelStateDropDownList.SelectedValue); model.Label = ModelLabelTextBox.Text.Trim(); model.DefaultContentName = defaultModelName; ModelType modelType = ModelType.ARTICLE; if (defaultModelName == "Template.AdviceModel" || MyModelType == "ADVICE") { modelType = ModelType.ADVICE; } else if (defaultModelName == "Template.AccountModel" || MyModelType == "ACCOUNT") { modelType = ModelType.ACCOUNT; if (!string.IsNullOrEmpty(RoleTextBox.Text)) { modelInfo.Parameters = "role:" + RoleTextBox.Text; } ; } model.Description = DescriptionTextBox.Text.Trim(); model.Type = modelType; if (string.IsNullOrEmpty(this.ModelNameTextBox.Text.Trim())) { Messages.ShowError("模型名称不能为空!"); return; } bool success = ModelHelper.SaveContentModel(model); BindModelGroup(); if (success) { modelInfo.Label = model.Label; modelInfo.ModelName = model.Name; modelInfo.Desc = model.Description; modelInfo.DataSet.Tables[0].Name = ModelNameTextBox.Text.Trim(); modelInfo.Type = modelType; modelInfo.AuthorityType = AuthorityTypeCheckBox.Checked; if (defaultModelName == "Template.ArticleModel" || MyModelType == "ARTICLE") { string tempvalue = modelInfo.Layout.Panels["list"].ListInfo.Groups[0].Columns["Manage"].Params["cmd"].Replace("Template.ArticleModel", model.Name); modelInfo.Layout.Panels["list"].ListInfo.Groups[0].Columns["Manage"].Params["cmd"] = tempvalue; modelInfo.RelationModelName = ddlRelationModelName.SelectedValue; } ModelHelper.SaveModelInfo(modelInfo, model.Name); if (defaultModelName == "Template.ArticleModel" || MyModelType == "ARTICLE") { //更新表结构 ModelHelper.CreateModelTable(modelInfo); } string tempName = RequestHelper.Get <string>("modelname"); string msg = ModelTypeName + " {0} 成功!继续 <a href='EditLayout.aspx?modelname={1}' target='_blank'>编辑模型布局</a> "; if (Action == ActionType.Add) { msg = string.Format(msg, "添加", model.Name); } else if (Action == ActionType.Edit) { msg = string.Format(msg, "修改", tempName); } Messages.ShowMessage(msg); } else { if (Action == ActionType.Add) { Messages.ShowError("添加失败!"); } else if (Action == ActionType.Edit) { Messages.ShowError("修改失败!"); } } }