16,548
社区成员




void CDataProcess::InitNewTrain(CString temp, int id)
{
static int num=0;
CTrain *ptrain=new CTrain(this,temp,id);
num++;
_CommandPtr pCommand;
pCommand.CreateInstance("ADODB.Command");
try
{
pCommand->ActiveConnection = theApp.m_pConnection_statistics;
}
catch (_com_error* e)
{
AfxMessageBox(e->ErrorMessage());
}
CString cmdstr;
cmdstr.Format("Insert into TrainInfo values (%d,'%s','%s','%s','%s')",num,ptrain->m_TrainParam.strTrainID,ptrain->m_TrainParam.strTrainType,ptrain->m_TrainParam.strTrainLong,ptrain->m_TrainParam.strTrainWeight);
pCommand->CommandText = _bstr_t(cmdstr);
pCommand->Execute(NULL, NULL, adCmdText);
cmdstr.Format("Insert into TrainInfo values (%d,'%s','%s','%s','%s')",num,ptrain->m_TrainParam.strTrainID,ptrain->m_TrainParam.strTrainType,ptrain->m_TrainParam.strTrainLong,ptrain->m_TrainParam.strTrainWeight);
pCommand->CommandText = _bstr_t(cmdstr);
pCommand->Execute(NULL, NULL, adCmdText);
CClientDC dc(m_pParentWnd);
((CCTCSFaceView* )m_pParentWnd)->OnPrepareDC(&dc);
ptrain->DrawTrain(&dc);
m_Trainlist.AddTail(ptrain);// m_Trainlist 是一个CPtrList类型的类成员变量
}