2016-01-05 y原始数据(4)
- (void)viewDidLoad {
[super viewDidLoad];
[self DocNavbar];
[self Rightaddview];
[self Downrefresh];
self.view.backgroundColor = [UIColor whiteColor];
isbool = NO;
isEmpty=NO;
_dataSpcialMutarr=[NSMutableArray array];
imagershuju = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2-ImagerWuWidth/2, SCREEN_HEIGHT/2-ImagerWuheight/2, ImagerWuWidth, ImagerWuheight)];
imagershuju.image = [UIImage imageNamed:@"zanwushuju1"];
imagershuju.hidden = YES;
[self.view addSubview:imagershuju];
tiwuxianLab = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2-TishiLabwidth/2, CGRectGetMaxY(imagershuju.frame), TishiLabwidth, 30)];
tiwuxianLab.text = @"暂无数据";
tiwuxianLab.textAlignment = YES;
tiwuxianLab.textColor = RGB(188, 188, 188);
tiwuxianLab.hidden = YES;
tiwuxianLab.font = SYSTEMFONT(TishiLabFont);
[self.view addSubview:tiwuxianLab];
//除去下面的多余的横线
DocUserdeful = [NSUserDefaults standardUserDefaults];
//gzz2016
//1.创建数据库 指定数据库的路径
NSString *path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject]stringByAppendingPathComponent:@"DocData11.sqlite"];
_dataBaseDoc = [FMDatabase databaseWithPath:path];
NSLog(@"==path=dddddd=%@",path);
BOOL success = [_dataBaseDoc open];
if (success) {
NSLog(@"创建数据库成功!");
//2.创建表 字段 ()
// sex,state,type,uuid,positionUuid,provId,qrcode,realName,realatoinType,nation,officeName,officePhone,officeUuid,photo,hospitalUuid,intro,isStar,mobile,monthIsEnable,cityId,clinicIsEnable,countyId,email,hospitalName,birthDate,callIsEnable,certificate,certificateImg,checkInfo
//1-5 id 主键 sex = 0;(性别) state = 6;(状态) type = 1(类型); uuid = 7L08qJnuVO3AJnFXHEy(uuid);
//6-10 positionUuid = "位置uuid"; provId = 1;(省) qrcode = "二维码"; realName = "真实姓名" ;realatoinType = 1(关系);
//11-15 nation = 0(民族); officeName = "办公室名字"; officePhone = "办公室电话"; officeUuid = "办公司uuid"; photo = "expert/2015-12-31/c229790e93d1404aae65b21e43854e2c.jpg"; (头像图像)
//16-20 hospitalUuid = "医院uuid"; intro = "介绍";isStar = 0;(是否有星星) mobile = 18039678870(手机号); monthIsEnable = 0;(是否包月服务)
//21-25 cityId = 2;市 clinicIsEnable = 1; 是否包月服务 countyId = 0; (区) email = "<null>"; (邮箱)hospitalName = "<null>"(医院名字);
//26-30 birthDate = "<null>";(生日 ) callIsEnable = 1(是否开通电话服务);certificate = "<null>"(证书);
// certificateImg = "<null>"(证书图片);
// checkInfo = "<null>"(检查信息) ;
// // 删除语句 删除表中所有数据
// NSString * delete=@"delete from t_DocDetail";
// BOOL dflag= [_dataBaseDoc executeUpdate:delete];
// if(dflag){
// NSLog(@"删除成功");
// }
//[_dataBaseDoc executeUpdate:@"DROP TABLE IF EXISTS t_DocDetail;"];//删除表
////2.创建表
NSString *str = @"CREATE TABLE IF NOT EXISTS t_DocDetail(id integer PRIMARY KEY AUTOINCREMENT , sex text NOT NULL,state text NOT NULL, type text NOT NULL,uuid text NOT NULL,positionUuid text NOT NULL,provId text NOT NULL, qrcode text NOT NULL,realName text NOT NULL,realatoinType text NOT NULL,nation text NOT NULL,officeName text NOT NULL, officePhone text NOT NULL,officeUuid text NOT NULL,photo text NOT NULL,hospitalUuid text NOT NULL,intro text NOT NULL, isStar text NOT NULL,mobile text NOT NULL,monthIsEnable text NOT NULL,cityId text NOT NULL,clinicIsEnable text NOT NULL, countyId text NOT NULL,email text NOT NULL,hospitalName text NOT NULL,birthDate text NOT NULL,callIsEnable text NOT NULL, certificate text NOT NULL,certificateImg text NOT NULL,checkInfo text NOT NULL,_id text NOT NULL);";
if ([_dataBaseDoc executeUpdate:str]) {
NSLog(@"表创建成功!");
}else{
NSLog(@"创建表失败!");
}
}else{
NSLog(@"创建数据库失败!");
}
[self selectDoc];
}
//保存到数据库数据
-(void)saveDataDoc{
// 删除语句
NSString * delete=@"delete from t_DocDetail";
BOOL dflag= [_dataBaseDoc executeUpdate:delete];
if(dflag){
NSLog(@"删除成功");
}
for (int i=0; i<_SpecialistMutarr.count; i++) {
// sex,state,type,uuid,positionUuid,provId,qrcode,realName,realatoinType,nation,officeName,officePhone,officeUuid,photo,hospitalUuid,intro,isStar,mobile,monthIsEnable,cityId,clinicIsEnable,countyId,email,hospitalName,birthDate,callIsEnable,certificate,certificateImg,checkInfo
NSString *callIsEnable=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"callIsEnable"]];
NSString *certificate=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"certificate"]];
NSString *certificateImg=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"certificateImg"]];
NSString *checkInfo=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"checkInfo"]];
NSString *cityId=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"cityId"]];
NSString *clinicIsEnable=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"clinicIsEnable"]];
NSString *countyId=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"countyId"]];
NSString *email=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"email"]];
NSLog(@"email ===%@",email);
NSString *hospitalName=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"hospitalName"]];
NSString *hospitalUuid=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"hospitalUuid"]];
NSString *intro=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"intro"]];
NSString *isStar=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"isStar"]];
NSString *mobile=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"mobile"]];
NSString *monthIsEnable=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"monthIsEnable"]];
NSString *nation=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"nation"]];
NSString *officeName=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"officeName"]];
NSString *officePhone=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"officePhone"]];
NSString *officeUuid=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"officeUuid"]];
NSString *photo=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"photo"]];
NSString *positionUuid=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"positionUuid"]];
NSString *provId=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"provId"]];
NSString *qrcode=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"qrcode"]];
NSString *realName=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"realName"]];
NSString *realatoinType=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"realatoinType"]];
NSString *sex=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"sex"]];
NSString *birthDate=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"birthDate"]];
NSString *state=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"state"]];
NSString *type=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"type"]];
NSString *uuid=[NSString stringWithFormat:@"%@",[[_SpecialistMutarr objectAtIndex:i] objectForKey:@"uuid"]];
NSString *IDD=[NSString stringWithFormat:@"%zd",(i+1)];
//
BOOL success = [_dataBaseDoc executeUpdate:@"INSERT INTO t_DocDetail(sex,state,type,uuid,positionUuid,provId,qrcode,realName,realatoinType,nation,officeName,officePhone,officeUuid,photo,hospitalUuid,intro,isStar,mobile,monthIsEnable,cityId,clinicIsEnable,countyId,email,hospitalName,birthDate,callIsEnable,certificate,certificateImg,checkInfo,_id) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);",sex,state,type,uuid,positionUuid,provId,qrcode,realName,realatoinType,nation,officeName,officePhone,officeUuid,photo,hospitalUuid,intro,isStar,mobile,monthIsEnable,cityId,clinicIsEnable,countyId,email,hospitalName,birthDate,callIsEnable,certificate,certificateImg,checkInfo,IDD];
if (success) {
// NSLog(@"添加成功!");
}else{
NSLog(@"添加失败!");
}
}
[self selectDoc];
}
-(void)selectDoc{
if (isEmpty) {
[_dataSpcialMutarr removeAllObjects];
NSInteger count=_SpecialistMutarr.count;
for (int i=1; i<count+1; i++) {
NSString *sql = [NSString stringWithFormat:@"SELECT * FROM t_DocDetail where _id='%zd';",i];
//查询语句 执行的方法
FMResultSet *set = [_dataBaseDoc executeQuery:sql];
while ([set next]) {
NSString *sex=[set stringForColumn:@"sex"];
NSString *state=[set stringForColumn:@"state"];
NSString *type=[set stringForColumn:@"type"];
NSString *uuid=[set stringForColumn:@"uuid"];
NSString *positionUuid=[set stringForColumn:@"positionUuid"];
NSString *provId=[set stringForColumn:@"provId"];
NSString *qrcode=[set stringForColumn:@"qrcode"];
NSString *realName=[set stringForColumn:@"realName"];
NSString *realatoinType=[set stringForColumn:@"realatoinType"];
NSString *nation=[set stringForColumn:@"nation"];
NSString *officeName=[set stringForColumn:@"officeName"];
NSString *officePhone=[set stringForColumn:@"officePhone"];
NSString *officeUuid=[set stringForColumn:@"officeUuid"];
NSString *photo=[set stringForColumn:@"photo"];
NSString *hospitalUuid=[set stringForColumn:@"hospitalUuid"];
NSString *intro=[set stringForColumn:@"intro"];
NSString *isStar=[set stringForColumn:@"isStar"];
NSString *mobile=[set stringForColumn:@"mobile"];
NSString *monthIsEnable=[set stringForColumn:@"monthIsEnable"];
NSString *cityId=[set stringForColumn:@"cityId"];
NSString *clinicIsEnable=[set stringForColumn:@"clinicIsEnable"];
NSString *countyId=[set stringForColumn:@"countyId"];
NSString *email=[set stringForColumn:@"email"];
NSLog(@"emial --set-%@",email);
NSString *hospitalName=[set stringForColumn:@"hospitalName"];
NSString *birthDate=[set stringForColumn:@"birthDate"];
NSString *callIsEnable=[set stringForColumn:@"callIsEnable"];
NSString *certificate=[set stringForColumn:@"certificate"];
NSString *certificateImg=[set stringForColumn:@"certificateImg"];
NSString *checkInfo=[set stringForColumn:@"checkInfo"];
NSMutableDictionary *dic0 = [NSMutableDictionary dictionaryWithObjectsAndKeys:sex,@"sex",state,@"state",type,@"type",uuid,@"uuid",positionUuid,@"positionUuid",provId,@"provId",qrcode,@"qrcode",realName,@"realName",realatoinType,@"realatoinType",nation,@"nation",officeName,@"officeName",officePhone,@"officePhone",officeUuid,@"officeUuid",photo,@"photo",hospitalUuid,@"hospitalUuid",intro,@"intro",isStar,@"isStar",mobile,@"mobile",monthIsEnable,@"monthIsEnable",cityId,@"cityId",clinicIsEnable,@"clinicIsEnable",countyId,@"countyId",email,@"email",hospitalName,@"hospitalName",birthDate,@"birthDate",callIsEnable,@"callIsEnable",certificate,@"certificate",certificateImg,@"certificateImg",checkInfo,@"checkInfo",nil];
[_dataSpcialMutarr addObject:dic0];
NSLog(@"data ==%zd success",i);
}
}
}else{
// NSString *sql = [NSString stringWithFormat:@"SELECT * FROM t_DocDetail where _id='%zd';",i];
NSString *sql = [NSString stringWithFormat:@"SELECT * FROM t_DocDetail "];
//查询语句 执行的方法
FMResultSet *set = [_dataBaseDoc executeQuery:sql];
while ([set next]) {
NSString *sex=[set stringForColumn:@"sex"];
NSString *state=[set stringForColumn:@"state"];
NSString *type=[set stringForColumn:@"type"];
NSString *uuid=[set stringForColumn:@"uuid"];
NSString *positionUuid=[set stringForColumn:@"positionUuid"];
NSString *provId=[set stringForColumn:@"provId"];
NSString *qrcode=[set stringForColumn:@"qrcode"];
NSString *realName=[set stringForColumn:@"realName"];
NSString *realatoinType=[set stringForColumn:@"realatoinType"];
NSString *nation=[set stringForColumn:@"nation"];
NSString *officeName=[set stringForColumn:@"officeName"];
NSString *officePhone=[set stringForColumn:@"officePhone"];
NSString *officeUuid=[set stringForColumn:@"officeUuid"];
NSString *photo=[set stringForColumn:@"photo"];
NSString *hospitalUuid=[set stringForColumn:@"hospitalUuid"];
NSString *intro=[set stringForColumn:@"intro"];
NSString *isStar=[set stringForColumn:@"isStar"];
NSString *mobile=[set stringForColumn:@"mobile"];
NSString *monthIsEnable=[set stringForColumn:@"monthIsEnable"];
NSString *cityId=[set stringForColumn:@"cityId"];
NSString *clinicIsEnable=[set stringForColumn:@"clinicIsEnable"];
NSString *countyId=[set stringForColumn:@"countyId"];
NSString *email=[set stringForColumn:@"email"];
NSLog(@"emial --set-%@",email);
NSString *hospitalName=[set stringForColumn:@"hospitalName"];
NSString *birthDate=[set stringForColumn:@"birthDate"];
NSString *callIsEnable=[set stringForColumn:@"callIsEnable"];
NSString *certificate=[set stringForColumn:@"certificate"];
NSString *certificateImg=[set stringForColumn:@"certificateImg"];
NSString *checkInfo=[set stringForColumn:@"checkInfo"];
NSMutableDictionary *dic0 = [NSMutableDictionary dictionaryWithObjectsAndKeys:sex,@"sex",state,@"state",type,@"type",uuid,@"uuid",positionUuid,@"positionUuid",provId,@"provId",qrcode,@"qrcode",realName,@"realName",realatoinType,@"realatoinType",nation,@"nation",officeName,@"officeName",officePhone,@"officePhone",officeUuid,@"officeUuid",photo,@"photo",hospitalUuid,@"hospitalUuid",intro,@"intro",isStar,@"isStar",mobile,@"mobile",monthIsEnable,@"monthIsEnable",cityId,@"cityId",clinicIsEnable,@"clinicIsEnable",countyId,@"countyId",email,@"email",hospitalName,@"hospitalName",birthDate,@"birthDate",callIsEnable,@"callIsEnable",certificate,@"certificate",certificateImg,@"certificateImg",checkInfo,@"checkInfo",nil];
[_dataSpcialMutarr addObject:dic0];
NSLog(@"first come in or failed in get request");
}
_SpecialistMutarr=_dataSpcialMutarr;
[self.tableView reloadData];
}
}