private bool DoEdit(int _id) { bool result = false; Cms.BLL.C_article_attribute_field bll = new Cms.BLL.C_article_attribute_field(); Cms.Model.C_article_attribute_field model = bll.GetModel(_id); if (model.is_sys == 0) { model.control_type = ddlControlType.SelectedValue; model.data_length = Utils.StrToInt(txtDataLength.Text.Trim(), 0); model.data_place = Utils.StrToInt(ddlDataPlace.SelectedValue, 0); model.data_type = rblDataType.SelectedValue; } model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99); model.title = txtTitle.Text; if (cbIsRequired.Checked == true) { model.is_required = 1; } else { model.is_required = 0; } if (cbIsPassword.Checked == true) { model.is_password = 1; } else { model.is_password = 0; } if (cbIsHtml.Checked == true) { model.is_html = 1; } else { model.is_html = 0; } model.editor_type = Utils.StrToInt(rblEditorType.SelectedValue, 0); model.item_option = txtItemOption.Text.Trim(); model.default_value = txtDefaultValue.Text.Trim(); model.valid_pattern = txtValidPattern.Text.Trim(); model.valid_tip_msg = txtValidTipMsg.Text.Trim(); model.valid_error_msg = txtValidErrorMsg.Text.Trim(); if (bll.Update(model)) { adminUser.AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "修改扩展字段:" + model.title); //记录日志 result = true; } return(result); }
private void ShowInfo(int _id) { Cms.BLL.C_article_attribute_field bll = new Cms.BLL.C_article_attribute_field(); Cms.Model.C_article_attribute_field model = bll.GetModel(_id); txtName.Enabled = false; txtName.Attributes.Remove("ajaxurl"); txtName.Attributes.Remove("datatype"); ddlControlType.SelectedValue = model.control_type; showControlHtml(model.control_type); //显示对应的HTML txtSortId.Text = model.sort_id.ToString(); txtName.Text = model.name; txtTitle.Text = model.title; if (model.is_required == 1) { cbIsRequired.Checked = true; } else { cbIsRequired.Checked = false; } if (model.is_password == 1) { cbIsPassword.Checked = true; } else { cbIsPassword.Checked = false; } if (model.is_html == 1) { cbIsHtml.Checked = true; } else { cbIsHtml.Checked = false; } rblEditorType.SelectedValue = model.editor_type.ToString(); rblDataType.SelectedValue = model.data_type; txtDataLength.Text = model.data_length.ToString(); ddlDataPlace.SelectedValue = model.data_place.ToString(); txtItemOption.Text = model.item_option; txtDefaultValue.Text = model.default_value; txtValidPattern.Text = model.valid_pattern; txtValidTipMsg.Text = model.valid_tip_msg; txtValidErrorMsg.Text = model.valid_error_msg; if (model.is_sys == 1) { ddlControlType.Enabled = false; } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Cms.Model.C_article_attribute_field model) { switch (model.control_type) { case "single-text": //单行文本 if (model.data_length > 0 && model.data_length <= 4000) { model.data_type = "nvarchar(" + model.data_length + ")"; } else if (model.data_length > 4000) { model.data_type = "ntext"; } else { model.data_length = 50; model.data_type = "nvarchar(50)"; } break; case "multi-text": //多行文本 goto case "single-text"; case "editor": //编辑器 model.data_type = "ntext"; break; case "images": //图片 model.data_type = "nvarchar(255)"; break; case "number": //数字 if (model.data_place > 0) { model.data_type = "decimal(9," + model.data_place + ")"; } else { model.data_type = "int"; } break; case "checkbox": //复选框 model.data_type = "tinyint"; break; case "multi-radio": //多项单选 if (model.data_type == "int") { model.data_length = 4; model.data_type = "int"; } else { if (model.data_length > 0 && model.data_length <= 4000) { model.data_type = "nvarchar(" + model.data_length + ")"; } else if (model.data_length > 4000) { model.data_type = "ntext"; } else { model.data_length = 50; model.data_type = "nvarchar(50)"; } } break; case "multi-checkbox": //多项多选 goto case "single-text"; } return(dal.Add(model)); }