Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string id = RequestData.Get <string>("id");

            switch (RequestActionString)
            {
            case "delete":
                string leaderids = RequestData.Get <string>("leaderids");
                sql = "delete from BJKY_IntegratedManage..InstituteLeader where '" + leaderids + "' like '%'+Id+'%'";
                DataHelper.ExecSql(sql);
                break;

            case "downlevel":
                ilEnt1 = InstituteLeader.Find(id);    //待降级的
                sql    = @"select top 1 Id from BJKY_IntegratedManage..InstituteLeader where SortIndex=
                         (select min(SortIndex) from (select * from  BJKY_IntegratedManage..InstituteLeader  where SortIndex > {0}) t )";
                sql    = string.Format(sql, ilEnt1.SortIndex);
                dics   = DataHelper.QueryDictList(sql);
                if (dics.Count > 0)    //如果有比他靠后的领导
                {
                    ilEnt2 = InstituteLeader.Find(dics[0].Get <string>("Id"));
                    int?temp = ilEnt2.SortIndex;
                    ilEnt2.SortIndex = ilEnt1.SortIndex;
                    ilEnt2.DoUpdate();
                    ilEnt1.SortIndex = temp;
                    ilEnt1.DoUpdate();
                }
                break;

            case "uplevel":
                ilEnt1 = InstituteLeader.Find(id);    //待升级的
                sql    = @"select top 1 Id from BJKY_IntegratedManage..InstituteLeader where SortIndex=
                         (select max(SortIndex) from (select * from  BJKY_IntegratedManage..InstituteLeader  where SortIndex <{0}) t )";
                sql    = string.Format(sql, ilEnt1.SortIndex);
                dics   = DataHelper.QueryDictList(sql);
                if (dics.Count > 0)    //如果有比他靠后的领导
                {
                    ilEnt2 = InstituteLeader.Find(dics[0].Get <string>("Id"));
                    int?temp = ilEnt2.SortIndex;
                    ilEnt2.SortIndex = ilEnt1.SortIndex;
                    ilEnt2.DoUpdate();
                    ilEnt1.SortIndex = temp;
                    ilEnt1.DoUpdate();
                }
                break;

            case "AddLeader":
                string   userIds = RequestData.Get <string>("userIds");
                string[] idarray = userIds.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                IList <InstituteLeader> ilEnts = new List <InstituteLeader>();
                sql = "select max(SortIndex) from BJKY_IntegratedManage..InstituteLeader";
                int maxval = DataHelper.QueryValue <int>(sql);
                foreach (string userid in idarray)
                {
                    InstituteLeader ilEnt = new InstituteLeader();
                    ilEnt.UserId   = userid;
                    ilEnt.UserName = SysUser.Find(userid).Name;
                    maxval++;
                    ilEnt.SortIndex = maxval;
                    sql             = @"select top 1 case [Type] when 3 then ParentDeptName when 2 then ChildDeptName end as DeptName,
                        case [Type] when 3 then ParentId when 2 then DeptId end as DeptId
                        from View_SysUserGroup where UserId='{0}'";
                    sql             = string.Format(sql, userid);
                    IList <EasyDictionary> deptDics = DataHelper.QueryDictList(sql);
                    if (deptDics.Count > 0)
                    {
                        ilEnt.DeptId   = deptDics[0].Get <string>("DeptId");
                        ilEnt.DeptName = deptDics[0].Get <string>("DeptName");
                    }
                    ilEnt.DoCreate();
                    ilEnts.Add(ilEnt);
                }
                PageState.Add("ilEnts", ilEnts);
                break;

            default:
                DoSelect();
                break;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            id = RequestData.Get <string>("id");
            switch (RequestActionString)
            {
            case "update":
                ent = GetMergedData <IntegratedConfig>();
                ent.DoUpdate();
                break;

            case "create":
                ent = GetPostedData <IntegratedConfig>();
                ent.DoCreate();
                break;

            case "AddLeader":
                IList <string>          userIds = RequestData.GetList <string>("UserIds");
                IList <InstituteLeader> ilEnts  = new List <InstituteLeader>();
                foreach (string userId in userIds)
                {
                    ilEnt          = new InstituteLeader();
                    ilEnt.UserId   = userId;
                    ilEnt.UserName = SysUser.Find(userId).Name;
                    string sql = @"select top 1 case [Type] when 3 then ParentDeptName when 2 then ChildDeptName end as DeptName,
                        case [Type] when 3 then ParentId when 2 then DeptId end as DeptId
                        from View_SysUserGroup where UserId='{0}'";
                    sql = string.Format(sql, userId);
                    IList <EasyDictionary> deptDics = DataHelper.QueryDictList(sql);
                    if (deptDics.Count > 0)
                    {
                        ilEnt.DeptId   = deptDics[0].Get <string>("DeptId");
                        ilEnt.DeptName = deptDics[0].Get <string>("DeptName");
                    }
                    ilEnt.DoCreate();
                    ilEnts.Add(ilEnt);
                }
                PageState.Add("ilEnts", ilEnts);
                break;

            case "UpdateSortIndex":
                ilEnt           = InstituteLeader.Find(RequestData.Get <string>("InstituteLeaderId"));
                ilEnt.SortIndex = RequestData.Get <int>("SortIndex");
                ilEnt.DoUpdate();
                break;

            case "UpdateUser":
                suEnt       = SysUser.Find(RequestData.Get <string>("UserId"));
                suEnt.Email = RequestData.Get <string>("Email");
                suEnt.Phone = RequestData.Get <string>("Phone");
                suEnt.DoUpdate();
                break;

            case "delete":
                IList <string> instituteLeaderIds = RequestData.GetList <string>("InstituteLeaderIds");
                foreach (string instituteLeaderId in instituteLeaderIds)
                {
                    ilEnt = InstituteLeader.Find(instituteLeaderId);
                    ilEnt.DoDelete();
                }
                break;

            default:
                DoSelect();
                break;
            }
        }