代码拉取完成,页面将自动刷新
// CClientDlg.cpp: 实现文件
//
#include "pch.h"
#include "HotelManagementMFC.h"
#include "afxdialogex.h"
#include "CQueryClientDlg.h"
// CClientDlg 对话框
IMPLEMENT_DYNAMIC(CQueryClientDlg, CDialog)
CQueryClientDlg::CQueryClientDlg(CWnd* pParent /*=nullptr*/)
: CDialog(IDD_DLG_CLIENT, pParent)
{
}
CQueryClientDlg::~CQueryClientDlg()
{
}
void CQueryClientDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_PAPERNUM, m_sPaperNum);
DDX_Control(pDX, IDC_LIST_CLIENT, m_listClient);
DDX_Control(pDX, IDOK, m_bSearch);
}
BEGIN_MESSAGE_MAP(CQueryClientDlg, CDialog)
ON_BN_CLICKED(IDOK, &CQueryClientDlg::OnBnClickedSearchOK)
ON_BN_CLICKED(IDCANCEL, &CQueryClientDlg::OnBnClickedCancel)
END_MESSAGE_MAP()
// CClientDlg 消息处理程序
BOOL CQueryClientDlg::OnInitDialog()
{
CDialog::OnInitDialog();
switch (theApp.userFlag)
{
case theApp.USER_ALL:
m_nTitle = L"查询所有用户";
m_sPaperNum.SetWindowTextW(L"-- 请点击查找 --");
m_sPaperNum.SetReadOnly(1);
break;
case theApp.USER_SPECIIFIC:
m_nTitle = L"用户信息查询";
break;
}
SetWindowText(m_nTitle);
// TODO: 在此添加额外的初始化
m_listClient.ModifyStyle(0, LVS_REPORT | LVS_SHOWSELALWAYS);
m_listClient.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP);
m_listClient.SetBkColor(RGB(247, 247, 255));
m_listClient.SetTextColor(RGB(0, 0, 255));
m_listClient.SetTextBkColor(RGB(247, 247, 255));
m_listClient.InsertColumn(0, L"顾客姓名", LVCFMT_CENTER, 80);
m_listClient.InsertColumn(1, L"性别", LVCFMT_CENTER, 60);
m_listClient.InsertColumn(2, L"籍贯", LVCFMT_CENTER, 100);
m_listClient.InsertColumn(3, L"证件号码", LVCFMT_CENTER, 120);
m_listClient.InsertColumn(4, L"入住时间", LVCFMT_CENTER, 120);
m_listClient.InsertColumn(5, L"入住房间", LVCFMT_CENTER, 80);
m_listClient.InsertColumn(6, L"押金", LVCFMT_CENTER, 60);
// TODO: Table NULL
//m_listClient.InsertColumn(6, L"结算时间", LVCFMT_CENTER, 120);
//m_listClient.InsertColumn(7, L"预交费用", LVCFMT_CENTER, 80);
//m_sPaperNum.SetWindowTextW(L"");
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
void CQueryClientDlg::OnBnClickedSearchOK()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData(1);
// 清空原列表框
m_listClient.DeleteAllItems();
// SQL查询过程
CString strSQL;
switch (theApp.userFlag)
{
case theApp.USER_ALL:
strSQL = L"Select ClientName, Sex, NativePlace, PaperNum, InDate, RoomNo, Deposit From Client";
break;
case theApp.USER_SPECIIFIC:
CString search_Num;
m_sPaperNum.GetWindowTextW(search_Num);
if (search_Num == "")
{
MessageBoxW(L"证件号码不能为空,请重新输入!");
return;
}
strSQL.Format(L"Select ClientName, Sex, NativePlace, PaperNum, InDate, RoomNo, Deposit From Client Where PaperNum = '%s'", search_Num);
break;
}
int i = 0;
try {
m_pRecordSet.CreateInstance(__uuidof(Recordset));
m_pRecordSet->Open(strSQL.AllocSysString(),
theApp.m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
// 遍历结果集
CString tmp;
_variant_t Holder;
// 判断为空
if (!m_pRecordSet->GetRecordCount() == 0)
{
m_pRecordSet->MoveFirst();
while (!m_pRecordSet->adoEOF)
{
theApp.m_GetCollect(m_pRecordSet, Holder, tmp, "ClientName");
m_listClient.InsertItem(i, tmp);
theApp.m_GetCollect(m_pRecordSet, Holder, tmp, "Sex");
m_listClient.SetItemText(i, 1, tmp);
theApp.m_GetCollect(m_pRecordSet, Holder, tmp, "NativePlace");
m_listClient.SetItemText(i, 2, tmp);
theApp.m_GetCollect(m_pRecordSet, Holder, tmp, "PaperNum");
m_listClient.SetItemText(i, 3, tmp);
theApp.m_GetCollect(m_pRecordSet, Holder, tmp, "InDate");
m_listClient.SetItemText(i, 4, tmp);
theApp.m_GetCollect(m_pRecordSet, Holder, tmp, "RoomNo");
m_listClient.SetItemText(i, 5, tmp);
theApp.m_GetCollect(m_pRecordSet, Holder, tmp, "Deposit");
m_listClient.SetItemText(i, 6, tmp);
m_pRecordSet->MoveNext();
i++;
}
}
else
AfxMessageBox(L"没有客户数据!", MB_OK);
}
catch (_com_error& e)
{
AfxMessageBox(e.Description());
}
}
void CQueryClientDlg::OnBnClickedCancel()
{
// TODO: 在此添加控件通知处理程序代码
CDialog::OnCancel();
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。