@ -37,24 +37,26 @@ namespace FactorySystemBll
 
			
		
	
		
			
				
					            { 
 
			
		
	
		
			
				
					                viewList  =  db . Queryable < TFS_ViewMaterial ,  TFS_Material > ( ( a ,  b )  = > 
 
			
		
	
		
			
				
					                    new  JoinQueryInfos ( JoinType . Inner ,  a . FMaterialID  = =  b . FID ) ) 
 
			
		
	
		
			
				
					                   . Where ( ( a ,  b )  = >  a . FTeamID  = =  teamId ) 
 
			
		
	
		
			
				
					                   //.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID) 
 
			
		
	
		
			
				
					                   . WhereIF ( currUser  ! =  null ,  ( a ,  b )  = >  currUser . FFactoryList . Contains ( a . FFactoryID . ToString ( ) ) ) 
 
			
		
	
		
			
				
					                   . WhereIF ( viewType  >  0 ,  ( a ,  b )  = >  a . FViewType  = =  viewType ) 
 
			
		
	
		
			
				
					                   . Select < object > ( "distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode,b.FTestCode,b.FRelationCode,b.FRelationName,b.FSAPCode,b.FSAPDescription,b.FMaterialGroup,b.FMaterialType,b.FCustomerCode,b.FStoreHouse,"  + 
 
			
		
	
		
			
				
					                   "b.FBomEntry,b.FLineHouse,b.FProductDesc,b.FWorkCenter,b.FCraftExplain,b.FIidentifier,b.FGuaranteePeriod,b.FBStorageConditions,b.FSafetyStock,b.FTriggerRatio,b.FMinAmount,b.FMaxAmount,b.FYield,b.FFixedLoss,b.FTheoryYield,"  + 
 
			
		
	
		
			
				
					                   "b.FQualityTest1,b.FQualityTest2" ) . ToDictionaryList ( ) ; 
 
			
		
	
		
			
				
					                    . Where ( ( a ,  b )  = >  a . FTeamID  = =  teamId ) 
 
			
		
	
		
			
				
					                    . Where ( ( a ,  b )  = >  a . FTeamType  = =  0 ) 
 
			
		
	
		
			
				
					                    //.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID) 
 
			
		
	
		
			
				
					                    . WhereIF ( currUser  ! =  null ,  ( a ,  b )  = >  currUser . FFactoryList . Contains ( a . FFactoryID . ToString ( ) ) ) 
 
			
		
	
		
			
				
					                    . WhereIF ( viewType  >  0 ,  ( a ,  b )  = >  a . FViewType  = =  viewType ) 
 
			
		
	
		
			
				
					                    . Select < object > ( "distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode,b.FTestCode,b.FRelationCode,b.FRelationName,b.FSAPCode,b.FSAPDescription,b.FMaterialGroup,b.FMaterialType,b.FCustomerCode,b.FStoreHouse,"  + 
 
			
		
	
		
			
				
					                    "b.FBomEntry,b.FLineHouse,b.FProductDesc,b.FWorkCenter,b.FCraftExplain,b.FIidentifier,b.FGuaranteePeriod,b.FBStorageConditions,b.FSafetyStock,b.FTriggerRatio,b.FMinAmount,b.FMaxAmount,b.FYield,b.FFixedLoss,b.FTheoryYield,"  + 
 
			
		
	
		
			
				
					                    "b.FQualityTest1,b.FQualityTest2" ) . ToDictionaryList ( ) ; 
 
			
		
	
		
			
				
					            } 
 
			
		
	
		
			
				
					            else  if  ( viewType  = =  10 ) 
 
			
		
	
		
			
				
					            { 
 
			
		
	
		
			
				
					                viewList  =  db . Queryable < TFS_ViewMaterial ,  TFS_Material > ( ( a ,  b )  = > 
 
			
		
	
		
			
				
					                    new  JoinQueryInfos ( JoinType . Inner ,  a . FMaterialID  = =  b . FID ) ) 
 
			
		
	
		
			
				
					                   . Where ( ( a ,  b )  = >  a . FTeamID  = =  teamId ) 
 
			
		
	
		
			
				
					                   //.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID) 
 
			
		
	
		
			
				
					                   . WhereIF ( currUser  ! =  null ,  ( a ,  b )  = >  currUser . FFactoryList . Contains ( a . FFactoryID . ToString ( ) ) ) 
 
			
		
	
		
			
				
					                   . Select < object > ( "distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode,b.FTestCode,b.FRelationCode,b.FRelationName,b.FSAPCode,b.FSAPDescription,b.FMaterialGroup,b.FMaterialType,b.FCustomerCode,b.FStoreHouse,"  + 
 
			
		
	
		
			
				
					                   "b.FBomEntry,b.FLineHouse,b.FProductDesc,b.FWorkCenter,b.FCraftExplain,b.FIidentifier,b.FGuaranteePeriod,b.FBStorageConditions,b.FSafetyStock,b.FTriggerRatio,b.FMinAmount,b.FMaxAmount,b.FYield,b.FFixedLoss,b.FTheoryYield,"  + 
 
			
		
	
		
			
				
					                   "b.FQualityTest1,b.FQualityTest2" ) . ToDictionaryList ( ) ; 
 
			
		
	
		
			
				
					                    . Where ( ( a ,  b )  = >  a . FTeamID  = =  teamId ) 
 
			
		
	
		
			
				
					                    . Where ( ( a ,  b )  = >  a . FTeamType  = =  0 ) 
 
			
		
	
		
			
				
					                    //.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID) 
 
			
		
	
		
			
				
					                    . WhereIF ( currUser  ! =  null ,  ( a ,  b )  = >  currUser . FFactoryList . Contains ( a . FFactoryID . ToString ( ) ) ) 
 
			
		
	
		
			
				
					                    . Select < object > ( "distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode,b.FTestCode,b.FRelationCode,b.FRelationName,b.FSAPCode,b.FSAPDescription,b.FMaterialGroup,b.FMaterialType,b.FCustomerCode,b.FStoreHouse,"  + 
 
			
		
	
		
			
				
					                    "b.FBomEntry,b.FLineHouse,b.FProductDesc,b.FWorkCenter,b.FCraftExplain,b.FIidentifier,b.FGuaranteePeriod,b.FBStorageConditions,b.FSafetyStock,b.FTriggerRatio,b.FMinAmount,b.FMaxAmount,b.FYield,b.FFixedLoss,b.FTheoryYield,"  + 
 
			
		
	
		
			
				
					                    "b.FQualityTest1,b.FQualityTest2" ) . ToDictionaryList ( ) ; 
 
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					                TFS_FTeamwork  teamWork  =  db . Queryable < TFS_FTeamwork > ( ) . Where ( s  = >  s . FID  = =  teamId ) . First ( ) ; 
 
			
		
	
		
			
				
					                TFS_PackageMain  packAge  =  db . Queryable < TFS_PackageMain > ( ) . Where ( s  = >  s . FCode  = =  teamWork . FPackCode ) . First ( ) ; 
 
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -81,11 +83,12 @@ namespace FactorySystemBll
 
			
		
	
		
			
				
					            { 
 
			
		
	
		
			
				
					                viewList  =  db . Queryable < TFS_ViewMaterial ,  TFS_Material > ( ( a ,  b )  = > 
 
			
		
	
		
			
				
					                 new  JoinQueryInfos ( JoinType . Inner ,  a . FMaterialID  = =  b . FID ) ) 
 
			
		
	
		
			
				
					               . Where ( ( a ,  b )  = >  a . FTeamID  = =  teamId ) 
 
			
		
	
		
			
				
					               //.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID) 
 
			
		
	
		
			
				
					               . WhereIF ( currUser  ! =  null ,  ( a ,  b )  = >  currUser . FFactoryList . Contains ( a . FFactoryID . ToString ( ) ) ) 
 
			
		
	
		
			
				
					               . WhereIF ( viewType  >  0 ,  ( a ,  b )  = >  a . FViewType  = =  1 ) 
 
			
		
	
		
			
				
					               . Select < object > ( "distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode,b.FTestCode,b.FRelationCode,b.FRelationName,b.FSAPCode,b.FSAPDescription,b.FMaterialGroup,b.FMaterialType,b.FCustomerCode,b.FStoreHouse,"  + 
 
			
		
	
		
			
				
					                . Where ( ( a ,  b )  = >  a . FTeamID  = =  teamId ) 
 
			
		
	
		
			
				
					                . Where ( ( a ,  b )  = >  a . FTeamType  = =  0 ) 
 
			
		
	
		
			
				
					                //.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID) 
 
			
		
	
		
			
				
					                . WhereIF ( currUser  ! =  null ,  ( a ,  b )  = >  currUser . FFactoryList . Contains ( a . FFactoryID . ToString ( ) ) ) 
 
			
		
	
		
			
				
					                . WhereIF ( viewType  >  0 ,  ( a ,  b )  = >  a . FViewType  = =  1 ) 
 
			
		
	
		
			
				
					                . Select < object > ( "distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode,b.FTestCode,b.FRelationCode,b.FRelationName,b.FSAPCode,b.FSAPDescription,b.FMaterialGroup,b.FMaterialType,b.FCustomerCode,b.FStoreHouse,"  + 
 
			
		
	
		
			
				
					                "b.FBomEntry,b.FLineHouse,b.FProductDesc,b.FWorkCenter,b.FCraftExplain,b.FIidentifier,b.FGuaranteePeriod,b.FBStorageConditions,b.FSafetyStock,b.FTriggerRatio,b.FMinAmount,b.FMaxAmount,b.FYield,b.FFixedLoss,b.FTheoryYield,"  + 
 
			
		
	
		
			
				
					                "b.FQualityTest1,b.FQualityTest2" ) . ToDictionaryList ( ) ; 
 
			
		
	
		
			
				
					                List < TFS_MaterialInfo >  Minfo  =  GetMaterialInfoList ( viewList . GroupBy ( s  = >  s [ "FMaterialID" ] ) . Select ( s  = >  int . Parse ( s . Key . ToString ( ) ) ) . ToList ( ) ,  "" ,  "" ,  currUserId ) ; 
 
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -281,6 +284,7 @@ namespace FactorySystemBll
 
			
		
	
		
			
				
					            List < Dictionary < string ,  object > >  viewList  =  db . Queryable < TFS_ViewMaterial ,  TFS_Material > ( ( a ,  b )  = > 
 
			
		
	
		
			
				
					                 new  JoinQueryInfos ( JoinType . Inner ,  a . FMaterialID  = =  b . FID ) ) 
 
			
		
	
		
			
				
					                . Where ( ( a ,  b )  = >  a . FTeamID  = =  teamId ) 
 
			
		
	
		
			
				
					                . Where ( ( a ,  b )  = >  a . FTeamType  = =  0 ) 
 
			
		
	
		
			
				
					                //.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID) 
 
			
		
	
		
			
				
					                . Select < object > ( "distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode" ) . ToDictionaryList ( ) ; 
 
			
		
	
		
			
				
					
 
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -294,10 +298,11 @@ namespace FactorySystemBll
 
			
		
	
		
			
				
					                    { 
 
			
		
	
		
			
				
					                        List < Dictionary < string ,  object > >  viewList1  =  db . Queryable < TFS_ViewMaterial ,  TFS_Material > ( ( a ,  b )  = > 
 
			
		
	
		
			
				
					                         new  JoinQueryInfos ( JoinType . Inner ,  a . FMaterialID  = =  b . FID ) ) 
 
			
		
	
		
			
				
					                       . Where ( ( a ,  b )  = >  a . FTeamID  = =  teamId ) 
 
			
		
	
		
			
				
					                       . WhereIF ( currUser  ! =  null ,  ( a ,  b )  = >  a . FFactoryID  = =  currUser . FFactoryID ) 
 
			
		
	
		
			
				
					                        . Where ( ( a ,  b )  = >  a . FTeamID  = =  teamId ) 
 
			
		
	
		
			
				
					                        . Where ( ( a ,  b )  = >  a . FTeamType  = =  0 ) 
 
			
		
	
		
			
				
					                        . WhereIF ( currUser  ! =  null ,  ( a ,  b )  = >  a . FFactoryID  = =  currUser . FFactoryID ) 
 
			
		
	
		
			
				
					                        . WhereIF ( viewType  >  0 ,  ( a ,  b )  = >  a . FViewType  = =  2 ) 
 
			
		
	
		
			
				
					                       . Select < object > ( "distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode" ) . ToDictionaryList ( ) ; 
 
			
		
	
		
			
				
					                         . Select < object > ( "distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode" ) . ToDictionaryList ( ) ; 
 
			
		
	
		
			
				
					                        List < TFS_MaterialInfo >  Minfo  =  GetMaterialInfoList ( viewList1 . GroupBy ( s  = >  s [ "FMaterialID" ] ) . Select ( s  = >  int . Parse ( s . Key . ToString ( ) ) ) . ToList ( ) ,  "" ,  "" ,  currUserId ) ; 
 
			
		
	
		
			
				
					                        if  ( Minfo . Count  >  0 ) 
 
			
		
	
		
			
				
					                        {