判断哪个单选按钮被选择,并来传递特定的变量

来源:互联网 发布:sql server 独有sql 编辑:程序博客网 时间:2024/04/27 16:00

// ScoreInfo.cpp : implementation file
//

#include "stdafx.h"
#include "train.h"
#include "ScoreInfo.h"
#include "ScoreSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CScoreInfo dialog


CScoreInfo::CScoreInfo(CWnd* pParent /*=NULL*/)
 : CDialog(CScoreInfo::IDD, pParent)
{
 //{{AFX_DATA_INIT(CScoreInfo)
 m_personid = 0;
 m_courseid = 0;
 m_site = _T("");
 m_teacherid = 0;
 m_score2 = 0;
 m_score1 = 0;
 m_teachernote = _T("");
 m_date = 0;
 //}}AFX_DATA_INIT
}


void CScoreInfo::DoDataExchange(CDataExchange* pDX)
{
 CDialog::DoDataExchange(pDX);
 //{{AFX_DATA_MAP(CScoreInfo)
 DDX_Text(pDX, IDC_EDIT2, m_courseid);
 DDX_Text(pDX, IDC_EDIT4, m_site);
 DDX_Text(pDX, IDC_EDIT9, m_teacherid);
 DDX_Text(pDX, IDC_EDIT7, m_score2);
 DDX_Text(pDX, IDC_EDIT6, m_score1);
 DDX_Text(pDX, IDC_EDIT8, m_teachernote);
 DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER2, m_date);
 //}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CScoreInfo, CDialog)
 //{{AFX_MSG_MAP(CScoreInfo)
 ON_BN_CLICKED(IDC_BUTTONRESET, OnButtonreset)
 //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CScoreInfo message handlers

void CScoreInfo::OnCancel()
{
 // TODO: Add extra cleanup here
 m_database.Close();
 CDialog::OnCancel();
}

void CScoreInfo::OnButtonreset()
{
 // TODO: Add your control notification handler code here
 m_courseid=0;
 m_personid=0;
 m_score1=0;
 m_score2=0;
 m_site.Empty();
 m_teacherid=0;
 UpdateData(FALSE);
}

void CScoreInfo::OnOK()
{
 // TODO: Add extra validation here
 UpdateData(TRUE);
 int m_check;
 int choice=CDialog::GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO1);
 if(choice==IDC_RADIO1) m_check=1;
 else m_check=0;
 CString strSQL;
// CResourceSet m_recordset(&m_database);
 CScoreSet m_recordset(&m_database);
 strSQL.Format("insert into SCORE values(%d,%d,/'%d-%d-%d/',/'%s/',%d,%d,%d,/'%s/',%d)",person_id,m_courseid,m_date.GetYear(),m_date.GetMonth(),m_date.GetDay(),m_site,m_teacherid,m_score1,m_score2,m_teachernote,m_check);
 m_database.ExecuteSQL(strSQL);
 m_database.Close();
 CDialog::OnOK();
}

原创粉丝点击