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

📄 bookadd.cpp

📁 Check customer the legitimacy of the importation Check this book number whether already existence
💻 CPP
字号:
// BookAdd.cpp : implementation file
//

#include "stdafx.h"
#include "library.h"
#include "BookAdd.h"

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

/////////////////////////////////////////////////////////////////////////////
// CBookAdd dialog


CBookAdd::CBookAdd(CWnd* pParent /*=NULL*/)
	: CDialog(CBookAdd::IDD, pParent)
{
	//{{AFX_DATA_INIT(CBookAdd)
	m_Author = _T("");
	m_BookID = _T("");
	m_Borrowed = FALSE;
	m_Press = _T("");
	m_Price = _T("");
	m_PublishDate = COleDateTime::GetCurrentTime();
	m_BookName = _T("");
	//}}AFX_DATA_INIT
}


void CBookAdd::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CBookAdd)
	DDX_Text(pDX, IDC_AUTHOR, m_Author);
	DDX_Text(pDX, IDC_BOOKID, m_BookID);
	DDX_Check(pDX, IDC_BORROWED, m_Borrowed);
	DDX_Text(pDX, IDC_PRESS, m_Press);
	DDX_Text(pDX, IDC_PRICE, m_Price);
	DDX_DateTimeCtrl(pDX, IDC_PUBLISH_DATE, m_PublishDate);
	DDX_Text(pDX, IDC_BOOK_NAME, m_BookName);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CBookAdd, CDialog)
	//{{AFX_MSG_MAP(CBookAdd)
	ON_BN_CLICKED(IDC_TEXT_CLEAR, OnTextClear)
	ON_BN_CLICKED(IDC_BOOK_ADD, OnBookAdd)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CBookAdd message handlers

void CBookAdd::OnTextClear() 
{
	// TODO: Add your control notification handler code here
	//清空基本数据区的数据
	COleDateTime publishTime;

	m_BookID.Empty();
	m_BookName.Empty();
	m_Author.Empty();
	m_Price.Empty();

	publishTime=COleDateTime::GetCurrentTime();
	nYear=publishTime.GetYear();
	nMonth=publishTime.GetMonth();
	nDay=publishTime.GetDay();
	m_PublishDate.SetDate(nYear,nMonth,nDay);

	m_Press.Empty();
	m_Borrowed=false;

	UpdateData(false);
	GetDlgItem(IDC_BOOKID)->SetFocus();
	
}

void CBookAdd::OnBookAdd() 
{
	// TODO: Add your control notification handler code here
	//向book表中添加纪录
	if(!CheckValid())
		return;

	m_BookSet.AddNew();
	m_BookSet.m_bookid=m_BookID;
	m_BookSet.m_bookname=m_BookName;
	m_BookSet.m_author=m_Author;
	m_BookSet.m_price=m_Price;

	nYear=m_PublishDate.GetYear();
	nMonth=m_PublishDate.GetMonth();
	nDay=m_PublishDate.GetDay();
	CTime PublishTime(nYear,nMonth,nDay,0,0,0);
	m_BookSet.m_publishtime=PublishTime;

	m_BookSet.m_press=m_Press;
	m_BookSet.m_borrowed=m_Borrowed;
	
	m_BookSet.Update();
	m_BookSet.Close();

	OnTextClear();

}

BOOL CBookAdd::CheckValid()
{
	//检查用户输入的合法性
	UpdateData();

	if(m_BookID.IsEmpty())
	{
		AfxMessageBox("书号不能为空,请输入书号!");
		GetDlgItem(IDC_BOOKID)->SetFocus();
		return false;
	}

	//检查此书号是否已经存在
	m_BookSet.Open();
	m_BookSet.m_strFilter="bookid='"+m_BookID+"'";
	m_BookSet.Requery();
	if(m_BookSet.GetRecordCount()!=0)
	{
		AfxMessageBox("您输入的书号已经存在,请重新输入!");
		GetDlgItem(IDC_BOOKID)->SetFocus();
		m_BookSet.Close();
		return false;
	}

	return true;

}

⌨️ 快捷键说明

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