sasdf

#import "sqlite3.h"

@interface Register : NSObject

{

    sqlite3 *link;

    NSString *path;

    

}

-(void)addNewPeople:(NSString *)addRegister andSecret:(NSString *)addSecret andContent:(NSString *)addContent;

-(NSMutableArray *) showAccountInformation;

@end

-(id)init

{

    self=[super init];

    //确定数据库文件,完成数据库链接

    path=@"/Users/feifanchengxuyuan/Desktop/登录注册.db";

    sqlite3_open([path UTF8String], &link);

    //创建表

    NSString *creatTable=@"create table if not exists register(account varchar(40),secret varchar(20),content varchar(1000))";

    

    sqlite3_exec(link, [creatTable UTF8String], nil, nil, nil);

    

    

    return self;

}

// 插入数据

-(void)addNewPeople:(NSString *)addRegister andSecret:(NSString *)addSecret andContent:(NSString *)addContent

{

    NSString *insertData=[NSString stringWithFormat:@"insert into register(account,secret,content) values (\"%@\",\"%@\",\"%@\")",addRegister,addSecret,addContent];

    sqlite3_exec(link, [insertData UTF8String], nil, nil, nil  );

}


//查找数据库中的信息

-(NSMutableArray *) showAccountInformation

{

    NSMutableArray *informationArray=[[NSMutableArray alloc]initWithCapacity:10];

    NSDictionary *informationDict=[[NSDictionary alloc]init];

    sqlite3_stmt *state;

    NSString *account;

    NSString *secret;

    NSString *content;

    NSString *selectData=[NSString stringWithFormat:@"select *from register"];

    sqlite3_prepare_v2(link, [selectData UTF8String], -1, &state, nil);

    

    while (sqlite3_step(state)==SQLITE_ROW) {

        account= [[NSString alloc ]initWithCString:(char *)sqlite3_column_text( state, 0 )encoding:NSUTF8StringEncoding];

        secret= [[NSString alloc ]initWithCString:(char *)sqlite3_column_text( state, 1 )encoding:NSUTF8StringEncoding];

        content = [[NSString alloc]initWithCString:(char *) sqlite3_column_text( state, 2 )encoding:NSUTF8StringEncoding];

        informationDict=@{@"account":account,@"secret":secret,@"content":content};

        [informationArray addObject:informationDict];

    }

    return informationArray;

}



@end

#import <UIKit/UIKit.h>

#import "ViewController.h"

#import "TwoViewController.h"

#import "ThreeViewController.h"

#import "FourViewController.h"

#import "FiveViewController.h"

@interface AppDelegate : UIResponder <UIApplicationDelegate>


@property (strong, nonatomic) UIWindow *window;

@property (strong ,nonatomic )ViewController * viewController ;

@property (strong ,nonatomic )TwoViewController * twoViewController ;

@property (strong ,nonatomic )ThreeViewController * threeViewController ;

@property(nonatomic,strong)FourViewController *fourViewController;

@property(nonatomic,strong)FiveViewController *fiveViewController;


@end



- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];

    self.window.tintColor = [UIColor redColor];//设置点击后颜色为红色

    self.window.backgroundColor = [UIColor whiteColor];

    _viewController = [[ViewController alloc]init];

    _twoViewController = [[TwoViewController alloc]init];

    _threeViewController = [[ThreeViewController alloc]init];

    _fourViewController = [[FourViewController alloc]init];

    _fiveViewController = [[FiveViewController alloc]init];

    

    _viewController.tabBarItem.title=@"One";

    _viewController.tabBarItem.image=[UIImage imageNamed:@"1"];

    _twoViewController.tabBarItem.title=@"Two";

    _twoViewController.tabBarItem.image=[UIImage imageNamed:@"2"];

    _threeViewController.tabBarItem.title=@"Three";

    _threeViewController.tabBarItem.image=[UIImage imageNamed:@"3"];

    _fourViewController.tabBarItem.title = @"Four";

    _fourViewController.tabBarItem.image = [UIImage imageNamed:@"4"];

    _fiveViewController.tabBarItem.title = @"Five";

    _fiveViewController.tabBarItem.image = [UIImage imageNamed:@"dada"];

    

    UITabBarController *tabber = [[UITabBarController alloc]init];

    tabber.viewControllers = @[_viewController,_twoViewController,_threeViewController,_fourViewController,_fiveViewController];

    self.window.rootViewController = tabber;

    return YES;

}


 


