📄 trasquerydlg.cpp
字号:
source2+="'and 车站表.车站号=行车表2.车站号";
source3="select * from 车站表,行车表1 where 行车表1.路线号='"+m_lineStr;
source3+="'and 车站表.车站号=行车表1.车站号 order by 上行序号 desc";
lineNo="select 路线号,隶属公司,起始站,终点站,首班时间,末班时间,票价 from 路线名 where 路线号='"+m_lineStr;
lineNo+="'";
m_ado.SetRecordSource(lineNo);
m_ado.Refresh();
Execute(source1);
CString str;
int staNum=0;
((CListBox *)GetDlgItem(IDC_LIST1))->AddString(" 去程:");
while (!m_pRec->traEOF)
{
((CListBox *)GetDlgItem(IDC_LIST1))->AddString((_bstr_t)m_pRec->GetCollect("车站名"));
staNum++;
m_pRec->MoveNext();
}
CString staStr;
str.Format("%d",staNum);
if(staNum==0)
{
((CListBox *)GetDlgItem(IDC_LIST1))->AddString("输入有误或数据正在录入中...");
SendDlgItemMessage(IDC_LINE_INPUT,EM_SETSEL,0,-1);
GetDlgItem(IDC_LINE_INPUT)->SetFocus();
m_Edit1=FALSE;
m_Combo1=FALSE;
return false;
}
else
{
staStr=" 去程总计"+str+"站";
((CListBox *)GetDlgItem(IDC_LIST1))->AddString(staStr);
}
lineBool="select 重叠性 from 路线名 where 路线号='"+m_lineStr;
lineBool+="'";
_variant_t lineBo;
try{
Execute(lineBool);
while (!m_pRec->traEOF)
{
lineBo=m_pRec->GetCollect("重叠性");
m_pRec->MoveNext();
}
}
catch (_com_error e)
{
AfxMessageBox(e.Description());
}
if((_bstr_t)lineBo=='0')
{
Execute(source2);
staNum=0;
((CListBox *)GetDlgItem(IDC_LIST1))->AddString(" 返程:");
while (!m_pRec->traEOF)
{
((CListBox *)GetDlgItem(IDC_LIST1))->AddString((_bstr_t)m_pRec->GetCollect("车站名"));
staNum++;
m_pRec->MoveNext();
}
str.Format("%d",staNum);
staStr=" 返程总计"+str+"站";
((CListBox *)GetDlgItem(IDC_LIST1))->AddString(staStr);
}
else
{
Execute(source3);
staNum=0;
((CListBox *)GetDlgItem(IDC_LIST1))->AddString(" 返程:");
while (!m_pRec->traEOF)
{
((CListBox *)GetDlgItem(IDC_LIST1))->AddString((_bstr_t)m_pRec->GetCollect("车站名"));
staNum++;
m_pRec->MoveNext();
}
str.Format("%d",staNum);
staStr=" 返程总计"+str+"站";
((CListBox *)GetDlgItem(IDC_LIST1))->AddString(staStr);
}
ExitConn();
m_StaQue=FALSE;
m_Edit1=FALSE;
m_Combo1=FALSE;
SendDlgItemMessage(IDC_LINE_INPUT,EM_SETSEL,0,-1);
GetDlgItem(IDC_LINE_INPUT)->SetFocus();
return true;
}
else
{
MessageBox("请输入您要查询的路线!");
return false;
}
}
bool CTrasQueryDlg::OnStationQuery()
{
// TODO: Add your control notification handler code here
CString lineStr;
m_StaQue=TRUE;
m_Combo2=TRUE;
int count=0;
count=((CListBox *)GetDlgItem(IDC_LIST1))->GetSelCount();
if(count!=0)
((CListBox *)GetDlgItem(IDC_LIST1))->ResetContent();
GetDlgItem(IDC_LINE_STATION)->SetWindowText("所经过的公交线路:");
if(m_Edit2)
{
GetDlgItem(IDC_STATION_INPUT)->GetWindowText(m_Station);
((CComboBox *)GetDlgItem(IDC_COMBO2))->SelectString(-1,m_Station);
m_Combo2=FALSE;
}
else if(m_Combo2)
{
CString str;
((CComboBox *)GetDlgItem(IDC_COMBO2))->GetWindowText(str);
UpdateData(false);
m_Station=str;
GetDlgItem(IDC_STATION_INPUT)->SetWindowText(m_Station);
m_Edit2=FALSE;
Invalidate();
}
_bstr_t source,staStr;
if(m_Station!="")
{
Initconn();
staStr="select * from 车站表 where 车站名='" + m_Station;
staStr+="'";
m_ado.SetRecordSource(staStr);
m_ado.Refresh();
source="select 路线号 from 行车表1 where 车站号 in (select 车站号 from 车站表 where 车站名='" + m_Station +"')";
Execute(source);
int lineNum=0;
while (!m_pRec->traEOF)
{
((CListBox *)GetDlgItem(IDC_LIST1))->AddString((_bstr_t)m_pRec->GetCollect("路线号"));
lineNum++;
m_pRec->MoveNext();
}
CString str;
str.Format("%d",lineNum);
if(lineNum==0)
{
((CListBox *)GetDlgItem(IDC_LIST1))->AddString("输入有误或数据正在录入中...");
SendDlgItemMessage(IDC_STATION_INPUT,EM_SETSEL,0,-1);
GetDlgItem(IDC_STATION_INPUT)->SetFocus();
m_Edit2=FALSE;
m_Combo2=FALSE;
return FALSE;
}
ExitConn();
m_LinQue=FALSE;
m_Edit2=FALSE;
m_Combo2=FALSE;
SendDlgItemMessage(IDC_STATION_INPUT,EM_SETSEL,0,-1);
GetDlgItem(IDC_STATION_INPUT)->SetFocus();
return true;
}
else
{
MessageBox("请输入您要查询的站点!");
m_Edit2=FALSE;
m_Combo2=FALSE;
return false;
}
}
void CTrasQueryDlg::OnImportMap()
{
// TODO: Add your command handler code here
if(m_LinQue)
{
CString str;
int i;
i=atoi(m_lineStr);
str.Format("%d",m_lineStr);
CMap1 dlg1;
CMap2 dlg2;
CMap3 dlg3;
CMap4 dlg4;
CMap5 dlg5;
CMap6 dlg6;
CMap7 dlg7;
CMap9 dlg9;
CMap10 dlg10;
switch(i)
{
case 1:
dlg1.DoModal();
break;
case 2:
dlg2.DoModal();
break;
case 3:
dlg3.DoModal();
break;
case 4:
dlg4.DoModal();
break;
case 5:
dlg5.DoModal();
break;
case 6:
dlg6.DoModal();
break;
case 7:
dlg7.DoModal();
break;
case 9:
dlg9.DoModal();
break;
case 10:
dlg10.DoModal();
break;
default:
MessageBox("您输入的线路错误或地图未载入");
break;
}
}
else
{
MessageBox("请您先输入线路");
}
}
HBRUSH CTrasQueryDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
// TODO: Change any attributes of the DC here
if(pWnd->GetDlgCtrlID()==IDC_LIST1)
{
pDC->SetBkColor(RGB(255,25,166));
// return m_brush;
}
if(pWnd->GetDlgCtrlID()==IDC_LINE_STATION ||
pWnd->GetDlgCtrlID()==IDC_QUERY_INFOR ||
pWnd->GetDlgCtrlID()==IDC_QUERY_WAYS)
{
pDC->SetBkColor(RGB(255,0,0));
pDC->SelectObject(&m_font);
}
if(pWnd->GetDlgCtrlID()==IDC_POINT_OUT1 ||
pWnd->GetDlgCtrlID()==IDC_POINT_OUT2)
{
pDC->SetBkColor(RGB(7,159,244));
}
if(pWnd->GetDlgCtrlID()==IDC_CHOOSE_LINE ||
pWnd->GetDlgCtrlID()==IDC_CHOOSE_STATION)
{
pDC->SetBkColor(RGB(255,255,0));
}
// TODO: Return a different brush if the default is not desired
//return hbr;
return m_brush;
}
HBRUSH CAboutDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if(pWnd->GetDlgCtrlID()==IDC_ABOUT)
{
pDC->SelectObject(&m_font);
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
void CTrasQueryDlg::OnChangeLineInput()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
m_Edit1=TRUE;
// GetDlgItem(IDC_LINE_QUERY)->SetFocus();
}
void CTrasQueryDlg::OnChangeStationInput()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
m_Edit2=TRUE;
//MessageBox("error");
//GetDlgItem(IDR_STATION_QUERY)->SetFocus();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -