📄 instrcm.cpp
字号:
// INSTRCM.cpp : implementation file
//
#include "stdafx.h"
#include "Student.h"
#include "INSTRCM.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CINSTRCM dialog
CINSTRCM::CINSTRCM(CWnd* pParent /*=NULL*/)
: CDialog(CINSTRCM::IDD, pParent)
{
//{{AFX_DATA_INIT(CINSTRCM)
m_classno = _T("");
m_classrno = _T("");
m_courseno = _T("");
m_year = 0;
m_teano = _T("");
m_month = 0;
m_day = 0;
//}}AFX_DATA_INIT
}
void CINSTRCM::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CINSTRCM)
DDX_Text(pDX, IDC_EDIT_CLASS_NO, m_classno);
DDV_MaxChars(pDX, m_classno, 4);
DDX_Text(pDX, IDC_EDIT_CLASSR_NO, m_classrno);
DDV_MaxChars(pDX, m_classrno, 4);
DDX_Text(pDX, IDC_EDIT_COURSE_NO, m_courseno);
DDV_MaxChars(pDX, m_courseno, 13);
DDX_Text(pDX, IDC_EDIT_YEAR, m_year);
DDX_Text(pDX, IDC_EDIT_TEA_NO, m_teano);
DDX_Text(pDX, IDC_EDIT_MONTH, m_month);
DDV_MinMaxInt(pDX, m_month, 1, 12);
DDX_Text(pDX, IDC_EDIT_DAY, m_day);
DDV_MinMaxInt(pDX, m_day, 1, 31);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CINSTRCM, CDialog)
//{{AFX_MSG_MAP(CINSTRCM)
ON_BN_CLICKED(IDC_BTN_NEXTI, OnBtnNexti)
ON_BN_CLICKED(IDC_BTN_PREV, OnBtnPrev)
ON_BN_CLICKED(IDC_BTN_RETURN, OnBtnReturn)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CINSTRCM message handlers
void CINSTRCM::OnBtnNexti()
{
// TODO: Add your control notification handler code here
m_pInstru->MoveNext();
if(m_pInstru->IsEOF())
m_pInstru->MoveLast();
UpdateField(FALSE);
}
void CINSTRCM::OnBtnPrev()
{
// TODO: Add your control notification handler code here
m_pInstru->MovePrev();
UpdateField(FALSE);
}
void CINSTRCM::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
void CINSTRCM::OnOK()
{
// TODO: Add extra validation here
CModifydlg modify;
int result=modify.DoModal();
if(result == IDCANCEL)
return;
if(m_kind == 1)//教师
UpdateField(true);
else MessageBox("你无权修改数据!");
}
void CINSTRCM::OnBtnReturn()
{
// TODO: Add your control notification handler code here
UpdateField(FALSE);
}
BOOL CINSTRCM::OnInitDialog()
{
CString strSQL;
BOOL Success;
CDialog::OnInitDialog();
CInstrucSet rs;
// TODO: Add extra initialization here
try{
strSQL="select teacher_no,Course_no,classroom_no,class_no,Inputtime from Instruction";
Success=rs.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL);
if(!Success)
{
MessageBox("授课情况表打开失败!");
this->OnCancel();
return TRUE;
}
UpdateField(FALSE);
rs.Close();
}
catch(CDBException *pe){
AfxMessageBox(pe->m_strError);
pe->Delete();
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CINSTRCM::UpdateField(BOOL bSave)
{
CString strTemp;
CString strExpress,strSQL,strField;
if(bSave)
{
this->UpdateData(bSave);
strExpress.Format("teacher_no=\'%s\'",m_teano);
strSQL="update group1.Instruction set "+strExpress;
strExpress.Format("class=%s",m_classno);
strSQL+=","+strExpress;
strExpress.Format("Course=%s",m_courseno);
strSQL+=","+strExpress;
strExpress.Format("classroom=%s",m_classrno);
strSQL+=","+strExpress;
strExpress.Format("birthday=to_date(\'%4d-%02d-%02d\',\'yyyy-mm-dd\')",m_year,m_month,m_day);
strSQL+=","+strExpress;
m_pDB->ExecuteSQL(strSQL);
m_pInstru->Requery();
UpdateField(FALSE);
}
else
{
m_pInstru->GetFieldValue("TEACHER_NO",m_teano);
m_pInstru->GetFieldValue("COURSE_NO",m_courseno);
m_pInstru->GetFieldValue("CLASS_NO",m_classno);
m_pInstru->GetFieldValue("CLASSROOM",m_classrno);
m_pInstru->GetFieldValue("INPUTTIME",strTemp);
m_year=atoi(strTemp.Left(4));
m_month=atoi(strTemp.Mid(5,2));
m_day=atoi(strTemp.Right(2));
this->UpdateData(bSave);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -