www.pudn.com > Library.rar > ReturnBookDlg.cpp, change:2009-04-10,size:3149b


// ReturnBookDlg.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "time.h" 
#include "Library.h" 
#include "ReturnBookDlg.h" 
#include "BookDataSet.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CReturnBookDlg dialog 
 
 
CReturnBookDlg::CReturnBookDlg(CWnd* pParent /*=NULL*/) 
	: CDialog(CReturnBookDlg::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CReturnBookDlg) 
	m_Book_ID = _T(""); 
	m_BorrowDate = _T(""); 
	m_Days = 0; 
	m_ReaderName = _T(""); 
	m_ReturnDate = _T(""); 
	//}}AFX_DATA_INIT 
 
} 
 
 
void CReturnBookDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CReturnBookDlg) 
	DDX_Text(pDX, IDC_EDITBook_ID, m_Book_ID); 
	DDX_Text(pDX, IDC_EDITBorrowDate, m_BorrowDate); 
	DDX_Text(pDX, IDC_EDITDays, m_Days); 
	DDX_Text(pDX, IDC_EDITReaderName, m_ReaderName); 
	DDX_Text(pDX, IDC_EDITReturnDate, m_ReturnDate); 
	//}}AFX_DATA_MAP 
	 
} 
 
 
BEGIN_MESSAGE_MAP(CReturnBookDlg, CDialog) 
	//{{AFX_MSG_MAP(CReturnBookDlg) 
	ON_EN_KILLFOCUS(IDC_EDITBook_ID, OnKillfocusEDITBookID) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CReturnBookDlg message handlers 
 
int CReturnBookDlg::QryBorrow() 
{ 
	CString m_strtmp; 
	UpdateData(true); 
	if (strcmp(m_Book_ID,"")==0)  
		return 0; 
	m_rsDataSet.m_strFilter ="reader.reader_ID=borrow.reader_ID and BOOK_ID='"+m_Book_ID+"'"; 
	if (!m_rsDataSet.Open()) 
	{ 
		AfxMessageBox("数据打开失败!"); 
		return -1; 
	} 
	 
	m_rsDataSet.Requery(); 
	if (m_rsDataSet.GetRecordCount()!=0)  
	{ 
		m_ReaderName=m_rsDataSet.m_ReaderName ; 
	    UpdateData(false); 
		m_rsDataSet.Close(); 
		return 1; 
	} 
	else 
	{ 
		return 0; 
	} 
} 
 
void CReturnBookDlg::OnKillfocusEDITBookID()  
{ 
	int rs; 
	CWnd *pWnd; 
	CString m_strtmp; 
 
	rs=QryBorrow(); 
    if(rs==1) 
	{ 
		if(::MessageBox(this->m_hWnd,"还书处理正常完成","提示",MB_YESNO)==IDYES){ 
		     
		} 
		else 
			CDialog::OnClose(); 
 
	} 
	else if(rs==0) 
	{ 
		if (m_Book_ID == "") 
			return; 
		::MessageBox(this->m_hWnd,"该书号信息不存在!","警告",MB_OK); 
	}   
	 
	// TODO: Add your control notification handler code here 
	pWnd=GetDlgItem(IDC_EDITBook_ID); 
	pWnd->SetFocus(); 
} 
 
void CReturnBookDlg::OnCancel()  
{ 
	// TODO: Add extra cleanup here 
	 
	CDialog::OnCancel(); 
} 
 
 
int CReturnBookDlg::SetTxtNull() 
{	 
	CWnd *pWnd; 
	m_Book_ID=""; 
	m_BorrowDate=""; 
	m_Days=0; 
	m_ReaderName=""; 
	m_ReturnDate=""; 
	UpdateData(false); 
	pWnd=GetDlgItem(IDC_EDITBook_ID); 
//	pWnd->SetFocus(); 
	return 1; 
} 
 
int CReturnBookDlg::setTxtDisable() 
{ 
	CWnd *pWnd; 
	pWnd=GetDlgItem(IDC_EDITReaderName); 
	pWnd->EnableWindow(false); 
	pWnd=GetDlgItem(IDC_EDITBorrowDate); 
	pWnd->EnableWindow(false); 
	pWnd=GetDlgItem(IDC_EDITReturnDate); 
	pWnd->EnableWindow(false); 
	pWnd=GetDlgItem(IDC_EDITDays); 
	pWnd->EnableWindow(false); 
	return 1; 
 
} 
 
BOOL CReturnBookDlg::OnInitDialog() 
{ 
	CDialog::OnInitDialog(); 
//	setTxtDisable(); 
	return true; 
}