|
|
@@ -0,0 +1,103 @@
|
|
|
+//
|
|
|
+// OLDataProvider.m
|
|
|
+// iSales-NPD
|
|
|
+//
|
|
|
+// Created by Ray on 2/2/16.
|
|
|
+// Copyright © 2016 United Software Applications, Inc. All rights reserved.
|
|
|
+//
|
|
|
+
|
|
|
+#import "OLDataProvider.h"
|
|
|
+#import "iSalesDB.h"
|
|
|
+@interface OLDataProvider ()
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+@implementation OLDataProvider
|
|
|
++(NSDictionary*) get_category :(NSMutableDictionary *) params
|
|
|
+{
|
|
|
+
|
|
|
+// if(appDelegate.user!=nil)
|
|
|
+// [params setValue:appDelegate.user forKey:@"user"];
|
|
|
+// if(appDelegate.contact_id!=nil)
|
|
|
+// [params setValue:appDelegate.contact_id forKey:@"contactId"];
|
|
|
+// if(appDelegate.password!=nil)
|
|
|
+// [params setValue:appDelegate.password forKey:@"password"];
|
|
|
+// if(appDelegate.order_code!=nil)
|
|
|
+// [params setValue:appDelegate.order_code forKey:@"orderCode"];
|
|
|
+// [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
|
|
|
+// [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
|
|
|
+// [params setValue:[NSString stringWithFormat:@"%@",category] forKey:@"category"];
|
|
|
+// [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
|
|
|
+// [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
|
|
|
+// [params setValue:[NSString stringWithFormat:@"%ld",limit] forKey:@"limit"];
|
|
|
+// [params setValue:[NSString stringWithFormat:@"%ld",offset] forKey:@"offset"];
|
|
|
+// [params setValue:filter forKey:@"filter"];
|
|
|
+// [params setValue:keyword forKey:@"keyword"];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ NSString* orderCode = [params valueForKey:@"orderCode"];
|
|
|
+
|
|
|
+ NSString* category = [params valueForKey:@"category"];
|
|
|
+
|
|
|
+ int limit = [[params valueForKey:@"limit"] intValue];
|
|
|
+ int offset = [[params valueForKey:@"offset"] intValue];
|
|
|
+
|
|
|
+ NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ sqlite3 *db = [iSalesDB get_db];
|
|
|
+
|
|
|
+ int count = [iSalesDB get_recordcount:db table:@"model" where:[NSString stringWithFormat:@"category like'#%@%#'",category]];
|
|
|
+
|
|
|
+
|
|
|
+ NSString *sqlQuery = @"select m.name,m.description,m.product_id,i.name from model m LEFT join model_image i on m.product_id = i.product_id";
|
|
|
+ sqlite3_stmt * statement;
|
|
|
+// int count=0;
|
|
|
+ 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, 1);
|
|
|
+ // NSString *nsNameStr = [[NSString alloc]initWithUTF8String:name];
|
|
|
+
|
|
|
+ char *name = (char*)sqlite3_column_text(statement, 0);
|
|
|
+ NSString *nsname = [[NSString alloc]initWithUTF8String:name];
|
|
|
+
|
|
|
+ char *description = (char*)sqlite3_column_text(statement, 1);
|
|
|
+ NSString *nsdescription = [[NSString alloc]initWithUTF8String:description];
|
|
|
+
|
|
|
+
|
|
|
+// NSLog(@"product name:%@ price:%@",nsname,nsprice);
|
|
|
+
|
|
|
+ // NSData* img_data=[ApexMobileDB load_cached_img:nsname];
|
|
|
+ //
|
|
|
+ // if(img_data!=nil)
|
|
|
+ // {
|
|
|
+ //
|
|
|
+ // UIImage * img =[UIImage imageWithData:img_data];
|
|
|
+ // self.imageView.image = img;
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // char *address = (char*)sqlite3_column_text(statement, 3);
|
|
|
+ // NSString *nsAddressStr = [[NSString alloc]initWithUTF8String:address];
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ sqlite3_finalize(statement);
|
|
|
+ }
|
|
|
+ NSLog(@"count:%d",count);
|
|
|
+
|
|
|
+
|
|
|
+ sqlite3_close(db);
|
|
|
+
|
|
|
+
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+@end
|