📄 teacher.cpp
字号:
// teacher.cpp : implementation file
//
#include "stdafx.h"
#include "mark.h"
#include "teacher.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
/////////////////////////////////////////////////////////////////////////////
// Cteacher
IMPLEMENT_DYNCREATE(Cteacher, CFormView)
Cteacher::Cteacher()
: CFormView(Cteacher::IDD)
{
//{{AFX_DATA_INIT(Cteacher)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
Cteacher::~Cteacher()
{
}
void Cteacher::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Cteacher)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Cteacher, CFormView)
//{{AFX_MSG_MAP(Cteacher)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Cteacher diagnostics
#ifdef _DEBUG
void Cteacher::AssertValid() const
{
CFormView::AssertValid();
}
void Cteacher::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// Cteacher message handlers
void Cteacher::OnButton1()
{
CString jsh,jsm,yx,dh,bz;
CEdit *yuanx=(CEdit *)GetDlgItem(IDC_EDIT1);
CEdit *jiaosh=(CEdit *)GetDlgItem(IDC_EDIT2);
CEdit *jiaosm=(CEdit *)GetDlgItem(IDC_EDIT3);
CEdit *dianh=(CEdit *)GetDlgItem(IDC_EDIT4);
CEdit *beiz=(CEdit *)GetDlgItem(IDC_EDIT5);
yuanx->GetWindowText(yx);
jiaosh->GetWindowText(jsh);
jiaosm->GetWindowText(jsm);
dianh->GetWindowText(dh);
beiz->GetWindowText(bz);
CAdodc *adodc1=(CAdodc *)GetDlgItem(IDC_ADODC1);
adodc1->GetRecordset().AddNew(COleVariant("教师号"),COleVariant(jsh));
adodc1->GetRecordset().GetFields().GetItem(COleVariant("教师名")).SetValue(COleVariant(jsm));
adodc1->GetRecordset().GetFields().GetItem(COleVariant("院系")).SetValue(COleVariant(yx));
adodc1->GetRecordset().GetFields().GetItem(COleVariant("电话")).SetValue(COleVariant(dh));
adodc1->GetRecordset().GetFields().GetItem(COleVariant("备注")).SetValue(COleVariant(bz));
jiaosh->SetWindowText("");
jiaosm->SetWindowText("");
dianh->SetWindowText("");
beiz->SetWindowText("");
jiaosh->SetFocus();
CMainFrame *pframe=(CMainFrame *)AfxGetMainWnd();
pframe->Agenttalk("你增加了一位名叫 "+jsm+" 的教师。");
}
void Cteacher::OnButton2()
{
bool isfind=false;
CEdit *find=(CEdit *)GetDlgItem(IDC_EDIT6);
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 Cteacher::OnButton3()
{
bool isfound=false;
CEdit *found=(CEdit *)GetDlgItem(IDC_EDIT7);
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 + -