C + + Course Design -- Library Lending System (MFC)

Lesson title

Library borrowing system

Class setting requirements

Design content
There are two types of books in a library: books and magazines, and readers: teachers and students. Use text files to store books and readers' information. Shan librarian input library card number, data number, etc. for daily book borrowing, women return business. The main functions include:

  1. user management
  2. Basic information of books (book name, barcode, internal classification number, author, inventory), basic information of magazines (book name, barcode, volume number, inventory), basic information of teachers and students (name, library card number) entry, deletion, modification and preservation
  3. Book data and reader information entry, including manual entry and file import
  4. Borrowing and returning (students are required to borrow up to 3 books and S magazines; teachers can borrow up to 5 books and 10 magazines)
  5. Readers can check their current book making situation at any time
  6. The inquiry and statistics of the collection of books and materials
  7. The export of information, reader information and report

Program operation interface


Part of source code

void CLibraryView::OnInitialUpdate()
{
	CFormView::OnInitialUpdate();
	GetParentFrame()->RecalcLayout();
	ResizeParentToFit();

DWORD dwStyle1=m_bookshow.GetExtendedStyle();
	dwStyle1 |=LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT|LVS_EX_CHECKBOXES;
	m_bookshow.SetExtendedStyle(dwStyle1);
	m_bookshow.InsertColumn(0,_T("Title"),0,100);
	m_bookshow.InsertColumn(1,_T("bar code"),0,100);
	m_bookshow.InsertColumn(2,_T("author"),0,100);
	m_bookshow.InsertColumn(3,_T("Inventory"),0,100);



	DWORD dwStyle2=m_magazineshow.GetExtendedStyle();
	dwStyle2 |=LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT|LVS_EX_CHECKBOXES;
	m_magazineshow.SetExtendedStyle(dwStyle2);
	m_magazineshow.InsertColumn(0,_T("Title"),0,100);
	m_magazineshow.InsertColumn(1,_T("Volume number"),0,100);
	m_magazineshow.InsertColumn(2,_T("bar code"),0,100);
	m_magazineshow.InsertColumn(3,_T("Inventory"),0,100);
DWORD dwStyle3=m_teachershow.GetExtendedStyle();
		dwStyle3 |=LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT|LVS_EX_CHECKBOXES;
	m_teachershow.SetExtendedStyle(dwStyle3);
	m_teachershow.InsertColumn(0,_T("Full name"),0,70);
	m_teachershow.InsertColumn(1,_T("Library card number"),0,100);
	
DWORD dwStyle4=m_studentshow.GetExtendedStyle();
		dwStyle4 |=LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT|LVS_EX_CHECKBOXES;
	m_studentshow.SetExtendedStyle(dwStyle4);
	m_studentshow.InsertColumn(0,_T("Full name"),0,70);
	m_studentshow.InsertColumn(1,_T("Library card number"),0,100);
}
void CLibraryView::OnButton1() //Data manual import
{
	// TODO: Add your control notification handler code here

	UpdateData();
	CLibraryDoc *p=GetDocument();
	if(m_book!=1)
	{
		bookset a;
		if(IDOK==a.DoModal())
		{
			UpdateData();
			strncpy(p->book[p->bookpos].name,(LPCTSTR)a.m_bookname,sizeof(p->book[p->bookpos].name));
			strncpy(p->book[p->bookpos].zuozhe,(LPCTSTR)a.m_zuozhe,sizeof(p->book[p->bookpos].zuozhe));
			p->book[p->bookpos].num=a.m_num;
			p->book[p->bookpos].tiaoma=a.m_tiaoma;
			p->bookpos++;
		}else
		{

		MessageBox("You canceled the entry");
		}
	}
	else
	{
		magazineset a;
		if(IDOK==a.DoModal())
		{UpdateData();
		strncpy(p->maganize[p->magznizepos].name,(LPCTSTR)a.m_magazinename,sizeof(p->maganize[p->magznizepos].name));
		p->maganize[p->magznizepos].jvanhao=a.m_jvanhao;
		p->maganize[p->magznizepos].num=a.m_num;
		p->maganize[p->magznizepos].tiaoma=a.m_tiaoma;
		p->magznizepos++;

		}else
		{

		MessageBox("You canceled the entry");
		}
	}
}

void CLibraryView::OnButton6() //Readers
{
	// TODO: Add your control notification handler code here
	UpdateData();
	CLibraryDoc *p=GetDocument();
	if(m_teacher!=1)
	{
	inforset a;
	if(IDOK==a.DoModal())
	{
		p->teacher[p->teacherpos].id=a.m_id;
	strncpy(p->teacher[p->teacherpos].name,(LPCTSTR)a.m_name,sizeof(p->teacher[p->teacherpos].name));
	p->teacherpos++;

	}
	else
	{
	MessageBox("You canceled the entry");
	}
	}
	else
	{

	inforset a;
	if(IDOK==a.DoModal())
	{
			p->student[p->studentpos].id=a.m_id;
	strncpy(p->student[p->studentpos].name,(LPCTSTR)a.m_name,sizeof(p->student[p->studentpos].name));
	p->studentpos++;
	}
	else
	{
	MessageBox("You canceled the entry");
	}

	}
}

void CLibraryView::OnButton18() //information display
{
	// TODO: Add your control notification handler code here
		CLibraryDoc *p=GetDocument();
		m_bookshow.DeleteAllItems();
		m_magazineshow.DeleteAllItems();
		m_teachershow.DeleteAllItems();
		m_studentshow.DeleteAllItems();
		for(int i=0;i<p->bookpos;i++)
		{
			CString z,x,c,v;
			z.Format("%s",p->book[i].name);
			x.Format("%d",p->book[i].tiaoma);
			c.Format("%s",p->book[i].zuozhe);
			v.Format("%d",p->book[i].num);
			m_bookshow.InsertItem(i,z);
			m_bookshow.SetItemText(i,1,x);
			m_bookshow.SetItemText(i,2,c);
			m_bookshow.SetItemText(i,3,v);
		}
		for( i=0;i<p->magznizepos;i++)
		{
			CString z,x,c,v;
			z.Format("%s",p->maganize[i].name);
			x.Format("%d",p->maganize[i].jvanhao);
			c.Format("%d",p->maganize[i].tiaoma);
			v.Format("%d",p->maganize[i].num);
			m_magazineshow.InsertItem(i,z);
			m_magazineshow.SetItemText(i,1,x);
			m_magazineshow.SetItemText(i,2,c);
			m_magazineshow.SetItemText(i,3,v);
		}
		for( i=0;i<p->teacherpos;i++)
		{
			CString z,x;
			z.Format("%s",p->teacher[i].name);
			x.Format("%d",p->teacher[i].id);
			m_teachershow.InsertItem(i,z);
			m_teachershow.SetItemText(i,1,x);
		}
		for( i=0;i<p->studentpos;i++)
		{
			CString z,x;
			z.Format("%s",p->student[i].name);
			x.Format("%d",p->student[i].id);
			m_studentshow.InsertItem(i,z);
			m_studentshow.SetItemText(i,1,x);
		}
}
155 original articles published, praised 103, visited 50000+
Private letter follow

Posted on Sat, 08 Feb 2020 04:05:13 -0800 by SoberDude