#import <UIKit/UIKit.h>

#import "ThreeViewController.h"


@interface TwoViewController : UIViewController

@property(nonatomic,strong)UILabel *labelAccount;

@property(nonatomic,strong)UILabel *labelSecret;

@property(nonatomic,strong)UITextField *textAccount;

@property(nonatomic,strong)UITextField *textSecret;

@property(nonatomic,strong)UIButton *buttonEnter;

@property(nonatomic,strong)UIButton *buttonRegister;

@property(nonatomic,strong)ThreeViewController *threeView;

@property(nonatomic,strong)UILabel *label;

-(void)promptMessage:(NSString *)string;


 [super viewDidLoad];

    _labelAccount = [[UILabel alloc]initWithFrame:CGRectMake(16, 220, 34, 21)];

    _labelSecret = [[UILabel alloc]initWithFrame:CGRectMake(16, 293, 34, 21)];

    _textAccount = [[UITextField alloc]initWithFrame:CGRectMake(79, 217, 220, 30)];

    _textSecret = [[UITextField alloc]initWithFrame:CGRectMake(79, 289, 220, 30)];

    _buttonEnter = [[UIButton alloc]initWithFrame:CGRectMake(74, 380, 41, 30)];

    _buttonRegister = [[UIButton alloc]initWithFrame:CGRectMake(243, 380, 46, 30)];

    UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 375, 156)];

    

    image.image = [UIImage imageNamed:@"6"];

    [_buttonEnter setTitle:@"登录" forState:UIControlStateNormal];

    [_buttonEnter setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];

    _buttonEnter.backgroundColor = [UIColor grayColor];

    _buttonEnter.layer.borderWidth = 2;

    _buttonEnter.layer.cornerRadius = 5;

    

    [_buttonRegister setTitle:@"注册" forState:UIControlStateNormal];

    [_buttonRegister setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];

    _buttonRegister.backgroundColor = [UIColor grayColor];

    _buttonRegister.layer.borderWidth = 2;

    _buttonRegister.layer.cornerRadius = 5;

    

    

    _labelAccount.text = @"账户";

    _textAccount.layer.borderWidth = 1;

    _textAccount.layer.borderColor = [UIColor blackColor].CGColor;

    _textAccount.layer.cornerRadius = 9;

    

    _labelSecret.text = @"密码";

    _textSecret.layer.borderWidth = 1;

    _textSecret.layer.borderColor = [UIColor blackColor].CGColor;

    _textSecret.layer.cornerRadius = 9;

    //提示框

    _label = [[UILabel alloc]initWithFrame:CGRectMake(100, 335, 170, 28)];

    [_buttonRegister addTarget:self action:@selector(Register) forControlEvents:UIControlEventTouchUpInside];

    [_buttonEnter addTarget:self  action:@selector(Enter) forControlEvents:(UIControlEventTouchUpInside)];

   

    [self.view addSubview:_label];

    [self.view addSubview:_textAccount];

    [self.view addSubview:_textSecret];

    [self.view addSubview:_labelAccount];

    [self.view addSubview:_labelSecret];

    [self.view addSubview:_buttonEnter];

    [self.view addSubview:_buttonRegister];

    [self.view addSubview:image];


}

-(void)promptMessage:(NSString *)string{

    _label.text = string;

    _label.textAlignment=NSTextAlignmentCenter;

    _label.textColor=[UIColor redColor];

    _label.layer.borderWidth=2;

    _label.layer.borderColor=[[UIColor alloc]initWithRed:0.2 green:0.4 blue:0.7 alpha:0.2].CGColor;

    _label.layer.cornerRadius=10;


}

-(void)Register{

    _threeView=[[ThreeViewController alloc]init];

    [self presentViewController:_threeView animated:YES completion:nil];


}

-(int)judgeWithText:(NSString *)textAccount andSecret:(NSString*)secret and:(Register *)data

{

    NSMutableArray *array=[[NSMutableArray alloc]init];

    array=[data showAccountInformation];

    int flag=0;

    for (int i=0; i<[array count]; i++) {

        if ([textAccount isEqual: array[i][@"account"] ]) {

            if ([secret isEqual:array[i][@"secret"]]) {

                flag++;

            }

        }

    }

    return flag;

    

}


-(void)Enter

{

    

    Register *data=[[Register alloc]init];

    if ([self judgeWithText:_textAccount.text andSecret:_textSecret.text and:data]!=1) {

        [self promptMessage:@"账号或密码错误"];

    }

    else

    {

        

        UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提示框" message:@"登录成功" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];

        [alert show];

    }

}



#import <UIKit/UIKit.h>

#import "Register.h"

@class TwoViewController;

@interface ThreeViewController : UIViewController

@property(nonatomic,strong)UILabel *labelHead;

@property(nonatomic,strong)UILabel *labelName;

@property(nonatomic,strong)UILabel *labelAge;

@property(nonatomic,strong)UILabel *accountLabel;

@property(nonatomic,strong)UILabel *secretLabel;

@property(nonatomic,strong)UITextField *fieldName;

@property(nonatomic,strong)UITextField *fieldAge;

@property(nonatomic,strong)UITextField *accountField;

@property(nonatomic,strong)UITextField *secretField;

@property(nonatomic,strong)UIButton *registerButton;

@property(nonatomic,strong)UILabel *label;

-(void)promptMessage:(UILabel *)label and: (NSString *)message;

-(int)judgeWithText:(NSString *)text and:(Register *)data;

@property(nonatomic,strong)UIButton *backButton;

@property(nonatomic,strong)TwoViewController *twoView;

@end



#import "ThreeViewController.h"


@interface ThreeViewController ()


@end


@implementation ThreeViewController


- (void)viewDidLoad {

    [super viewDidLoad];

    UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(0, 500, 382, 158)];

    image.image = [UIImage imageNamed:@"6"];

    _labelHead = [[UILabel alloc]initWithFrame:CGRectMake(142, 41, 69, 21)];

    _labelName = [[UILabel alloc]initWithFrame:CGRectMake(40, 102, 34, 21)];

    _labelAge = [[UILabel alloc]initWithFrame:CGRectMake(40, 182, 34, 21)];

    _accountLabel = [[UILabel alloc]initWithFrame:CGRectMake(40, 258, 34, 21)];

    _secretLabel = [[UILabel alloc]initWithFrame:CGRectMake(40, 337, 34, 21)];

    _fieldName = [[UITextField alloc]initWithFrame:CGRectMake(104, 99, 209, 30)];

    _fieldAge = [[UITextField alloc]initWithFrame:CGRectMake(104, 178, 209, 30)];

    _accountField = [[UITextField alloc]initWithFrame:CGRectMake(104, 254, 209, 30)];

    _secretField = [[UITextField alloc]initWithFrame:CGRectMake(104, 333, 209, 30)];

    _registerButton = [[UIButton alloc]initWithFrame:CGRectMake(168, 436, 39, 30)];

    _backButton = [[UIButton alloc]initWithFrame:CGRectMake(5, 50, 46, 30)];

    [_registerButton setTitle:@"注册" forState:UIControlStateNormal];

    [_registerButton setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];

    _registerButton.backgroundColor = [UIColor grayColor];

    _registerButton.layer.borderWidth = 2;

    _registerButton.layer.cornerRadius = 5;

    

    [_backButton setTitle:@"back" forState:UIControlStateNormal];

    [_backButton setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];

    _backButton.backgroundColor = [UIColor grayColor];

    _backButton.layer.borderWidth = 2;

    _backButton.layer.cornerRadius = 5;

    [_backButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];


    

    _labelHead.text = @"注册信息";

    _labelName.text = @"姓名";

    _labelAge.text = @"年龄";

    _accountLabel.text = @"账户";

    _secretLabel.text = @"密码";

    _fieldName.layer.borderWidth = 1;

    _fieldName.layer.borderColor = [UIColor blackColor].CGColor;

    _fieldName.layer.cornerRadius = 9;

    _fieldAge.layer.borderWidth = 1;

    _fieldAge.layer.borderColor = [UIColor blackColor].CGColor;

    _fieldAge.layer.cornerRadius = 9;

    _accountField.layer.borderWidth = 1;

    _accountField.layer.borderColor = [UIColor blackColor].CGColor;

    _accountField.layer.cornerRadius = 9;

    _secretField.layer.borderWidth = 1;

    _secretField.layer.borderColor = [UIColor blackColor].CGColor;

    _secretField.layer.cornerRadius = 9;

    _fieldName.placeholder = @"请输入真实姓名";

    _fieldAge.placeholder = @"请输入真实年龄";

    _accountField.placeholder = @"请输入账户名";

    _secretField.placeholder = @"请输入密码";

    

    _label=[[UILabel alloc]initWithFrame:CGRectMake(120, 370, 170, 28)];

    [self.view addSubview:_label];

    [_registerButton addTarget:self action:@selector(clickRegister) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:_labelHead];

    [self.view addSubview:_labelName];

    [self.view addSubview:_labelAge];

    [self.view addSubview:_accountLabel];

    [self.view addSubview:_secretLabel];

    [self.view addSubview:_fieldName];

    [self.view addSubview:_fieldAge];

    [self.view addSubview:_accountField];

    [self.view addSubview:_secretField];

    [self.view addSubview:_registerButton];

    [self.view addSubview:_backButton];

    [self.view addSubview:image];

    

}

-(void)promptMessage:(UILabel *)label and: (NSString *)message

{

    label.text=message;

    label.textAlignment=NSTextAlignmentCenter;

    label.textColor=[UIColor redColor];

    label.layer.borderWidth=2;

    label.layer.borderColor=[[UIColor alloc]initWithRed:0.2 green:0.4 blue:0.7 alpha:0.2].CGColor;

    label.layer.cornerRadius=10;

}

-(int)judgeWithText:(NSString *)text and:(Register *)data

{

    NSMutableArray *array=[[NSMutableArray alloc]init];

    array=[data showAccountInformation];

    int flag=0;

    for (int i=0; i<[array count]; i++) {

        if ([text isEqual: array[i][@"account"] ]) {

            flag++;

        }

    }

    

    return flag;

    

}

#pragma 注册账号

-(void)clickRegister

{

    Register *addData=[[Register alloc]init];

    

    //判断信息是否为空

    if (([_accountField.text isEqual:@""])||( [_secretField.text isEqual:@""]) ) {

        

        [self promptMessage:_label and:@"个人信息不能为空!"];

        

    }

    //判断用户名长度是否超限制

    else if ((_accountField.text.length>12)||(_accountField.text.length<6))

    {

        [self promptMessage:_label and:@"请重新输入用户名"];

    }

    

    else if ([self judgeWithText:_accountField.text and:addData]!=0)

    {

        [self promptMessage:_label and:@"此账号已存在"];

        

    }

    else

    {

        //将数据添加进数据库

        [addData addNewPeople:_accountField.text andSecret:_secretField.text andContent:nil];

        

        //注册成功的时候给一个提示框,告诉用户注册成功

        UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提示框" message:@"注册成功" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];

        [alert show];

        

        //注册成功自动跳转到登录界面

        [self dismissViewControllerAnimated:NO completion:nil];

        

    }

    //    [self dismissViewControllerAnimated:NO completion:nil];

}

-(void)back{

    [self dismissViewControllerAnimated:_twoView completion:nil];

}



#import <UIKit/UIKit.h>


@interface FourViewController : UIViewController

@property(nonatomic,strong)UILabel *publishLabel;

@property(nonatomic,strong)UILabel *headingLabel;

@property(nonatomic,strong)UILabel *summarizeLabel;

@property(nonatomic,strong)UILabel *mainbodyLabel;

@property(nonatomic,strong)UITextField *headingField;

@property(nonatomic,strong)UITextField *summarizeField;

@property(nonatomic,strong)UITextView *mainbodyText;

@property(nonatomic,strong)UIButton *publishButton;

-(NSString *)content:(NSString *)Acount and:(NSString *)Mima;

-(void)join;

@end



#import "FourViewController.h"

#import "FiveViewController.h"

#import "TwoViewController.h"

#import "Register.h"

@interface FourViewController ()


@end


@implementation FourViewController


