?? instrucidlg.cpp
字號(hào):
// InstrucIdlg.cpp : implementation file
//
#include "stdafx.h"
#include "Student.h"
#include "InstrucIdlg.h"
#include "InstrucSet.h"
#include "myrecord.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CInstrucIdlg dialog
CInstrucIdlg::CInstrucIdlg(CWnd* pParent /*=NULL*/)
: CDialog(CInstrucIdlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CInstrucIdlg)
m_class_no = _T("");
m_classroom_no = _T("");
m_course_no = _T("");
m_teacher_no = _T("");
m_help = _T("");
m_instruct_time = _T("");
//}}AFX_DATA_INIT
}
void CInstrucIdlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CInstrucIdlg)
DDX_Text(pDX, IDC_EDIT_CLASS_NO, m_class_no);
DDX_Text(pDX, IDC_EDIT_CLASSR_NO, m_classroom_no);
DDX_Text(pDX, IDC_EDIT_COURSE_NO, m_course_no);
DDX_Text(pDX, IDC_EDIT_TEA_NO, m_teacher_no);
DDX_Text(pDX, IDC_EDIT_HELP, m_help);
DDX_Text(pDX, IDC_EDIT_INSTRCT_TIME, m_instruct_time);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CInstrucIdlg, CDialog)
//{{AFX_MSG_MAP(CInstrucIdlg)
ON_BN_CLICKED(IDC_BTN_OK, OnBtnOk)
ON_EN_SETFOCUS(IDC_EDIT_CLASS_NO, OnSetfocusEditClassNo)
ON_EN_SETFOCUS(IDC_EDIT_CLASSR_NO, OnSetfocusEditClassrNo)
ON_EN_SETFOCUS(IDC_EDIT_INSTRCT_TIME, OnSetfocusEditInstrctTime)
ON_EN_SETFOCUS(IDC_EDIT_COURSE_NO, OnSetfocusEditCourseNo)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CInstrucIdlg message handlers
BOOL CInstrucIdlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
GenNext();
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CInstrucIdlg::OnBtnOk()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_course_no.IsEmpty())
{
MessageBeep(MB_ICONEXCLAMATION);
this->GetDlgItem(IDC_EDIT_COURSE_NO)->SetFocus();
return;
}
if(m_class_no.IsEmpty())
{
MessageBeep(MB_ICONEXCLAMATION);
this->GetDlgItem(IDC_EDIT_CLASS_NO)->SetFocus();
return;
}
if(m_instruct_time.IsEmpty())
{
MessageBeep(MB_ICONEXCLAMATION);
this->GetDlgItem(IDC_EDIT_INSTRCT_TIME)->SetFocus();
return;
}
if(!UpdateDB())
return;
GenNext();
UpdateData(FALSE);
this->GetDlgItem(IDC_EDIT_COURSE_NO)->SetFocus();
}
void CInstrucIdlg::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
void CInstrucIdlg::OnSetfocusEditClassNo()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_help="請(qǐng)輸入班級(jí)編號(hào)信息從0001開始編號(hào)";
UpdateData(FALSE);
}
void CInstrucIdlg::OnSetfocusEditClassrNo()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_help="請(qǐng)輸入教室編號(hào)信息從001(普教)或101(電教)開始編號(hào)";
UpdateData(FALSE);
}
void CInstrucIdlg::OnSetfocusEditInstrctTime()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_help="請(qǐng)選擇課程時(shí)間信息:A為星期編號(hào)(1-7分別對(duì)應(yīng)星期一到星期日),B為時(shí)間起始編號(hào)(1=8:00,2=9:00,3=10:10,4=11:10,5=14:30,6=15:30,7=16:30,8=17:30,9=19:00,A=20:00),C為上課小時(shí)節(jié)數(shù)(1為1小時(shí),依此類推),D為單雙周標(biāo)志(1=單周,0=雙周,2=每周都有)";
UpdateData(FALSE);
}
void CInstrucIdlg::OnSetfocusEditCourseNo()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_help="請(qǐng)選擇課程編號(hào)信息";
UpdateData(FALSE);
}
CString CInstrucIdlg::GetNextNo()
{
static int num=0;
CInstrucSet rs;
CString strValue,strSQL;
BOOL Success;
if(num==0)
{
strSQL.Format("select max(substr(stu_no,5)) from Teacher where substr(teacher_no,1,4)=\'%02d%s\'");
Success=rs.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL);
if (Success && rs.GetRecordCount()>0)
rs.GetFieldValue((short)0,strValue);
else
strValue="0";
num=atoi(strValue);
}
num++;
strValue.Format("%04d",num);
return strValue;
}
void CInstrucIdlg::GenNext()
{
CInstrucSet rs;
CString strValue;
CString strFileName;
static HBITMAP hBitmap=NULL;
// TODO: Add extra initialization here
m_teacher_no=GetNextNo();
m_instruct_time ="";
m_course_no ="";
m_classroom_no ="";
m_class_no = "";
}
BOOL CInstrucIdlg::UpdateDB()
{
CString strSQL,strValue,strTemp;
strTemp.Format("to_date(\'%4d-%2d-%2d\',\'yyyy-mm-dd\')",m_instruct_time);
strSQL="insert into introduction(teacher_no,course_no,class_no,instruct_time";
strValue="\'"+m_teacher_no+"\',\'"+m_course_no+"\',\'"+m_class_no+"\',\'"+strTemp;
if (! m_classroom_no.IsEmpty())
{
strSQL+=",classroom";
strValue+=",\'"+m_classroom_no+"\'";
}
strSQL+=") values("+strValue+")";
//MessageBox(strSQL);
m_pDB->ExecuteSQL(strSQL);
return TRUE;
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -