stu_classidlg.cpp
来自「这是一个学生管理系统 包含学生基本信息 选课信息 宿舍信息 教师信息 课程信息 」· C++ 代码 · 共 159 行
CPP
159 行
// Stu_classIdlg.cpp : implementation file
//
#include "stdafx.h"
#include "Student.h"
#include "Stu_classIdlg.h"
#include "Stu_classSet.h"
#include "myrecord.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CStu_classIdlg dialog
CStu_classIdlg::CStu_classIdlg(CWnd* pParent /*=NULL*/)
: CDialog(CStu_classIdlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CStu_classIdlg)
m_stu_no = _T("");
m_help = _T("");
m_course_no = _T("");
m_inputtime = COleDateTime::GetCurrentTime();
m_score = 0;
//}}AFX_DATA_INIT
}
void CStu_classIdlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CStu_classIdlg)
DDX_Text(pDX, IDC_EDIT_NO, m_stu_no);
DDX_Text(pDX, IDC_EDIT_HELP, m_help);
DDX_Text(pDX, IDC_EDIT_COURSE_NO, m_course_no);
DDX_Text(pDX, IDC_EDIT_TIME, m_inputtime);
DDX_Text(pDX, IDC_EDIT_SCORE, m_score);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CStu_classIdlg, CDialog)
//{{AFX_MSG_MAP(CStu_classIdlg)
ON_BN_CLICKED(IDC_BTN_OK, OnBtnOk)
ON_EN_SETFOCUS(IDC_EDIT_SCORE, OnSetfocusEditScore)
ON_EN_SETFOCUS(IDC_EDIT_COURSE_NO, OnSetfocusEditCourseNo)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CStu_classIdlg message handlers
BOOL CStu_classIdlg::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 CStu_classIdlg::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(!UpdateDB())
return;
GenNext();
UpdateData(FALSE);
this->GetDlgItem(IDC_EDIT_COURSE_NO)->SetFocus();
}
void CStu_classIdlg::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
void CStu_classIdlg::OnSetfocusEditScore()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_help="请输入入学成绩信息:最小0,最大100";
UpdateData(FALSE);
}
void CStu_classIdlg::OnSetfocusEditCourseNo()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_help="请输入课程编号来源信息:长度限制60个字符(30个汉字)";
UpdateData(FALSE);
}
CString CStu_classIdlg::GetNextNo()
{
static int num=0;
CStu_classSet rs;
CString strValue,strSQL;
BOOL Success;
if(num==0)
{
strSQL.Format("select max(substr(stu_no,5)) from Student where substr(stu_no,1,4)=\'%02d%s\'",m_year%100,m_CollegeNo);
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("%02d%s%04d",m_year%100,m_CollegeNo,num);
return strValue;
}
void CStu_classIdlg::GenNext()
{
CStu_classSet rs;
CString strValue;
CString strFileName;
static HBITMAP hBitmap=NULL;
// TODO: Add extra initialization here
m_stu_no=GetNextNo();
m_score =0;
//m_inputtime ="";//?
}
BOOL CStu_classIdlg::UpdateDB()
{
CString strSQL,strValue,strTemp;
strTemp.Format("%d,to_date(\'%4d-%2d-%2d\',\'yyyy-mm-dd\')",m_score,m_inputtime);
strSQL="insert into stu_course(stu_no,course_no,score,inputtime";
strValue="\'"+m_stu_no+"\',\'"+m_course_no+"\',\'"+strTemp;
strSQL+=") values("+strValue+")";
//MessageBox(strSQL);
m_pDB->ExecuteSQL(strSQL);
return TRUE;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?