Ejemplo n.º 1
0
        private void BindDGOrganizations(string keyword)
        {
            FilterElement           fe  = CHelper.GetSearchFilterElementByKeyword(keyword, OrganizationEntity.GetAssignedMetaClassName());
            FilterElementCollection fec = new FilterElementCollection();

            fec.Add(fe);

            dgOrganizations.DataSource = BusinessManager.List(OrganizationEntity.GetAssignedMetaClassName(), fec.ToArray());
            dgOrganizations.DataBind();

            int RowCount = dgOrganizations.Items.Count;

            if (RowCount == 0)
            {
                Sep11.Visible = false;
                Pan11.Visible = false;
            }
            else
            {
                Sep11.Title = String.Format("{0} ({1})", LocRM.GetString("Organizations"), RowCount);
            }
        }
Ejemplo n.º 2
0
        private EntityObject[] GetEntityObjectListForExport()
        {
            string variant = "0";

            if (Request["variant"] != null)
            {
                variant = Request["variant"];
            }

            SortingElementCollection sec = new SortingElementCollection();

            if (_pc[grdMain.GetPropertyKey(EntityGrid.SortingPropertyKey)] != null)
            {
                string             sort = _pc[grdMain.GetPropertyKey(EntityGrid.SortingPropertyKey)];
                SortingElementType set  = SortingElementType.Asc;
                if (sort.IndexOf(" DESC") >= 0)
                {
                    sort = sort.Substring(0, sort.IndexOf(" DESC"));
                    set  = SortingElementType.Desc;
                }

                sec.Add(new SortingElement(sort, set));
            }

            int pageSize = 10;

            if (_pc[grdMain.GetPropertyKey(EntityGrid.PageSizePropertyKey)] != null)
            {
                pageSize = Convert.ToInt32(_pc[grdMain.GetPropertyKey(EntityGrid.PageSizePropertyKey)].ToString());
                if (pageSize == -1)
                {
                    pageSize = 10000;
                }
            }
            int pageIndex = 0;

            if (_pc["EntityList_" + ClassName + "_" + _profileName + "_PageIndex"] != null)
            {
                pageIndex = int.Parse(_pc["EntityList_" + ClassName + "_" + _profileName + "_PageIndex"]);
            }

            ListViewProfile lvp = null;

            switch (variant)
            {
            case "1":                           //OnlyView
                lvp = ListViewProfile.Load(ClassName, _profileName, _placeName);
                if (sec.Count == 0)
                {
                    sec = lvp.Sorting;
                }
                return(BusinessManager.List(ClassName, lvp.Filters.ToArray(), sec.ToArray()));

            case "2":                           //Only Visible
                lvp = ListViewProfile.Load(ClassName, _profileName, _placeName);

                FilterElementCollection fec = new FilterElementCollection(lvp.Filters.ToArray());

                if (!String.IsNullOrEmpty(txtSearch.Text))
                {
                    FilterElement fe = CHelper.GetSearchFilterElementByKeyword(txtSearch.Text, ClassName);
                    fec.Add(fe);
                }

                EntityObject[]      list    = BusinessManager.List(ClassName, fec.ToArray(), sec.ToArray());
                List <EntityObject> newList = new List <EntityObject>();
                int start  = pageIndex * pageSize;
                int finish = start + pageSize;
                for (int i = start; i <= finish && i < list.Length; i++)
                {
                    newList.Add(list[i]);
                }
                return(newList.ToArray());

            case "3":                           //Only Selected
                string              values           = Request["ids"];
                string[]            selectedElements = values.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                List <PrimaryKeyId> listPkey         = new List <PrimaryKeyId>();
                foreach (string elem in selectedElements)
                {
                    string       id  = elem.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[0];
                    PrimaryKeyId key = PrimaryKeyId.Parse(id);
                    if (key != PrimaryKeyId.Empty)
                    {
                        listPkey.Add(key);
                    }
                }
                FilterElementCollection fecPkey = new FilterElementCollection();
                foreach (PrimaryKeyId id in listPkey)
                {
                    FilterElement fe = FilterElement.EqualElement(FilterElement.PrimaryKeyFieldName, id);
                    fecPkey.Add(fe);
                }
                FilterElement orFilter = new OrBlockFilterElement(fecPkey.ToArray());
                fecPkey.Clear();
                fecPkey.Add(orFilter);

                return(BusinessManager.List(ClassName, fecPkey.ToArray(), sec.ToArray()));

            default:                            //All
                return(BusinessManager.List(ClassName, (new FilterElementCollection()).ToArray(), sec.ToArray()));
            }
        }