Explorar el Código

1.修改NPD、Homer以及GATIT AppDelegate,将部分全局变量放入GlobalParameter字典。
2.修改CommonEditor,全局变量的获取通过GlobalParameter字典获取。

Pen Li hace 8 años
padre
commit
82d0636ac5

+ 17 - 8
RedAnt ERP Mobile/common/CommonEditor/CommonEditorViewController.m

@@ -179,8 +179,9 @@
 - (int)level {
 - (int)level {
     if (_level == -1) {
     if (_level == -1) {
         AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
         AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+        NSDictionary *urgencyDic = [appDelegate globalParameterForKey:@"urgencyDic"];
         
         
-        id count = [appDelegate.urgencyDic objectForKey:@"count"];
+        id count = [urgencyDic objectForKey:@"count"];
         
         
         _level = count == nil ? 0 : [count intValue];
         _level = count == nil ? 0 : [count intValue];
     }
     }
@@ -3443,8 +3444,10 @@
                     
                     
                     if([type isEqualToString:@"price"])
                     if([type isEqualToString:@"price"])
                     {
                     {
+                        BOOL can_see_price = [[appDelegate globalParameterForKey:@"can_see_price"] boolValue];
+                        BOOL price_hidden = [[appDelegate globalParameterForKey:@"price_hidden"] boolValue];
                         
                         
-                        if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
+                        if(can_see_price&&price_hidden==false)
                         {
                         {
                             
                             
                         }
                         }
@@ -3811,8 +3814,10 @@
             NSString* totalprice = [NSString stringWithFormat:@"%.2f",(unitprice* (1.0-discount/100)+dprice)*count];
             NSString* totalprice = [NSString stringWithFormat:@"%.2f",(unitprice* (1.0-discount/100)+dprice)*count];
             
             
             
             
+            BOOL can_see_price = [[appDelegate globalParameterForKey:@"can_see_price"] boolValue];
+            BOOL price_hidden = [[appDelegate globalParameterForKey:@"price_hidden"] boolValue];
             
             
-            if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
+            if(can_see_price&&price_hidden==false)
             {
             {
                 
                 
             }
             }
@@ -4505,7 +4510,8 @@
             if(signimg!=nil)
             if(signimg!=nil)
             {
             {
 #ifdef OFFLINE_MODE
 #ifdef OFFLINE_MODE
-                if(appDelegate.offline_mode)
+                BOOL offline_mode = [[appDelegate globalParameterForKey:@"offline_mode"] boolValue];
+                if(offline_mode)
                 {
                 {
                     
                     
                    
                    
@@ -4566,10 +4572,13 @@
                 
                 
                 NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
                 NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
                 AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
                 AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                if(appDelegate.user!=nil)
-                    [params setValue:appDelegate.user forKey:@"user"];
-                if(appDelegate.password!=nil)
-                    [params setValue:appDelegate.password forKey:@"password"];
+                NSString *user = [appDelegate globalParameterForKey:@"user"];
+                NSString *password = [appDelegate globalParameterForKey:@"password"];
+                
+                if(user!=nil)
+                    [params setValue:user forKey:@"user"];
+                if(password!=nil)
+                    [params setValue:password forKey:@"password"];
                 
                 
                 UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Upload Signature"];
                 UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Upload Signature"];
                 
                 

+ 9 - 2
RedAnt ERP Mobile/iSales-GATIT/AppDelegate.h

@@ -56,10 +56,10 @@
 @property long cart_count;
 @property long cart_count;
 @property long port_count;
 @property long port_count;
 
 
-@property bool offline_mode;
+@property (nonatomic,assign) bool offline_mode;
 
 
 @property bool can_show_price;
 @property bool can_show_price;
-@property bool can_see_price;
+@property (nonatomic,assign) bool can_see_price;
 @property bool can_create_portfolio;
 @property bool can_create_portfolio;
 @property bool can_cancel_order;
 @property bool can_cancel_order;
 @property bool can_set_cart_price;
 @property bool can_set_cart_price;
@@ -138,4 +138,11 @@
 
 
 @property (nonatomic,assign) BOOL can_create_backorder;
 @property (nonatomic,assign) BOOL can_create_backorder;
 
 
+#pragma mark - Global Param Begin
+
+- (void)setGlobalParameter:(id)param forKey:(NSString *)key;
+- (id)globalParameterForKey:(NSString *)key;
+
+#pragma mark - Globale Param End
+
 @end
 @end

+ 66 - 0
RedAnt ERP Mobile/iSales-GATIT/AppDelegate.m

@@ -38,6 +38,7 @@
 
 
 @interface AppDelegate ()
 @interface AppDelegate ()
 
 
+@property (nonatomic,strong) NSMutableDictionary *globalParameters;
 @property (nonatomic,strong) NSDate *forgroundDate;
 @property (nonatomic,strong) NSDate *forgroundDate;
 
 
 @end
 @end
@@ -54,6 +55,71 @@
 @synthesize ScanApiConsumer;
 @synthesize ScanApiConsumer;
 @synthesize scanApiVersion;
 @synthesize scanApiVersion;
 //@synthesize devices;
 //@synthesize devices;
+
+
+#pragma mark - Global Parameter
+
+- (NSMutableDictionary *)globalParameters {
+    if (!_globalParameters) {
+        _globalParameters = [NSMutableDictionary dictionary];
+    }
+    return _globalParameters;
+}
+
+
+- (void)setGlobalParameter:(id)param forKey:(NSString *)key {
+    if (param == nil || key == nil) {
+        return;
+    }
+    [self.globalParameters setObject:param forKey:key];
+}
+
+- (id)globalParameterForKey:(NSString *)key {
+    if (key == nil) {
+        return nil;
+    }
+    return [self.globalParameters objectForKey:key];
+}
+
+#pragma mark - Setter
+
+- (void)setUrgencyDic:(NSMutableDictionary *)urgencyDic {
+    _urgencyDic = urgencyDic;
+    [self setGlobalParameter:_urgencyDic forKey:@"urgencyDic"];
+}
+
+- (void)setCan_see_price:(bool)can_see_price {
+    _can_see_price = can_see_price;
+    [self setGlobalParameter:@(_can_see_price) forKey:@"can_see_price"];
+}
+
+- (void)setPrice_hidden:(bool)price_hidden {
+    _price_hidden = price_hidden;
+    [self setGlobalParameter:@(_price_hidden) forKey:@"price_hidden"];
+    
+    ActiveViewController* avc=(ActiveViewController*)self.active_controller;
+    
+    [avc showHidePrice];
+    
+}
+
+- (void)setOffline_mode:(bool)offline_mode {
+    _offline_mode = offline_mode;
+    [self setGlobalParameter:@(_offline_mode) forKey:@"offline_mode"];
+}
+
+- (void)setUser:(NSString *)user {
+    _user = user;
+    [self setGlobalParameter:_user forKey:@"user"];
+}
+
+- (void)setPassword:(NSString *)password {
+    _password = password;
+    [self setGlobalParameter:_password forKey:@"password"];
+}
+
+#pragma mark - Normal
+
 -(void) set_priceHidden:(bool)price_hidden
 -(void) set_priceHidden:(bool)price_hidden
 {
 {
     _price_hidden = price_hidden;
     _price_hidden = price_hidden;

+ 9 - 2
RedAnt ERP Mobile/iSales-HOMER/AppDelegate.h

@@ -56,10 +56,10 @@
 @property long cart_count;
 @property long cart_count;
 @property long port_count;
 @property long port_count;
 
 
-@property bool offline_mode;
+@property (nonatomic,assign) bool offline_mode;
 
 
 @property bool can_show_price;
 @property bool can_show_price;
-@property bool can_see_price;
+@property (nonatomic,assign) bool can_see_price;
 @property bool can_create_portfolio;
 @property bool can_create_portfolio;
 @property bool can_cancel_order;
 @property bool can_cancel_order;
 @property bool can_set_cart_price;
 @property bool can_set_cart_price;
@@ -138,4 +138,11 @@
 
 
 @property (nonatomic,assign) BOOL can_create_backorder;
 @property (nonatomic,assign) BOOL can_create_backorder;
 
 
+#pragma mark - Global Param Begin
+
+- (void)setGlobalParameter:(id)param forKey:(NSString *)key;
+- (id)globalParameterForKey:(NSString *)key;
+
+#pragma mark - Globale Param End
+
 @end
 @end

+ 66 - 0
RedAnt ERP Mobile/iSales-HOMER/AppDelegate.m

@@ -38,6 +38,7 @@
 
 
 @interface AppDelegate ()
 @interface AppDelegate ()
 
 
+@property (nonatomic,strong) NSMutableDictionary *globalParameters;
 @property (nonatomic,strong) NSDate *forgroundDate;
 @property (nonatomic,strong) NSDate *forgroundDate;
 
 
 @end
 @end
@@ -54,6 +55,71 @@
 @synthesize ScanApiConsumer;
 @synthesize ScanApiConsumer;
 @synthesize scanApiVersion;
 @synthesize scanApiVersion;
 //@synthesize devices;
 //@synthesize devices;
+
+
+#pragma mark - Global Parameter
+
+- (NSMutableDictionary *)globalParameters {
+    if (!_globalParameters) {
+        _globalParameters = [NSMutableDictionary dictionary];
+    }
+    return _globalParameters;
+}
+
+
+- (void)setGlobalParameter:(id)param forKey:(NSString *)key {
+    if (param == nil || key == nil) {
+        return;
+    }
+    [self.globalParameters setObject:param forKey:key];
+}
+
+- (id)globalParameterForKey:(NSString *)key {
+    if (key == nil) {
+        return nil;
+    }
+    return [self.globalParameters objectForKey:key];
+}
+
+#pragma mark - Setter
+
+- (void)setUrgencyDic:(NSMutableDictionary *)urgencyDic {
+    _urgencyDic = urgencyDic;
+    [self setGlobalParameter:_urgencyDic forKey:@"urgencyDic"];
+}
+
+- (void)setCan_see_price:(bool)can_see_price {
+    _can_see_price = can_see_price;
+    [self setGlobalParameter:@(_can_see_price) forKey:@"can_see_price"];
+}
+
+- (void)setPrice_hidden:(bool)price_hidden {
+    _price_hidden = price_hidden;
+    [self setGlobalParameter:@(_price_hidden) forKey:@"price_hidden"];
+    
+    ActiveViewController* avc=(ActiveViewController*)self.active_controller;
+    
+    [avc showHidePrice];
+    
+}
+
+- (void)setOffline_mode:(bool)offline_mode {
+    _offline_mode = offline_mode;
+    [self setGlobalParameter:@(_offline_mode) forKey:@"offline_mode"];
+}
+
+- (void)setUser:(NSString *)user {
+    _user = user;
+    [self setGlobalParameter:_user forKey:@"user"];
+}
+
+- (void)setPassword:(NSString *)password {
+    _password = password;
+    [self setGlobalParameter:_password forKey:@"password"];
+}
+
+#pragma mark - Normal
+
 -(void) set_priceHidden:(bool)price_hidden
 -(void) set_priceHidden:(bool)price_hidden
 {
 {
     _price_hidden = price_hidden;
     _price_hidden = price_hidden;

+ 10 - 2
RedAnt ERP Mobile/iSales-NPD/AppDelegate.h

@@ -56,10 +56,10 @@
 @property long cart_count;
 @property long cart_count;
 @property long port_count;
 @property long port_count;
 
 
-@property bool offline_mode;
+@property (nonatomic,assign) bool offline_mode;
 
 
 @property bool can_show_price;
 @property bool can_show_price;
-@property bool can_see_price;
+@property (nonatomic,assign) bool can_see_price;
 @property bool can_create_portfolio;
 @property bool can_create_portfolio;
 @property bool can_cancel_order;
 @property bool can_cancel_order;
 @property bool can_set_cart_price;
 @property bool can_set_cart_price;
@@ -138,4 +138,12 @@
 
 
 @property (nonatomic,assign) BOOL can_create_backorder;
 @property (nonatomic,assign) BOOL can_create_backorder;
 
 
+#pragma mark - Global Param Begin
+
+- (void)setGlobalParameter:(id)param forKey:(NSString *)key;
+- (id)globalParameterForKey:(NSString *)key;
+
+#pragma mark - Globale Param End
+
+
 @end
 @end

+ 67 - 6
RedAnt ERP Mobile/iSales-NPD/AppDelegate.m

@@ -36,8 +36,12 @@
 #define UNZIP_NO_SPACE 2
 #define UNZIP_NO_SPACE 2
 #define UNZIP_FILE_DAMAGE 3
 #define UNZIP_FILE_DAMAGE 3
 
 
+
+
 @interface AppDelegate ()
 @interface AppDelegate ()
 
 
+@property (nonatomic,strong) NSMutableDictionary *globalParameters;
+
 @property (nonatomic,strong) NSDate *forgroundDate;
 @property (nonatomic,strong) NSDate *forgroundDate;
 
 
 @end
 @end
@@ -54,16 +58,73 @@
 @synthesize ScanApiConsumer;
 @synthesize ScanApiConsumer;
 @synthesize scanApiVersion;
 @synthesize scanApiVersion;
 //@synthesize devices;
 //@synthesize devices;
--(void) set_priceHidden:(bool)price_hidden
-{
+
+#pragma mark - Global Parameter
+
+- (NSMutableDictionary *)globalParameters {
+    if (!_globalParameters) {
+        _globalParameters = [NSMutableDictionary dictionary];
+    }
+    return _globalParameters;
+}
+
+
+- (void)setGlobalParameter:(id)param forKey:(NSString *)key {
+    if (param == nil || key == nil) {
+        return;
+    }
+    [self.globalParameters setObject:param forKey:key];
+}
+
+- (id)globalParameterForKey:(NSString *)key {
+    if (key == nil) {
+        return nil;
+    }
+    return [self.globalParameters objectForKey:key];
+}
+
+#pragma mark - Setter
+
+- (void)setUrgencyDic:(NSMutableDictionary *)urgencyDic {
+    _urgencyDic = urgencyDic;
+    [self setGlobalParameter:_urgencyDic forKey:@"urgencyDic"];
+}
+
+- (void)setCan_see_price:(bool)can_see_price {
+    _can_see_price = can_see_price;
+    [self setGlobalParameter:@(_can_see_price) forKey:@"can_see_price"];
+}
+
+- (void)setPrice_hidden:(bool)price_hidden {
     _price_hidden = price_hidden;
     _price_hidden = price_hidden;
+    [self setGlobalParameter:@(_price_hidden) forKey:@"price_hidden"];
     
     
     ActiveViewController* avc=(ActiveViewController*)self.active_controller;
     ActiveViewController* avc=(ActiveViewController*)self.active_controller;
     
     
-    //    NSObject* obj;
-    //    [obj isEqual:@""];
-    
     [avc showHidePrice];
     [avc showHidePrice];
+    
+}
+
+- (void)setOffline_mode:(bool)offline_mode {
+    _offline_mode = offline_mode;
+    [self setGlobalParameter:@(_offline_mode) forKey:@"offline_mode"];
+}
+
+- (void)setUser:(NSString *)user {
+    _user = user;
+    [self setGlobalParameter:_user forKey:@"user"];
+}
+
+- (void)setPassword:(NSString *)password {
+    _password = password;
+    [self setGlobalParameter:_password forKey:@"password"];
+}
+
+#pragma mark - Normal
+
+-(void) set_priceHidden:(bool)price_hidden
+{
+    [self setPrice_hidden:price_hidden];
 }
 }
 
 
 -(void) setCustomerInfo:(NSMutableDictionary*)customerInfo
 -(void) setCustomerInfo:(NSMutableDictionary*)customerInfo
@@ -789,7 +850,7 @@ void UncaughtExceptionHandler(NSException *exception) {
         
         
     }
     }
     
     
-    _urgencyDic = [NSMutableDictionary dictionary];
+    self.urgencyDic = [NSMutableDictionary dictionary];
 
 
     return resultDic;
     return resultDic;
 }
 }