Răsfoiți Sursa

增加方法offline_getStateByCountryCodeId: checkedState:用来以countryCodeId值来查询state

Pen Li 9 ani în urmă
părinte
comite
a1e501cfd0

BIN
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


+ 43 - 0
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m

@@ -2673,6 +2673,45 @@
     return dic;
     return dic;
 }
 }
 
 
++ (NSDictionary *)offline_getStateByCountryCodeId:(NSString *)codeId checkedState:(NSString *)stateCode {
+    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
+    
+    sqlite3 *db = [iSalesDB get_db];
+    
+    NSString *sqlQuery = [NSString stringWithFormat:@"select name,code from offline_state where country_code = (select code as country_code FROM offline_country where countrycode_id = %@);",codeId];
+    
+    DebugLog(@"query state:%@",sqlQuery);
+    
+    sqlite3_stmt * statement;
+    
+    if (sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil) == SQLITE_OK) {
+        int i = 0;
+        while (sqlite3_step(statement) == SQLITE_ROW) {
+            char *name = (char *) sqlite3_column_text(statement, 0); // value
+            char *code = (char *) sqlite3_column_text(statement, 1); // value_id
+            
+            NSMutableDictionary *stateDic = [NSMutableDictionary dictionaryWithCapacity:2];
+            [stateDic setValue:[NSString stringWithUTF8String:name] forKey:@"value"];
+            [stateDic setValue:[NSString stringWithUTF8String:code] forKey:@"value_id"];
+            [stateDic setValue:[NSNumber numberWithInt:0] forKey:@"check"];
+            
+            if (stateCode && [[NSString stringWithUTF8String:code] isEqualToString:stateCode]) {
+                [stateDic setValue:[NSNumber numberWithInt:1] forKey:@"check"];
+            }
+            
+            NSString *key = [NSString stringWithFormat:@"val_%d",i++];
+            [dic setValue:stateDic forKey:key];
+        }
+        
+        sqlite3_finalize(statement);
+    }
+    
+    sqlite3_close(db);
+    [dic setValue:[NSNumber numberWithInt:dic.allKeys.count] forKey:@"count"];
+    return dic;
+
+}
+
 + (NSDictionary *)offline_getPrice {
 + (NSDictionary *)offline_getPrice {
     NSMutableDictionary *dic = [NSMutableDictionary dictionary];
     NSMutableDictionary *dic = [NSMutableDictionary dictionary];
     
     
@@ -2852,6 +2891,8 @@
             NSString *zip_code = params[@"zipcode"];
             NSString *zip_code = params[@"zipcode"];
             zipCode = zip_code;
             zipCode = zip_code;
             
             
+            countryCode_id = params[@"country"];
+            
             NSDictionary *dic = [self offline_dealZipCode:zip_code];
             NSDictionary *dic = [self offline_dealZipCode:zip_code];
             
             
             countryCode = [dic valueForKey:@"country_code"];
             countryCode = [dic valueForKey:@"country_code"];
@@ -2869,6 +2910,7 @@
     } else {
     } else {
         // default: US United States
         // default: US United States
         countryCode = @"US";
         countryCode = @"US";
+        countryCode_id = @"228";
     }
     }
     
     
     // country
     // country
@@ -2877,6 +2919,7 @@
     
     
     // state
     // state
     NSDictionary *allState = [self offline_getStateByCountryCode:countryCode checkedState:stateCode];
     NSDictionary *allState = [self offline_getStateByCountryCode:countryCode checkedState:stateCode];
+//     NSDictionary *allState = [self offline_getStateByCountryCodeId:countryCode_id checkedState:stateCode];
     [self setValue:allState forItemKey:@"item_11" valueKey:@"cadedate" inDictionary:section_0];
     [self setValue:allState forItemKey:@"item_11" valueKey:@"cadedate" inDictionary:section_0];
     
     
     // city
     // city