⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scoreadddlg.cpp

📁 最后的成品vc考勤ACCSEE数据库做的 还有文档 希望大家多多指点jilinshidalvdi@163.com
💻 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("请输入考勤分数");
	}
	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
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -