Răsfoiți Sursa

20170116

fix offline model detail multiple bugs.
Ray Zhang 9 ani în urmă
părinte
comite
c92dee49a5

+ 17 - 2
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m

@@ -2494,6 +2494,8 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
     
     NSData* json =nil;
     json=[NSData dataWithContentsOfFile:img_cache];
+    if(json==nil)
+        return nil;
     NSError *error=nil;
     NSMutableDictionary* menu = [[NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error] mutableCopy];
     
@@ -2572,7 +2574,11 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
     
     NSString* sqlQuery = nil;
     if(appDelegate.contact_id==nil)
+    {
+        if(!appDelegate.bLogin)
+            return nil;
         sqlQuery=[NSString stringWithFormat:@"select a.name,b.price,b.type from price as a left join model_price as b on a.name=b.price_name and b.item_id=%d  order by a.order_by;",item_id];
+    }
     else
         sqlQuery=[NSString stringWithFormat:@"select a.name,b.price,b.type from price as a left join model_price as b on a.name=b.price_name and b.item_id=%d and b.price_name in(%@) order by a.order_by;",item_id,whereprice];
     sqlite3_stmt * statement;
@@ -2623,7 +2629,7 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
             }
             
 //            int type= sqlite3_column_int(statement, 2);
-//            item[@"type"]=[NSNumber numberWithInt:type ];
+            //item[@"type"]=@"price";
             // item[nsname]= nsprice;
             
             ret[[NSString stringWithFormat:@"item_%d",count]]= item;
@@ -3299,7 +3305,7 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
             for(int l=0;l<[pricejson[@"count"] intValue];l++)
             {
                 NSDictionary* price_item = pricejson[[NSString stringWithFormat:@"item_%d",l]];
-                [detail0_section setObject:[self model_kvItem:price_item.allKeys[0] value:price_item.allValues[0]] forKey:[NSString stringWithFormat:@"item_%d",detail0_item_count++]];
+                [detail0_section setObject:[self model_priceKvItem:price_item.allKeys[0] value:price_item.allValues[0]] forKey:[NSString stringWithFormat:@"item_%d",detail0_item_count++]];
             }
             
             
@@ -4969,6 +4975,15 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
     return ret;
     
     
+}
++(NSDictionary*) model_priceKvItem:(NSString*) key value:(NSString*)value
+{
+    NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
+    
+    [ret setValue:key forKey:@"key"];
+    [ret setValue:value forKey:@"val"];
+    [ret setValue:@"price" forKey:@"type"];
+    return ret;
 }
 +(NSDictionary*) model_kvItem:(NSString*) key value:(NSString*)value
 {