using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using CB.Data; using CB.Entity; using CB.Framework; using CB.Common; using System.Reflection; using CB.TrendChart; using CB.TrendMiss; using CB.TrendMiss.LotteryTrendMiss; namespace CB.Admin.Plugins.TrendMissConfig { public partial class TrendMissItemInfo1 : AdminPage { protected int chartId = 0, Cid = 0; protected string typeName = ""; List Attributelist = new List(); protected void Page_Load(object sender, EventArgs e) { chartId = WRequest.GetQueryInt("Id"); Cid = WRequest.GetQueryInt("Cid"); BindList(); if (!Page.IsPostBack) { InitData(); } } protected override void InitData() { #region dlFuntionType列表绑定 ddlFuntionType.Items.Clear(); for (int i = 0; i < Attributelist.Count; i++) { ddlFuntionType.Items.Add(new ListItem(Attributelist[i].Name, i.ToString())); } #endregion if (0 < chartId) { typeName = GetChartName(chartId); TrendMissItemInfo entity = CB.Data.TrendMissItemService.Get(chartId); if (null != entity && 0 < entity.Id) { //txtChartId.Text = entity.ChartId.ToString(); txtCycle.Text = entity.Cycle.ToString(); txtItemCycle.Text = string.Join(",", entity.ItemCycle); txtItemMinValue.Text = entity.ItemMinValue.ToString(); txtItemMaxValue.Text = entity.ItemMaxValue.ToString(); txtItemCount.Text = entity.ItemCount.ToString(); txtItemString.Text = string.Join(",", entity.ItemString); txtSplitNumberOfDX.Text = entity.SplitNumberOfDX.ToString(); txtIndexStart.Text = entity.IndexStart.ToString(); txtIndexEnd.Text = entity.IndexEnd.ToString(); for (int i = 0; i < Attributelist.Count; i++) { if (Attributelist[i].ItemType == entity.FuntionType) { ddlFuntionType.SelectedIndex = i; break; } } labID.Text = entity.Id.ToString(); } } base.InitData(); } protected void btnUpdate_Click(object sender, EventArgs e) { var entity = new Entity.TrendMissItemInfo() { Id = TypeConverter.StrToInt(labID.Text.Trim()), ChartId = chartId, Cycle = TypeConverter.StrToInt(txtCycle.Text.Trim()), ItemCycle = txtItemCycle.Text.TrimEnd(',').Split(','), ItemMinValue = TypeConverter.StrToInt(txtItemMinValue.Text.Trim()), ItemMaxValue = TypeConverter.StrToInt(txtItemMaxValue.Text.Trim()), ItemCount = TypeConverter.StrToInt(txtItemCount.Text.Trim()), ItemString = txtItemString.Text.TrimEnd(',').Split(','), SplitNumberOfDX = TypeConverter.StrToInt(txtSplitNumberOfDX.Text.Trim()), IndexStart = TypeConverter.StrToInt(txtIndexStart.Text.Trim()), IndexEnd = TypeConverter.StrToInt(txtIndexEnd.Text.Trim()), FuntionType = Attributelist[ddlFuntionType.SelectedIndex].ItemType, ClassName = Attributelist[ddlFuntionType.SelectedIndex].ClassName }; Validate(entity);//验证数据 if (0 < entity.Id) { if (CB.Data.TrendMissItemService.Update(entity)) { ChangeState(TrendChartStatus.Test, chartId); Logs("修改遗漏配置信息", string.Format("修改遗漏配置信息:[{0}]", entity.Id)); ShowMessageBox("提示:修改成功!", string.Format("TrendMissItemInfo.aspx?authPage={0}&id={1}", authPage, entity.ChartId)); } else { ShowMessageBox("提示:修改失败!"); } } else { if (CB.Data.TrendMissItemService.Save(entity)) { ChangeState(TrendChartStatus.Test, chartId); Logs("新增遗漏配置信息", string.Format("新增遗漏配置:[{0}]", entity.Id)); Entity.TrendMissItemInfo info = CB.Data.TrendMissItemService.Get(entity.ChartId); ShowMessageBox("提示:添加成功!!!", string.Format("TrendMissItemInfo.aspx?authPage={0}&id={1}", authPage, info.ChartId)); } else { ShowMessageBox("提示:添加失败!"); } } } public string GetChartName(int chartid) { var entity = CB.Data.TrendChartService.Get(chartid); return null != entity ? entity.Name : ""; } //绑定方法列表方法 private void BindList() { MethodInfo[] methodList = typeof(T).GetMethods(); if (null != methodList && 0 < methodList.Length) { foreach (MethodInfo item in methodList) { MissFunction[] Description = item.GetCustomAttributes(typeof(MissFunction), false) as MissFunction[]; if (null != Description && 1 <= Description.Length) Attributelist.Add(new MissFunction(Description[0].Name, Description[0].ItemType, Description[0].ClassName)); } } } //数据验证 public void Validate(Entity.TrendMissItemInfo entity) { if (entity.ItemCycle.Length != entity.ItemCount) ShowMessageBox("配置项个数不等于项长度!"); if (entity.ItemString.Length != entity.ItemCount) ShowMessageBox("项的字符串个数不等于项长度"); if (entity.ItemMinValue != -1 || entity.ItemMaxValue != -1) if (entity.ItemMaxValue < entity.ItemMinValue) ShowMessageBox("项的最大值小于最小值"); else if ((entity.ItemMaxValue - entity.ItemMinValue + 1) != entity.ItemCount) ShowMessageBox("配置项最大值和最小值之间个数不等于项长度!"); else if (entity.SplitNumberOfDX != -1) if (entity.ItemMaxValue < entity.SplitNumberOfDX && entity.SplitNumberOfDX > entity.ItemMinValue) ShowMessageBox("项的大小分隔值不在配置项最大值和最小值之间!"); } //生成遗漏数据 protected void btn_CreateMissData_Click_Click(object sender, EventArgs e) { switch (Cid) { case 1: FC3DTrendMiss.CreateMissData(chartId, 0, null); break; case 2: TCP3TrendMiss.CreateMissData(chartId, 0, null); break; case 4: FCSSQTrendMiss.CreateMissData(chartId, 0, null); break; } } } }