📄 resinfodlg.cpp
字号:
// ResInfoDlg.cpp : implementation file
//
#include "stdafx.h"
#include "TRS.h"
#include "ResInfoDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CResInfoDlg dialog
CResInfoDlg::CResInfoDlg(CWnd* pParent /*=NULL*/)
: CDialog(CResInfoDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CResInfoDlg)
m_strCustName = _T("");
m_resvType = _T("");
//}}AFX_DATA_INIT
}
void CResInfoDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CResInfoDlg)
DDX_Control(pDX, IDC_LIST_RES_INFO, m_listResInfo);
DDX_Text(pDX, IDC_EDIT_RES_CUSTNAME, m_strCustName);
DDX_Text(pDX, IDC_EDIT_RES_RESTYPE, m_resvType);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CResInfoDlg, CDialog)
//{{AFX_MSG_MAP(CResInfoDlg)
ON_BN_CLICKED(ID_BTN_RES_QUERY, OnBtnResQuery)
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CResInfoDlg message handlers
void CResInfoDlg::OnBtnResQuery()
{
// TODO: Add your control notification handler code here
CString strSQL;
int choice = CDialog::GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO2);
UpdateData();
if( choice == IDC_RADIO1 )
{
if(m_strCustName.IsEmpty())
{
MessageBox("客户名不能为空!");
return;
}
strSQL = "select * from RESERVATIONS where custName ='" + m_strCustName + "'";
}
else if( choice == IDC_RADIO2 )
{
if(m_resvType.IsEmpty())
{
MessageBox("客户名不能为空!");
return;
}
strSQL = "select * from RESERVATIONS where resvType =" + m_resvType;
}
else
{
strSQL = "select * from RESERVATIONS";
}
CString custName,resvType;
m_listResInfo.DeleteAllItems();
CRecordset rs(&(((CTRSApp*)AfxGetApp())->db));
rs.Open(CRecordset::forwardOnly,strSQL);
int i=0;
while( !rs.IsEOF() )
{
rs.GetFieldValue("custName",custName);
m_listResInfo.InsertItem(i,custName);
rs.GetFieldValue("resvType",resvType);
m_listResInfo.SetItemText(i,1,resvType);
rs.MoveNext();
i++;
}
rs.Close();
}
void CResInfoDlg::OnRadio1()
{
// TODO: Add your control notification handler code here
CDialog::CheckRadioButton(IDC_RADIO1,IDC_RADIO2,IDC_RADIO1);
CWnd::GetDlgItem(IDC_EDIT_RES_CUSTNAME)->EnableWindow(true);
CWnd::GetDlgItem(IDC_EDIT_RES_RESTYPE)->EnableWindow(false);
}
void CResInfoDlg::OnRadio2()
{
// TODO: Add your control notification handler code here
CDialog::CheckRadioButton(IDC_RADIO1,IDC_RADIO2,IDC_RADIO2);
CWnd::GetDlgItem(IDC_EDIT_RES_CUSTNAME)->EnableWindow(false);
CWnd::GetDlgItem(IDC_EDIT_RES_RESTYPE)->EnableWindow(true);
}
BOOL CResInfoDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CWnd::GetDlgItem(IDC_EDIT_RES_CUSTNAME)->EnableWindow(false);
CWnd::GetDlgItem(IDC_EDIT_RES_RESTYPE)->EnableWindow(false);
m_listResInfo.InsertColumn(0,"客户名");
m_listResInfo.InsertColumn(1,"预定类型");
RECT rect;
m_listResInfo.GetWindowRect(&rect);
int rectWidth = rect.right - rect.left;
m_listResInfo.SetColumnWidth(0,rectWidth/2);
m_listResInfo.SetColumnWidth(1,rectWidth/2);
m_listResInfo.SetExtendedStyle(LVS_EX_FULLROWSELECT);//单行选中
RefreshData();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CResInfoDlg::RefreshData()
{
CString custName,resvType;
m_listResInfo.DeleteAllItems();
CRecordset rs(&(((CTRSApp*)AfxGetApp())->db));
rs.Open(CRecordset::forwardOnly,"select * from RESERVATIONS");
int i=0;
while( !rs.IsEOF() )
{
rs.GetFieldValue("custName",custName);
m_listResInfo.InsertItem(i,custName);
rs.GetFieldValue("resvType",resvType);
m_listResInfo.SetItemText(i,1,resvType);
rs.MoveNext();
i++;
}
rs.Close();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -