📄 returndlg.cpp
字号:
// ReturnDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Library.h"
#include "LibrarySet.h"
#include "Bookset.h"
#include "Borrowset.h"
#include "ReturnDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CReturnDlg dialog
CReturnDlg::CReturnDlg(CWnd* pParent /*=NULL*/)
: CDialog(CReturnDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CReturnDlg)
m_strproofID = _T("");
m_strreadername = _T("");
m_strbookID = _T("");
m_strbookname = _T("");
m_strreturndate = _T("");
m_strextended = _T("");
m_strbackdate = _T("");
m_strdays = _T("");
//}}AFX_DATA_INIT
}
void CReturnDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CReturnDlg)
DDX_Text(pDX, IDC_EDIT_PROOF_ID, m_strproofID);
DDX_Text(pDX, IDC_EDIT_READER_NAME, m_strreadername);
DDX_Text(pDX, IDC_EDIT_BOOK_ID, m_strbookID);
DDX_Text(pDX, IDC_EDIT_BOOK_NAME, m_strbookname);
DDX_Text(pDX, IDC_EDIT_RETURN_DATE, m_strreturndate);
DDX_Text(pDX, IDC_EDIT_EXTENDED, m_strextended);
DDX_Text(pDX, IDC_EDIT_BACK_TIME, m_strbackdate);
DDX_Text(pDX, IDC_EDIT_DAYS, m_strdays);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CReturnDlg, CDialog)
//{{AFX_MSG_MAP(CReturnDlg)
ON_EN_CHANGE(IDC_EDIT_PROOF_ID, OnChangeEditProofId)
ON_EN_CHANGE(IDC_EDIT_BOOK_ID, OnChangeEditBookId)
ON_BN_CLICKED(IDC_BUTTON_CLEAR, OnButtonClear)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CReturnDlg message handlers
void CReturnDlg::OnOK()
{
UpdateData(TRUE);
CString strSQL;
CLibrarySet m_readerset;
CBookset m_bookset;
CBorrowset m_borrowset;
strSQL.Format("select * from readerinfo where Proof_ID='%s'",m_strproofID);
if(!m_readerset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL))
{
MessageBox("数据库打开失败!","数据库错误",MB_OK);
return;
}
m_readerset.Edit();
m_readerset.m_Borrow_Amount--;
m_readerset.Update();
m_readerset.Close();
strSQL.Format("select * from bookinfo where Book_ID='%s'",m_strbookID);
if(!m_bookset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL))
{
MessageBox("数据库打开失败!","数据库错误",MB_OK);
return;
}
m_bookset.Edit();
m_bookset.m_Total_Amount++;
m_bookset.Update();
m_bookset.Close();
strSQL.Format("select * from borrowinfo where Book_ID='%s'",m_strbookID);
if(!m_borrowset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL))
{
MessageBox("数据库打开失败!","数据库错误",MB_OK);
return;
}
m_borrowset.Delete();
m_borrowset.Close();
AfxMessageBox("图书归还成功");
}
void CReturnDlg::OnChangeEditProofId()
{
UpdateData();
CString strSQL;
CLibrarySet m_readerset;
strSQL.Format("select * from readerinfo where Proof_ID='%s'",m_strproofID);
if(!m_readerset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL))
{
MessageBox("数据库打开失败!","数据库错误",MB_OK);
return;
}
if(m_readerset.GetRecordCount()==0)
{
m_readerset.Close();
return;
}
m_strreadername=m_readerset.m_Name;
m_readerset.Close();
UpdateData(FALSE);
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here*/
}
void CReturnDlg::OnChangeEditBookId()
{
UpdateData();
CString strSQL;
CBookset m_bookset;
strSQL.Format("select * from bookinfo where Book_ID='%s'",m_strbookID);
if(!m_bookset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL))
{
MessageBox("数据库打开失败!","数据库错误",MB_OK);
return;
}
if(m_bookset.GetRecordCount()==0)
{
m_bookset.Close();
return;
}
m_strbookname=m_bookset.m_Book_Name;
CTime tm=CTime::GetCurrentTime();
//CString strtime;
m_strreturndate.Format("%d年%d月%d日",tm.GetYear(),tm.GetMonth(),tm.GetDay());
CBorrowset m_borrowset;
strSQL.Format("select * from borrowinfo where Book_ID='%s'",m_strbookID);
if(!m_borrowset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL))
{
MessageBox("数据库打开失败!","数据库错误",MB_OK);
return;
}
m_strbackdate.Format("%d年%d月%d日",m_borrowset.m_Return_Date.GetYear(),m_borrowset.m_Return_Date.GetMonth(),m_borrowset.m_Return_Date.GetDay());
if(tm>m_borrowset.m_Return_Date)
{
days=(int)(tm-m_borrowset.m_Return_Date).GetDays();
m_strextended="超期";
}
else
{
days=0;
m_strextended="不超期";
}
m_strdays.Format("%d",days);
m_bookset.Close();
m_borrowset.Close();
UpdateData(FALSE);
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void CReturnDlg::OnButtonClear()
{
m_strproofID="";
m_strreadername="";
m_strbookID="";
m_strbookname="";
m_strreturndate="";
m_strbackdate="";
m_strextended="";
UpdateData(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -