Parcourir la source

增加保存当前打开的数据库对象。
修复保存PDF时,QTY错误(qty = qty * percent / 100)。

Pen Li il y a 9 ans
Parent
commit
2257492480

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


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

@@ -10321,7 +10321,7 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
             
         }
         if (percentage) {
-            qty = qty * percent;
+            qty = qty * percent / 100;
         }
         
         // Special Price

+ 3 - 0
RedAnt ERP Mobile/common/data_provider/iSalesDB.m

@@ -9,6 +9,7 @@
 #import "iSalesDB.h"
 #import "AESCrypt.h"
 #import "AppDelegate.h"
+#import "Singleton.h"
 
 NSLock *dblock ;
 int count_dbconn;
@@ -388,6 +389,7 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
     }
     
     [self AddExFunction:db];
+    [Singleton sharedInstance].currentDB = db;
     return db;
     
     
@@ -400,6 +402,7 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
     sqlite3_close(db);
     count_dbconn--;
     NSLog(@"CLOSE DB current dbconn: %d",count_dbconn);
+    [Singleton sharedInstance].currentDB = nil;
     [dblock unlock];
     
     

+ 4 - 1
RedAnt ERP Mobile/iSales-NPD/AppDelegate.m

@@ -23,6 +23,7 @@
 #import "OrderDetailViewController.h"
 #import "AddressEditorViewController.h"
 #import "config.h"
+#import "Singleton.h"
 #define UNZIP_OPEN_FAILED 0
 #define UNZIP_SUCCESS 1
 #define UNZIP_NO_SPACE 2
@@ -487,7 +488,9 @@ void UncaughtExceptionHandler(NSException *exception) {
     
     
     NSString *sql = [NSString stringWithFormat:@"insert into errlog (errmsg,params) values ('%@','%@');",versionNum,content];
-    
+    if ([Singleton sharedInstance].currentDB) {
+        [iSalesDB close_db:[Singleton sharedInstance].currentDB];
+    }
     [iSalesDB execSql:sql];
     
     AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;

+ 3 - 0
RedAnt ERP Mobile/iSales-NPD/Singleton.h

@@ -7,9 +7,12 @@
 //
 
 #import <Foundation/Foundation.h>
+#import <sqlite3.h>
 
 @interface Singleton : NSObject
 
+@property (nonatomic,assign) sqlite3 *currentDB;///<当前打开的数据库
+
 @property (nonatomic,assign) NSInteger npd_shop_price_type;///<Shop 设置的价格类型
 
 #pragma mark - Shop 用户权限