// TestVC0Dlg.cpp : implementation file
//
...
.............................................................................................................................................
.............................................................................................................................................
void CTestVC0Dlg::OnSelchangeComboTitle()
{
CString varcombo;
CString vcombtitle1, vcombchapter1;
long varrecno;
//Record corresponding to the item selected of the title conbobox
m_pRS->MoveFirst();
m_combotitlerecno.SetCurSel(m_combotitle.GetCurSel());
m_combotitlerecno.GetLBText(m_combotitlerecno.GetCurSel(),varcombo);
varrecno = atol(varcombo.GetBuffer(80));
m_pRS->Move(varrecno);
CalculValue();
SetSituation();
//In the current string of the book combobox displays the order of the book
m_combobook.SetCurSel(m_combotitle.GetCurSel());
//Recordset declaration
if (m_pRSW0)
if (m_pRSW0->IsOpen())
m_pRSW0->Close();
delete m_pRSW0;
m_pRSW0 = new CDaoRecordset(m_pDB);
m_pRSW0->Open(dbOpenDynaset, "SELECT * from BibleTable", 0);
//Clear the comboboxes
m_combochapter.ResetContent();
m_combochapterrecno.ResetContent();
m_comboverse.ResetContent();
m_comboverserecno.ResetContent();
//Chapter combobox stores all chapters orders of the book
//Verse combobox stores all verses orders of the 1st chapter
m_combotitle.GetLBText(m_combobook.GetCurSel(),vcombtitle1);
m_pRSW0->Move(varrecno);
m_pRSW0->GetFieldValue(_T("BookTitle"), vartitle);
m_pRSW0->GetFieldValue(_T("Chapter"), varchapter0);
while (!m_pRSW0->IsEOF())
{
m_pRSW0->GetFieldValue(_T("BookTitle"), vartitle);
m_pRSW0->GetFieldValue(_T("Chapter"), varchapter1);
m_pRSW0->GetFieldValue(_T("Verse"), varverse1);
pos = m_pRSW0->GetAbsolutePosition();
ltoa(pos,chrrecno,10);
if (CString(V_BSTRT(&vartitle)) == vcombtitle1)
{
if (CString(V_BSTRT(&varchapter1)) == "001")
{
if (CString(V_BSTRT(&varverse1)) == "001")
{
m_combochapter.AddString(CString(V_BSTRT(&varchapter1)));
m_comboverse.AddString(CString(V_BSTRT(&varverse1)));
m_combochapterrecno.AddString(CString(chrrecno));
m_comboverserecno.AddString(CString(chrrecno));
}
else
{
m_comboverse.AddString(CString(V_BSTRT(&varverse1)));
m_comboverserecno.AddString(CString(chrrecno));
}
}
else
{
if (CString(V_BSTRT(&varchapter0)) != CString(V_BSTRT(&varchapter1)))
{
m_combochapter.AddString(CString(V_BSTRT(&varchapter1)));
m_combochapterrecno.AddString(CString(chrrecno));
varchapter0 = varchapter1;
}
}
}
m_pRSW0->MoveNext();
}
//In the current string of the chapter coombobox displays the first chapter order of the book
//In the current string of the verse coombobox displays the first verse order of the 1st chapter
m_combochapter.SetCurSel(0);
m_comboverse.SetCurSel(0);
UpdateData(FALSE);
// TODO: Add your control notification handler code here
}
.............................................................................................................................................
.............................................................................................................................................
...
|