/// <summary> /// 判断当前操作者所有权限的城市是否和传过来的城市是相同城市的 /// </summary> /// <param name="strPKID">城市PKID</param> /// <returns></returns> public bool IsSameCity(string strPKID) { bool IsSameCity = false; string strCity = string.Empty; BusinessRule.BaseData.Region rule = new BusinessRule.BaseData.Region(); DataTable dtCity = rule.GetAuthorizedCitiesAll(GlobalFacade.SystemContext.GetContext().UserID).GetDataTable(); if (dtCity.Rows.Count > 0) { for (int i = 0; i < dtCity.Rows.Count; i++) { strCity += "'" + dtCity.Rows[i]["PKID"].ToString() + "',"; } if (strCity != string.Empty) { strCity = strCity.Substring(0, strCity.Length - 1); } } if (strCity.IndexOf("'" + strPKID + "'") != -1) { IsSameCity = true; } return(IsSameCity); }
//Qick新加方法 public DataTable GetCityListAD(out int totalCount, int pageSize, int pageIndex, Common.OrderByType obType, BusinessFilter filter) { //获取没有中心的城市 string sql = "select pkid from dictionaryAd where pkid in (select pkid from dictionaryAd where [name] not in (select [name] from dictionary where isvalid =1 and ([level]=1 or [level]=0)) and isvalid = 1 and ([level]=1 or [level]=0)) and ([level]=1 or [level]=0)"; Wicresoft.Session.Session session = new Wicresoft.Session.Session(); DataTable dt = session.SqlHelper.ExcuteDataTable(null, sql, CommandType.Text); string NOPKIDs = ""; for (int i = 0; i < dt.Rows.Count; i++) { NOPKIDs += "," + dt.Rows[i][0]; } //获取登陆用户拥有权限的城市 /* Andy Modify 2009-12-17 用DictionaryAD表的PKID和FK_Dictionary过滤不同值 */ BusinessRule.BaseData.Region regionRule = new BusinessRule.BaseData.Region(); string cityPKIDs = regionRule.GetAuthorizedCitiesPKID(GlobalFacade.SystemContext.GetContext().UserID).ToString(); if (cityPKIDs.IndexOf("2,") != -1) { cityPKIDs += ",1"; } if (NOPKIDs != string.Empty) { NOPKIDs = NOPKIDs.Substring(1, NOPKIDs.Length - 1); } // string cityPKIDs = ","+regionRule.GetAuthorizedCitiesPKID(GlobalFacade.SystemContext.GetContext().UserID).ToString()+","; // if(cityPKIDs.IndexOf(",2,")!=-1) // { // cityPKIDs=cityPKIDs.Substring(1,cityPKIDs.Length-2); // cityPKIDs+=",1"; // if(NOPKIDs!=null&&NOPKIDs!=""&&NOPKIDs!=string.Empty) // { // cityPKIDs+=NOPKIDs; // } // } // else // { // cityPKIDs=cityPKIDs.Substring(1,cityPKIDs.Length-2); // } Common commonRule = new Common(); BusinessFilter flt = new BusinessFilter("DictionaryAD"); flt.AddCustomerFilter("(DictionaryAD.PKID IN(" + NOPKIDs + ") OR DictionaryAD.FK_Dictionary IN (" + cityPKIDs + "))", AndOr.AND); // flt.AddCustomerFilter("(DictionaryAD.PKID IN(" + cityPKIDs + ") OR DictionaryAD.PKID IN (" + cityPKIDs + "))", AndOr.AND); flt.AddFilterItem("IsValid", "1", Operation.Equal, FilterType.NumberType, AndOr.AND); flt.AddFilter(filter, AndOr.AND); // Add Data Permission // flt.AddFilter(GetAuthorizedCityFilter(GlobalFacade.SystemContext.GetContext().UserID), AndOr.AND); BusinessObjectCollection boc = new BusinessObjectCollection("DictionaryAD"); boc.SessionInstance = new Session(); boc.AddFilter(flt); DataSet ds = boc.GetPagedRecords(pageIndex, pageSize, "PKID", (obType == Common.OrderByType.ASC) ? true : false); totalCount = Convert.ToInt32(ds.Tables[0].Rows[0][0]); return(ds.Tables[1]); }