Exemplo n.º 1
0
void WelcomeUI(SOCKET sd)
{
    char account[ACCOUNT_LEN];	//存储帐号
    char password[PASSWORD_LEN];	//密码长度
    char buffer;//接收从服务器返回的帐号密码查询结果.

    system("cls");//清屏
    gotoxy(25, 5);
    printf( "欢迎来到学生成绩管理系统(V 1.0)\n" );
    gotoxy(10, 6);
    printf("-----------------------------------------------------\n");
    AccountInput(account, "请输入帐号: ", ACCOUNT_LEN);	//输入帐号
    PasswordInput(password, "请输入密码: " ,PASSWORD_LEN);	//输入密码

    //将帐号和密码发送到服务器进行验证
    if (0 == CompleteSend(sd, account, ACCOUNT_LEN) || 0 == CompleteSend(sd, password, PASSWORD_LEN))
    {
        printf("传输数据失败!\n");
        return;
    }

    //接收帐号密码查询结果:返回1个char值,a表示学生帐号;b表示教师帐号;c表示密码错误但是帐号存在,d表示帐号不存在.
    if (0 == CompleteRecv(sd, &buffer, 1))
    {
        printf("传输数据失败!\n");
        return;
    }

    //根据服务器返回的结果,判断帐号密码

    switch (buffer)
    {
    case 'a'://学生帐号
        StudentUI(sd);//进入学生界面
        getchar();
        break;
    case 'b'://教师帐号
        TeacherUI(sd);//printf("进入教师界面");
        getchar();
        break;
    case 'c'://密码错误
        system("cls");
        printf("密码错误!按回车返回欢迎界面\n");
        getchar();
        getchar();
        break;
    case 'd'://帐号不存在
        system("cls");
        printf("帐号密码不存在!按回车返回欢迎界面\n");
        getchar();
        getchar();
        break;
    }

    return;
}
Exemplo n.º 2
0
int Connections::CompleteIO(IOCONTEXT* IOContext, DWORD Param)
{
    switch (IOContext->iomode)
    {
    case IOMODE_ACCEPT:
        return CompleteAccept(Param);

    case IOMODE_CONNECT:
        return CompleteConnect(Param);

    case IOMODE_RECV:
        return CompleteRecv(Param);

    case IOMODE_SEND:
        return CompleteSend(Param);

    default:
        return -1; //ERR_NET_INVALID_COMPLETE_IO_MODE
    }
}
Exemplo n.º 3
0
//-----------------------------------------------------------------------------------
//		Purpose	:
//		Return	:
//-----------------------------------------------------------------------------------
// Called by Worker TH ( IOCP )
//-----------------------------------------------------------------------------------
int CNtlConnection::CompleteIO(sIOCONTEXT * pIOContext, DWORD dwParam)
{
	switch( pIOContext->iomode )
	{
	case IOMODE_ACCEPT:
		return CompleteAccept( dwParam );

	case IOMODE_CONNECT:
		return CompleteConnect( dwParam );

	case IOMODE_RECV:
		return CompleteRecv( dwParam );

	case IOMODE_SEND:
		return CompleteSend( dwParam );

	default:
		return NTL_ERR_NET_INVALID_COMPLETE_IO_MODE;
	}
}
Exemplo n.º 4
0
void TeacherUI(SOCKET sd)
{
    int select;
    char send;
    char rec;

    while (1)
    {
        Menu();
        printf("请输入您的选择:");
        scanf("%d", &select);

        switch (select)
        {
        case 1:
            send = 'b';
            CompleteSend(sd, &send, 1);
            Add(sd);
            CompleteRecv(sd, &rec, 1);
            if (rec =='Y')
            {
                printf("添加成功\n");
            }
            else
            {
                printf("添加失败!\n");
            }
            getchar();
            break;
        case 2:
            send = 'c';
            CompleteSend(sd, &send, 1);
            Del(sd);
            CompleteRecv(sd, &rec, 1);
            if (rec =='Y')
            {
                printf("删除成功\n");
            }
            else
            {
                printf("删除失败!\n");
            }
            getchar();
            getchar();
            break;
        case 3:	//显示
            send = 'a';
            CompleteSend(sd, &send, 1);
            ClientFromServer(sd);
            getchar();
            break;
        case 4:
            send = 'd';
            CompleteSend(sd, &send ,1);
            Modify(sd);
            CompleteRecv(sd, &rec, 1);
            if (rec =='Y')
            {
                printf("修改成功\n");
            }
            else
            {
                printf("修改失败!\n");
            }
            getchar();
            break;
        case 5:
            send = 'f';
            CompleteSend(sd, &send ,1);
            CompleteRecv(sd, &rec, 1);
            if (rec =='Y')
            {
                printf("排序成功\n");
            }
            else
            {
                printf("排序失败!\n");
            }
            getchar();
            getchar();
            break;
        case 6:
            send = 'g';
            CompleteSend(sd, &send ,1);
            RecTongji(sd);
            getchar();
            break;
        case 7:
            send = 'h';
            CompleteSend(sd, &send, 1);
            Found(sd);
            ClientFromServer(sd);
            getchar();
            break;
        default:
            break;;
        }
    }
    return;
}