protected void btnSave_Click(object sender, EventArgs e)
        {
            T_Train_Plan_BLL tpBll = new T_Train_Plan_BLL();
            T_Train_Plan_MDL tpMdl = new T_Train_Plan_MDL();

            if (ViewState["model"] != null)
            {
                tpMdl = ViewState["model"] as T_Train_Plan_MDL;
            }

            object obj = Comm.GetValueToObject(tpMdl, tb_TranPlan);//将窗体控件值赋给Model对象

            if (obj != null)
            {
                T_Train_Plan_MDL new_tpMdl = obj as T_Train_Plan_MDL;
                switch ((CommonEnum.PageState)ViewState["PageState"])
                {
                case CommonEnum.PageState.ADD:
                    int TrainPlanID = tpBll.Add(new_tpMdl);
                    SetTrainRec(Action, TrainPlanID, ctrArchiveUserList.GetSelectList());
                    break;

                case CommonEnum.PageState.EDIT:
                    tpBll.Update(new_tpMdl);
                    SetTrainRec(Action, new_tpMdl.TrainPlanID, ctrArchiveUserList.GetSelectList());
                    break;
                }
            }
            Response.Redirect("TrainPlanList.aspx?sqlwhere=" + SqlWhere + "&PageIndex=" + pPageIndex + "");
        }
Пример #2
0
        //查询
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            T_Train_Plan_MDL tpMdl = new T_Train_Plan_MDL();

            Search(tblSearch, tpMdl);
            BindGridView();
        }
        private void BindPage(string ID)
        {
            if (!String.IsNullOrEmpty(ID))
            {
                T_Train_Plan_BLL tpBll = new T_Train_Plan_BLL();
                T_Train_Plan_MDL tpMdl = tpBll.GetModel(Common.ConvertEx.ToInt(ID));//根据传入ID获得Model对象

                ViewState["model"] = tpMdl;
                if (tpMdl != null)
                {
                    Comm.SetValueToPage(tpMdl, tb_TranPlan);//将Model值赋给控件

                    List <T_Train_Rec_MDL> ltTrMdl = new T_Train_Rec_BLL().GetModelList("TrainPlanID=" + ID);
                    if (ltTrMdl.Count > 0)
                    {
                        List <string> ltKey = new List <string>();
                        foreach (T_Train_Rec_MDL trMdl in ltTrMdl)
                        {
                            ltKey.Add(trMdl.UserID.ToString());
                        }

                        ctrArchiveUserList.SetItemSelected(ltKey);
                    }
                }
            }
        }