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

📄 searchstudent.cpp

📁 学生住宿管理系统 本程序用于交流方面,仅共学习交流,用于其他方面 功能欠缺
💻 CPP
字号:
// SearchStudent.cpp : implementation file
//

#include "stdafx.h"
#include "Dormitory.h"
#include "SearchStudent.h"
#include "room.h"
#include "student.h"
#include "floor.h"
#include "building.h"
#include "StuRoom.h"
#include "search.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// SearchStudent dialog

extern CDormitoryApp theApp;
SearchStudent::SearchStudent(CWnd* pParent /*=NULL*/)
	: CDialog(SearchStudent::IDD, pParent)
{
	//{{AFX_DATA_INIT(SearchStudent)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void SearchStudent::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(SearchStudent)
	DDX_Control(pDX, IDC_LISTstu, m_student);
	DDX_Control(pDX, IDC_LISTroom, m_room);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(SearchStudent, CDialog)
	//{{AFX_MSG_MAP(SearchStudent)
	ON_NOTIFY(NM_CLICK, IDC_LISTroom, OnClickLISTroom)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// SearchStudent message handlers

BOOL SearchStudent::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_student.SetRedraw(FALSE);
	m_room.SetRedraw(FALSE);
	// TODO: Add extra initialization here
	m_student.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_HEADERDRAGDROP);
    m_student.SetBkColor(RGB(0, 128, 128));
	m_student.SetTextColor(RGB(0,0,0));
	m_student.SetTextBkColor(RGB(0,128, 128));

	m_student.InsertColumn(1,"学号");
	m_student.InsertColumn(2,"姓名");
	m_student.InsertColumn(3,"班级");
	m_student.InsertColumn(4,"学院");
	m_student.InsertColumn(5,"性别");

	int wid = 25;
	m_student.SetColumnWidth(0,wid*6);
	m_student.SetColumnWidth(1,wid*6);
	m_student.SetColumnWidth(2,wid*6);
	m_student.SetColumnWidth(3,wid*6);
	m_student.SetColumnWidth(4,wid*6);

	m_room.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_HEADERDRAGDROP);
    m_room.SetBkColor(RGB(0, 128, 128));
	m_room.SetTextColor(RGB(0,0,0));
	m_room.SetTextBkColor(RGB(0,128, 128));

	m_room.InsertColumn(1,"房间号");
	m_room.InsertColumn(2,"楼层");
	m_room.InsertColumn(3,"楼号");
	m_room.InsertColumn(4,"学院");
	m_room.InsertColumn(5,"面积");
	m_room.InsertColumn(6,"阳台");
	m_room.InsertColumn(7,"厕所");
	m_room.InsertColumn(8,"床");
	m_room.InsertColumn(9,"桌子");
	m_room.InsertColumn(10,"椅子");
	m_room.InsertColumn(11,"还可住几人");

	m_room.SetColumnWidth(0,wid*6);
	m_room.SetColumnWidth(1,wid*6);
	m_room.SetColumnWidth(2,wid*6);
	m_room.SetColumnWidth(3,wid*6);
	m_room.SetColumnWidth(4,wid*6);
	m_room.SetColumnWidth(5,wid*6);
	m_room.SetColumnWidth(6,wid*6);
	m_room.SetColumnWidth(7,wid*6);
	m_room.SetColumnWidth(8,wid*6);
	m_room.SetColumnWidth(9,wid*6);
	m_room.SetColumnWidth(10,wid*6);

	Cbuilding*bd;
	Croom *p;
	Cfloor *flr;
	int i=0;
	bd=(Cbuilding*)theApp.dm.vec1.getFirstRecord();
	if(bd)
	{
	flr=(Cfloor*)bd->getFirstRecord();
	p=(Croom*)flr->getFirstRecord();
	while(bd)
	{     
	   while(flr)
	   {
			  
		 while(p)
		 {
             
		    CString strTemp;
		    strTemp = p->getField("no");
			strTemp.TrimRight();
			m_room.InsertItem(i, strTemp);

		    strTemp = p->getField("floor");
			strTemp.TrimRight();
			m_room.SetItemText(i,1, strTemp);

			strTemp = p->getField("building");
			strTemp.TrimRight();
			m_room.SetItemText(i, 2,strTemp);

			strTemp = p->getField("dept");
			strTemp.TrimRight();
			m_room.SetItemText(i,3, strTemp);

			strTemp = p->getField("size");
			strTemp.TrimRight();
			m_room.SetItemText(i, 4,strTemp);
		    
		    
			strTemp = p->getField("balcony");
			strTemp.TrimRight();
			m_room.SetItemText(i, 5,strTemp);
		    
			strTemp = p->getField("toilet");
			strTemp.TrimRight();
			m_room.SetItemText(i, 6,strTemp);
		    
			strTemp = p->getField("bed");
			strTemp.TrimRight();
			m_room.SetItemText(i, 7,strTemp);
		    
			strTemp = p->getField("desk");
			strTemp.TrimRight();
			m_room.SetItemText(i, 8,strTemp);
		    
			strTemp = p->getField("chair");
			strTemp.TrimRight();
			m_room.SetItemText(i, 9,strTemp);
		    
            strTemp = p->getField("remain");
			strTemp.TrimRight();
			m_room.SetItemText(i, 10,strTemp);
		    
            p=(Croom*)flr->getNext();
		 }//room

		flr=(Cfloor*)bd->getNext();
		if(flr)
        p=(Croom*)flr->getFirstRecord();
	
		} //floor
	    bd=(Cbuilding*)theApp.dm.vec1.getNext();
		if(bd)
		flr=(Cfloor*)bd->getFirstRecord();
	}//building
	}
    m_student.SetRedraw(TRUE);
	m_room.SetRedraw(TRUE);
   
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void SearchStudent::OnClickLISTroom(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	int i = m_room.GetSelectionMark();
	m_student.DeleteAllItems();
	CString sno;
	CString flag;
	sno=m_room.GetItemText(i,0);

	i=0;
	Cobjectset*stu;
	Csearch*sh;//调用查询类
	sh=new Csearch();
	stu=sh->searchstudent(sno);//查询住在sno号房间的学生集合,赋给stu
	Cstudent*rm;
	rm=(Cstudent*)(stu->getFirstRecord());
	if(rm){

		while(rm){//把得到的学生集合插入列表中
		    CString strTemp;
		    strTemp = rm->getField("no");
			strTemp.TrimRight();
			m_student.InsertItem(i, strTemp);

		    strTemp = rm->getField("name");
			strTemp.TrimRight();
			m_student.SetItemText(i,1, strTemp);

			strTemp = rm->getField("grade");
			strTemp.TrimRight();
			m_student.SetItemText(i,2, strTemp);

			strTemp = rm->getField("dept");
			strTemp.TrimRight();
			m_student.SetItemText(i,3, strTemp);

			strTemp = rm->getField("sex");
			strTemp.TrimRight();
			m_student.SetItemText(i,4, strTemp);

			rm=(Cstudent*)(stu->getNext());
		}
	}
	else
		MessageBox("该宿舍没有分配");
	m_student.SetRedraw(TRUE);
	*pResult = 0;
}

⌨️ 快捷键说明

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