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

📄 chengji.cpp

📁 本系统是vc开发的成绩管理系统,功能强大易于阅读.
💻 CPP
字号:
// chengji.cpp : implementation file
//

#include "stdafx.h"
#include "mark.h"
#include "chengji.h"
#include "MainFrm.h"
#include "adodc.h"
#include "_recordset.h"
#include "fields.h"
#include "field.h"

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

/////////////////////////////////////////////////////////////////////////////
// Cchengji

IMPLEMENT_DYNCREATE(Cchengji, CFormView)

Cchengji::Cchengji()
	: CFormView(Cchengji::IDD)
{
	//{{AFX_DATA_INIT(Cchengji)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}

Cchengji::~Cchengji()
{
}

void Cchengji::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(Cchengji)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(Cchengji, CFormView)
	//{{AFX_MSG_MAP(Cchengji)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Cchengji diagnostics

#ifdef _DEBUG
void Cchengji::AssertValid() const
{
	CFormView::AssertValid();
}

void Cchengji::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// Cchengji message handlers

void Cchengji::OnButton1() 
{
	CMainFrame *pframe=(CMainFrame *)AfxGetMainWnd();
	CEdit *kech=(CEdit *)GetDlgItem(IDC_EDIT1);
	CString kch;
	kech->GetWindowText(kch);
	if(kch==""){
		pframe->Agenttalk("必须输入课程号!");
		return;
	}
	bool isfound=false;
	CAdodc *adodc1=(CAdodc *)GetDlgItem(IDC_ADODC1);
	CComboBox *jiaosh=(CComboBox *)GetDlgItem(IDC_COMBO1);
	jiaosh->ResetContent();
	CEdit *kcmc=(CEdit *)GetDlgItem(IDC_EDIT2);
	adodc1->GetRecordset().MoveFirst();
	while(!adodc1->GetRecordset().GetEof()){
		COleVariant kechenghao=adodc1->GetRecordset().GetFields().GetItem(COleVariant("课程号")).GetValue();
		if(COleVariant(kch)==kechenghao){
			isfound=true;
			COleVariant jsh=adodc1->GetRecordset().GetFields().GetItem(COleVariant("教师号")).GetValue();
			CString jiaoshihao;
			jiaoshihao=jsh.bstrVal;
			jiaosh->AddString(jiaoshihao);
			jsh=adodc1->GetRecordset().GetFields().GetItem(COleVariant("课程名称")).GetValue();
			jiaoshihao=jsh.bstrVal;
			kcmc->SetWindowText(jiaoshihao);
		}
		adodc1->GetRecordset().MoveNext();
	}
	if(!isfound){
		pframe->Agenttalk("找不到该课程!");
		kech->SetWindowText("");
		kech->SetFocus();
	}
	adodc1->GetRecordset().MoveFirst();
}

void Cchengji::OnSelchangeCombo1() 
{
	CComboBox *combo=(CComboBox *)GetDlgItem(IDC_COMBO1);
	CAdodc *adodc=(CAdodc *)GetDlgItem(IDC_ADODC1);
	CEdit *kech=(CEdit *)GetDlgItem(IDC_EDIT1);
	CString kch;
	kech->GetWindowText(kch);
	CString str;
	int i=combo->GetCurSel();
	combo->GetLBText(i,str);
	adodc->GetRecordset().MoveFirst();
	bool isfound=false;
	while(!adodc->GetRecordset().GetEof()){
		COleVariant jsh=adodc->GetRecordset().GetFields().GetItem(COleVariant("教师号")).GetValue();
		if(jsh==COleVariant(str)){
			COleVariant k=adodc->GetRecordset().GetFields().GetItem(COleVariant("课程号")).GetValue();
			if(COleVariant(kch)==k){
				isfound=true;
				k=adodc->GetRecordset().GetFields().GetItem(COleVariant("教师名")).GetValue();
				CEdit *pedit=(CEdit *)GetDlgItem(IDC_EDIT3);
				CString temp=k.bstrVal;
				pedit->SetWindowText(temp);
				CEdit *detail=(CEdit *)GetDlgItem(IDC_EDIT4);
				COleVariant tem=adodc->GetRecordset().GetFields().GetItem(COleVariant("课程名称")).GetValue();
				CString tem1=tem.bstrVal;
				CString det="课程名:"+tem1;
				tem=adodc->GetRecordset().GetFields().GetItem(COleVariant("院系")).GetValue();
				tem1=tem.bstrVal;
				det+=",由"+tem1+"的"+temp+"老师任课,共";
				tem=adodc->GetRecordset().GetFields().GetItem(COleVariant("学时")).GetValue();
				tem1=tem.bstrVal;
				det+=tem1+"学时,";
				tem=adodc->GetRecordset().GetFields().GetItem(COleVariant("学分")).GetValue();
				tem1=tem.bstrVal;
				det+=tem1+"学分,该门课属于";
				tem=adodc->GetRecordset().GetFields().GetItem(COleVariant("课程类别")).GetValue();
				tem1=tem.bstrVal;
				det+=tem1;
				detail->SetWindowText(det);
				CString m_kch,m_jsh;
				kech->GetWindowText(m_kch);
				combo->GetLBText(i,m_jsh);
				CString sql="Select 学生档案表.班级,学生档案表.学号,学生档案表.姓名,学生档案表.性别,选课情况.成绩,选课情况.状态 from 学生档案表,选课情况,课程,授课,教师档案表 where 学生档案表.学号=选课情况.学号 and 选课情况.课程号=课程.课程号 and 课程.课程号=授课.课程号 and 授课.教师号=教师档案表.教师号 and 选课情况.教师号="+m_jsh+" and 教师档案表.教师号="+m_jsh+" and 课程.课程号="+m_kch;
				CAdodc *ado=(CAdodc *)GetDlgItem(IDC_ADODC2);
				ado->SetRecordSource(sql);
				ado->Refresh();
				break;
			}
		}
		adodc->GetRecordset().MoveNext();
	}
	if(!isfound){
		CMainFrame *pframe=(CMainFrame *)AfxGetMainWnd();
		pframe->Agenttalk("没有找到符合条件的信息!");
		adodc->GetRecordset().MoveFirst();
	}	
}

void Cchengji::OnButton2() 
{
	CAdodc *pdo=(CAdodc *)GetDlgItem(IDC_ADODC2);
	CMainFrame *pframe=(CMainFrame *)AfxGetMainWnd();
	pdo->GetRecordset().MoveFirst();
	while(!pdo->GetRecordset().GetEof()){
		COleVariant t=pdo->GetRecordset().GetFields().GetItem(COleVariant("成绩")).GetValue();
		CString a=t.bstrVal;
		if(a!=""){
			int c=atoi(a.GetBuffer(0));
			if(c>=60){
				pdo->GetRecordset().GetFields().GetItem(COleVariant("状态")).SetValue(COleVariant("通过"));
			}else{
				pdo->GetRecordset().GetFields().GetItem(COleVariant("状态")).SetValue(COleVariant("重修"));
			}
		}
		pdo->GetRecordset().MoveNext();
	}
	pframe->Agenttalk("添加状态列完成!");
	pdo->Refresh();	
}

⌨️ 快捷键说明

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