//添加新活动
        protected void addnewactivityButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.activityname.Text))
            {
                this.ErrotLable.Text = "请输入活动名称";
                return;
            }

            if (string.IsNullOrEmpty(this.idTextBox.Text))
            {
                this.ErrotLable.Text = "请输入活动ID";
            }
            else
            {
                mw.ActivityConfig addacticityConfig = new mw.ActivityConfig();
                addacticityConfig.id        = int.Parse(this.idTextBox.Text);
                addacticityConfig.name      = this.activityname.Text;
                addacticityConfig.sign      = int.Parse(this.signTextBox.Text);
                addacticityConfig.param     = int.Parse(this.paramTextBox.Text);
                addacticityConfig.last_days = int.Parse(this.lastTextBox.Text);
                ////如果活动ID已经存在,则不允许添加
                //for (int i = 0; i < ActivityManger.ActivityDataDictionary.Count; i++)
                //{
                //    //字典中已经存在了该ID
                //    if(addacticityConfig.id==ActivityManger.ActivityDataDictionary[i].id)
                //    {
                //        this.ErrotLable.Text = "该活动ID已存在,请重新填写活动ID";
                //        return;
                //    }


                //}


                List <mw.ActivityConfig> list = new List <mw.ActivityConfig>();
                list = RWManager.Load <mw.ActivityConfig>("ActivityConfig.protodata.bytes");
                //添加新活动到链表中
                list.Add(addacticityConfig);
                //把新活动放入字典中
                ActivityManger.ActivityDataDictionary.Add(addacticityConfig.id, addacticityConfig);
                //ActivityManger.ActivityDataDictionary.Remove(3600);
                RWManager.Save <mw.ActivityConfig>("ActivityConfig.protodata.bytes", list);
                //刷新界面
                this.nextListBox.Items.Clear();
                List <mw.ActivityConfig> afterlist = new List <mw.ActivityConfig>();
                afterlist = RWManager.Load <mw.ActivityConfig>("ActivityConfig.protodata.bytes");
                if (afterlist == null)
                {
                    return;
                }
                for (int i = 0; i < afterlist.Count; i++)
                {
                    this.nextListBox.Items.Add(new ListItem(ActivityManger.GetConfigText(afterlist[i], -1), afterlist[i].id.ToString()));
                }

                this.ErrotLable.Text = "新活动添加成功";
            }
        }
        //测试数据
        public static void test()
        {
            List <mw.ActivityConfig> list = new List <mw.ActivityConfig>();

            list.Add(new mw.ActivityConfig());
            RWManager.Save <mw.ActivityConfig>("Activity1.bytes", list);

            //RWManager.Load<mw.ActivityConfig>("ActivityConfig.protodata.bytes");
            RWManager.Load <mw.ActivityConfig>("Activity1.bytes");
        }
        //修改
        protected void UpdateBtn_Click(object sender, EventArgs e)
        {
            List <mw.SysNtfConfig> list = new List <mw.SysNtfConfig>();

            if (this.SysNtfListBox.SelectedIndex == -1)
            {
                this.TipLabel.Text = "请选择修改项";
                return;
            }

            //填写信息校验,ID不允许重复
            string id = this.SysNtfID.Text;

            if (this.SysNtfListBox.Items.FindByValue(id) != null && id != this.SysNtfListBox.SelectedValue)
            {
                this.TipLabel.Text = "ID不能重复";
                return;
            }

            mw.SysNtfConfig config = SysNtfDictionary[int.Parse(this.SysNtfListBox.SelectedItem.Value)];
            config.title_str = this.SysNtfname.Text;
            config.id        = int.Parse(this.SysNtfID.Text);

            foreach (var pair in SysNtfDictionary.Values)
            {
                list.Add(pair);
            }
            RWManager.Save <mw.SysNtfConfig>("SysNtfConfig.protodata.bytes", list);

            //刷新数据
            this.SysNtfListBox.Items.Clear();
            SysNtfDictionary.Clear();
            List <mw.SysNtfConfig> list2 = new List <mw.SysNtfConfig>();

            list2 = RWManager.Load <mw.SysNtfConfig>("SysNtfConfig.protodata.bytes");
            for (int i = 0; i < list2.Count; i++)
            {
                SysNtfDictionary.Add(list2[i].id, list2[i]);
                this.SysNtfListBox.Items.Add(new ListItem(list2[i].id.ToString() + "" + list2[i].title_str + "" + list2[i].details_str, list2[i].id.ToString()));
            }

            this.ErrorLable.Text = list2.Count.ToString();
        }
        //移除
        protected void RemoveactivityButton_Click(object sender, EventArgs e)
        {
            //从字典中移除
            ActivityData removedata = new ActivityData(int.Parse(this.nextListBox.SelectedItem.Value), -1);

            mw.ActivityConfig removedataactivityConfig = ActivityManger.ActivityDataDictionary[removedata.Id];
            ActivityManger.ActivityDataDictionary.Remove(removedataactivityConfig.id);

            this.nextListBox.Items.RemoveAt(this.nextListBox.SelectedIndex);

            List <mw.ActivityConfig> list = new List <mw.ActivityConfig>();

            for (int i = 0; i < this.nextListBox.Items.Count; i++)
            {
                ActivityData      data           = new ActivityData(int.Parse(this.nextListBox.Items[i].Value), -1);
                mw.ActivityConfig activityConfig = ActivityManger.ActivityDataDictionary[data.Id];
                list.Add(activityConfig);
            }

            //重新保存文件
            RWManager.Save <mw.ActivityConfig>("ActivityConfig.protodata.bytes", list);

            this.ErrotLable.Text = "移除活动成功!";
        }
        //修改取出的活动按钮
        protected void UpdateacticityButton_Click(object sender, EventArgs e)
        {
            ActivityData changedata = new ActivityData(int.Parse(this.nextListBox.SelectedItem.Value), -1);

            mw.ActivityConfig changeactivityConfig = ActivityManger.ActivityDataDictionary[changedata.Id];
            changeactivityConfig.name      = this.activityname.Text;
            changeactivityConfig.param     = int.Parse(this.paramTextBox.Text);
            changeactivityConfig.sign      = int.Parse(this.signTextBox.Text);
            changeactivityConfig.last_days = int.Parse(this.lastTextBox.Text);
            List <mw.ActivityConfig> list = new List <mw.ActivityConfig>();

            for (int i = 0; i < this.nextListBox.Items.Count; i++)
            {
                ActivityData      data           = new ActivityData(int.Parse(this.nextListBox.Items[i].Value), -1);
                mw.ActivityConfig activityConfig = ActivityManger.ActivityDataDictionary[data.Id];
                list.Add(activityConfig);
            }

            //重新保存文件
            RWManager.Save <mw.ActivityConfig>("ActivityConfig.protodata.bytes", list);
            //刷新页面
            this.nextListBox.Items.Clear();
            List <mw.ActivityConfig> newlist = new List <mw.ActivityConfig>();

            newlist = RWManager.Load <mw.ActivityConfig>("ActivityConfig.protodata.bytes");
            if (newlist == null)
            {
                return;
            }
            for (int i = 0; i < newlist.Count; i++)
            {
                this.nextListBox.Items.Add(new ListItem(ActivityManger.GetConfigText(newlist[i], -1), newlist[i].id.ToString()));
            }

            this.ErrotLable.Text = "修改活动成功";
        }