int C51JobWebPost::GetFirstUsefulKey()
{
	int iRet = -1;
	CAdoConnection adoConn;
	CAdoRecordSet adoRst;
	try
	{
		if ( !adoConn.IsOpen() )		//如果未连接上服务器
		{
			CString strAppPath = "";
			CUserFile::GetInstance()->GetAppPath(strAppPath);
			if ( !adoConn.ConnectAccess(strAppPath+"machineInfo.mdb",""))
			{
				ShowMessage("连接数据库失败");
				return -1; 
			}
			adoRst.SetAdoConnection(&adoConn);
			adoRst.SetCursorLocation(adUseClient);
		}
		CString strSQL;		
		strSQL.Format("select top 1 * from [machine] where datediff('d',lastusetime,now()) > 0 order by [ID] asc");
		if(!adoRst.Open(strSQL,adCmdText))
		{
			iRet = -1;
			ShowMessage("读取键值信息失败");
		}
		else
		{
			if (!adoRst.IsEOF())
			{
				adoRst.GetCollect("ID",m_iID);
				adoRst.GetCollect("machineserial",m_strMac);
				adoRst.GetCollect("transactionid",m_strTrans);
				adoRst.GetCollect("verify",m_strVerify);
				iRet = 0;
			}
			else
			{
				ShowMessage("当天已经没有可用的键值信息,请调用生成程序");
				iRet = -1;
			}
		}
		adoRst.Close();
		adoConn.Close();
		return iRet;
	}
	catch (...)
	{
		adoRst.Close();
		adoConn.Close();
		ShowMessage("读取键值信息异常");
	}
	return -1;
}
int C51JobWebPost::WriteToBase(RegisterPack rgPack,int iFlag)
{
	int iRet = -1;
	CAdoConnection adoConn;
	CAdoRecordSet adoRst;
	try
	{
		if ( !adoConn.IsOpen() )		//如果未连接上服务器
		{
			CString strAppPath = "";
			CUserFile::GetInstance()->GetAppPath(strAppPath);
			if ( !adoConn.ConnectAccess(strAppPath+"7pRegister.mdb",""))
			{
				ShowMessage("连接数据库失败");
				return -1; 
			}
			adoRst.SetAdoConnection(&adoConn);
			adoRst.SetCursorLocation(adUseClient);
		}
		CString strSQL;		
		strSQL.Format("insert into [Users] ([userid],[userpwd],flag)values('%s','%s',%d,)",rgPack.strAcc,rgPack.strPwd,iFlag);
		if( !adoRst.Open(strSQL,adCmdText))
		{
			iRet = -1;
			ShowMessage("保存账号信息失败");
		}
		else
		{
			iRet = 0;
		}
		adoRst.Close();
		adoConn.Close();
		return iRet;
	}
	catch (...)
	{
		adoRst.Close();
		adoConn.Close();
		ShowMessage("保存账号信息异常");
	}
	return -1;
}
int C51JobWebPost::DisableKey(int iKeyNum)
{
	int iRet = -1;
	CAdoConnection adoConn;
	CAdoRecordSet adoRst;
	try
	{
		if ( !adoConn.IsOpen() )		//如果未连接上服务器
		{
			CString strAppPath = "";
			CUserFile::GetInstance()->GetAppPath(strAppPath);
			if ( !adoConn.ConnectAccess(strAppPath+"machineInfo.mdb",""))
			{
				ShowMessage("连接数据库失败");
				return -1; 
			}
			adoRst.SetAdoConnection(&adoConn);
			adoRst.SetCursorLocation(adUseClient);
		}
		CString strSQL;		
		strSQL.Format("update [machine] set [lastusetime]=now() where [ID]=%d",iKeyNum);
		if(!adoRst.Open(strSQL,adCmdText))
		{
			iRet = -1;
			ShowMessage("删除机器信息失败");
		}
		else
		{
			iRet = 0;
		}
		adoRst.Close();
		adoConn.Close();
		return iRet;
	}
	catch (...)
	{
		adoRst.Close();
		adoConn.Close();
		ShowMessage("删除机器信息异常");
	}
	return -1;
}
Example #4
0
void CStoredMessage::AddMessage(CString strMessage)
{
    if (!strMessage.IsEmpty())
    {
        CAdoConnection conn;
        conn.ConnectAccess(CStoredMember::GetFilePath());

        CString szCmdText;
        szCmdText.Format("insert into messages(message) values('%s')", strMessage);
        conn.Execute(szCmdText);
        conn.Close();
    }
}
Example #5
0
void CStoredMessage::ClearMessage()
{
    CAdoConnection conn;
    conn.ConnectAccess(CStoredMember::GetFilePath());
    
    CString szCmdText;
    szCmdText.Format("drop table messages");
	conn.Execute(szCmdText);
    szCmdText.Format("create table messages(id autoincrement, message Memo)");
    conn.Execute(szCmdText);

    conn.Close();
}
Example #6
0
void CStoredAccount::AddAccount(CString strUserName, CString pwd)
{    
    if (!strUserName.IsEmpty())
    {
        CAdoConnection conn;
        conn.ConnectAccess(CStoredMember::GetFilePath());

        CString szCmdText;
        szCmdText.Format("insert into accounts(uid, pwd) values('%s', '%s')", strUserName, pwd);
        conn.Execute(szCmdText);
        conn.Close();
    }
}
Example #7
0
void CStoredAccount::ClearAccount()
{
    CAdoConnection conn;
    conn.ConnectAccess(CStoredMember::GetFilePath());
    
    CString szCmdText;
    szCmdText.Format("drop table accounts");
	conn.Execute(szCmdText);
    szCmdText.Format("create table accounts(id autoincrement, uid varchar(50), pwd varchar(50))");
    conn.Execute(szCmdText);

    conn.Close();
}
Example #8
0
int CStoredMessage::GetNextMessage(int startId, CString& szMessage)
{
    long id = -1;

    CString szCmdText;
    szCmdText.Format("select top 1 id, message from messages where id > %d", startId);
    
    CAdoConnection conn;
    if (conn.ConnectAccess(CStoredMember::GetFilePath()))
    {
        CAdoRecordSet rs(&conn);
        if (rs.Open(szCmdText) && rs.MoveFirst())
        {
            rs.GetCollect(0L, id);
            rs.GetCollect(1L, szMessage);
        }
        conn.Close();
    }

    return id;
}
Example #9
0
int CStoredAccount::GetNextAccount(int startId, CString& strUserName, CString& pwd)
{
    long id = -1;

    CString szCmdText;
    szCmdText.Format("select top 1 id, uid, pwd from accounts where id > %d", startId);
    
    CAdoConnection conn;
    if (conn.ConnectAccess(CStoredMember::GetFilePath()))
    {
        CAdoRecordSet rs(&conn);
        if (rs.Open(szCmdText) && rs.MoveFirst())
        {
            rs.GetCollect(0L, id);
            rs.GetCollect(1L, strUserName);
            rs.GetCollect(2L, pwd);
        }
        conn.Close();
    }

    return id;
}