فهرست منبع

修改表Portfolio和表PDF的增删改查。

Pen Li 9 سال پیش
والد
کامیت
ed07996fc4

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


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

@@ -9973,11 +9973,11 @@
     NSString *orderBy = @"";
     switch (sort) {
         case 0:{
-            orderBy = @"modifytime desc";
+            orderBy = @"modify_time desc";
         }
             break;
         case 1:{
-            orderBy = @"modifytime asc";
+            orderBy = @"modify_time asc";
         }
             break;
         case 2:{
@@ -9998,7 +9998,7 @@
     }
     
     
-    NSString *sql = [NSString stringWithFormat:@"select p.product_id,p.name,p.description,ifnull(p.sheet_price,'null'),p.sheet_discount,ifnull(p.available_qty,'null'),p.percentage,p.item_id,p.fashion_id,i.url,p.line_note,p.percent from offline_portfolio as p left join model_image as i on i.product_id = p.product_id where i.type = 1  group by  p.product_id order by %@ limit %d offset %d;",orderBy,limit,offset];
+    NSString *sql = [NSString stringWithFormat:@"select p.product_id,p.name,p.description,ifnull(p.sheet_price,'null'),p.sheet_discount,ifnull(p.available_qty,'null'),p.percentage,p.item_id,p.fashion_id,i.url,p.line_note,p.percent from offline_portfolio as p left join model_image as i on i.product_id = p.product_id where i.type = 1 and (p.is_delete is null or  p.is_delete = 0) group by  p.product_id order by %@ limit %d offset %d;",orderBy,limit,offset];
     
     __block NSMutableDictionary *dic = [NSMutableDictionary dictionary];
     
@@ -10212,7 +10212,7 @@
         [resultDictionary setObject:[NSNumber numberWithInt:RESULT_FALSE] forKey:@"result"];
         return [RAUtils dict2data:resultDictionary];
     }
-    pdf_path = newPath;
+    pdf_path = [newPath lastPathComponent];
     
     // 保存信息
     
@@ -10239,11 +10239,11 @@
     int limit = [[params valueForKey:@"limit"] integerValue];
     NSString *keyword = [params valueForKey:@"keyWord"];
     
-    NSString *where = @"";
+    NSString *where = @"where is_delete is null or is_delete = 0";
     
     if (keyword.length) {
         keyword = [self translateSingleQuote:keyword];
-        where = [NSString stringWithFormat:@"where lower(create_user) like '%%%@%%' or lower(tear_note) like '%%%@%%'  or lower(tear_name) like '%%%@%%'",keyword.lowercaseString,keyword.lowercaseString,keyword.lowercaseString];
+        where = [NSString stringWithFormat:@"where (is_delete is null or is_delete = 0 ) and lower(create_user) like '%%%@%%' or lower(tear_note) like '%%%@%%'  or lower(tear_name) like '%%%@%%'",keyword.lowercaseString,keyword.lowercaseString,keyword.lowercaseString];
     }
     
     NSString *sql = [NSString stringWithFormat:@"select tear_name,tear_note,createtime,create_user,pdf_path,tearsheets_id from offline_pdf %@ order by createtime desc limit %d offset %d;",where,limit,offset];
@@ -10293,7 +10293,7 @@
     
     NSString *prodct_ids = [params objectForKey:@"product_id"];
 //    NSString *user = [params objectForKey:@"user"];
-    NSString *sql = [NSString stringWithFormat:@"insert into offline_portfolio (product_id,name,description,item_id,img) select * from (select p.product_id,p.name,p.description,p.item_id,i.url from product as p left join model_image as i on i.product_id = p.product_id  where p.product_id in (%@) and p.product_id not in (select product_id from offline_portfolio) and i.type = 1  group by  p.product_id order by i.default_img desc, i._id asc );",prodct_ids];
+    NSString *sql = [NSString stringWithFormat:@"insert into offline_portfolio (product_id,name,description,item_id,img) select * from (select p.product_id,p.name,p.description,p.item_id,i.url from product as p left join model_image as i on i.product_id = p.product_id  where p.product_id in (%@) and p.product_id not in (select product_id from offline_portfolio) and i.type = 1 group by  p.product_id order by i.default_img desc, i._id asc );insert into offline_portfolio (product_id,name,description,item_id,img,is_delete) select * from (select p.product_id,p.name,p.description,p.item_id,i.url,0 from product as p left join model_image as i on i.product_id = p.product_id  where p.product_id in (%@) and p.product_id in (select product_id from offline_portfolio where is_delete = 1) and i.type = 1 and (select count(0) from offline_portfolio where product_id = p.product_id) = 1 group by  p.product_id order by i.default_img desc, i._id asc );delete from offline_portfolio where (select count(0) from offline_portfolio where product_id in (%@)) > 1 and is_delete = 1;",prodct_ids,prodct_ids,prodct_ids];
     
     int result = [iSalesDB execSql:sql];
     
