航班订票系统
MFC 数据库 ODBC 增加 ,删除,改,查询操作
void CMyView::OnBtnAdd()
{
// TODO: Add your control notification handler code here
CAddDialog dlg;
if(dlg.DoModal()==IDOK)
{
if(dlg.m_arrive_city.IsEmpty()||dlg.m_arrive_time.IsEmpty()||
dlg.m_body_id.IsEmpty()||dlg.m_book_person_name.IsEmpty()||
dlg.m_date.IsEmpty()||dlg.m_hbh.IsEmpty()||
dlg.m_lanch_time.IsEmpty()||dlg.m_seat_level.IsEmpty()||
dlg.m_start_city.IsEmpty() )
{
AfxMessageBox("有信息未填写,请填写完毕!");
}
else
{
m_pSet->AddNew();
m_pSet->m_arrive_city=dlg.m_arrive_city;
m_pSet->m_arrive_time=dlg.m_arrive_time;
m_pSet->m_body_id=dlg.m_body_id;
m_pSet->m_date=dlg.m_date;
m_pSet->m_dingpiaoren=dlg.m_book_person_name;
m_pSet->m_hbh=dlg.m_hbh;
m_pSet->m_lanch_time=dlg.m_lanch_time;
m_pSet->m_seat_level=dlg.m_seat_level;
m_pSet->m_start_city=dlg.m_start_city;
m_pSet->Update();
m_pSet->Requery();
AfxMessageBox("订票成功!");
UpdateData(false);
}
}
/* if(dlg.DoModal()==IDOK)
{
if(dlg.m_addnum.IsEmpty()||dlg.m_addpsw.IsEmpty())
{
}
m_pSet->AddNew();
m_pSet->m_column1 = dlg.m_addnum;
m_pSet->m_column2 = dlg.m_addpsw;
m_pSet->Update();
m_pSet->Requery();
AfxMessageBox("已经添加"+dlg.m_addnum+"密码为"+dlg.m_addpsw);
UpdateData(false); */
}
//DEL void CMyView::OnBtnAsure()
//DEL {
//DEL // TODO: Add your control notification handler code here
//DEL
//DEL }
void CMyView::OnBtnChange()
{
// TODO: Add your control notification handler code here
CAddDialog dlg;
dlg.m_arrive_city=m_pSet->m_arrive_city;
dlg.m_arrive_time=m_pSet->m_arrive_time;
dlg.m_body_id=m_pSet->m_body_id;
dlg.m_date= m_pSet->m_date;
dlg.m_book_person_name= m_pSet->m_dingpiaoren;
dlg.m_hbh= m_pSet->m_hbh;
dlg.m_lanch_time=m_pSet->m_lanch_time;
dlg.m_seat_level=m_pSet->m_seat_level;
dlg.m_start_city=m_pSet->m_start_city;
if(dlg.DoModal()==IDOK)
{
if(dlg.m_hbh.IsEmpty()||dlg.m_book_person_name.IsEmpty())
{
AfxMessageBox("航班号,乘客姓名,身份证,不能为空!");
}
else
{
m_pSet->Edit();
m_pSet->m_arrive_city=dlg.m_arrive_city;
m_pSet->m_arrive_time=dlg.m_arrive_time;
m_pSet->m_body_id=dlg.m_body_id;
m_pSet->m_date=dlg.m_date;
m_pSet->m_dingpiaoren=dlg.m_book_person_name;
m_pSet->m_hbh=dlg.m_hbh;
m_pSet->m_lanch_time=dlg.m_lanch_time;
m_pSet->m_seat_level=dlg.m_seat_level;
m_pSet->m_start_city=dlg.m_start_city;
m_pSet->Update();
m_pSet->Requery();
AfxMessageBox("已经修改票成功!");
UpdateData(false);
}
}
}
void CMyView::OnBtnRollBack()
{
// TODO: Add your control notification handler code here
if(AfxMessageBox("真的要退票吗",MB_OKCANCEL)==IDCANCEL)
return;
else
{
if(m_pSet->IsEOF())
{
AfxMessageBox("没有票可以退?");
}
else
{
m_pSet->Delete();
if(m_pSet->IsEOF())
m_pSet->MoveLast();
else m_pSet->MoveNext();
m_pSet->Requery();
UpdateData(false);
AfxMessageBox("退票成功!");
}
}
}
void CMyView::OnBtnSearchInfo()
{
// TODO: Add your control notification handler code here
/* CDlgQuery Dlgquery;
CString value;
if(Dlgquery.DoModal()==IDOK)
{
value="职工编号=+"+Dlgquery.m_query+"";
m_pSet->m_strFilter=value;
m_pSet->Requery();
UpdateData(FALSE);
}
*/
CSearchDlg search;
CString str;
if(search.DoModal()==IDOK)
{
// str="订票人="+search.m_C_NAME+"and 身份证号="+search.m_C_SFZ+"";
/* str.Format("订票人=%s and 身份证号
=%s",search.m_C_NAME,search.m_C_SFZ);
m_pSet->m_strFilter=str;
m_pSet->Requery();
UpdateData(FALSE);*/
/* m_pSet->m_strFilter="订票人=? and 身份证号= ?";
m_pSet->m_dingpiaoren=search.m_C_NAME;
m_pSet->m_body_id=search.m_C_SFZ;
*/
str.Format("身份证号= %s%s%s","'",search.m_C_SFZ,"'");
m_pSet->m_strFilter=str;
m_pSet->Requery();
UpdateData(FALSE);
}
}