📄 dlgbuy.cpp
字号:
// DlgBuy.cpp : implementation file
//
#include "stdafx.h"
#include "AirLine.h"
#include "MainFrm.h"
#include "AirLineDoc.h"
#include "AirLineView.h"
#include "DlgBuy.h"
#include "DlgSearch.h"
#include "ADOConn.h"
#include "DlgClient.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgBuy dialog
CDlgBuy::CDlgBuy(CWnd* pParent /*=NULL*/)
: CDialog(CDlgBuy::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgBuy)
m_EdtId = _T("");
m_EdtNum = _T("");
m_EdtTotal = _T("");
m_EdtPart = _T("");
//}}AFX_DATA_INIT
}
void CDlgBuy::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgBuy)
DDX_Control(pDX, IDC_BtnNew, m_new);
DDX_Text(pDX, IDC_EdtId, m_EdtId);
DDX_Text(pDX, IDC_EdtNum, m_EdtNum);
DDX_Text(pDX, IDC_EdtTotal, m_EdtTotal);
DDX_Text(pDX, IDC_EdtPart, m_EdtPart);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgBuy, CDialog)
//{{AFX_MSG_MAP(CDlgBuy)
ON_BN_CLICKED(IDC_BtnNew, OnBtnNew)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgBuy message handlers
void CDlgBuy::OnOK()
{
UpdateData();
// TODO: Add extra validation here
CMainFrame *pFrame=(CMainFrame *)AfxGetApp()->m_pMainWnd;
CAirLineView *m_pView=(CAirLineView *)pFrame->GetActiveView();
CString strMoney,strMessage;
CString strNum;
CString strTm;
CString strPrice;
strPrice.Format("%.2f",price);
CTime tm;
tm=CTime::GetCurrentTime();
strTm=tm.Format("%Y%m%d");
CString strDt=tm.Format("%Y-%m-%d");
strMoney.Format("%.2f",price*atoi(m_EdtTotal)*0.2);
strMessage="需要订金"+strMoney+"元";
if(MessageBox(strMessage,"提示",1)==1)
{
ADOConn adoConn;
adoConn.OnInitADOConn();
_RecordsetPtr m_pRs;
_bstr_t vsql;
vsql="select top 1 * from list order by 订单号 desc";
try{
m_pRs=adoConn.GetRecordSet(vsql);
if(!m_pRs->adoEOF)
strNum=(LPCTSTR)(_bstr_t)m_pRs->GetCollect("订单号");
}
catch(_com_error e){
AfxMessageBox(e.Description());
}
if(strNum.Left(8)==strTm) //判断订单号前8位是不是今天
{
int temp=atoi(strNum.Right(4))+1;
CString strTemp;
strTemp.Format("%04d",temp);
strNum=strNum.Left(8)+strTemp;
}
else
{
strNum=strTm+"0001";
}
vsql="insert into list values('"+strNum+"','"+m_EdtNum+"','"+m_EdtId+"','"
+strDt+"','"+strDate+"','未处理','"+m_EdtPart+"','"+m_EdtTotal+"','"+strPrice+"','"+
strMoney+"')";
try {
adoConn.ExecuteSQL( (_bstr_t) vsql) ;
} catch ( _com_error e ){
AfxMessageBox ( e.Description () ) ;
}
vsql="insert into accounts values('"+strTm+"','"+strMoney+"','订票')";
try {
adoConn.ExecuteSQL( (_bstr_t) vsql) ;
} catch ( _com_error e ){
AfxMessageBox ( e.Description () ) ;
}
adoConn.ExitConnect();
}
m_pView->BuyDone();
CDialog::OnOK();
}
void CDlgBuy::OnBtnNew()
{
// TODO: Add your control notification handler code here
CDlgClient dlg;
dlg.DoModal();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -