Commit cca20747 authored by 陈俊俊's avatar 陈俊俊

本地存储

parent 482c9ee6
......@@ -65,6 +65,9 @@
7217E9F31B72364300FE5C1D /* SurveyCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 7217E9E11B72364300FE5C1D /* SurveyCell.m */; };
7217E9F41B72364300FE5C1D /* SurveyListCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 7217E9E31B72364300FE5C1D /* SurveyListCell.m */; };
7217E9F61B724A7600FE5C1D /* mask.png in Resources */ = {isa = PBXBuildFile; fileRef = 7217E9F51B724A7600FE5C1D /* mask.png */; };
72C8034C1B7B72DB00990363 /* AddWorkSheetViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 72C8034B1B7B72DB00990363 /* AddWorkSheetViewController.m */; };
72C8034F1B7B735300990363 /* TopSheetView.m in Sources */ = {isa = PBXBuildFile; fileRef = 72C8034E1B7B735300990363 /* TopSheetView.m */; };
72C803521B7B897B00990363 /* DataManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 72C803511B7B897B00990363 /* DataManager.m */; };
72F56CB21B76EC200077F0C9 /* SurveyUser.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F56CB11B76EC200077F0C9 /* SurveyUser.m */; };
871F9F047CDDAC523E4358DC /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 86D33EC280C440156ED1B976 /* libPods.a */; };
C10214CD1AD8FE200024637E /* ICRStoreDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C10214CC1AD8FE200024637E /* ICRStoreDetailViewController.m */; };
......@@ -439,6 +442,12 @@
7217E9E21B72364300FE5C1D /* SurveyListCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SurveyListCell.h; sourceTree = "<group>"; };
7217E9E31B72364300FE5C1D /* SurveyListCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SurveyListCell.m; sourceTree = "<group>"; };
7217E9F51B724A7600FE5C1D /* mask.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = mask.png; sourceTree = "<group>"; };
72C8034A1B7B72DB00990363 /* AddWorkSheetViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AddWorkSheetViewController.h; sourceTree = "<group>"; };
72C8034B1B7B72DB00990363 /* AddWorkSheetViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AddWorkSheetViewController.m; sourceTree = "<group>"; };
72C8034D1B7B735300990363 /* TopSheetView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopSheetView.h; sourceTree = "<group>"; };
72C8034E1B7B735300990363 /* TopSheetView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopSheetView.m; sourceTree = "<group>"; };
72C803501B7B897B00990363 /* DataManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataManager.h; sourceTree = "<group>"; };
72C803511B7B897B00990363 /* DataManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DataManager.m; sourceTree = "<group>"; };
72F56CB01B76EC200077F0C9 /* SurveyUser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SurveyUser.h; sourceTree = "<group>"; };
72F56CB11B76EC200077F0C9 /* SurveyUser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SurveyUser.m; sourceTree = "<group>"; };
7DDFB1D460448C3B45118195 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; };
......@@ -788,14 +797,14 @@
7217E9C01B72364300FE5C1D /* Survey */ = {
isa = PBXGroup;
children = (
7217E9C11B72364300FE5C1D /* controllers */,
7217E9C81B72364300FE5C1D /* models */,
7217E9C11B72364300FE5C1D /* Controllers */,
7217E9C81B72364300FE5C1D /* Models */,
7217E9CF1B72364300FE5C1D /* Views */,
);
path = Survey;
sourceTree = "<group>";
};
7217E9C11B72364300FE5C1D /* controllers */ = {
7217E9C11B72364300FE5C1D /* Controllers */ = {
isa = PBXGroup;
children = (
7217E9C41B72364300FE5C1D /* NewSurveyViewController.h */,
......@@ -811,10 +820,11 @@
FE2FCC861B7492C500BBC6FB /* ResultDetailViewController.h */,
FE2FCC871B7492C500BBC6FB /* ResultDetailViewController.m */,
);
name = Controllers;
path = controllers;
sourceTree = "<group>";
};
7217E9C81B72364300FE5C1D /* models */ = {
7217E9C81B72364300FE5C1D /* Models */ = {
isa = PBXGroup;
children = (
7217E9C91B72364300FE5C1D /* Attachment.h */,
......@@ -828,6 +838,7 @@
FE7155D71B7B328400595B0A /* Product.h */,
FE7155D81B7B328400595B0A /* Product.m */,
);
name = Models;
path = models;
sourceTree = "<group>";
};
......@@ -873,6 +884,45 @@
path = GrowingTextView;
sourceTree = "<group>";
};
72C803431B7B6F0200990363 /* WorkSheet */ = {
isa = PBXGroup;
children = (
72C803471B7B728700990363 /* Controllers */,
72C803481B7B728700990363 /* Models */,
72C803491B7B728700990363 /* Views */,
);
name = WorkSheet;
path = Worksheet;
sourceTree = "<group>";
};
72C803471B7B728700990363 /* Controllers */ = {
isa = PBXGroup;
children = (
72C8034A1B7B72DB00990363 /* AddWorkSheetViewController.h */,
72C8034B1B7B72DB00990363 /* AddWorkSheetViewController.m */,
);
name = Controllers;
path = XFFruit/ViewControllers/WorkSheet/Controllers;
sourceTree = SOURCE_ROOT;
};
72C803481B7B728700990363 /* Models */ = {
isa = PBXGroup;
children = (
);
name = Models;
path = XFFruit/ViewControllers/WorkSheet/Models;
sourceTree = SOURCE_ROOT;
};
72C803491B7B728700990363 /* Views */ = {
isa = PBXGroup;
children = (
72C8034D1B7B735300990363 /* TopSheetView.h */,
72C8034E1B7B735300990363 /* TopSheetView.m */,
);
name = Views;
path = XFFruit/ViewControllers/WorkSheet/Views;
sourceTree = SOURCE_ROOT;
};
8CDB3C30A601E08F91ED44F8 /* Frameworks */ = {
isa = PBXGroup;
children = (
......@@ -1328,6 +1378,8 @@
C15039201ADE39190081A686 /* IBTUIControl.h */,
C15039211ADE39190081A686 /* IBTUIControl.m */,
C123A8F51B254348003C0C36 /* IBTInputViewHandleDelegate.h */,
72C803501B7B897B00990363 /* DataManager.h */,
72C803511B7B897B00990363 /* DataManager.m */,
);
path = IBTUIKit;
sourceTree = "<group>";
......@@ -1508,6 +1560,7 @@
C1C6FEED1AB88A3400D4C41A /* ViewControllers */ = {
isa = PBXGroup;
children = (
72C803431B7B6F0200990363 /* WorkSheet */,
7217E9C01B72364300FE5C1D /* Survey */,
C159180B1ABE88030013B391 /* Login */,
C159185D1AC078020013B391 /* Home */,
......@@ -1915,6 +1968,7 @@
C1FE50501AE024FA00C18080 /* UIActionSheet+Blocks.m in Sources */,
C123A92B1B26EDDA003C0C36 /* ICRQuestionHelperView.m in Sources */,
7217E9EB1B72364300FE5C1D /* HPGrowingTextView.m in Sources */,
72C803521B7B897B00990363 /* DataManager.m in Sources */,
C1C5643E1AD62BD8006A1050 /* ICRPlaceholderTextView.m in Sources */,
307059D21AF2211300E9DB8E /* ICRSyncCellContentView.m in Sources */,
C1374F581B33C40D00594D19 /* IBTWebViewController.m in Sources */,
......@@ -1965,6 +2019,7 @@
7217E9EE1B72364300FE5C1D /* MaskCell.m in Sources */,
C15918671AC19FCF0013B391 /* ICRStoreViewController.m in Sources */,
C1FBC1291ACA9651007B1A44 /* ICRHTTPApiTestViewController.m in Sources */,
72C8034C1B7B72DB00990363 /* AddWorkSheetViewController.m in Sources */,
C1D017231AD8F41400CD9CB8 /* IBTRefreshTableView.m in Sources */,
C15295BF1B24511F00DF60D1 /* ICRQStoreStudyViewController.m in Sources */,
30D749551ACE421A00C63BA1 /* IBTUITextField.m in Sources */,
......@@ -2015,6 +2070,7 @@
C1FE503D1AE0235D00C18080 /* IBTAudioServicesManager.m in Sources */,
7217E9F41B72364300FE5C1D /* SurveyListCell.m in Sources */,
C10214D21AD904F30024637E /* ICRPatrolPlanViewController.m in Sources */,
72C8034F1B7B735300990363 /* TopSheetView.m in Sources */,
C1E108591ADA53C700620375 /* ICRTaskResultViewController.m in Sources */,
FEAE16EF1B79CAE3009D9E01 /* SingleScrollView.m in Sources */,
C10C909D1AE56E8700B911CD /* JTOptionsViewController.m in Sources */,
......
//
// DataManager.h
// XFFruit
//
// Created by 陈俊俊 on 15/8/12.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface DataManager : NSObject
//非标准单例
+ (DataManager *)sharedDatabaseManager;
- (void)createDB;
@end
//
// DataManager.m
// XFFruit
//
// Created by 陈俊俊 on 15/8/12.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "DataManager.h"
#import "FMDatabase.h"
@implementation DataManager
{
FMDatabase *_database;
}
//非标准单例
+ (DataManager *)sharedDatabaseManager{
static DataManager *manager = nil;
@synchronized(self){
if (manager == nil) {
manager = [[self alloc] init];
}
}
return manager;
}
- (void)createDB
{
//先获取app.db在沙盒中的路径
NSString *path = [self getFullDatabasePathFromFileName:@"kitchen.db"];
//创建数据库对象
_database = [[FMDatabase alloc] initWithPath:path];
//打开数据库
if ([_database open]) {//第一次打开如果没有那么就创建并打开 如果有直接打开
//打开成功 那么就创建表
[self creatTable];
}else{
NSLog(@"open database:%@",[_database lastErrorMessage]);
}
}
#pragma mark - 获取数据库文件的全路径
- (NSString *)getFullDatabasePathFromFileName:(NSString *)name{
//文件夹路径
NSString * userFolderPath=[NSString stringWithFormat:@"%@/Documents",NSHomeDirectory()];
//库文件路径
NSString * chatDBPath=[userFolderPath stringByAppendingFormat:@"/%@",name];
//文件管理单例
NSFileManager * fileManager=[NSFileManager defaultManager];
//如果文件夹不存在,则创建文件夹
if (![fileManager fileExistsAtPath:userFolderPath]) {
[fileManager createDirectoryAtPath:userFolderPath withIntermediateDirectories:YES attributes:nil error:nil];
[fileManager createFileAtPath:chatDBPath contents:nil attributes:nil];
}
return chatDBPath;
}
- (void)creatTable{
NSArray *arr = @[@"CREATE TABLE IF NOT EXISTS kitchen(serial integer PRIMARY KEY AUTOINCREMENT,foreign_id Varchar(1024),type Varchar(1024),title Varchar(1024),create_time Varchar(1024),name Varchar(1024),image Varchar(1024))",@"CREATE TABLE IF NOT EXISTS menu(serial integer PRIMARY KEY AUTOINCREMENT,id Varchar(1024),sUrl Varchar(1024),title Varchar(1024),works Varchar(1024),favourite Varchar(1024),view Varchar(1024),url Varchar(1024))",@"CREATE TABLE IF NOT EXISTS fresh(serial integer PRIMARY KEY AUTOINCREMENT,id Varchar(1024),title Varchar(1024),url Varchar(1024),time Varchar(1024),desp Varchar(1024))"];
//遍历数组创建表
for (NSString *sql in arr) {
BOOL isSeccess = [_database executeUpdate:sql];
if (!isSeccess) {
NSLog(@"create table failed%@",[_database lastErrorMessage]);
}
}
}
@end
......@@ -24,7 +24,7 @@
#import "NewSurveyViewController.h"
#import "SurveyViewController.h"
#import "AddWorkSheetViewController.h"
@interface ICRHomeViewController ()
<
......@@ -143,9 +143,11 @@
break;
case kFunctionMyShop:
{
ICRStoreListViewController *sVC = [[ICRStoreListViewController alloc] initWithBHaveToChooseOne:NO];
sVC.title = [IBTCommon localizableString:@"MyStore"];
sVC.m_delegate = self;
// ICRStoreListViewController *sVC = [[ICRStoreListViewController alloc] initWithBHaveToChooseOne:NO];
// sVC.title = [IBTCommon localizableString:@"MyStore"];
// sVC.m_delegate = self;
// [self PushViewController:sVC animated:YES];
AddWorkSheetViewController *sVC = [[AddWorkSheetViewController alloc] init];
[self PushViewController:sVC animated:YES];
}
break;
......
......@@ -61,7 +61,7 @@ typedef enum : NSUInteger {
[IBTLoadingView hideHUDWithText:nil];
[IBTLoadingView showTips:data];
};
[IBTLoadingView showProgressLabel:@"正在保存..."];
[IBTLoadingView showProgressLabel:@"正在加载..."];
[[ICRHTTPController sharedController] querySurveyWithBillNUmberLinke:@"fdsfds" state:@"initial" titleLike:@"fds" orderFiled:@"fdsafds" orderDirection:@"asc" page_number:0 page_size:100 success:succ failure:fail];
// [[ICRHTTPController sharedController] getResultsWithSurveyUuid:@"111" success:succ failure:fail];
......
//
// AddWorkSheetViewController.h
// XFFruit
//
// Created by 陈俊俊 on 15/8/12.
// Copyright (c) 2015年 Xummer. All rights reserved.
// 新建加工单
#import "ICRBaseViewController.h"
@interface AddWorkSheetViewController : ICRBaseViewController
@end
//
// AddWorkSheetViewController.m
// XFFruit
//
// Created by 陈俊俊 on 15/8/12.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "AddWorkSheetViewController.h"
#import "TopSheetView.h"
#define TopHeight 200
@interface AddWorkSheetViewController ()<TopSheetViewDelegate>
{
TopSheetView *_sheetView;
}
@end
@implementation AddWorkSheetViewController
- (void)viewDidLoad {
[super viewDidLoad];
//布局
[self bulidLayout];
}
- (void)bulidLayout{
_sheetView = [[TopSheetView alloc]initWithFrame:CGRectMake(0, 0, ScreenSize.width, TopHeight)];
_sheetView.delegate = self;
[self.view addSubview:_sheetView];
}
#pragma mark - 协议方法
- (void)hiddenKeyBoard{
[self keyboardHidden];
}
- (void)keyboardHidden{
[_sheetView.titleTextFiled resignFirstResponder];
[_sheetView.peopleTextFiled resignFirstResponder];
[_sheetView.peopleTextFiled resignFirstResponder];
[_sheetView.phoneTextFiled resignFirstResponder];
[_sheetView.remarkTextView resignFirstResponder];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
//
// TopSheetView.h
// XFFruit
//
// Created by 陈俊俊 on 15/8/12.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "HPGrowingTextView.h"
@protocol TopSheetViewDelegate <NSObject>
- (void)hiddenKeyBoard;
@end
@interface TopSheetView : UIView
@property (nonatomic,strong)UITextField *titleTextFiled;//标题
@property (nonatomic,strong)NSString *supplier;//供应商
@property (nonatomic,strong)UITextField *peopleTextFiled;//联系人
@property (nonatomic,strong)UITextField *phoneTextFiled;//电话
@property (nonatomic,strong)NSString *factory;//标题
@property (nonatomic,strong)HPGrowingTextView *remarkTextView;//标题
@property (nonatomic,strong)UIButton *factoryBtn;
@property (nonatomic,strong)UIButton *supplierBtn;
@property (nonatomic,strong)UILabel *factoryLabel;
@property (nonatomic,strong)UILabel *supplierLabel;
@property (nonatomic,weak)id <TopSheetViewDelegate>delegate;
@end
//
// TopSheetView.m
// XFFruit
//
// Created by 陈俊俊 on 15/8/12.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "TopSheetView.h"
#define LeftMargin 15
#define TopMargin 10
#define LeftWidth 80
#define ContentHeight 25
#define SpaceHeight 10
@interface TopSheetView ()<UITextFieldDelegate,HPGrowingTextViewDelegate>
@end
@implementation TopSheetView
- (instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
//界面
[self bulidLayout];
}
return self;
}
#pragma mark - 布局
- (void)bulidLayout
{
NSArray *arr = @[@"标题:",@"供应商:",@"联系人:",@"联系电话:",@"加工工厂:",@"备注:"];
for (NSInteger i = 0; i < arr.count; i++) {
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(LeftMargin, TopMargin + (ContentHeight + SpaceHeight)*i, LeftWidth, ContentHeight)];
label.text = arr[i];
label.font = FontSize(17);
[self addSubview:label];
if (i == 0) {
self.titleTextFiled = [self getTextFileWithFrame:CGRectMake(LeftWidth+LeftMargin, TopMargin + (ContentHeight + SpaceHeight)*i, self.frame.size.width - LeftMargin*2-LeftWidth, ContentHeight) title:@"请输入标题"];
}else if (i == 1){
self.supplierBtn = [UIButton buttonWithType:UIButtonTypeCustom];
self.supplierBtn.frame = CGRectMake(LeftWidth+LeftMargin, TopMargin + (ContentHeight + SpaceHeight)*i, self.frame.size.width - LeftMargin*2-LeftWidth, ContentHeight);
[self addSubview:self.supplierBtn];
self.supplierLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width - LeftMargin*4-LeftWidth, ContentHeight)];
self.supplierLabel.font = FontSize(15);
self.supplierLabel.backgroundColor = [UIColor redColor];
[self.supplierBtn addSubview:self.supplierLabel];
}else if (i == 2){
self.peopleTextFiled = [self getTextFileWithFrame:CGRectMake(LeftWidth+LeftMargin, TopMargin + (ContentHeight + SpaceHeight)*i, self.frame.size.width - LeftMargin*2-LeftWidth, ContentHeight) title:@"请输入联系人"];
}else if (i == 3){
self.phoneTextFiled = [self getTextFileWithFrame:CGRectMake(LeftWidth+LeftMargin, TopMargin + (ContentHeight + SpaceHeight)*i, self.frame.size.width - LeftMargin*2-LeftWidth, ContentHeight) title:@"请输入联系电话"];
}else if (i == 4){
self.factoryBtn = [UIButton buttonWithType:UIButtonTypeCustom];
self.factoryBtn.frame = CGRectMake(LeftWidth+LeftMargin, TopMargin + (ContentHeight + SpaceHeight)*i, self.frame.size.width - LeftMargin*2-LeftWidth, ContentHeight);
[self addSubview:self.factoryBtn];
self.factoryLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width - LeftMargin*4-LeftWidth, ContentHeight)];
self.factoryLabel.font = FontSize(15);
self.factoryLabel.backgroundColor = [UIColor redColor];
[self.factoryBtn addSubview:self.factoryLabel];
}else if (i == 5){
self.remarkTextView = [[HPGrowingTextView alloc] initWithFrame:CGRectMake(LeftWidth+LeftMargin, TopMargin + (ContentHeight + SpaceHeight)*i, self.frame.size.width - LeftMargin*2-LeftWidth, ContentHeight)];
self.remarkTextView.contentInset = UIEdgeInsetsMake(5, 5, 5, 0);
self.remarkTextView.minNumberOfLines = 1;
self.remarkTextView.maxNumberOfLines = 2;
self.remarkTextView.font = FontSize(15);
self.remarkTextView.textAlignment = NSTextAlignmentLeft;
self.remarkTextView.delegate = self;
self.remarkTextView.returnKeyType = UIReturnKeyDone;
self.remarkTextView.placeholder = @"输入备注内容";
[self addSubview:self.remarkTextView];
}
}
}
- (UITextField *)getTextFileWithFrame:(CGRect)frame title:(NSString *)title{
UITextField *textField = [[UITextField alloc] initWithFrame:frame];
textField.textAlignment = NSTextAlignmentLeft;
textField.textColor = HexColor(@"444444");
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.placeholder = title;
textField.font = FontSize(15);
textField.delegate = self;
textField.returnKeyType = UIReturnKeyDone;
[self addSubview:textField];
return textField;
}
- (BOOL)growingTextViewShouldReturn:(HPGrowingTextView *)growingTextView{
[self.remarkTextView resignFirstResponder];
return YES;
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
[self.delegate hiddenKeyBoard];
return YES;
}
@end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment