コード例 #1
0
        /// <summary>
        /// 页面加载与控件事件绑定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            //btnSetAction.Click += BtnSetActions_Click;//设计计划的操作
            btnSubmit.Click    += BtnSubmit_Click;//提交计划保存
            btnCancel.Click    += BtnCancel_Click;
            btnAddSingle.Click += BtnAddSingle_Click;
            btnAddMulti.Click  += BtnAddMulti_Click;
            ddlPlanAction.SelectedIndexChanged += DdlPlanAction_SelectedIndexChanged;
            //btnSaveToPlan.Click += BtnSaveToPlan_Click;
            btnSaveToList.Click    += BtnSaveToList_Click;
            btnCancelToList.Click  += BtnCancelToList_Click;
            gvPlans.RowDataBound   += GvPlans_RowDataBound;
            gvActions.RowDataBound += GvActions_RowDataBound;
            gvPlans.RowCommand     += GvPlans_RowCommand;
            if (!IsPostBack)
            {
                int userId = VSDLL.Common.Users.UserID;
                if (userId == 0)
                {
                    divList.Visible   = false;
                    divPlan.Visible   = false;
                    divAction.Visible = false;
                    lbPTitle.Visible  = false;
                    lbErr.Text        = "你尚未登录,无法管理个人计划!";
                }
                else
                {
                    lbPTitle.Visible = true;
                    lbErr.Text       = "";
                    try
                    {
                        //获取计划列表
                        DataSet   dsPlans = TaskDAL.GetDailyTask(userId);
                        DataTable dtPlans = dsPlans.Tables[0];
                        ViewState["dtPlans"] = dtPlans;
                        //获取操作列表
                        DataSet   dsActions = ActionDAL.GetAllActions(0);
                        DataTable dtActions = dsActions.Tables[0];
                        ViewState["dtActions"] = dtActions;
                        //获取操作关系列表
                        DataSet   dsRelations = ActionDAL.GetActionRelation();
                        DataTable dtRelations = dsRelations.Tables[0];
                        ViewState["dtRelations"] = dtRelations;

                        //绑定计划列表
                        BindgvPlans(dtPlans);
                    }
                    catch (Exception ex)
                    {
                        lbErr.Text = ex.ToString();
                    }
                }
            }
        }