Ejemplo n.º 1
0
        public List <JSTreeViewModel> GetUserManPower(int?type, int?divid, int?depid, int?secid, int?poid)
        {
            var items = new List <JSTreeViewModel>();

            using (SATEntities db = new SATEntities())
            {
                var user = db.vw_Man_Power.Where(m => m.TypeID == type && m.DivID == divid && m.DepID == depid && m.SecID == secid && m.PoID == poid &&
                                                 !string.IsNullOrEmpty(m.DivName) && !string.IsNullOrEmpty(m.DepName) && !string.IsNullOrEmpty(m.SecName) && !string.IsNullOrEmpty(m.FullNameTh))
                           .GroupBy(item => item.UserID, (key, group) => new
                {
                    UserID      = key,
                    TiShortName = group.FirstOrDefault().TiShortName,
                    FullNameTh  = group.FirstOrDefault().FullNameTh,
                    MpID        = group.FirstOrDefault().MpID,
                    DivID       = group.FirstOrDefault().DivID,
                    DepID       = group.FirstOrDefault().DepID,
                    SecID       = group.FirstOrDefault().SecID,
                    PoID        = group.FirstOrDefault().PoID,
                }).OrderBy(o => o.MpID).ToList();

                foreach (var item in user)
                {
                    var model = new JSTreeViewModel()
                    {
                        id        = item.MpID.ToString(),
                        icon      = SysConfig.ApplicationRoot + "Content/assets/img/user2.png",
                        node_type = "user",
                        text      = "(" + (type.ToString() == "1" ? item.MpID.ToString().PadLeft(3, '0') : item.MpID.ToString().PadLeft(4, '0')) + ") " + item.TiShortName + item.FullNameTh,
                    };
                    items.Add(model);
                }
            }
            return(items);
        }
Ejemplo n.º 2
0
        public List <JSTreeViewModel> GetPositionBySec(int usertype, int?divid, int?depid, int?secid)
        {
            var items = new List <JSTreeViewModel>();

            using (SATEntities db = new SATEntities())
            {
                var position = GetPositionManPower(usertype, divid, depid, secid);

                foreach (var item in position)
                {
                    var countChild = db.vw_Man_Power.Where(m => m.TypeID == usertype && m.DivID == divid && m.DepID == depid && m.SecID == secid && m.PoID == item.PoID &&
                                                           !string.IsNullOrEmpty(m.DivName) && !string.IsNullOrEmpty(m.DepName) && !string.IsNullOrEmpty(m.SecName) && !string.IsNullOrEmpty(m.FullNameTh))
                                     .GroupBy(g => g.UserID).Select(group => new { UserID = group.Key }).Count();

                    var model = new JSTreeViewModel()
                    {
                        id    = "Pos" + item.PoID.ToString(),
                        text  = item.PoName + " (" + countChild + ")",
                        state = new JSTreeState()
                        {
                            opened = false
                        },
                        icon      = SysConfig.ApplicationRoot + "Content/assets/img/flag_white.gif",
                        node_type = "pos",
                        children  = GetUserManPower(usertype, item.DivID, item.DepID, item.SecID, item.PoID),
                    };
                    items.Add(model);
                }
            }

            return(items);
        }
Ejemplo n.º 3
0
        public List <JSTreeViewModel> GetDepartmentByDiv(int usertype, int divid)
        {
            var items = new List <JSTreeViewModel>();

            using (SATEntities db = new SATEntities())
            {
                var department = GetDepartmentManPower(usertype, divid);

                foreach (var item in department)
                {
                    var countChild = db.vw_Man_Power.Where(m => m.TypeID == usertype && m.DepID == item.DepID && m.DivID == divid && !string.IsNullOrEmpty(m.SecName))
                                     .GroupBy(g => g.SecID).Select(group => new { SecID = group.Key }).Count();

                    var model = new JSTreeViewModel()
                    {
                        id    = "Dep" + item.DepID.ToString(),
                        text  = item.DepName + " (" + countChild + ")",
                        state = new JSTreeState()
                        {
                            opened = true
                        },
                        icon      = SysConfig.ApplicationRoot + "Content/assets/img/department.gif",
                        node_type = "dep",
                        children  = GetSectionByDep(usertype, item.DivID, item.DepID),
                    };
                    items.Add(model);
                }
            }

            return(items);
        }
Ejemplo n.º 4
0
        public static JSTreeViewModel MapToJSTreeViewModel(Category category)
        {
            string parentCategoryId = String.IsNullOrEmpty(category.ParentId.ToString()) ? "#" : category.ParentId.ToString();

            JSTreeViewModel model = new JSTreeViewModel
            {
                id     = category.ID.ToString(),
                text   = category.Name,
                parent = parentCategoryId,
                type   = category.Type
            };

            return(model);
        }
Ejemplo n.º 5
0
        public JSTreeViewModel GetTreeAll(int usertype)
        {
            var model = new JSTreeViewModel()
            {
                id    = "0",
                text  = "การกีฬาแห่งประเทศไทย",
                state = new JSTreeState()
                {
                    opened = true
                },
                icon     = SysConfig.ApplicationRoot + "Content/assets/img/home.png",
                children = GetDivision(usertype)
            };

            return(model);
        }
Ejemplo n.º 6
0
        private JSTreeViewModel ToJsTreeVM(Organization org, bool IsChildren)
        {
            JSTreeViewModel vm = new JSTreeViewModel();

            vm.id       = org.OrgCode.ToString();
            vm.children = IsChildren;
            vm.text     = org.OrgName;
            if (org.ParentCode == Guid.Empty)
            {
                vm.parent = "#";
            }
            else
            {
                vm.parent = org.ParentCode.ToString();
            }
            vm.state = JSTreeState.Create(false);
            return(vm);
        }