123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using CB.Common;
- using CB.Entity;
- using CB.Framework;
- using CB.Data;
- using CB.TVUCenter.Config;
- namespace CB.Admin.Plugins.Lottery
- {
- public partial class AreaEdit : AdminPage
- {
- protected string Action = string.Empty;
- private static int id;
- protected void Page_Load(object sender, EventArgs e)
- {
- Action = WRequest.GetQueryString("Action");
- if (!Page.IsPostBack)
- {
- InitData();
- }
- }
- protected override void InitData()
- {
- BindList();
- }
- protected void BindList()
- {
- id = WRequest.GetQueryInt("id");
- AreaInfo entity = AreaService.Get(id);
- //绑定父类型
- int aindex = 0;
- int areaindex = 0;
- IList<AreaInfo> ais = AreaService.ToList();
- int j = 0;
- foreach (var item in ais)
- {
- ddlParent.Items.Add(new ListItem(item.Name,item.Aid.ToString()));
- j++;
- if (entity!=null&&entity.ParentId==item.Aid)
- {
- aindex = j;
- }
- }
- Array temp = Enum.GetValues(typeof(AreaType));
- for (int i = 0; i < temp.Length; i++)
- {
- string info = temp.GetValue(i).ToString();
- ddlAreaTypes.Items.Add(new ListItem(GetType(info),(i+1).ToString()));
- if (entity != null && info == entity.Depth.ToString())
- {
- areaindex = i + 1;
- }
- }
- if (entity!=null)
- {
- txtName.Text = entity.Name.ToString().Trim();
- ddlAreaTypes.SelectedIndex = areaindex;
- ddlParent.SelectedIndex = aindex;
- }
- }
- private string GetType(string type)
- {
- switch (type)
- {
- case "Country":
- return "全国性";
- case "Province":
- return "全省性";
- case "Area":
- return "地区联销";
- default:
- return "";
- }
- }
- //新增或修改
- protected void btnEdit_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(txtName.Text.Trim()))
- {
- ShowMessageBox("名称不能为空!");
- }
- if (ddlAreaTypes.SelectedIndex==0)
- {
- ShowMessageBox("请选择区域类型!");
- }
- AreaInfo entity = new AreaInfo {
- Aid=id,
- Name=txtName.Text.Trim(),
- ParentId=Convert.ToInt32(this.ddlParent.SelectedValue),
- Depth=(AreaType)Convert.ToInt32(this.ddlAreaTypes.SelectedValue)
- };
- if (AreaService.Save(entity))
- {
- //生成当期及后期数据走势图和遗漏数据
- if (Action == "Add")
- {
- UpdateTvConfig();
- Logs("添加区域", string.Format("添加区域[Name={0}]", entity.Name));
- ShowMessageBox("提示:添加成功!");
- }
- if (Action == "Modify")
- {
- UpdateTvConfig();
- Logs("修改区域", string.Format("修改区域[ID={0}]", entity.Aid));
- ShowMessageBox("提示:修改成功!");
- }
- }
- else
- {
- ShowMessageBox("提示:操作失败!");
- }
- }
- private bool UpdateTvConfig()
- {
- TVConfigInfo entity = CB.TVUCenter.Config.TVConfigs.GetConfig();
- entity.AreaVersion =TypeConverter.StrToInt(DateTime.Now.ToString("yyyyMMddHH").Substring(2, 8));
- return CB.TVUCenter.Config.TVConfigs.UpdateConfig(entity);
- }
- //重置
- protected void btnClear_Click(object sender, EventArgs e)
- {
- txtName.Text = string.Empty;
- ddlAreaTypes.SelectedIndex = 0;
- ddlParent.SelectedIndex = 0;
- }
- }
- }
|