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

📄 yuyuehistory.cpp

📁 “图书馆书籍检索与借阅管理系统”软件旨在为在校学生提供一个功能全面、使用方便的个人数据库系统
💻 CPP
字号:
// YuYueHistory.cpp : implementation file
//

#include "stdafx.h"
#include "work.h"
#include "CommonData.h"
#include "YuYueHistory.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CYuYueHistory dialog


CYuYueHistory::CYuYueHistory(CWnd* pParent /*=NULL*/)
	: CDialog(CYuYueHistory::IDD, pParent)
{
	//{{AFX_DATA_INIT(CYuYueHistory)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CYuYueHistory::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CYuYueHistory)
	DDX_Control(pDX, IDC_YUYUEHISTORY_LIST, m_YuYueHistory_List);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CYuYueHistory, CDialog)
	//{{AFX_MSG_MAP(CYuYueHistory)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CYuYueHistory message handlers

BOOL CYuYueHistory::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	LV_COLUMN h;
	h.mask=LVCF_FMT|LVCF_TEXT|LVCF_WIDTH;
	h.fmt=LVCFMT_CENTER;
	h.cx=110;

	h.pszText="书目名称";
	m_YuYueHistory_List.InsertColumn(0,&h);
	h.pszText="条码号";
	m_YuYueHistory_List.InsertColumn(1,&h);
	h.pszText="预约时间";
	m_YuYueHistory_List.InsertColumn(2,&h);
	h.pszText="应取时间";
	m_YuYueHistory_List.InsertColumn(3,&h);

	//查询预约历史
	_RecordsetPtr m_pRecordset;
	CString QueryString,number,tiaoma,predate,qdate;
	int i,year,month,day;

	QueryString="SELECT * FROM Book_Borrow_Infor WHERE BSNumber='"+CCommonData::userNumber+"'";
	m_pRecordset.CreateInstance("ADODB.Recordset");

	try{
		m_pRecordset->Open((_variant_t)QueryString,_variant_t((IDispatch *)m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);
	}
	catch(_com_error e)
	{
		MessageBox(e.ErrorMessage());
	}

	if(!m_pRecordset->BOF)
	{
		i=0;
		m_pRecordset->MoveFirst();
		while(!m_pRecordset->adoEOF)
		{
			predate=(LPCTSTR)_bstr_t(m_pRecordset->GetCollect("BPreDate"));

			if(predate!="3000-1-1")
			{
				number=(LPCTSTR)_bstr_t(m_pRecordset->GetCollect("BSNumber"));
				m_YuYueHistory_List.InsertItem(i,number);
				tiaoma=(LPCTSTR)_bstr_t(m_pRecordset->GetCollect("BNTiaoma"));
				m_YuYueHistory_List.SetItemText(i,1,tiaoma);
				m_YuYueHistory_List.SetItemText(i,2,predate);

				sscanf(predate,"%d-%d-%d",&year,&month,&day);
				CTime ydate(year,month,day,0,0,0);
				CTimeSpan t(3,0,0,0);
				ydate+=t;
				year=ydate.GetYear();
				month=ydate.GetMonth();
				day=ydate.GetDay();
				qdate.Format("%d-%d-%d",year,month,day);
				m_YuYueHistory_List.SetItemText(i,3,qdate);

				i++;
			}

			m_pRecordset->MoveNext();
		}
	}
	else
	{
		MessageBox("您的预约历史记录为空……");
		m_pRecordset->Close();
		return TRUE;
	}

	m_pRecordset->Close();
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

⌨️ 快捷键说明

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