private bool UpdateAction(int typeId, int targetId) { TargetProperty targetModel = new TargetProperty(); TargetPropertyManager targetBLL = new TargetPropertyManager(); targetModel = targetBLL.GetModel(typeId, targetId); if (HidMainFlag.Value == string.Empty) { targetModel.MainFlag = null; } else { targetModel.MainFlag = HidMainFlag.Value == "chkMain_0" ? true : false; } targetModel.IsRequired = this.isrequired.Checked;//是否必填 targetModel.PropertyName = txtName.Text; targetModel.PropertyType = Convert.ToInt32(rdoDataType.SelectedValue); if (rdoDataType.Items.FindByValue("9").Selected)//数据类型为多选一 { TargetEnum enumModel = new TargetEnum(); TargetEnumManager enumBLL = new TargetEnumManager(); string temp = HidItem.Value; if (temp.EndsWith("$¥$")) { temp = temp.TrimEnd("$¥$".ToCharArray()); } temp = temp.Replace("$¥$", "$"); string[] enumValues = temp.Split('$'); int id = targetModel.EnumTypeId; enumBLL.Delete(id); enumModel.EnumTypeId = id; for (int i = 0; i < enumValues.Count(); i++) { enumModel.EnumId = i + 1; enumModel.EnumValue = enumValues[i]; enumBLL.Add(enumModel); } } return(targetBLL.Update(targetModel)); }
/// <summary> /// 初始化数据 /// </summary> /// <param name="typeId"></param> /// <param name="targetId"></param> private void InitData() { object typeId = Request.QueryString["typeid"]; //标的种类编号 object targetId = Request.QueryString["targetid"]; object action = Request.QueryString["action"]; TargetProperty targetModel = new TargetProperty(); TargetPropertyManager targetBLL = new TargetPropertyManager(); targetModel = targetBLL.GetModel(Convert.ToInt32(typeId), Convert.ToInt32(targetId)); if (typeId == null || action == null || typeId.ToString() == string.Empty || action.ToString() == string.Empty) { return; } if (action.ToString() == "edit" && targetId != null && targetId.ToString() != string.Empty) { txtName.Text = targetModel.PropertyName; txtNum.Text = targetModel.PropertyNO; if (targetModel.MainFlag != null) { if (targetModel.MainFlag == true) { chkMain.SelectedIndex = 0; } else { chkMain.SelectedIndex = 1; } } if (targetModel.IsRequired != null) { this.isrequired.Checked = (bool)targetModel.IsRequired; } else { this.isrequired.Checked = false; } //根据数据类型设定选中项(0:文字描述;3:是非判断;5:日期;9:多选一) ListItem item = rdoDataType.Items.FindByValue(targetModel.PropertyType.ToString()); item.Selected = true; ListItem selItem = rdoDataType.Items.FindByValue("9"); if (targetModel.PropertyType == 9) { selItem.Enabled = true; List <TargetEnum> enumModel = new List <TargetEnum>(); TargetEnumManager enumBLL = new TargetEnumManager(); enumModel = enumBLL.GetModelList(string.Format("EnumTypeId={0}", targetModel.EnumTypeId)); if (enumModel.Count > 0) { foreach (TargetEnum enumItem in enumModel) { LtlEnum.Text += string.Format("<tr><td><input class='tbxprocess' value='{0}' type='text' /></td><td><img class='add imgBtn' onclick='addRow()' alt='添加一行' src='Image/add.png' /></td></tr>", enumItem.EnumValue); } } else { LtlEnum.Text = "<tr><td><input class='tbxprocess' type='text' /></td><td><img class='add imgBtn' onclick='addRow()' alt='添加一行' src='Image/add.png' /><img class='delete imgBtn' onclick='delRow(this)' alt='删除' src='Image/backto.png' /></td></tr>"; } this.HidShow.Value = "true"; } else { selItem.Enabled = false; this.HidShow.Value = "false"; } rdoDataType.Items.FindByValue("0").Enabled = rdoDataType.Items.FindByValue("3").Enabled = rdoDataType.Items.FindByValue("5").Enabled = !selItem.Enabled; } //自动生成标的编号 else if (action.ToString() == "new") { StringBuilder num = new StringBuilder(); TargetTypeManager typeBll = new TargetTypeManager(); TargetType type = typeBll.GetModel(Convert.ToInt32(typeId)); for (int i = 1; i < 100; i++) { num.Append(type.TypeNo); if (i.ToString().Length == 1) { num.Append("0"); } num.Append(i.ToString()); if (!ExitsNum(num.ToString())) { break; } else { num.Clear(); } } txtNum.Text = num.ToString(); LtlEnum.Text = "<tr><td><input class='tbxprocess' type='text' /></td><td><img class='add imgBtn' onclick='addRow()' alt='添加一行' src='Image/add.png' /><img class='delete imgBtn' onclick='delRow(this)' alt='删除' src='Image/backto.png' /></td></tr>"; } }
public string GetValue(object value, int dataType, int id, int typeID) { StringBuilder html = new StringBuilder(); switch (dataType) { //文字描述 case 0: html.AppendFormat("<input type='text' value='{0}' />", value); break; //是非判断 case 3: if (value.ToString() == "是") { html.Append("<select><option value='1' selected='selected'>是</option><option value='0'>否</option></select>"); } else { html.Append("<select><option value='1'>是</option><option value='0' selected='selected'>否</option></select>"); } break; //日期 case 5: html.AppendFormat("<input type='text' class='Wdate' value='{0}' onFocus='WdatePicker({1}isShowClear:false,readOnly:true{2})' />", value, "{", "}"); break; //多选一 case 9: TargetPropertyManager tpBLL = new TargetPropertyManager(); TargetEnumManager enumBLL = new TargetEnumManager(); TargetProperty tpModel = tpBLL.GetModel(typeID, id); if (tpModel != null) { DataTable dtEnum = enumBLL.GetList(string.Format("EnumTypeId={0}", tpModel.EnumTypeId)); html.Append("<select>"); for (int i = 0; i < dtEnum.Rows.Count; i++) { if (value.ToString().Trim() == dtEnum.Rows[i]["EnumValue"].ToString().Trim()) { html.AppendFormat("<option value='{0}' selected='selected' >{1}</option>", i, dtEnum.Rows[i]["EnumValue"]); } else { html.AppendFormat("<option value='{0}' >{1}</option>", i, dtEnum.Rows[i]["EnumValue"]); } } html.Append("</select>"); } else { html.Append("<select>"); html.AppendFormat("<option value='' >{0}</option>", value); html.Append("</select>"); } break; default: break; } return(html.ToString()); }