protected void Page_Load(object sender, EventArgs e)
        {
            PersonFirstIndicator ent = null;

            CustomIndicatorId = RequestData.Get <string>("CustomIndicatorId");
            switch (RequestActionString)
            {
            case "delete":
                IList <string> ids = RequestData.GetList <string>("ids");
                foreach (string str in ids)
                {
                    ent = PersonFirstIndicator.Find(str);
                    IList <PersonSecondIndicator> psiEnts = PersonSecondIndicator.FindAllByProperty(PersonSecondIndicator.Prop_PersonFirstIndicatorId, str);
                    foreach (PersonSecondIndicator psiEnt in psiEnts)
                    {
                        psiEnt.DoDelete();
                    }
                    ent.DoDelete();
                }
                break;

            case "AutoUpdate":
                IList <string> entStrList = RequestData.GetList <string>("data");
                if (entStrList.Count > 0)
                {
                    ents = entStrList.Select(tent => JsonHelper.GetObject <PersonFirstIndicator>(tent) as PersonFirstIndicator).ToList();
                }
                if (ents.Count > 0)
                {
                    ents[0].DoUpdate();
                }
                break;

            case "create":
                PersonFirstIndicator pfiEnt = new PersonFirstIndicator();
                CustomIndicator      ciEnt  = CustomIndicator.Find(CustomIndicatorId);
                string sql = @"select max(SortIndex) from BJKY_Examine..PersonFirstIndicator where CustomIndicatorId='" + CustomIndicatorId + "'";
                pfiEnt.SortIndex         = DataHelper.QueryValue <int>(sql) + 1;
                pfiEnt.CustomIndicatorId = ciEnt.Id;
                pfiEnt.TotalWeight       = ciEnt.Weight;
                pfiEnt.DoCreate();
                PageState.Add("Entity", pfiEnt);
                break;

            default:
                DoSelect();
                break;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            IList <string> entStrList = RequestData.GetList <string>("data");

            id = RequestData.Get <string>("id");
            if (!string.IsNullOrEmpty(id))
            {
                ciEnt = CustomIndicator.Find(id);
            }
            switch (RequestActionString)
            {
            case "create":
                ciEnt                     = new CustomIndicator();
                ciEnt.IndicatorNo         = DataHelper.QueryValue <string>("select BJKY_Examine.dbo.fun_getIndicatorNo()");
                ciEnt.DeptId              = RequestData.Get <string>("DeptId");
                ciEnt.DeptName            = RequestData.Get <string>("DeptName");
                ciEnt.IndicatorSecondId   = RequestData.Get <string>("IndicatorSecondId");
                ciEnt.IndicatorSecondName = RequestData.Get <string>("IndicatorSecondName");
                ciEnt.DeptIndicatorName   = RequestData.Get <string>("DeptIndicatorName");
                ciEnt.Weight              = RequestData.Get <int>("Weight");
                PersonConfig pcEnt = PersonConfig.Find(ciEnt.DeptId);
                if (pcEnt != null)
                {
                    ciEnt.Remark = pcEnt.GroupID;    //备注字段用来存储足够机构的ID  方便选人
                }
                ciEnt.State = "0";
                ciEnt.DoCreate();
                if (!string.IsNullOrEmpty(RequestData.Get <string>("originalId")))   //如果改字段不为空  说明是复制操作
                {
                    IList <PersonFirstIndicator> pfiEnts = PersonFirstIndicator.FindAllByProperty(PersonFirstIndicator.Prop_CustomIndicatorId, RequestData.Get <string>("originalId"));
                    foreach (PersonFirstIndicator pfiEnt in pfiEnts)
                    {
                        PersonFirstIndicator nEnt1 = new PersonFirstIndicator();
                        nEnt1.CustomIndicatorId        = ciEnt.Id;
                        nEnt1.PersonFirstIndicatorName = pfiEnt.PersonFirstIndicatorName;
                        nEnt1.TotalWeight   = pfiEnt.TotalWeight;
                        nEnt1.Weight        = pfiEnt.Weight;
                        nEnt1.SortIndex     = pfiEnt.SortIndex;
                        nEnt1.IndicatorType = pfiEnt.IndicatorType;
                        nEnt1.CreateId      = UserInfo.UserID;
                        nEnt1.CreateName    = UserInfo.Name;
                        nEnt1.CreateTime    = DateTime.Now;
                        nEnt1.DoCreate();
                        IList <PersonSecondIndicator> psiEnts = PersonSecondIndicator.FindAllByProperty(PersonSecondIndicator.Prop_PersonFirstIndicatorId, pfiEnt.Id);
                        foreach (PersonSecondIndicator psiEnt in psiEnts)
                        {
                            PersonSecondIndicator NEnt2 = new PersonSecondIndicator();
                            NEnt2.PersonFirstIndicatorId    = nEnt1.Id;
                            NEnt2.PersonFirstIndicatorName  = nEnt1.PersonFirstIndicatorName;
                            NEnt2.PersonSecondIndicatorName = psiEnt.PersonSecondIndicatorName;
                            NEnt2.Weight     = psiEnt.Weight;
                            NEnt2.SortIndex  = psiEnt.SortIndex;
                            NEnt2.ToolTip    = psiEnt.ToolTip;
                            NEnt2.SelfRemark = psiEnt.SelfRemark;
                            NEnt2.CreateId   = UserInfo.UserID;
                            NEnt2.CreateName = UserInfo.Name;
                            NEnt2.CreateTime = DateTime.Now;
                            NEnt2.DoCreate();
                        }
                    }
                }
                PageState.Add("Entity", ciEnt);
                break;

            case "AutoUpdate":
                string ApproveUserId   = RequestData.Get <string>("ApproveUserId");
                string ApproveUserName = RequestData.Get <string>("ApproveUserName");
                if (!string.IsNullOrEmpty(ApproveUserId))
                {
                    ciEnt.ApproveUserId   = ApproveUserId;
                    ciEnt.ApproveUserName = ApproveUserName;
                }
                ciEnt.DoUpdate();
                break;

            case "submit":
                sql = @"select isnull(sum(A.Weight),0) from BJKY_Examine..PersonSecondIndicator as A 
                    left join BJKY_Examine..PersonFirstIndicator as B on A.PersonFirstIndicatorId=B.Id where B.CustomIndicatorId='" + id + "'";
                int useWeight = DataHelper.QueryValue <int>(sql);
                if (ciEnt.Weight == useWeight)
                {
                    ciEnt.State  = "1";
                    ciEnt.Result = "审批中";
                    ciEnt.DoUpdate();
                    PageState.Add("Result", "T");
                }
                else
                {
                    PageState.Add("Result", "F");
                }
                break;

            case "delete":
                DoBatchDelete();
                break;

            case "UpLoadSummary":
                ciEnt.Summary = RequestData.Get <string>("Summary");
                ciEnt.DoUpdate();
                PageState.Add("Result", ciEnt.Summary);
                break;

            default:
                DoSelect();
                break;
            }
        }