Przeglądaj źródła

修复离线保存联系人空值问题

Pen Li 9 lat temu
rodzic
commit
c7d42e7f07

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


+ 57 - 10
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m

@@ -3240,66 +3240,113 @@
     NSString *companyName = [params objectForKey:@"company"];
     if (companyName) {
         companyName = [AESCrypt fastencrypt:companyName];
+    } else {
+        companyName = @"";
     }
     
     NSString *addr1 = [params objectForKey:@"address"];
     if (addr1) {
         addr1 = [AESCrypt fastencrypt:addr1];
+    } else {
+        addr1 = @"";
     }
     NSString *addr2 = [params objectForKey:@"address2"];
-    //    if (addr2) {
-    //        addr2 = [AESCrypt fastencrypt:addr2];
-    //    }
+    if (!addr2) {
+        addr2 = @"";
+    }
     NSString *addr3 = [params objectForKey:@"address_3"];
-    //    if (addr3) {
-    //        addr3 = [AESCrypt fastencrypt:addr3];
-    //    }
+    if (!addr3) {
+        addr3 = @"";
+    }
     NSString *addr4 = [params objectForKey:@"address_4"];
-    //    if (addr4) {
-    //        addr4 = [AESCrypt fastencrypt:addr4];
-    //    }
+    if (!addr4) {
+        addr4 = @"";
+    }
     
     NSString *country = [params objectForKey:@"country"];
     if (country) {
         country = [self countryNameByCountryCodeId:country];
+    } else {
+        country = @"";
     }
     NSString *state = [params objectForKey:@"state"];
+    if (!state) {
+        state = @"";
+    }
     NSString *city = [params objectForKey:@"city"];
+    if (!city) {
+        city = @"";
+    }
     NSString *zipcode = [params objectForKey:@"zipcode"];
+    if (!zipcode) {
+        zipcode = @"";
+    }
     
     NSString *fistName = [params objectForKey:@"firstname"];
+    if (!fistName) {
+        fistName = @"";
+    }
     NSString *lastName = [params objectForKey:@"lastname"];
+    if (!lastName) {
+        lastName = @"";
+    }
     
     NSString *phone = [params objectForKey:@"phone"];
     if (phone) {
         phone = [AESCrypt fastencrypt:phone];
+    } else {
+        phone = @"";
     }
     
     NSString *fax = [params objectForKey:@"fax"];
+    if (!fax) {
+        fax = @"";
+    }
     NSString *email = [params objectForKey:@"email"];
-    
+    if (!email) {
+        email = @"";
+    }
     NSString *notes = [params objectForKey:@"contact_notes"];
+    if (!notes) {
+        notes = @"";
+    }
     
     NSString *price = [params objectForKey:@"price_name"];
     if (price) {
         price = [self priceNameByPriceId:price];
+    } else {
+        price = @"";
     }
     NSString *salesRep = [params objectForKey:@"sales_rep"];
     if (salesRep) {
         salesRep = [self salesRepCodeById:salesRep];
+    } else {
+        salesRep = @"";
     }
     
     NSString *img = [params objectForKey:@"business_card"];
     NSArray *array = [img componentsSeparatedByString:@","];
     NSString *img_0 = array[0];
+    if (!img_0) {
+        img_0 = @"";
+    }
     NSString *img_1 = array[1];
+    if (!img_1) {
+        img_1 = @"";
+    }
     NSString *img_2 = array[2];
+    if (!img_2) {
+        img_2 = @"";
+    }
     
     NSString *contact_id = [NSUUID UUID].UUIDString;
     
     NSString *sql = nil;
     if (update){
         contact_id = [params objectForKey:@"contact_id"];
+        if (!contact_id) {
+            contact_id = [NSUUID UUID].UUIDString;
+        }
         sql = [NSString stringWithFormat:@"update offline_contact set company_name = '%@',addr_1 = '%@',addr_2 = '%@',addr_3 = '%@',addr_4 = '%@',country = '%@',state = '%@',city = '%@',zipcode = '%@',first_name = '%@',last_name = '%@',phone = '%@',fax = '%@',email = '%@',notes = '%@',price_type = '%@',sales_rep = '%@',img_0 = '%@',img_1 = '%@',img_2 = '%@' where contact_id = '%@';",companyName,addr1,addr2,addr3,addr4,country,state,city,zipcode,fistName,lastName,phone,fax,email,notes,price,salesRep,img_0,img_1,img_2,contact_id];
     } else
         sql = [NSString stringWithFormat:@"insert into offline_contact (company_name,addr_1,addr_2,addr_3,addr_4,country,state,city,zipcode,first_name,last_name,phone,fax,email,notes,price_type,sales_rep,img_0,img_1,img_2,editable,contact_id,Sales_Order_Customer,Sales_Order_Freight_Bill_To,Sales_Order_Ship_From,Sales_Order_Merchandise_Bill_To,Contact_Return_To,Sales_Order_Ship_To) values ('%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@',1,'%@',1,1,0,1,0,1)",companyName,addr1,addr2,addr3,addr4,country,state,city,zipcode,fistName,lastName,phone,fax,email,notes,price,salesRep,img_0,img_1,img_2,contact_id];