怎样在下图中实现点击左边添加的时候,先查看这条数据在右边的列表空间中存在不存在,如果存在就退出不存在就添加。
这是我写的代码:
int nCount = m_info.GetItemCount();
CString strcou;
strcou.Format("%d",nCount);
AfxMessageBox(strcou);
for (int i = -1;i < nCount; i++)
{
CString strTime,strDate,strSit,strhall;
strhall.Format(m_info.GetItemText(i,1));
strTime.Format(m_info.GetItemText(i,2));
strDate.Format(m_info.GetItemText(i,3));
strSit.Format(m_info.GetItemText(i,4));
if (strhall == m_strHall && strTime == m_stTime && strDate == m_strDate && strSit == m_strSit)
{
AfxMessageBox("该座位已经在已选列表中!");
continue;
// EndDialog(IDD_TICKETINFO);
}
else
{
m_info.InsertItem(nCount,m_strFname);
m_info.SetItemText(nCount,1,m_strHall);
m_info.SetItemText(nCount,2,m_stTime);
m_info.SetItemText(nCount,3,m_strDate);
m_info.SetItemText(nCount,4,m_strSit);
m_info.SetItemText(nCount,5,m_strTmoney);
CString strSql;
strSql.Format("insert into TI_info values('%s','%s','%s','%s','%s','%s')",\
m_strFname,m_strHall,m_stTime,m_strDate,m_strSit,m_strTmoney);
CADORecordset Rs1(&CTicketSystem11App::m_DB);
Rs1.Open((LPCTSTR)strSql);
// EndDialog(IDD_TICKETINFO);
}
}
请指教!!!