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

📄 instrucqdlg.cpp

📁 这是一个学生管理系统 包含学生基本信息 选课信息 宿舍信息 教师信息 课程信息 班机信息 教师信息等录入 查询 修改删除等强大功能
💻 CPP
字号:
// InstrucQdlg.cpp : implementation file
//

#include "stdafx.h"
#include "Student.h"
#include "InstrucQdlg.h"

#include "InstrucSet.h"
#include "CourseSet.h"
#include "TeacherSet.h"

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

/////////////////////////////////////////////////////////////////////////////
// CInstrucQdlg dialog


CInstrucQdlg::CInstrucQdlg(CWnd* pParent /*=NULL*/)
	: CDialog(CInstrucQdlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CInstrucQdlg)
	m_course_name = _T("");
	m_teach_name = _T("");
	//}}AFX_DATA_INIT
}


void CInstrucQdlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CInstrucQdlg)
	DDX_Control(pDX, IDC_LIST_INSTRUCQ, m_stuQuery_List);
	DDX_Text(pDX, IDC_EDIT_COURSE_NAME, m_course_name);
	DDX_Text(pDX, IDC_EDIT_TEA_NAME, m_teach_name);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CInstrucQdlg, CDialog)
	//{{AFX_MSG_MAP(CInstrucQdlg)
	ON_BN_CLICKED(IDC_BTN_QUERY, OnBtnQuery)
	ON_BN_CLICKED(IDC_BTN_DELETE, OnBtnDelete)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CInstrucQdlg message handlers

void CInstrucQdlg::OnBtnQuery() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	CDialog::OnCancel();
    CInstrucSet pinstuction;
	CCourseSet pcourse;
    CTeacherSet pteacher;
	
    CString strSQL;
	try{
		if((!m_course_name.IsEmpty())&& (!m_teach_name.IsEmpty())){
			strSQL="select * from Instruction where pinstuction.Course_no=(select course.Course_no from course where pcourse.Name=m_course ) and pinstruction.Teacher_no=(select teacher.Teacher_no from teacher where pteacher.Name=m_teach_name)"; 
		}
		else if((m_course_name.IsEmpty())&&(!m_teach_name.IsEmpty())){
            strSQL="select * from Instruction where pinstruction.Teacher_no=(select teacher.Teacher_no from teacher where pteacher.Name=m_teach_name)"; 
		}
		else if((!m_course_name.IsEmpty())&&(m_teach_name.IsEmpty())){
            strSQL="select * from Instruction where pinstuction.Course_no=(select course.Course_no from course where pcourse.Name=m_course ) "; 
		}
		else{
				AfxMessageBox("请输入要查询的课程名称或教师姓名!");
				return;
			}
			
			
	//AfxMessageBox("打开数据库!");
	if(!pinstuction.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL))
	{
		 AfxMessageBox("打开数据库失败!");
		return;
	}
	m_stuQuery_List.DeleteAllItems();//将表中原有的记录全部删掉
	int i=0;
	
	while(!pinstuction.IsEOF())
	{
	    m_stuQuery_List.InsertItem(i,pinstuction.m_Teacher_no);
		m_stuQuery_List.SetItemText(i,1,pinstuction.m_Course_no);
		m_stuQuery_List.SetItemText(i,2,pinstuction.m_Classroom_no);
		m_stuQuery_List.SetItemText(i,3,pinstuction.m_Class_no);
		m_stuQuery_List.SetItemText(i,4,pinstuction.m_Instruct_time);
		i++;
		pinstuction.MoveNext();
	}
	pinstuction.Close();
}
	catch(CDBException *pe){
		AfxMessageBox(pe->m_strError);
		pe->Delete();
	}	
}

void CInstrucQdlg::OnCancel() 
{
	// TODO: Add extra cleanup here
	
	CDialog::OnCancel();
}

void CInstrucQdlg::OnBtnDelete() 
{
	// TODO: Add your control notification handler code here
	
}

BOOL CInstrucQdlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	//初始化授课情况表
	m_stuQuery_List.InsertColumn(0,"教师编号");
	m_stuQuery_List.InsertColumn(1,"课程编号");
	m_stuQuery_List.InsertColumn(2,"教室编号");
	m_stuQuery_List.InsertColumn(3,"班级编号");
	m_stuQuery_List.InsertColumn(4,"授课时间");
    

	m_stuQuery_List.SetColumnWidth(0,100);
	m_stuQuery_List.SetColumnWidth(1,100);
	m_stuQuery_List.SetColumnWidth(2,100);
    m_stuQuery_List.SetColumnWidth(3,100);
	m_stuQuery_List.SetColumnWidth(4,100);
	m_stuQuery_List.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

⌨️ 快捷键说明

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