Display data of particular division and circles and filter data separated by comma

Display data of particular division and circles and filter data separated by comma

 public void UserRigths()  
 {  
 currentUserId = curUserId();  
 select * from sysCompanyUserInfo  
 where sysCompanyUserInfo.UserId == currentUserID;  
 if(sysCompanyUserInfo)  
 {  
 if(sysCompanyUserInfo.EmplId != "")  
 {  
 while select * from EmplTable2 where EmplTable2.EmplId == sysCompanyUserInfo.EmplId  
 {  
 d1 = System.Convert::ToString(EmplTable2.Dimension[2]);  
 }  
 if(d1 != "")  
 {  
 while select * from _OrganizationChart2_1 where _OrganizationChart2_1.WareHouseCode == d1  
 {  
 _Office_type = _OrganizationChart2_1.Office_type;  
 }  
 }  
 if (d1 != "")  
 {  
 if ((enum2str(_Office_type) == "Sachivalaya") || (enum2str(_Office_type) == "CE") || (enum2str(_Office_type) == "Circle") )  
 {  
 while select * from _OrganizationChart2_2 where _OrganizationChart2_2.ParentWareHouseCode == d1  
 {  
 OfficeName += _OrganizationChart2_2.WareHouseCode + ",";  
 }  
 }  
 else if (enum2str(_Office_type) == "Division")  
 {  
 OfficeName = d1;  
 }  
 }  
 // dimensionRange = ProjTable_ds.query().dataSourceTable(TableNum(ProjTable)).addRange(FieldId2Ext(FieldNum(ProjTable, Dimension),2));  
 // dimensionRange.value(SysQuery::valueEmptyString());  
 len = strlen(OfficeName);  
 pos = strfind(OfficeName,",", len, -len );  
 s = strdel( OfficeName, pos, strlen( OfficeName ) - pos + 1 );  
 s = s + "," + SysQuery::valueEmptyString();  
 dimensionRange = ProjTable_ds.query().dataSourceTable(TableNum(ProjTable)).addRange(FieldId2Ext(FieldNum(ProjTable, Dimension),2));  
 dimensionRange.value(s);  
 // dimensionRange.value(SysQuery::valueEmptyString());  
 }  
 }  
 }