📄 dlgticket.cpp
字号:
// DlgTicket.cpp : implementation file
//
#include "stdafx.h"
#include "AirLine.h"
#include "DlgTicket.h"
#include "ADOConn.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgTicket dialog
CDlgTicket::CDlgTicket(CWnd* pParent /*=NULL*/)
: CDialog(CDlgTicket::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgTicket)
m_EdtNum = _T("");
//}}AFX_DATA_INIT
}
void CDlgTicket::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgTicket)
DDX_Text(pDX, IDC_EdtNum, m_EdtNum);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgTicket, CDialog)
//{{AFX_MSG_MAP(CDlgTicket)
ON_BN_CLICKED(IDC_BtnTake, OnBtnTake)
ON_BN_CLICKED(IDC_BtnBack, OnBtnBack)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgTicket message handlers
BOOL CDlgTicket::OnInitDialog()
{
CDialog::OnInitDialog();
today=CTime::GetCurrentTime();
strToday=today.Format("%Y-%m-%d");
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgTicket::OnBtnTake()
{
UpdateData(); // TODO: Add your control notification handler code here
ADOConn adoConn;
adoConn.OnInitADOConn();
_RecordsetPtr m_pRs;
_bstr_t vsql;
vsql="select * from list where 订单号='"+m_EdtNum+" ' ";
try{
m_pRs=adoConn.GetRecordSet(vsql);
if(m_pRs->adoEOF)
{
AfxMessageBox("查无此订单,请核对");
return;
}
else
{
strPrice=(LPCTSTR)(_bstr_t)m_pRs->GetCollect("机票单价");
strTotal=(LPCTSTR)(_bstr_t)m_pRs->GetCollect("票数");
strPay=(LPCTSTR)(_bstr_t)m_pRs->GetCollect("已付金额");
}
}catch(_com_error e){
AfxMessageBox(e.Description());
}
money=(atof(strPrice))*(atof(strTotal))-atof(strPay);
CString totalMoney;
totalMoney.Format("%.2f",(atof(strPrice))*(atof(strTotal)));
strMoney.Format("%.2f",money);
if(MessageBox("需要交"+strMoney+"元钱","提示",1)==1)
{
vsql="update list set 处理情况='已处理', 已付金额="+totalMoney+"where 订单号='"+m_EdtNum+"'";
try{
adoConn.ExecuteSQL(vsql);
}
catch(_com_error e){
AfxMessageBox(e.Description());
}
vsql="insert into accounts values('"+strToday+"','"+strMoney+"','取票')";
try{
adoConn.ExecuteSQL(vsql);
}
catch(_com_error e){
AfxMessageBox(e.Description());
}
adoConn.ExitConnect();
CDialog::OnOK();
}
}
void CDlgTicket::OnBtnBack()
{
// TODO: Add your control notification handler code here
UpdateData(); // TODO: Add your control notification handler code here
ADOConn adoConn;
adoConn.OnInitADOConn();
_RecordsetPtr m_pRs;
_bstr_t vsql;
vsql="select * from list where 订单号='"+m_EdtNum+" ' ";
try{
m_pRs=adoConn.GetRecordSet(vsql);
if(m_pRs->adoEOF)
{
AfxMessageBox("查无此订单,请核对");
return;
}
else
{
strPay=(LPCTSTR)(_bstr_t)m_pRs->GetCollect("已付金额");
}
}catch(_com_error e){
AfxMessageBox(e.Description());
}
money=atof(strPay)*0.8;
strMoney.Format("%.2f",money);
if(MessageBox("需要退"+strMoney+"元钱","提示",1)==1)
{
vsql="delete list where 订单号='"+m_EdtNum+"'";
try{
adoConn.ExecuteSQL(vsql);
}
catch(_com_error e){
AfxMessageBox(e.Description());
}
vsql="insert into accounts values('"+strToday+"','-"+strMoney+"','退票')";
try{
adoConn.ExecuteSQL(vsql);
}
catch(_com_error e){
AfxMessageBox(e.Description());
}
adoConn.ExitConnect();
CDialog::OnOK();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -