Эх сурвалжийг харах

增加对数据库查询结果为text的数据为空的判断

Pen Li 9 жил өмнө
parent
commit
0b4ed3aa99

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


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

@@ -2684,6 +2684,13 @@
         char *name = (char *) sqlite3_column_text(stmt, 1); // value
         char *code = (char *) sqlite3_column_text(stmt, 2); // value_id
         
+        if (name == NULL) {
+            name = "";
+        }
+        if (code == NULL) {
+            code = "";
+        }
+        
         NSMutableDictionary *stateDic = [NSMutableDictionary dictionaryWithCapacity:2];
         [stateDic setValue:[NSString stringWithUTF8String:name] forKey:@"value"];
         [stateDic setValue:[NSString stringWithUTF8String:code] forKey:@"value_id"];
@@ -2711,6 +2718,14 @@
         char *name = (char *) sqlite3_column_text(stmt, 0); // value
         char *code = (char *) sqlite3_column_text(stmt, 1); // value_id
         
+        if (name == NULL) {
+            name = "";
+        }
+        if (code == NULL) {
+            code = "";
+        }
+
+        
         NSMutableDictionary *stateDic = [NSMutableDictionary dictionaryWithCapacity:2];
         [stateDic setValue:[NSString stringWithUTF8String:name] forKey:@"value"];
         [stateDic setValue:[NSString stringWithUTF8String:code] forKey:@"value_id"];
@@ -2739,6 +2754,11 @@
         int type = sqlite3_column_int(stmt, 2);
         int orderBy = sqlite3_column_int(stmt, 3);
         
+        if (name == NULL) {
+            name = "";
+        }
+    
+        
         NSMutableDictionary *priceDic = [NSMutableDictionary dictionary];
         [priceDic setValue:[NSString stringWithUTF8String:name] forKey:@"value"];
         [priceDic setValue:[NSNumber numberWithInt:type] forKey:@"value_id"];
@@ -2768,6 +2788,14 @@
         char *code = (char *)sqlite3_column_text(stmt, 2);
         int salesrep_id = sqlite3_column_int(stmt, 3);
         
+        if (name == NULL) {
+            name = "";
+        }
+        if (code == NULL) {
+            code = "";
+        }
+
+        
         NSMutableDictionary *repDic = [NSMutableDictionary dictionary];
         [repDic setValue:[NSString stringWithFormat:@"%s - %s",code,name] forKey:@"value"];
         [repDic setValue:[NSNumber numberWithInt:salesrep_id] forKey:@"value_id"];
@@ -2792,6 +2820,24 @@
         char *country_code = (char *)sqlite3_column_text(stmt, 3);
         char *state_code = (char *)sqlite3_column_text(stmt, 4);
         
+        if (country == NULL) {
+            country = "";
+        }
+        if (state == NULL) {
+            state = "";
+        }
+        if (city == NULL) {
+            city = "";
+        }
+        if (country_code == NULL) {
+            country_code = "";
+        }
+        if (state_code == NULL) {
+            state_code = "";
+        }
+
+
+        
         [container setValue:[NSString stringWithUTF8String:country] forKey:@"country"];
         [container setValue:[NSString stringWithUTF8String:state] forKey:@"state"];
         [container setValue:[NSString stringWithUTF8String:city] forKey:@"city"];
@@ -2823,6 +2869,9 @@
     if (sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil) == SQLITE_OK) {
         while (sqlite3_step(statement) == SQLITE_ROW) {
             char *code = (char *)sqlite3_column_text(statement, 0);
+            if (code == NULL) {
+                code = "";
+            }
             ret = [NSString stringWithUTF8String:code];
         }
         
@@ -2844,6 +2893,9 @@
     if (sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil) == SQLITE_OK) {
         while (sqlite3_step(statement) == SQLITE_ROW) {
             char *_id = (char *)sqlite3_column_text(statement, 0);
+            if (_id == NULL) {
+                _id = "";
+            }
             ret = [NSString stringWithFormat:@"%s",_id];
         }
         
@@ -2865,6 +2917,9 @@
     if (sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil) == SQLITE_OK) {
         while (sqlite3_step(statement) == SQLITE_ROW) {
             char *value = (char *)sqlite3_column_text(statement, 0);
+            if (value == NULL) {
+                value = "";
+            }
             name = [NSString stringWithUTF8String:value];
         }
         
@@ -2886,6 +2941,9 @@
     if (sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil) == SQLITE_OK) {
         while (sqlite3_step(statement) == SQLITE_ROW) {
             char *name = (char *)sqlite3_column_text(statement, 0);
+            if (name == NULL) {
+                name = "";
+            }
             ret = [NSString stringWithUTF8String:name];
         }
         
@@ -2907,6 +2965,9 @@
     if (sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil) == SQLITE_OK) {
         while (sqlite3_step(statement) == SQLITE_ROW) {
             char *rep = (char *)sqlite3_column_text(statement, 0);
+            if (rep == NULL) {
+                rep = "";
+            }
             ret = [NSString stringWithUTF8String:rep];
         }
         
@@ -2919,7 +2980,11 @@
 }
 
 + (NSString *)textAtColumn:(int)col statement:(sqlite3_stmt *)stmt{
-    NSString *text = [NSString stringWithFormat:@"%s",(char *)sqlite3_column_text(stmt, col)];
+    char *tx = (char *)sqlite3_column_text(stmt, col);
+    if (tx == NULL) {
+        tx = "";
+    }
+    NSString *text = [NSString stringWithFormat:@"%s",tx];
     if (!text) {
         text = @"";
     }
@@ -3491,7 +3556,7 @@
         [self check:params[@"sold_by_qty"] valueKey:@"qty" inDictionary:filter];
         NSString *qty = params[@"sold_by_qty"];
         if ([qty isEqualToString:@"Display All"]) {
-            qty = @"like 'Sold in quantities of _'";
+            qty = @"like 'Sold in quantities of %'";
         } else {
             qty = [NSString stringWithFormat:@"= 'Sold in quantities of %@'",qty];
         }

+ 5 - 1
RedAnt ERP Mobile/common/data_provider/iSalesDB.m

@@ -958,7 +958,11 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
     if (sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil) == SQLITE_OK) {
         
         while (sqlite3_step(statement) == SQLITE_ROW) {
-            ret = [NSString stringWithFormat:@"%s",(char *)sqlite3_column_text(statement, 0)];
+            char *text = (char *)sqlite3_column_text(statement, 0);
+            if (text == NULL) {
+                text = "";
+            }
+            ret = [NSString stringWithFormat:@"%s",text];
         }
         
         sqlite3_finalize(statement);