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

📄 kecheng.cpp

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

#include "stdafx.h"
#include "mark.h"
#include "kecheng.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

/////////////////////////////////////////////////////////////////////////////
// Ckecheng

IMPLEMENT_DYNCREATE(Ckecheng, CFormView)

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

Ckecheng::~Ckecheng()
{
}

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


BEGIN_MESSAGE_MAP(Ckecheng, CFormView)
	//{{AFX_MSG_MAP(Ckecheng)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Ckecheng diagnostics

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

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

/////////////////////////////////////////////////////////////////////////////
// Ckecheng message handlers

void Ckecheng::OnButton1() 
{
	CString xn,kclb,kch,kcmc,xs,xf;
	CEdit *xuen=(CEdit *)GetDlgItem(IDC_EDIT1);
	CEdit *keclb=(CEdit *)GetDlgItem(IDC_EDIT2);
	CEdit *kech=(CEdit *)GetDlgItem(IDC_EDIT3);
	CEdit *kecmc=(CEdit *)GetDlgItem(IDC_EDIT4);
	CEdit *xues=(CEdit *)GetDlgItem(IDC_EDIT5);
	CEdit *xuef=(CEdit *)GetDlgItem(IDC_EDIT6);
	xuen->GetWindowText(xn);
	keclb->GetWindowText(kclb);
	kech->GetWindowText(kch);
	kecmc->GetWindowText(kcmc);
	xues->GetWindowText(xs);
	xuef->GetWindowText(xf);
	CAdodc *adodc1=(CAdodc *)GetDlgItem(IDC_ADODC1);
	adodc1->GetRecordset().AddNew(COleVariant("课程号"),COleVariant(kch));
	adodc1->GetRecordset().GetFields().GetItem(COleVariant("学年")).SetValue(COleVariant(xn));
	adodc1->GetRecordset().GetFields().GetItem(COleVariant("课程类别")).SetValue(COleVariant(kclb));
	adodc1->GetRecordset().GetFields().GetItem(COleVariant("课程名称")).SetValue(COleVariant(kcmc));
	adodc1->GetRecordset().GetFields().GetItem(COleVariant("学时")).SetValue(COleVariant(xs));
	adodc1->GetRecordset().GetFields().GetItem(COleVariant("学分")).SetValue(COleVariant(xf));
	adodc1->GetRecordset().GetFields().GetItem(COleVariant("是否可选")).SetValue(COleVariant("否"));
	kech->SetWindowText("");
	kecmc->SetWindowText("");
	xues->SetWindowText("");
	xuef->SetWindowText("");
	kech->SetFocus();
	CMainFrame *pframe=(CMainFrame *)AfxGetMainWnd();
	pframe->Agenttalk("你增加了一门课程: "+kcmc+" 。");
}

void Ckecheng::OnButton2() 
{
	bool isfind=false;
	CEdit *find=(CEdit *)GetDlgItem(IDC_EDIT7);
	CString findstr;
	find->GetWindowText(findstr);
	if(findstr==""){
		CMainFrame *pframe=(CMainFrame *)AfxGetMainWnd();
		pframe->Agenttalk("查找的课程号不能为空!");
		return;
	}
	CAdodc *adodc2=(CAdodc *)GetDlgItem(IDC_ADODC1);
	long i=adodc2->GetRecordset().GetAbsolutePosition();
	adodc2->GetRecordset().MoveFirst();
	while(!adodc2->GetRecordset().GetEof()){
		COleVariant temp=adodc2->GetRecordset().GetFields().GetItem(COleVariant("课程号")).GetValue();
		if(COleVariant(findstr)==temp){
			isfind=true;
			break;
		}
		adodc2->GetRecordset().MoveNext();
	}
	if(!isfind){
		adodc2->GetRecordset().SetAbsolutePosition(i);
		CMainFrame *pframe=(CMainFrame *)AfxGetMainWnd();
		pframe->Agenttalk("没有找到课程号为 "+findstr+" 的课程。");
		find->SetWindowText("");
		find->SetFocus();
	}	
}

void Ckecheng::OnButton3() 
{
	bool isfound=false;
	CEdit *found=(CEdit *)GetDlgItem(IDC_EDIT8);
	CString foundstr;
	found->GetWindowText(foundstr);
	if(foundstr==""){
		CMainFrame *pframe=(CMainFrame *)AfxGetMainWnd();
		pframe->Agenttalk("查找的课程名不能为空!");
		return;
	}
	CAdodc *adodc3=(CAdodc *)GetDlgItem(IDC_ADODC1);
	long i=adodc3->GetRecordset().GetAbsolutePosition();
	adodc3->GetRecordset().MoveFirst();
	while(!adodc3->GetRecordset().GetEof()){
		COleVariant temp=adodc3->GetRecordset().GetFields().GetItem(COleVariant("课程名称")).GetValue();
		if(COleVariant(foundstr)==temp){
			isfound=true;
			break;
		}
		adodc3->GetRecordset().MoveNext();
	}
	if(!isfound){
		adodc3->GetRecordset().SetAbsolutePosition(i);
		CMainFrame *pframe=(CMainFrame *)AfxGetMainWnd();
		pframe->Agenttalk("没有找到课程名为 "+foundstr+" 的课程。");
		found->SetWindowText("");
		found->SetFocus();
	}	
}

⌨️ 快捷键说明

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