student_sent.cpp

来自「图书管理系统 语言:C,SQL 功能:实现图书管理的数字化」· C++ 代码 · 共 110 行

CPP
110
字号
// Student_sent.cpp : implementation file
//

#include "stdafx.h"
#include "Library.h"
#include "Student_sent.h"

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

/////////////////////////////////////////////////////////////////////////////
// Student_sent dialog


Student_sent::Student_sent(CWnd* pParent /*=NULL*/)
	: CDialog(Student_sent::IDD, pParent)
{
	//{{AFX_DATA_INIT(Student_sent)
	m_sid_temp = _T("");
	m_isbn_temp = _T("");
	//}}AFX_DATA_INIT
}


void Student_sent::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(Student_sent)
	DDX_Text(pDX, IDC_EDIT1, m_sid_temp);
	DDX_Text(pDX, IDC_EDIT2, m_isbn_temp);
	//}}AFX_DATA_MAP
}


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

/////////////////////////////////////////////////////////////////////////////
// Student_sent message handlers

void Student_sent::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData(TRUE);
	if(m_sid_temp.IsEmpty()||m_isbn_temp.IsEmpty())
	{
	   MessageBox("请输入完整信息!");
	   return;
	}
	CString str="Sid='"+m_sid_temp+"'";
	student_set.m_strFilter=str;
	student_set.Open();//打开数据集合
	int recount=student_set.GetRecordCount();
	if(recount==0)
	{
		MessageBox("无此学生记录!");
		student_set.m_strFilter="";
		UpdateData(FALSE);
		student_set.Close();
		return;
	}
	else
	{
		CString str2="ISBN='"+m_isbn_temp+"'";
		book_set.m_strFilter=str2;
		book_set.Open();
		int recount2=book_set.GetRecordCount();
		if(recount2==0)
		{
			MessageBox("无此图书借阅记录!");
			book_set.m_strFilter="";
			student_set.m_strFilter="";//
			UpdateData(FALSE);
			book_set.Close();
			student_set.Close();
			
			return;
			
		}
		else//既有此学生又有此图书的情况
		{
			borrow_set.Open();

			book_set.Edit();
			book_set.m_B_borrow_count--;
			book_set.Update();//增加和更新都要执行一个此操作
			book_set.MoveFirst();
    		book_set.Requery();
			book_set.m_strFilter="";
			
			borrow_set.Delete();
			borrow_set.MoveFirst();
    		borrow_set.Requery();
				
			MessageBox("还书操作已成功!");

			UpdateData(FALSE);
			borrow_set.Close();
			book_set.Close();
			student_set.Close();
			return;
		}
	}
}

⌨️ 快捷键说明

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