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

📄 stucourseqdlg.cpp

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

#include "stdafx.h"
#include "Student.h"
#include "StuCourseQdlg.h"

#include "StudentSet.h"
#include "StuCourseSet.h"
#include "CourseSet.h"

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

/////////////////////////////////////////////////////////////////////////////
// CStuCourseQdlg dialog


CStuCourseQdlg::CStuCourseQdlg(CWnd* pParent /*=NULL*/)
	: CDialog(CStuCourseQdlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CStuCourseQdlg)
	m_no = _T("");
	m_name = _T("");
	//}}AFX_DATA_INIT
}


void CStuCourseQdlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CStuCourseQdlg)
	DDX_Control(pDX, IDC_LIST_STU_COURSEQ, m_stuQery_List);
	DDX_Text(pDX, IDC_EDIT_NO, m_no);
	DDV_MaxChars(pDX, m_no, 8);
	DDX_Text(pDX, IDC_EDIT_NAME, m_name);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CStuCourseQdlg, CDialog)
	//{{AFX_MSG_MAP(CStuCourseQdlg)
	ON_BN_CLICKED(IDC_BTN_DELETE, OnBtnDelete)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CStuCourseQdlg message handlers

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

void CStuCourseQdlg::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData();

    CStudentSet pstu;
	CStuCourseSet pstucourse;
	CCourseSet pcourse;

    CString strSQL;
	try{
		if(!m_no.IsEmpty())
		    strSQL="select stu_course.Stu_no,stu_course.Score,course.Name from stu_course,course where pstucourse.m_Stu_no=m_no and pcourse.Course_no=(select Course_no from stu_course where pstucourse.m_Stu_no=)";

		else{
			if(m_name.IsEmpty()){
				AfxMessageBox("请输入要查询学生姓名或学号!");
				return;
			}
			
		    strSQL="select Stu_no,Score,Name from stu_course,course where pstucourse.m_Stu_no=(select Stu_no from student where pstu.m_Name=m_name) and pcourse.Course_no=(select Course_no from stu_course where pstucourse.m_Stu_no=(select Stu_no from student where pstu.m_Name=m_name))";
		}
	//AfxMessageBox("打开数据库!");
	if(!pstucourse.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL))
	{
		 AfxMessageBox("打开数据库失败!");
		return;
	}
	m_stuQery_List.DeleteAllItems();//将表中原有的记录全部删掉
	int i=0;
	while(!pstucourse.IsEOF())
	{
	    m_stuQery_List.InsertItem(i,pstucourse.m_Stu_no);
		m_stuQery_List.SetItemText(i,1,pcourse.m_Name);
		//itoa(pstucourse.m_Score,buffer,10);
		CString str;
		str.Format("%s",pstucourse.m_Score);
		m_stuQery_List.SetItemText(i,2,str);
		i++;
		pstucourse.MoveNext();
	}
	pstucourse.Close();
	}
	catch(CDBException *pe){
		AfxMessageBox(pe->m_strError);
		pe->Delete();
	}
	
//	CDialog::OnOK();
}

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

BOOL CStuCourseQdlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_stuQery_List.InsertColumn(0,"学号");
	m_stuQery_List.InsertColumn(1,"课程");
    m_stuQery_List.InsertColumn(2,"成绩");

	m_stuQery_List.SetColumnWidth(0,100);
	m_stuQery_List.SetColumnWidth(1,100);
	m_stuQery_List.SetColumnWidth(1,100);

	m_stuQery_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 + -