⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datebookdlg.cpp

📁 这是个火车订票系统。简易的。我做课程设计的时候用的。
💻 CPP
字号:
// datebookdlg.cpp : implementation file
//

#include "stdafx.h"
#include "ticketbook.h"
#include "datebookdlg.h"
#include "ticketset.h"
#include "ticketpriceset1.h"
#include "ticketbookedset1.h"
#include "trainclassset1.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// datebookdlg dialog


datebookdlg::datebookdlg(CWnd* pParent /*=NULL*/)
	: CDialog(datebookdlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(datebookdlg)
	m_stop1 = _T("西安");
	m_stoop2 = _T("");
	m_day = 0;
	m_month = 0;
	//}}AFX_DATA_INIT
}


void datebookdlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(datebookdlg)
	DDX_Control(pDX, IDC_LIST1, m_listbox);
	DDX_Text(pDX, IDC_stop1, m_stop1);
	DDX_Text(pDX, IDC_stop2, m_stoop2);
	DDX_Text(pDX, IDC_day, m_day);
	DDX_Text(pDX, IDC_month, m_month);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(datebookdlg, CDialog)
	//{{AFX_MSG_MAP(datebookdlg)
	ON_BN_CLICKED(ID_dabook, Ondabook)
	ON_BN_CLICKED(IDC_book, Onbook)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// datebookdlg message handlers
CString datebookdlg::n=" ";
CString datebookdlg::sit=" ";
CString datebookdlg::sit1=" ";
CString datebookdlg::p=" ";
int datebookdlg::c=13;
int datebookdlg::s=0;

void datebookdlg::Ondabook() 
{ticketset set;
trainclassset1 trainclass;
ticketbookedset1 booked;
ticketpriceset1 price;
CString p;
this->UpdateData(true);
CString laststop=m_stoop2;
price.Open();	
price.MoveFirst();
set.Open();
set.MoveFirst();
trainclass.Open();
trainclass.MoveFirst();

while(!set.IsEOF())
{
if(set.m_stop1==laststop||set.m_stop2==laststop||set.m_stop3==laststop||set.m_stop4==laststop||set.m_stop5==laststop||set.m_stop6==laststop)
{ n=set.m_trainNO;
char y[10],m[10],d[10],h[10],M[10];
sprintf(y,"%d",set.m_traintime.GetYear());
sprintf(m,"%d",set.m_traintime.GetMonth());
sprintf(d,"%d",set.m_traintime.GetDay());
sprintf(h,"%d",set.m_traintime.GetHour());
sprintf(M,"%d",set.m_traintime.GetMinute());
if(set.m_traintime.GetMonth()==m_month&&set.m_traintime.GetDay()==m_day&&set.m_ISsell==0)	
{  n=set.m_trainNO;
   s=set.m_sitclass;
   sit=set.m_sitNO;
while(!trainclass.IsEOF())
{if(trainclass.m_trainNo==n)
{c=trainclass.m_trainclass;
break;
}else trainclass.MoveNext();
}

if(s==1&&c==0)
{
while(!price.IsEOF())
if(m_stoop2==price.m_column1)
{p=price.m_column7;
sit1="硬座";
break;}
else
price.MoveNext();

} 
if(s==2&&c==0)
{while(!price.IsEOF())
 if(m_stoop2==price.m_column1)
 {p=price.m_column6;
 sit1="硬卧";
break;}
 else
	 price.MoveNext();
}
if(s==3&&c==0)
{while(!price.IsEOF())
 if(m_stoop2==price.m_column1)
 {p=price.m_column5;
 sit1="软卧";
 break;}
 else
	 price.MoveNext();
}

if(s==1&&c==1)
{while(!price.IsEOF())
 if(m_stoop2==price.m_column1)
 {p=price.m_column4;
 sit1="硬座";
 break;}
 else
	 price.MoveNext();
}
if(s==2&&c==1)
{while(!price.IsEOF())
 if(m_stoop2==price.m_column1)
 {p=price.m_column3;
 sit1="硬卧";
break;}
 else
	 price.MoveNext();
}
if(s==3&&c==1)
{while(!price.IsEOF())
 if(m_stoop2==price.m_column1)
 {p=price.m_column2;
 sit1="软卧";
 break;}
 else
	 price.MoveNext();
}

m_listbox.AddString("    "+n+"        "+y+"-"+m+"-"+d+" "+h+":"+M+"         "+sit1+" "+sit+"            "+p);
 }}
set.MoveNext();
if(set.IsEOF())
return;
}}


BOOL datebookdlg::OnInitDialog() 
{
CDialog::OnInitDialog();
m_listbox.AddString("    车次             发车时间                座号               票价    ");
return TRUE;  



}

void datebookdlg::Onbook() 
{int t;
ticketset set;
ticketbookedset1 set1;
int m=this->m_listbox.GetCurSel();
CString strtmp;
this->m_listbox.GetText(m,strtmp);
CString w;
CString w1;
//取车次
for(int i=0;;i++)
{w1=strtmp.Mid(i,1);
if(w1!=" ")break;
}
t=i;
for(int l=t;;l++)
{w1=strtmp.Mid(l,1);
if(w1==" ")
break;}
for(int h=l+3;;h++)
{w1=strtmp.Mid(h,1);
if(w1==" ")
break;}
//取座位号
w1=strtmp.Mid(t,l);
w=strtmp.Mid(l+37,h);
if(w==" ")
{set.Open(CRecordset::dynaset,_T("select * from traininfo where  trainNo='"+w1+"'and sitclass=0 "));
int tem=set.m_ISsell;
set.Edit();
set.m_ISsell=tem-1;
set.Update();
set.Close();
}
set.Open(CRecordset::dynaset,_T("select * from traininfo where  trainNo='"+w1+"' and sitNO='"+w+"'"));
set.Edit();
set.m_ISsell=1;
set.Update();
::MessageBox(NULL,"订票成功!","信息",MB_ICONINFORMATION);
//添加已买票记录到表ticketbooked
set1.Open();
set1.AddNew();
set1.m_trainNO=w1;
set1.m_startstop=m_stop1;
set1.m_laststop=m_stoop2;
set1.m_sitNO=w;
set1.Update();
set1.Close();

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -