?? scoreadddlg.cpp
字號:
// ScoreAddDlg.cpp : implementation file
//
#include "stdafx.h"
#include "studentscore.h"
#include "ScoreAddDlg.h"
#include "ScoreDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CScoreAddDlg dialog
CScoreAddDlg::CScoreAddDlg(CWnd* pParent /*=NULL*/)
: CDialog(CScoreAddDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CScoreAddDlg)
//}}AFX_DATA_INIT
}
void CScoreAddDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CScoreAddDlg)
DDX_Control(pDX, IDC_SCORE_BEIZHU, m_Beizhu);
DDX_Control(pDX, IDC_SCORE_SCORE, m_cScore);
DDX_Control(pDX, IDC_SCORE_COURSE, m_cCourse);
DDX_Control(pDX, IDC_SCORE_STUDENT, m_cStudent);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CScoreAddDlg, CDialog)
//{{AFX_MSG_MAP(CScoreAddDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CScoreAddDlg message handlers
void CScoreAddDlg::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK();
CString student,course,score,student_no,beizhu,course_no;
m_cStudent.GetWindowText(student);
m_cCourse.GetWindowText(course);
m_cScore.GetWindowText(score);
m_Beizhu.GetWindowText(beizhu);
if(score=="")
{
MessageBox("請輸入考勤分數(shù)");
}
if(beizhu=="")
{
MessageBox("請輸入情況");
}
else
{
CString strSQL;
strSQL.Format("select * from student where student_name='%s'",student);
CRecordset m_recordSet=&m_database;
m_recordSet.Open(CRecordset::forwardOnly,strSQL);
m_recordSet.GetFieldValue("student_no",student_no);
m_recordSet.Close();
strSQL.Format("select * from course where course_name='%s'",course);
//CRecordset m_recordSet=&m_database;
m_recordSet.Open(CRecordset::forwardOnly,strSQL);
m_recordSet.GetFieldValue("course_no",course_no);
m_recordSet.Close();
if(this->id=="0")
{
strSQL.Format("insert into score(student_no,course_no,score,beizhu)values('%s','%s',%d,'%s')",student_no,course_no,atoi(score),beizhu);
m_database.ExecuteSQL(strSQL);
}
else
{
strSQL.Format("update score set student_no='%s',course_no='%s',score=%d,beizhu='%s' where score_id=%s",student_no,course_no,atoi(score),beizhu,id);
m_database.ExecuteSQL(strSQL);
}
//RefreshList();
}
}
BOOL CScoreAddDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CRecordset m_recordSet;
if(!m_database.IsOpen())
{
m_database.Open(_T("studentscore"));
m_recordSet.m_pDatabase=&m_database;
}
CString strSQL;
strSQL.Format("select course_name from course");
m_recordSet.Open(CRecordset::forwardOnly,strSQL);
for(int i=0; i<m_recordSet.GetRecordCount();i++)
{
CString temp;
m_recordSet.GetFieldValue("course_name",temp);
m_cCourse.AddString(temp);
// m_cCourse.AddString("LOCAL GEO");
// m_cCourse.AddString("VC++");
// m_cCourse.AddString("ATIYU");
// m_cCourse.AddString("3 D MAX");
// m_cCourse.AddString("GEOI");
// m_cCourse.AddString("Jsp");
m_recordSet.MoveNext();
}
m_recordSet.Close();
m_cCourse.SetCurSel(1);
strSQL.Format("select student_name from student");
m_recordSet.Open(CRecordset::forwardOnly,strSQL);
for(int j=0; j<m_recordSet.GetRecordCount();j++)
{
CString temp;
m_recordSet.GetFieldValue("student_name",temp);
m_cStudent.AddString(temp);
m_recordSet.MoveNext();
}
m_recordSet.Close();
m_cStudent.SetCurSel(1);
if(id!="0")
{
this->SetWindowText("修改窗口");
strSQL.Format("select course.course_name,student.student_name,score.score,score.beizhu from student,course,score where score.student_no=student.student_no and course.course_no=score.course_no and score.score_id=%s",id);
m_recordSet.Open(CRecordset::forwardOnly,strSQL);
CString temp;
m_recordSet.GetFieldValue("student_name",temp);
m_cStudent.SelectString(0,temp);
m_recordSet.GetFieldValue("course_name",temp);
m_cCourse.SetWindowText(temp);
m_recordSet.GetFieldValue("score",temp);
m_cScore.SetWindowText(temp);
m_recordSet.GetFieldValue("beizhu",temp);
m_Beizhu.SetWindowText(temp);
}
else
{
this->SetWindowText("填加成績窗口");
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -