TrendToolListItemInfo.aspx.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using CB.Framework;
  8. using CB.Data;
  9. using CB.Entity;
  10. using CB.Common;
  11. namespace CB.Admin.Plugins.TrendTool
  12. {
  13. public partial class TrendToolListItemConfig : AdminPage
  14. {
  15. protected int ConfigId = 0;
  16. protected int PageID = 0;
  17. protected void Page_Load(object sender, EventArgs e)
  18. {
  19. ConfigId = WRequest.GetInt("ConfigID", 0);
  20. PageID = WRequest.GetInt("PageID", 0);
  21. if (!IsPostBack)
  22. { LoadData(); }
  23. }
  24. /// <summary>
  25. /// 加载初始数据
  26. /// </summary>
  27. private void LoadData()
  28. {
  29. TrendToolItemConfigInfo entity = new TrendToolItemConfigInfo();
  30. entity.ConfigID = ConfigId;
  31. IList<TrendToolItemConfigInfo> lists = new List<TrendToolItemConfigInfo>();
  32. lists = TrendToolItemConfigService.GetToolItemConfig(entity);
  33. repeaterList.DataSource = lists;
  34. repeaterList.DataBind();
  35. }
  36. protected void btnUpdate_Click(object sender, EventArgs e)
  37. {
  38. if (ConfigId < 1)
  39. { ShowMessageBox("获取Config失败!无法保存"); }
  40. TrendToolItemConfigInfo entity = new TrendToolItemConfigInfo();
  41. entity.ConfigID = ConfigId;
  42. entity.ItemID = TypeConverter.StrToInt(this.labItemID.Text.Trim());
  43. entity.FilterRemark = this.txtFilterRemark.Text.Trim();
  44. entity.LineCount = TypeConverter.StrToInt(this.txtLineCount.Text.Trim());
  45. entity.SpecialCode = this.txtSpecialCode.Text.Trim();
  46. entity.ControlArea = this.txtControlArea.Text.Trim();
  47. entity.ElementName = this.ddlElementName.SelectedValue.Trim();
  48. if (entity.ElementName == "input")
  49. { entity.ElementType = this.ddlElementType.SelectedValue.Trim(); }
  50. entity.ElementValue = this.txtElementValue.Text.Trim();
  51. entity.ElementCount = TypeConverter.StrToInt(this.txtElementCount.Text.Trim());
  52. entity.IsCheckeds = this.txtIsCheckeds.Text.Trim();
  53. entity.AttrOther = this.txtAttrOther.Text.Trim();
  54. entity.LabelValue = this.txtLabelValue.Text.Trim();
  55. entity.ItemOrder = TypeConverter.StrToInt(this.txtItemOrder.Text.Trim());
  56. entity.FilterCode = this.ddlFilterCode.SelectedValue;
  57. entity.FilterCodeGroup = this.txtFilterCodeGroup.Text.Trim();
  58. entity.NameControl = TypeConverter.StrToBool(this.ddlNameControl.SelectedValue, false);
  59. entity.IsControlArea = TypeConverter.StrToBool(this.ddlIsControlArea.SelectedValue, false);
  60. entity.HasLabel = TypeConverter.StrToBool(this.ddlHasLabel.SelectedValue, false);
  61. entity.Status = TypeConverter.StrToBool(this.ddlStatus.SelectedValue, false);
  62. TrendToolItemConfigService.Save(entity);
  63. TrendToolItemCssConfigInfo css = new TrendToolItemCssConfigInfo();
  64. css.ElementClass = this.txtElementClass.Text.Trim();
  65. css.ControlNameID = this.txtControlNameID.Text.Trim();
  66. css.OtherHTML = this.txtOtherHTML.Text.Trim();
  67. css.ItemID = TypeConverter.StrToInt(this.labItemID.Text.Trim());
  68. css.FilterCssID = TypeConverter.StrToInt(this.txtFilterCssID.Value.Trim());
  69. if (!(string.IsNullOrEmpty(css.ElementClass) || string.IsNullOrEmpty(css.OtherHTML)))
  70. { TrendToolItemCssConfigService.Save(css); }
  71. LoadData();
  72. ClearControls();
  73. }
  74. protected void repeaterList_ItemCommand(object source, RepeaterCommandEventArgs e)
  75. {
  76. int itemID = TypeConverter.ObjectToInt(e.CommandArgument);
  77. if (e.CommandName == "dnedit")
  78. {
  79. BindItemInfo(itemID);
  80. BindCssInfo(itemID);
  81. }
  82. if (e.CommandName == "dndel")
  83. {
  84. TrendToolItemConfigService.Delete(itemID);
  85. TrendToolItemCssConfigService.Delete(new TrendToolItemCssConfigInfo() { ItemID = itemID });
  86. LoadData();
  87. }
  88. }
  89. /// <summary>
  90. /// 绑定编辑数据
  91. /// </summary>
  92. /// <param name="itemID"></param>
  93. private void BindItemInfo(int itemID)
  94. {
  95. TrendToolItemConfigInfo entity = TrendToolItemConfigService.Get(itemID);
  96. if (entity == null || entity.ItemID < 1)
  97. { return; }
  98. this.txtConfigID.Value = entity.ConfigID.ToString();
  99. this.labItemID.Text = entity.ItemID.ToString();
  100. this.txtFilterRemark.Text = entity.FilterRemark;
  101. this.txtLineCount.Text = entity.LineCount.ToString();
  102. txtSpecialCode.Text = entity.SpecialCode;
  103. this.txtControlArea.Text = entity.ControlArea;
  104. this.txtElementValue.Text = entity.ElementValue;
  105. this.txtElementCount.Text = entity.ElementCount.ToString();
  106. this.txtIsCheckeds.Text = entity.IsCheckeds;
  107. this.txtAttrOther.Text = entity.AttrOther;
  108. this.txtLabelValue.Text = entity.LabelValue;
  109. this.txtItemOrder.Text = entity.ItemOrder.ToString();
  110. this.txtFilterCodeGroup.Text = entity.FilterCodeGroup;
  111. ListItem li1 = this.ddlFilterCode.Items.FindByValue(entity.FilterCode);
  112. if (li1 != null)
  113. {
  114. this.ddlFilterCode.ClearSelection();
  115. li1.Selected = true;
  116. }
  117. ListItem li2 = this.ddlElementName.Items.FindByValue(entity.ElementName);
  118. if (li2 != null)
  119. {
  120. this.ddlElementName.ClearSelection();
  121. li2.Selected = true;
  122. }
  123. ListItem li = this.ddlElementType.Items.FindByValue(entity.ElementType);
  124. if (li != null)
  125. {
  126. this.ddlElementType.ClearSelection();
  127. li.Selected = true;
  128. }
  129. string NameControl = entity.NameControl.ToString().ToLower();
  130. ListItem li3 = this.ddlNameControl.Items.FindByValue(NameControl);
  131. if (li3 != null)
  132. {
  133. this.ddlNameControl.ClearSelection();
  134. li3.Selected = true;
  135. }
  136. string IsControlArea = entity.IsControlArea.ToString().ToLower();
  137. ListItem li4 = this.ddlIsControlArea.Items.FindByValue(IsControlArea);
  138. if (li4 != null)
  139. {
  140. this.ddlIsControlArea.ClearSelection();
  141. li4.Selected = true;
  142. }
  143. string HasLabel = entity.HasLabel.ToString().ToLower();
  144. ListItem li5 = this.ddlHasLabel.Items.FindByValue(HasLabel);
  145. if (li5 != null)
  146. {
  147. this.ddlHasLabel.ClearSelection();
  148. li5.Selected = true;
  149. }
  150. string Status = entity.Status.ToString().ToLower();
  151. ListItem li6 = this.ddlStatus.Items.FindByValue(Status);
  152. if (li6 != null)
  153. {
  154. this.ddlStatus.ClearSelection();
  155. li6.Selected = true;
  156. }
  157. }
  158. /// <summary>
  159. /// 绑定CSS
  160. /// </summary>
  161. /// <param name="itemID"></param>
  162. private void BindCssInfo(int itemID)
  163. {
  164. TrendToolItemCssConfigInfo entity = TrendToolItemCssConfigService.Get(new TrendToolItemCssConfigInfo() { ItemID = itemID });
  165. this.txtElementClass.Text = entity.ElementClass;
  166. this.txtControlNameID.Text = entity.ControlNameID;
  167. this.txtOtherHTML.Text = entity.OtherHTML;
  168. this.txtFilterCssID.Value = entity.FilterCssID.ToString();
  169. }
  170. protected void btnClear_Click(object sender, EventArgs e)
  171. {
  172. ClearControls();
  173. }
  174. private void ClearControls()
  175. {
  176. this.form1.Controls.OfType<TextBox>().ToList().ForEach(t => t.Text = "");
  177. this.form1.Controls.OfType<DropDownList>().ToList().ForEach(t => { t.ClearSelection(); t.SelectedIndex = 0; });
  178. this.form1.Controls.OfType<HiddenField>().ToList().ForEach(t => t.Value = "");
  179. this.form1.Controls.OfType<Label>().ToList().ForEach(t => t.Text = "");
  180. }
  181. }
  182. }