- (void)viewDidLoad {

    [super viewDidLoad];

    _publishLabel = [[UILabel alloc]initWithFrame:CGRectMake(149, 44, 77, 21)];

    _headingLabel = [[UILabel alloc]initWithFrame:CGRectMake(37, 98, 34, 21)];

    _summarizeLabel = [[UILabel alloc]initWithFrame:CGRectMake(37, 160, 34, 21)];

    _mainbodyLabel = [[UILabel alloc]initWithFrame:CGRectMake(33, 248, 34, 21)];

    _mainbodyText = [[UITextView alloc]initWithFrame:CGRectMake(28, 300, 331, 260)];

    _headingField = [[UITextField alloc]initWithFrame:CGRectMake(99, 94, 139, 30)];

    _summarizeField = [[UITextField alloc]initWithFrame:CGRectMake(99, 157, 236, 30)];

    _publishButton = [[UIButton alloc]initWithFrame:CGRectMake(284, 580, 43, 30)];

    _publishLabel.text = @"发表博文";

    _headingLabel.text = @"标题";

    _summarizeLabel.text = @"摘要";

    _mainbodyLabel.text = @"正文";

    _headingField.layer.borderWidth = 1;

    _headingField.layer.borderColor = [UIColor blackColor].CGColor;

    _headingField.layer.cornerRadius = 9;

    _summarizeField.layer.borderWidth = 1;

    _summarizeField.layer.borderColor = [UIColor blackColor].CGColor;

    _summarizeField.layer.cornerRadius = 9;

    _mainbodyText.layer.borderWidth = 1;

    _mainbodyText.layer.borderColor = [UIColor blackColor].CGColor;

    _mainbodyText.layer.cornerRadius = 9;


    [_publishButton setTitle:@"发表" forState:UIControlStateNormal];

    [_publishButton setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];

    _publishButton.backgroundColor = [UIColor grayColor];

    _publishButton.layer.borderWidth = 2;

    _publishButton.layer.cornerRadius = 5;

    [_publishButton addTarget:self action:@selector(dianji) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:_publishLabel];

    [self.view addSubview:_headingLabel];

    [self.view addSubview:_summarizeLabel];

    [self.view addSubview:_mainbodyLabel];

    [self.view addSubview:_mainbodyText];

    [self.view addSubview:_headingField];

    [self.view addSubview:_summarizeField];

    [self.view addSubview:_publishButton];

}





@interface FiveViewController : UIViewController

@property(nonatomic,strong)UILabel *headLabel;

@property(nonatomic,strong)UILabel *label;

@property(nonatomic,strong)UILabel *label1;

@property(nonatomic,strong)UILabel *label2;

@property(nonatomic,strong)UILabel *label3;

@property(nonatomic,strong)UILabel *label4;

@property(nonatomic,strong)UILabel *label5;

@property(nonatomic,strong)UIButton *button;

@end


@implementation FiveViewController


- (void)viewDidLoad {

    [super viewDidLoad];

    _headLabel = [[UILabel alloc]initWithFrame:CGRectMake(149, 44, 77, 21)];

    _label = [[UILabel alloc]initWithFrame:CGRectMake(37, 98, 34, 21)];

    _label1 = [[UILabel alloc]initWithFrame:CGRectMake(37, 160, 34, 21)];

    _label2 = [[UILabel alloc]initWithFrame:CGRectMake(33, 248, 34, 21)];

    _label3 = [[UILabel alloc]initWithFrame:CGRectMake(99, 94, 139, 30)];

    _label4 = [[UILabel alloc]initWithFrame:CGRectMake(99, 157, 236, 30)];

    _label5 = [[UILabel alloc]initWithFrame:CGRectMake(28, 300, 331, 260)];

    _button = [[UIButton alloc]initWithFrame:CGRectMake(5, 50, 40, 21)];

    _label5.numberOfLines = 15;

    _headLabel.text = @"博文内容";

    _label.text = @"标题";

    _label1.text = @"摘要";

    _label2.text = @"正文";

    

    _label3.layer.borderWidth = 1;

    _label3.layer.borderColor = [UIColor blackColor].CGColor;

    _label3.layer.cornerRadius = 9;

    

    _label4.layer.borderWidth = 1;

    _label4.layer.borderColor = [UIColor blackColor].CGColor;

    _label4.layer.cornerRadius = 9;

    

    _label5.layer.borderWidth = 1;

    _label5.layer.borderColor = [UIColor blackColor].CGColor;

    _label5.layer.cornerRadius = 9;

    

    _button.backgroundColor = [UIColor grayColor];

    _button.layer.borderWidth = 2;

    _button.layer.cornerRadius = 5;

    [_button setTitle:@"返回" forState:UIControlStateNormal];

    [_button setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];

    [_button addTarget:self action:@selector(dianji) forControlEvents:UIControlEventTouchUpInside];

    


    [self.view addSubview:_button];

    [self.view addSubview:_headLabel];

    [self.view addSubview:_label];

    [self.view addSubview:_label1];

    [self.view addSubview:_label2];

    [self.view addSubview:_label3];

    [self.view addSubview:_label4];

    [self.view addSubview:_label5];

    

    

    

}

-(void)dianji{

    [self dismissViewControllerAnimated:NO completion:nil];

}

- (void)didReceiveMemoryWarning {


你可能感兴趣的:(sasdf)