示例#1
0
        public IQueryable <ComboBoxResult> GetCostCenters(string term, string DocTypes, string Process)
        {
            string[] ContraDocTypes = null;
            if (!string.IsNullOrEmpty(DocTypes))
            {
                ContraDocTypes = DocTypes.Split(",".ToCharArray());
            }
            else
            {
                ContraDocTypes = new string[] { "NA" };
            }

            string[] ContraProcess = null;
            if (!string.IsNullOrEmpty(Process))
            {
                ContraProcess = Process.Split(",".ToCharArray());
            }
            else
            {
                ContraProcess = new string[] { "NA" };
            }

            int SiteId     = (int)System.Web.HttpContext.Current.Session["SiteId"];
            int DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"];


            var temp = (from p in db.CostCenter
                        where (string.IsNullOrEmpty(DocTypes) ? 1 == 1 : ContraDocTypes.Contains(p.DocTypeId.ToString())) &&
                        (string.IsNullOrEmpty(term) ? 1 == 1 : p.CostCenterName.ToLower().Contains(term.ToLower())) &&
                        (string.IsNullOrEmpty(Process) ? 1 == 1 : ContraProcess.Contains(p.ProcessId.ToString())) &&
                        (string.IsNullOrEmpty(p.SiteId.ToString()) ? 1 == 1 : p.SiteId == SiteId) &&
                        (string.IsNullOrEmpty(p.DivisionId.ToString()) ? 1 == 1 : p.DivisionId == DivisionId) &&
                        p.IsActive == true
                        orderby p.CostCenterName
                        select new ComboBoxResult
            {
                text = p.CostCenterName + " | " + p.DocType.DocumentTypeShortName,
                id = p.CostCenterId.ToString(),
            });

            return(temp);
        }
示例#2
0
        public IQueryable <ComboBoxResult> GetLedgerAccounts(string term, string AccGroups, string ExcludeAccGroups, string Process)
        {
            string[] ContraAccGroups = null;
            if (!string.IsNullOrEmpty(AccGroups))
            {
                ContraAccGroups = AccGroups.Split(",".ToCharArray());
            }
            else
            {
                ContraAccGroups = new string[] { "NA" };
            }

            string[] ExcludeContraAccGroups = null;
            if (!string.IsNullOrEmpty(ExcludeAccGroups))
            {
                ExcludeContraAccGroups = ExcludeAccGroups.Split(",".ToCharArray());
            }
            else
            {
                ExcludeContraAccGroups = new string[] { "NA" };
            }

            string[] ContraProcess = null;
            if (!string.IsNullOrEmpty(Process))
            {
                ContraProcess = Process.Split(",".ToCharArray());
            }
            else
            {
                ContraProcess = new string[] { "NA" };
            }

            int CurrentSiteId     = (int)System.Web.HttpContext.Current.Session["SiteId"];
            int CurrentDivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"];

            string DivId  = "|" + CurrentDivisionId.ToString() + "|";
            string SiteId = "|" + CurrentSiteId.ToString() + "|";


            var temp = (from p in db.LedgerAccount
                        join t2 in db.BusinessEntity on p.PersonId equals t2.PersonID into table2 from tab2 in table2.DefaultIfEmpty()
                        join t in db.Persons on tab2.PersonID equals t.PersonID into table
                        from tab in table.DefaultIfEmpty()
                        join Pa in db.PersonAddress on tab.PersonID equals Pa.PersonId into PersonAddressTable from PersonAddressTab in PersonAddressTable.DefaultIfEmpty()
                        join t3 in db.PersonProcess on tab.PersonID equals t3.PersonId into table3 from perproc in table3.DefaultIfEmpty()
                        where (string.IsNullOrEmpty(AccGroups) ? 1 == 1 : ContraAccGroups.Contains(p.LedgerAccountGroupId.ToString())) &&
                        (string.IsNullOrEmpty(ExcludeAccGroups) ? 1 == 1 : !ExcludeContraAccGroups.Contains(p.LedgerAccountGroupId.ToString())) &&
                        p.IsActive == true &&
                        (string.IsNullOrEmpty(term) ? 1 == 1 : (p.LedgerAccountName.ToLower().Contains(term.ToLower())) ||
                         tab.Code.ToLower().Contains(term.ToLower()) ||
                         tab.Suffix.ToLower().Contains(term.ToLower())) &&
                        (tab2 == null || ((string.IsNullOrEmpty(Process) ? 1 == 1 : ContraProcess.Contains(perproc.ProcessId.ToString())) && tab2.DivisionIds.IndexOf(DivId) != -1 &&
                                          tab2.SiteIds.IndexOf(SiteId) != -1))
                        select new ComboBoxResult
            {
                id = p.LedgerAccountId.ToString(),
                text = p.LedgerAccountName + (tab2 == null ? "" : ", " + tab.Suffix + " [" + tab.Code + "]"),
                TextProp1 = p.LedgerAccountGroup.LedgerAccountGroupName,
                TextProp2 = ((PersonAddressTab.Address == null) ? "" : PersonAddressTab.Address + "," + PersonAddressTab.City.CityName)
            });

            var GroupedRec = from p in temp
                             group p by p.id into g
                             orderby g.Max(m => m.text)
                             select new ComboBoxResult
            {
                id        = g.Max(m => m.id),
                text      = g.Max(m => m.text),
                TextProp1 = g.Max(m => m.TextProp1),
                TextProp2 = g.Max(m => m.TextProp2),
            };

            return(GroupedRec);
        }