@@ -10445,14 +10445,14 @@
     
     sqlite3 *db = [iSalesDB get_db];
     
-    NSString *sql = [NSString stringWithFormat:@"delete from offline_portfolio where item_id in (%@);",portfolio_ids];
+    NSString *sql = [NSString stringWithFormat:@"update offline_portfolio set is_delete = 1 where item_id in (%@);",portfolio_ids];
     
     int result = [iSalesDB execSql:sql db:db];
     
     [dic setObject:[NSNumber numberWithInt:result] forKey:@"result"];
     [dic setObject:@"Regular Mode" forKey:@"mode"];
     
-    int count = [iSalesDB get_recordcount:db table:@"offline_portfolio" where:@"1=1"];
+    int count = [iSalesDB get_recordcount:db table:@"offline_portfolio" where:@"(is_delete is null or  is_delete = 0)"];
     
     [dic setObject:[NSNumber numberWithInt:count] forKey:@"portfolio_count"];
     
@@ -10477,7 +10477,7 @@
         return [RAUtils dict2data:dic];
     }
     
-    NSString *sql = [NSString stringWithFormat:@"delete from offline_pdf where tearsheets_id = %d and create_user = '%@';",tearsheetsId,[self translateSingleQuote:user]];
+    NSString *sql = [NSString stringWithFormat:@"update offline_pdf set is_delete = 1 where tearsheets_id = %d and create_user = '%@';",tearsheetsId,[self translateSingleQuote:user]];
     
     
     int result = [iSalesDB execSql:sql];

+ 2 - 2
RedAnt ERP Mobile/common/data_provider/iSalesDB.m

@@ -722,9 +722,9 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
     NSString* create_offline_salesrep=@"CREATE TABLE IF NOT EXISTS offline_salesrep ( _id INTEGER PRIMARY KEY, name text, code text,salesrep_id integer);";
     
     
-    NSString *create_offline_portfolio = @"CREATE TABLE IF NOT EXISTS offline_portfolio (_id integer PRIMARY KEY,product_id integer,name text,description tex,item_id integer,fashion_id integer,available_qty integer,percentage integer,percent double,sheet_price double,sheet_discount double,img text,line_note text,is_delete integer,is_dirty integer,createtime timestamp DEFAULT(datetime('now','localtime')),modifytime timestamp DEFAULT(datetime('now','localtime')));";
+    NSString *create_offline_portfolio = @"CREATE TABLE IF NOT EXISTS offline_portfolio (_id integer PRIMARY KEY,product_id integer,name text,description tex,item_id integer,fashion_id integer,available_qty integer,percentage integer,percent double,sheet_price double,sheet_discount double,img text,line_note text,is_delete integer,is_dirty integer,createtime timestamp DEFAULT(datetime('now','localtime')),modify_time timestamp DEFAULT(datetime('now','localtime')));";
     
-    NSString *create_offline_pdf = @"create table if not exists offline_pdf (_id integer primary key,tearsheets_id integer,pdf_path text,create_user text,tear_note text,tear_name text,model_info text,configureParams text,is_dirty integer,createtime timestamp default(datetime('now','localtime')));";
+    NSString *create_offline_pdf = @"create table if not exists offline_pdf (_id integer primary key,tearsheets_id integer,pdf_path text,create_user text,tear_note text,tear_name text,model_info text,configureParams text,is_delete integer,is_dirty integer,createtime timestamp default(datetime('now','localtime')),modify_time timestamp DEFAULT(datetime('now','localtime')));";
     
     
     NSString* create_order_trigger=@"CREATE TRIGGER  if not exists offline_order_insert after insert on offline_order BEGIN select offline_dirty();  UPDATE offline_order SET modify_time= datetime('now', 'localtime') WHERE _id=new._id;END;CREATE TRIGGER  if not exists offline_order_update after update on offline_order BEGIN select offline_dirty();  UPDATE offline_order SET modify_time= datetime('now', 'localtime') WHERE _id=new._id;END;CREATE TRIGGER  if not exists offline_order_delete after delete on offline_order BEGIN select offline_dirty();  END;";