@implementation AppGlobal

static NSString* strHostName;
static NSString* strVersion;
static PLSqliteDatabase* dbHelper;
static CConfigSetting* configSetting; + (BOOL) Init
{ strHostName = HTTPURLPREFIX; strVersion = @"1.01"; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *dbPath = [[paths objectAtIndex:] stringByAppendingPathComponent:@"TaxOffice.db"];
dbHelper = [[PLSqliteDatabase alloc] initWithPath:dbPath]; NSLog(@"TaxOffice.db path = %@",dbPath);
if (![DBInit initDB])
return FALSE; configSetting = [[CConfigSetting alloc] init];
return TRUE;
} + (void) DeInit
{
[dbHelper close];
[dbHelper release];
[configSetting release];
} + (NSString*) DefaultHost
{
return strHostName;
} + (NSString*) Version
{
return strVersion;
} + (PLSqliteDatabase*) DbHelper
{
return dbHelper;
} + (CConfigSetting*) ConfigSetting
{
return configSetting;
} @end
+(BOOL) initDB
{
PLSqliteDatabase* idb = [AppGlobal DbHelper]; if (![idb open]) {
return FALSE;
} // 配置信息表
if (![idb tableExists:@"Config"]) {
if (![idb executeUpdate: @"CREATE TABLE Config(key integer,value text)"])
return FALSE;
} // 客户信息表
if (![idb tableExists:@"Customers"]) {
NSString *strSql = @"CREATE TABLE Customers(id integer PRIMARY KEY autoincrement not null,"
"idno text, name text, tel text, remark text)";
if (![idb executeUpdate: strSql]) {
return FALSE;
}
} // 商品信息表
if (![idb tableExists:@"Products"]) {
NSString *strSql = @"CREATE TABLE Products(id integer PRIMARY KEY autoincrement not null,"
"idno text, name text, type integer, price real,"
"amount real, units text, remark text)";
if (![idb executeUpdate: strSql]) {
return FALSE;
}
} // return TRUE;
}

ios中Pldatabase的用法(2)的更多相关文章

  1. ios中Pldatabase的用法

    将PLDATABASE加入到工程 下载PLDatabase 的dmg文件 将PLDatabase的framework复制到工程根目录在工程中加入该framework使用该framework进行数据库操 ...

  2. ios中Pldatabase的用法(3)

    #import "ViewController.h" @interface ViewController () @property(nonatomic,retain)PLSqlit ...

  3. ios中Pldatabase的用法(4)

    封装成DAO@implementation SqlHelper +(BOOL)InsertSql:(NSString *)sql paramet:(NSMutableDictionary *)parm ...

  4. iOS中block的用法 以及和函数用法的区别

    ios中block的用法和函数的用法大致相同 但是block的用法的灵活性更高: 不带参数的block: void ^(MyBlock)() = ^{}; 调用的时候  MyBlock(); 带参数的 ...

  5. iOS中Block的用法,举例,解析与底层原理(这可能是最详细的Block解析)

    1. 前言 Block:带有自动变量(局部变量)的匿名函数.它是C语言的扩充功能.之所以是拓展,是因为C语言不允许存在这样匿名函数. 1.1 匿名函数 匿名函数是指不带函数名称函数.C语言中,函数是怎 ...

  6. ios中图片拉伸用法

    - (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCap ...

  7. iOS中的CocoaPods用法及常用命令

     CocoaPods是什么? ***CocoaPods的使用场景:*** 1. 当你开发iOS应用时,会经常使用到很多第三方开源类库,比如JSONKit,AFNetWorking等等.可能某个类库又用 ...

  8. iOS中NSScanner 的用法

    NSScanner是一个类,用于在字符串中扫描指定的字符,尤其是把它们翻译/转换为数字和别的字符串.可以创建NSScanner时制定他的String属性,然后scanner会按照你的要求从头到尾扫描这 ...

  9. IOS中NSUserDefaults的用法(轻量级本地数据存储)

    NSUserDefaults适合存储轻量级的本地数据,比如要保存一个登陆界面的数据,用户名.密码之类的,个人觉得使用NSUserDefaults是首选.下次再登陆的时候就可以直接从NSUserDefa ...

随机推荐

  1. Sharepoint2013 Report Service初探

    首先需要建立相应的report报表 如图: 这里的sql如下: SELECT PC.Name AS Category, PS.Name AS Subcategory, DATEPART(yy, SOH ...

  2. libnids

    一.简介 libnids的英文意思是 Network Intrusion Detect System library,即网络入侵监测系统函数库.它是在前面介绍的两种C函数接口库libnet和libpc ...

  3. [leetcode]Word Search @ Python

    原题地址:https://oj.leetcode.com/problems/word-search/ 题意: Given a 2D board and a word, find if the word ...

  4. IO流 简介 总结 API 案例 MD

    目录 IO 流 简介 关闭流的正确方式 关闭流的封装方法 InputStream 转 String 的方式 转换流 InputStreamReader OutputStreamWriter 测试代码 ...

  5. Ubuntu mysql开启远程登录的方法

    一.问题 Ubuntu  16.0.4   mysql5.7 二.解决问题 Ubuntu中MySQL的配置文件是在/etc/mysql/mysql.conf.d/mysqld.cnf,VI该文件把 b ...

  6. 深入理解FFM原理与实践

    原文:http://tech.meituan.com/deep-understanding-of-ffm-principles-and-practices.html 深入理解FFM原理与实践 del2 ...

  7. virtualBox导入虚拟机启动报错

    今天使用Oracle VMbox在导入虚拟机后,启动时报了如下错误: A new node couldn't be inserted because one with the same name ex ...

  8. Struts2的Action继承ActionSupport时,利用AOP来拦截Action出现NoSuchMethodException

    参考:http://zhanghua.1199.blog.163.com/blog/static/46449807201111139501298/ 做项目的时候,由于要用到在Struts2的Actio ...

  9. [Functional Programming] Using Last monoid with Maybe

    Imaging we have a deck of cards, eveytimes we need to pick one card from deck, the result we want to ...

  10. 【Python】用geopy查两经纬度间的距离

    代码: from geopy.distance import vincenty from geopy.distance import great_circle 天安门 = (39.90733345, ...