📄 instrucidlg.cpp
字号:
// 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="请输入班级编号信息从0001开始编号";
UpdateData(FALSE);
}
void CInstrucIdlg::OnSetfocusEditClassrNo()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_help="请输入教室编号信息从001(普教)或101(电教)开始编号";
UpdateData(FALSE);
}
void CInstrucIdlg::OnSetfocusEditInstrctTime()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_help="请选择课程时间信息:A为星期编号(1-7分别对应星期一到星期日),B为时间起始编号(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为上课小时节数(1为1小时,依此类推),D为单双周标志(1=单周,0=双周,2=每周都有)";
UpdateData(FALSE);
}
void CInstrucIdlg::OnSetfocusEditCourseNo()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_help="请选择课程编号信息";
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;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -