📄 dopacket.cpp
字号:
// Dopacket.cpp: implementation of the CDopacket class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ChenMiddleware.h"
#include "Dopacket.h"
#include "DataBase.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
extern CDB g_db;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CDopacket::CDopacket()
{
}
CDopacket::~CDopacket()
{
}
char CDopacket::AddStudents(char packet[], int iPacketLen)
{
CString SqlStr;
char stdid[11],userid[19],username[11],date[11],deptcode[3];
strncpy(deptcode,packet,2);
deptcode[2]=0;
strncpy(stdid,packet+2,10);
stdid[10]=0;
strncpy(username,packet+12,8);
username[8]=0;
strncpy(userid,packet+20,18);
userid[18]=0;
strncpy(date,packet+38,10);
date[10]=0;
SqlStr.Format("select top 1 StdNo from person where StdNo='%s'",stdid);
if(g_db.OpenTable(SqlStr)==false)
return '1'; //1- 数据库错误
if(!g_db.IsEOF())
{
g_db.CloseRecordSet();
return '2'; //2-已经存在
}
SqlStr.Format("INSERT INTO person (StdNo,UserId,UserName,DeptNo,RegDate)\
VALUES('%s','%s','%s','%s','%s')",stdid,userid,username,deptcode,date);
//TRACE1("%s",SqlStr);
if(g_db.ExecuteSQL(SqlStr)==false)
return '1';
//TRACE0("ok");
return '0'; //0-成功
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -