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

📄 dksj.cpp

📁 以班级为单位对每门课程的考试成绩进行评价。
💻 CPP
字号:
// Dksj.cpp : implementation file
//

#include "stdafx.h"
#include "sjfx.h"
#include "Dksj.h"
//#include "sjfxview.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDksj dialog
//class CSJFXView;

CDksj::CDksj(CWnd* pParent /*=NULL*/)
	: CDialog(CDksj::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDksj)
	m_nBj = -1;
	m_nKc = -1;
	m_nZy = -1;
	//}}AFX_DATA_INIT
}


void CDksj::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDksj)
	DDX_Control(pDX, IDC_CBZY, m_cZy);
	DDX_Control(pDX, IDC_CBKC, m_cKc);
	DDX_Control(pDX, IDC_CBBJ, m_cBj);
	DDX_CBIndex(pDX, IDC_CBBJ, m_nBj);
	DDX_CBIndex(pDX, IDC_CBKC, m_nKc);
	DDX_CBIndex(pDX, IDC_CBZY, m_nZy);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDksj, CDialog)
	//{{AFX_MSG_MAP(CDksj)
	ON_CBN_SELCHANGE(IDC_CBZY, OnSelchangeCbzy)
	ON_CBN_SELCHANGE(IDC_CBBJ, OnSelchangeCbbj)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDksj message handlers

void CDksj::OnOK() 
{
	// TODO: Add extra validation here

        UpdateData();
        
	CSJFXApp* pApp = (CSJFXApp*)AfxGetApp();
        HRESULT hr;
	CString strzy,strbj,strkc,strSql;
        m_cZy.GetLBText(m_nZy,strzy);
	m_cBj.GetLBText(m_nBj,strbj);
        m_cKc.GetLBText(m_nKc,strkc);

	strSql="SELECT * FROM sjxx where zy='"+strzy+"' and bj='"+strbj+"' and kc='"+strkc+"'";
        AfxMessageBox(strSql);
	pApp->m_pRecordset->Close();
        try {
	   hr = pApp->m_pRecordset->Open(strSql.AllocSysString(),
		pApp->m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
	}
	catch(_com_error e)
	{
	  CString errormessage;
	  errormessage.Format("打开试卷失败!\r\n错误信息:%s",e.ErrorMessage());
	  AfxMessageBox(errormessage);
	}
	if(!SUCCEEDED(hr))
	{  AfxMessageBox("打开试卷基本信息表出错!");  return ;	}
	if(pApp->m_pRecordset->adoEOF)
	{  AfxMessageBox("试卷库里没有该试卷!");  return ;  }

	pApp->m_pRecordset->Close();

	pApp->m_Sj.Zy=strzy;   
        pApp->m_Sj.Bj=strbj;
	pApp->m_Sj.Kc=strkc;
	pApp->m_Sj.Js=(char*)(_bstr_t)pApp->m_pRecordset->GetCollect(_variant_t("js"));
	pApp->m_Sj.Cjb=(char*)(_bstr_t)pApp->m_pRecordset->GetCollect(_variant_t("cjb"));

        AfxMessageBox("试卷打开成功!");  

     //   pApp->m_pView->UpdateWindow();

	CDialog::OnOK();
}

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

void CDksj::OnSelchangeCbzy() 
{
	// TODO: Add your control notification handler code here

        UpdateData();
        HRESULT hr;
	CString strSql, str, str2 ;
	CSJFXApp* pApp = (CSJFXApp*)AfxGetApp();

        m_cZy.GetLBText(m_nZy,str);
	str2.Format("你的选择是:'%s'", str);
	AfxMessageBox(str2);

	strSql="SELECT bj FROM sjxx where zy='"+ str +"'group by bj";
	AfxMessageBox(strSql);

	try {
	   hr = pApp->m_pRecordset->Open(strSql.AllocSysString(),
		pApp->m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
	}
        catch(_com_error e)
	{
	  CString errormessage;
	  errormessage.Format("查找班级失败!\r\n错误信息:%s",e.ErrorMessage());
	  AfxMessageBox(errormessage);
	}
	if(!SUCCEEDED(hr))
	{  AfxMessageBox("打开试卷基本信息表出错!");  return ;	}
	if(pApp->m_pRecordset->adoEOF)
	{  AfxMessageBox("试卷库里没有试卷!");	return ;  }

        while(!pApp->m_pRecordset->adoEOF)
	{
           str = (char*)(_bstr_t)pApp->m_pRecordset->GetCollect(_variant_t("bj"));
	   m_cBj.AddString(str);
	   pApp->m_pRecordset->MoveNext();
	}

	pApp->m_pRecordset->Close();
}

void CDksj::OnSelchangeCbbj() 
{
	// TODO: Add your control notification handler code here

        UpdateData();

	CString strSql, str;
	CSJFXApp* pApp = (CSJFXApp*)AfxGetApp();
        m_cBj.GetLBText(m_nBj,str);

	strSql="SELECT kc FROM sjxx where bj='"+ str  +"'group by kc";
	HRESULT hr = pApp->m_pRecordset->Open(strSql.AllocSysString(),
		pApp->m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
	
	if(!SUCCEEDED(hr))
	{  AfxMessageBox("打开试卷基本信息表出错!");  return ;	}
	if(pApp->m_pRecordset->adoEOF)
	{  AfxMessageBox("试卷库里没有试卷!");	return ;  }

        while(!pApp->m_pRecordset->adoEOF)
	{
           str = (char*)(_bstr_t)pApp->m_pRecordset->GetCollect(_variant_t("kc"));
	   m_cKc.AddString(str);
	   pApp->m_pRecordset->MoveNext();
	}

	pApp->m_pRecordset->Close();
}

BOOL CDksj::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	
        CString strSql, str;
	CSJFXApp* pApp = (CSJFXApp*)AfxGetApp();

	strSql="SELECT zy FROM sjxx group by zy";
	HRESULT hr = pApp->m_pRecordset->Open(strSql.AllocSysString(),
		pApp->m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
	
	if(!SUCCEEDED(hr))
	{  AfxMessageBox("打开试卷基本信息表出错!");  return FALSE;	}
	if(pApp->m_pRecordset->adoEOF)
	{  AfxMessageBox("试卷库里没有试卷!");	
	   pApp->m_pRecordset->Close();
	   return FALSE;  }

        while(!pApp->m_pRecordset->adoEOF)
	{
           str = (char*)(_bstr_t)pApp->m_pRecordset->GetCollect(_variant_t("zy"));
	   m_cZy.AddString(str);
	   pApp->m_pRecordset->MoveNext();
	}

	pApp->m_pRecordset->Close();
  
	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 + -