TrendMissItemInfo.aspx.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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.Data;
  8. using CB.Entity;
  9. using CB.Framework;
  10. using CB.Common;
  11. using System.Reflection;
  12. using CB.TrendChart;
  13. using CB.TrendMiss;
  14. using CB.TrendMiss.LotteryTrendMiss;
  15. namespace CB.Admin.Plugins.TrendMissConfig
  16. {
  17. public partial class TrendMissItemInfo1 : AdminPage
  18. {
  19. protected int chartId = 0, Cid = 0;
  20. protected string typeName = "";
  21. List<MissFunction> Attributelist = new List<MissFunction>();
  22. protected void Page_Load(object sender, EventArgs e)
  23. {
  24. chartId = WRequest.GetQueryInt("Id");
  25. Cid = WRequest.GetQueryInt("Cid");
  26. BindList<MissItemFunction>();
  27. if (!Page.IsPostBack)
  28. {
  29. InitData();
  30. }
  31. }
  32. protected override void InitData()
  33. {
  34. #region dlFuntionType列表绑定
  35. ddlFuntionType.Items.Clear();
  36. for (int i = 0; i < Attributelist.Count; i++)
  37. {
  38. ddlFuntionType.Items.Add(new ListItem(Attributelist[i].Name, i.ToString()));
  39. }
  40. #endregion
  41. if (0 < chartId)
  42. {
  43. typeName = GetChartName(chartId);
  44. TrendMissItemInfo entity = CB.Data.TrendMissItemService.Get(chartId);
  45. if (null != entity && 0 < entity.Id)
  46. {
  47. //txtChartId.Text = entity.ChartId.ToString();
  48. txtCycle.Text = entity.Cycle.ToString();
  49. txtItemCycle.Text = string.Join(",", entity.ItemCycle);
  50. txtItemMinValue.Text = entity.ItemMinValue.ToString();
  51. txtItemMaxValue.Text = entity.ItemMaxValue.ToString();
  52. txtItemCount.Text = entity.ItemCount.ToString();
  53. txtItemString.Text = string.Join(",", entity.ItemString);
  54. txtSplitNumberOfDX.Text = entity.SplitNumberOfDX.ToString();
  55. txtIndexStart.Text = entity.IndexStart.ToString();
  56. txtIndexEnd.Text = entity.IndexEnd.ToString();
  57. for (int i = 0; i < Attributelist.Count; i++)
  58. {
  59. if (Attributelist[i].ItemType == entity.FuntionType)
  60. {
  61. ddlFuntionType.SelectedIndex = i;
  62. break;
  63. }
  64. }
  65. labID.Text = entity.Id.ToString();
  66. }
  67. }
  68. base.InitData();
  69. }
  70. protected void btnUpdate_Click(object sender, EventArgs e)
  71. {
  72. var entity = new Entity.TrendMissItemInfo()
  73. {
  74. Id = TypeConverter.StrToInt(labID.Text.Trim()),
  75. ChartId = chartId,
  76. Cycle = TypeConverter.StrToInt(txtCycle.Text.Trim()),
  77. ItemCycle = txtItemCycle.Text.TrimEnd(',').Split(','),
  78. ItemMinValue = TypeConverter.StrToInt(txtItemMinValue.Text.Trim()),
  79. ItemMaxValue = TypeConverter.StrToInt(txtItemMaxValue.Text.Trim()),
  80. ItemCount = TypeConverter.StrToInt(txtItemCount.Text.Trim()),
  81. ItemString = txtItemString.Text.TrimEnd(',').Split(','),
  82. SplitNumberOfDX = TypeConverter.StrToInt(txtSplitNumberOfDX.Text.Trim()),
  83. IndexStart = TypeConverter.StrToInt(txtIndexStart.Text.Trim()),
  84. IndexEnd = TypeConverter.StrToInt(txtIndexEnd.Text.Trim()),
  85. FuntionType = Attributelist[ddlFuntionType.SelectedIndex].ItemType,
  86. ClassName = Attributelist[ddlFuntionType.SelectedIndex].ClassName
  87. };
  88. Validate(entity);//验证数据
  89. if (0 < entity.Id)
  90. {
  91. if (CB.Data.TrendMissItemService.Update(entity))
  92. {
  93. ChangeState(TrendChartStatus.Test, chartId);
  94. Logs("修改遗漏配置信息", string.Format("修改遗漏配置信息:[{0}]", entity.Id));
  95. ShowMessageBox("提示:修改成功!", string.Format("TrendMissItemInfo.aspx?authPage={0}&id={1}", authPage, entity.ChartId));
  96. }
  97. else
  98. {
  99. ShowMessageBox("提示:修改失败!");
  100. }
  101. }
  102. else
  103. {
  104. if (CB.Data.TrendMissItemService.Save(entity))
  105. {
  106. ChangeState(TrendChartStatus.Test, chartId);
  107. Logs("新增遗漏配置信息", string.Format("新增遗漏配置:[{0}]", entity.Id));
  108. Entity.TrendMissItemInfo info = CB.Data.TrendMissItemService.Get(entity.ChartId);
  109. ShowMessageBox("提示:添加成功!!!", string.Format("TrendMissItemInfo.aspx?authPage={0}&id={1}", authPage, info.ChartId));
  110. }
  111. else
  112. {
  113. ShowMessageBox("提示:添加失败!");
  114. }
  115. }
  116. }
  117. public string GetChartName(int chartid)
  118. {
  119. var entity = CB.Data.TrendChartService.Get(chartid);
  120. return null != entity ? entity.Name : "";
  121. }
  122. //绑定方法列表方法
  123. private void BindList<T>()
  124. {
  125. MethodInfo[] methodList = typeof(T).GetMethods();
  126. if (null != methodList && 0 < methodList.Length)
  127. {
  128. foreach (MethodInfo item in methodList)
  129. {
  130. MissFunction[] Description = item.GetCustomAttributes(typeof(MissFunction), false) as MissFunction[];
  131. if (null != Description && 1 <= Description.Length)
  132. Attributelist.Add(new MissFunction(Description[0].Name, Description[0].ItemType, Description[0].ClassName));
  133. }
  134. }
  135. }
  136. //数据验证
  137. public void Validate(Entity.TrendMissItemInfo entity)
  138. {
  139. if (entity.ItemCycle.Length != entity.ItemCount)
  140. ShowMessageBox("配置项个数不等于项长度!");
  141. if (entity.ItemString.Length != entity.ItemCount)
  142. ShowMessageBox("项的字符串个数不等于项长度");
  143. if (entity.ItemMinValue != -1 || entity.ItemMaxValue != -1)
  144. if (entity.ItemMaxValue < entity.ItemMinValue)
  145. ShowMessageBox("项的最大值小于最小值");
  146. else if ((entity.ItemMaxValue - entity.ItemMinValue + 1) != entity.ItemCount)
  147. ShowMessageBox("配置项最大值和最小值之间个数不等于项长度!");
  148. else if (entity.SplitNumberOfDX != -1)
  149. if (entity.ItemMaxValue < entity.SplitNumberOfDX && entity.SplitNumberOfDX > entity.ItemMinValue)
  150. ShowMessageBox("项的大小分隔值不在配置项最大值和最小值之间!");
  151. }
  152. //生成遗漏数据
  153. protected void btn_CreateMissData_Click_Click(object sender, EventArgs e)
  154. {
  155. switch (Cid)
  156. {
  157. case 1:
  158. FC3DTrendMiss.CreateMissData(chartId, 0, null);
  159. break;
  160. case 2:
  161. TCP3TrendMiss.CreateMissData(chartId, 0, null);
  162. break;
  163. case 4:
  164. FCSSQTrendMiss.CreateMissData(chartId, 0, null);
  165. break;
  166. }
  167. }
  168. }
  169. }