Beispiel #1
0
        public RoomPickerTree()
        {
            InitializeComponent();

            colCode.ImageGetter = delegate(object x)
            {
                if (_ShowImage)
                {
                    if (x is RoomPicker_Entity)
                    {
                        return("entity");
                    }
                    else
                    if (x is RoomPicker_Building)
                    {
                        return("building");
                    }
                    else
                    if (x is RoomPicker_Room)
                    {
                        return("room2");
                    }
                }

                return(null);
            };

            treeList.CanExpandGetter = delegate(object x)
            {
                if (x is Entities.RoomPicker_Entity)
                {
                    if (_PickerType == GlobalVariables.PickerType.Building || _PickerType == GlobalVariables.PickerType.Room)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                if (x is Entities.RoomPicker_Building)
                {
                    if (_PickerType == GlobalVariables.PickerType.Room)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }

                return(false);
            };

            treeList.ChildrenGetter = delegate(object x)
            {
                if (x is Entities.RoomPicker_Entity)
                {
                    Entities.RoomPicker_Entity  _ent  = (Entities.RoomPicker_Entity)x;
                    IList <RoomPicker_Building> _list = new List <RoomPicker_Building>();
                    if (_OnlyAvailable)
                    {
                        _list = RoomPicker_Building.Load("WHERE AVAILABLE='True' AND SITE='" + _SiteCode + "' AND FK_ENTITY=" + _ent.ID + " AND FK_MODULE=" + _ModuleID);
                    }
                    else
                    {
                        _list = RoomPicker_Building.Load("WHERE SITE='" + _SiteCode + "' AND FK_ENTITY=" + _ent.ID + " AND FK_MODULE=" + _ModuleID);
                    }

                    return(_list.OrderBy(y => y.CODE).ToList());
                }
                else
                {
                    Entities.RoomPicker_Building _bld  = (Entities.RoomPicker_Building)x;
                    IList <RoomPicker_Room>      _list = new List <RoomPicker_Room>();
                    if (_OnlyAvailable)
                    {
                        _list = RoomPicker_Room.Load("WHERE AVAILABLE='True' AND SITE='" + _SiteCode + "' AND FK_BUILDING=" + _bld.ID + " AND FK_MODULE=" + _ModuleID);
                    }
                    else
                    {
                        _list = RoomPicker_Room.Load("WHERE SITE='" + _SiteCode + "' AND FK_BUILDING=" + _bld.ID + " AND FK_MODULE=" + _ModuleID);
                    }

                    return(_list.OrderBy(y => y.CODE).ToList());
                }
            };
        }