protected void bt_AddDetail_Click(object sender, EventArgs e)
    {
        IList <CAT_FeeApplyDetail> _details = (IList <CAT_FeeApplyDetail>)ViewState["FeeListDetails"];
        CAT_FeeApplyDetail         _m       = new CAT_FeeApplyDetail();
        int client = 0;

        int.TryParse(select_Client.SelectValue, out client);
        _m.Client       = client;
        _m.AccountTitle = int.Parse(ddl_AccountTitle.SelectedValue);
        if (TreeTableBLL.GetChild("MCS_PUB.dbo.AC_AccountTitle", "ID", "SuperID", _m.AccountTitle).Rows.Count > 0)
        {
            MessageBox.Show(this, "费用科目必须选择最底级会计科目!" + ddl_AccountTitle.SelectedItem.Text);
            return;
        }
        _m.ApplyCost = decimal.Parse(tbx_ApplyCost.Text.Trim());
        _m.DICost    = decimal.Parse(tbx_DICost.Text.Trim());
        _m.Remark    = tbx_Remark.Text.Trim();
        if ((int)ViewState["ID"] != 0)
        {
            _m.BeginMonth = AC_AccountMonthBLL.GetMonthByDate(new CAT_ActivityBLL((int)ViewState["ID"]).Model.PlanBeginDate);
            _m.Activity   = (int)ViewState["ID"];
        }
        else
        {
            _m.BeginMonth = AC_AccountMonthBLL.GetCurrentMonth();
        }
        if (_details.Where(p => p.Client == client && p.AccountTitle == _m.AccountTitle).Count() == 0)
        {
            if (_m.Activity > 0)
            {
                CAT_FeeApplyDetailBLL _bll = new CAT_FeeApplyDetailBLL();
                _bll.Model = _m;
                _bll.Add();
            }
            _details.Add(_m);
            BindGrid();
        }
    }
 protected void bt_AddDetail_Click(object sender, EventArgs e)
 {
     IList<CAT_FeeApplyDetail> _details = (IList<CAT_FeeApplyDetail>)ViewState["FeeListDetails"];
     CAT_FeeApplyDetail _m = new CAT_FeeApplyDetail();
     int client = 0;
     int.TryParse(select_Client.SelectValue, out client);
     _m.Client = client;
     _m.AccountTitle = int.Parse(ddl_AccountTitle.SelectedValue);
     if (TreeTableBLL.GetChild("MCS_PUB.dbo.AC_AccountTitle", "ID", "SuperID", _m.AccountTitle).Rows.Count > 0)
     {
         MessageBox.Show(this, "费用科目必须选择最底级会计科目!" + ddl_AccountTitle.SelectedItem.Text);
         return;
     }
     _m.ApplyCost = decimal.Parse(tbx_ApplyCost.Text.Trim());
     _m.DICost = decimal.Parse(tbx_DICost.Text.Trim());
     _m.Remark = tbx_Remark.Text.Trim();
     if ((int)ViewState["ID"] != 0)
     {
         _m.BeginMonth = AC_AccountMonthBLL.GetMonthByDate(new CAT_ActivityBLL((int)ViewState["ID"]).Model.PlanBeginDate);
         _m.Activity = (int)ViewState["ID"];
     }
     else
     {
         _m.BeginMonth = AC_AccountMonthBLL.GetCurrentMonth();
     }
     if (_details.Where(p => p.Client == client && p.AccountTitle == _m.AccountTitle).Count() == 0)
     {
         if (_m.Activity > 0)
         {
             CAT_FeeApplyDetailBLL _bll = new CAT_FeeApplyDetailBLL();
             _bll.Model = _m;
             _bll.Add();
         }
         _details.Add(_m);
         BindGrid();
     }
 }
    protected void bt_OK_Click(object sender, EventArgs e)
    {
        CAT_ActivityBLL _bll;
        if ((int)ViewState["ID"] != 0)
        {
            //修改
            _bll = new CAT_ActivityBLL((int)ViewState["ID"]);

        }
        else
        {
            //新增
            _bll = new CAT_ActivityBLL();
        }

        pl_detail.GetData(_bll.Model);

        #region 判断必填项
        if (_bll.Model.OrganizeCity == 0)
        {
            MessageBox.Show(this, "请选择活动举办的管理片区!");
            return;
        }

        if (_bll.Model.Officialcity == 0)
        {
            MessageBox.Show(this, "请选择活动所属城市!");
            return;
        }

        if (_bll.Model.Topic == "")
        {
            MessageBox.Show(this, "活动主题不能为空!");
            return;
        }
        if (_bll.Model.Address == "")
        {
            MessageBox.Show(this, "举办地址不能为空!");
            return;
        }

        if (_bll.Model.Classify == 0)
        {
            MessageBox.Show(this, "请选择活动的分类!");
            return;
        }
        #endregion

        if ((int)ViewState["ID"] != 0)
        {
            //修改
            _bll.Model.UpdateStaff = (int)Session["UserID"];
            if (_bll.Update() == 0 && sender != null) MessageBox.ShowAndRedirect(this, "修改成功!", "CAT_ActivityList.aspx");
        }
        else
        {
            //新增

            _bll.Model.InsertStaff = (int)Session["UserID"];
            _bll.Model.ApproveFlag = 2;
            ViewState["ID"] = _bll.Add();
            if ((int)ViewState["ID"] > 0)
            {
                IList<CAT_FeeApplyDetail> _details = (IList<CAT_FeeApplyDetail>)ViewState["FeeListDetails"];
                IList<CAT_GiftApplyDetail> _giftdetail = (IList<CAT_GiftApplyDetail>)ViewState["GiftListDetails"];
                CAT_FeeApplyDetailBLL _feebll = new CAT_FeeApplyDetailBLL();
                CAT_GiftApplyDetailBLL _giftbll = new CAT_GiftApplyDetailBLL();
                foreach (CAT_GiftApplyDetail _m in _giftdetail)
                {
                    _m.Activity = (int)ViewState["ID"];
                    _giftbll.Model = _m;
                    _giftbll.Add();
                }
                foreach (CAT_FeeApplyDetail _m in _details)
                {
                    _m.Activity = (int)ViewState["ID"];
                    _feebll.Model = _m;
                    _feebll.Add();
                }
                MessageBox.ShowAndRedirect(this, "新增成功!", "CAT_ActivityDetail.aspx?ID=" + ViewState["ID"].ToString());
            }

        }
    }
    protected void bt_OK_Click(object sender, EventArgs e)
    {
        CAT_ActivityBLL _bll;

        if ((int)ViewState["ID"] != 0)
        {
            //修改
            _bll = new CAT_ActivityBLL((int)ViewState["ID"]);
        }
        else
        {
            //新增
            _bll = new CAT_ActivityBLL();
        }


        pl_detail.GetData(_bll.Model);


        #region 判断必填项
        if (_bll.Model.OrganizeCity == 0)
        {
            MessageBox.Show(this, "请选择活动举办的管理片区!");
            return;
        }

        if (_bll.Model.Officialcity == 0)
        {
            MessageBox.Show(this, "请选择活动所属城市!");
            return;
        }

        if (_bll.Model.Topic == "")
        {
            MessageBox.Show(this, "活动主题不能为空!");
            return;
        }
        if (_bll.Model.Address == "")
        {
            MessageBox.Show(this, "举办地址不能为空!");
            return;
        }

        if (_bll.Model.Classify == 0)
        {
            MessageBox.Show(this, "请选择活动的分类!");
            return;
        }
        #endregion

        if ((int)ViewState["ID"] != 0)
        {
            //修改
            _bll.Model.UpdateStaff = (int)Session["UserID"];
            if (_bll.Update() == 0 && sender != null)
            {
                MessageBox.ShowAndRedirect(this, "修改成功!", "CAT_ActivityList.aspx");
            }
        }
        else
        {
            //新增

            _bll.Model.InsertStaff = (int)Session["UserID"];
            _bll.Model.ApproveFlag = 2;
            ViewState["ID"]        = _bll.Add();
            if ((int)ViewState["ID"] > 0)
            {
                IList <CAT_FeeApplyDetail>  _details    = (IList <CAT_FeeApplyDetail>)ViewState["FeeListDetails"];
                IList <CAT_GiftApplyDetail> _giftdetail = (IList <CAT_GiftApplyDetail>)ViewState["GiftListDetails"];
                CAT_FeeApplyDetailBLL       _feebll     = new CAT_FeeApplyDetailBLL();
                CAT_GiftApplyDetailBLL      _giftbll    = new CAT_GiftApplyDetailBLL();
                foreach (CAT_GiftApplyDetail _m in _giftdetail)
                {
                    _m.Activity    = (int)ViewState["ID"];
                    _giftbll.Model = _m;
                    _giftbll.Add();
                }
                foreach (CAT_FeeApplyDetail _m in _details)
                {
                    _m.Activity   = (int)ViewState["ID"];
                    _feebll.Model = _m;
                    _feebll.Add();
                }
                MessageBox.ShowAndRedirect(this, "新增成功!", "CAT_ActivityDetail.aspx?ID=" + ViewState["ID"].ToString());
            }
        }
    }