📄 changeanddel.cpp
字号:
// ChangeAndDel.cpp : implementation file
//
#include "stdafx.h"
#include "qq.h"
#include "ChangeAndDel.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CChangeAndDel dialog
CChangeAndDel::CChangeAndDel(CString stuid,CWnd* pParent /*=NULL*/)
: CDialog(CChangeAndDel::IDD, pParent)
{
//{{AFX_DATA_INIT(CChangeAndDel)
m_edit1 = _T("");
m_edit2 = _T("");
m_edit3 = _T("");
m_edit4 = _T("");
m_edit5 = _T("");
m_edit6 = _T("");
m_edit7 = _T("");
m_edit8 = _T("");
m_edit9 = _T("");
m_edit10 = _T("");
//}}AFX_DATA_INIT
m_stuid = stuid;
m_flag = 0;
}
void CChangeAndDel::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CChangeAndDel)
DDX_Text(pDX, IDC_EDIT1, m_edit1);
DDX_Text(pDX, IDC_EDIT2, m_edit2);
DDX_Text(pDX, IDC_EDIT3, m_edit3);
DDX_Text(pDX, IDC_EDIT4, m_edit4);
DDX_Text(pDX, IDC_EDIT5, m_edit5);
DDX_Text(pDX, IDC_EDIT6, m_edit6);
DDX_Text(pDX, IDC_EDIT7, m_edit7);
DDX_Text(pDX, IDC_EDIT8, m_edit8);
DDX_Text(pDX, IDC_EDIT9, m_edit9);
DDX_Text(pDX, IDC_EDIT10, m_edit10);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CChangeAndDel, CDialog)
//{{AFX_MSG_MAP(CChangeAndDel)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChangeAndDel message handlers
void CChangeAndDel::OnOK()
{
// TODO: Add extra validation here
int nStart=0,nPos;
int nLen;
CString chKey1,chKey2,chKey3,chKey4;
CString enKey1,enKey2,enKey3,enKey4;
UpdateData(true);
m_StuInfoSet.Open(AFX_DB_USE_DEFAULT_TYPE);
if( m_StuInfoSet.IsEOF() )
{
m_StuInfoSet.Close();//关闭数据库
CDialog::OnOK();
// return;
}
m_StuInfoSet.MoveFirst();
do
{
if( m_StuInfoSet.m_stuid == m_edit1 )
break;
m_StuInfoSet.MoveNext();
}while(!m_StuInfoSet.IsEOF());
// m_StuInfoSet.Open(AFX_DB_USE_DEFAULT_TYPE);
m_StuInfoSet.Edit();
// m_StuInfoSet.m_stuid = StuNo;
m_StuInfoSet.m_stuname = m_edit3;
m_StuInfoSet.m_gradeclass = m_edit2;
m_StuInfoSet.Update();//更新记录
m_StuInfoSet.Close();//关闭数据库,写入了一条新的记录
m_ThesisInfoSet.Open(AFX_DB_USE_DEFAULT_TYPE);
m_ThesisInfoSet.MoveFirst();
do
{
if(m_ThesisInfoSet.m_stuid == m_edit1)
break;
m_ThesisInfoSet.MoveNext();
}while(!m_ThesisInfoSet.IsEOF());
// m_ThesisInfoSet.Open(AFX_DB_USE_DEFAULT_TYPE);
m_ThesisInfoSet.Edit();
// m_ThesisInfoSet.m_stuid = StuNo;
m_ThesisInfoSet.m_name = m_edit5;
m_ThesisInfoSet.m_type = m_edit10;
nLen = m_edit7.GetLength();
nPos = m_edit7.Find(",",nStart);
chKey1 = m_edit7.Mid(nStart,nPos-nStart);
nStart = nPos+1;
nPos = m_edit7.Find(",",nStart);
chKey2 = m_edit7.Mid(nStart,nPos-nStart);
nStart = nPos+1;
nPos = m_edit7.Find(",",nStart);
chKey3 = m_edit7.Mid(nStart,nPos-nStart);
nStart = nPos+1;
chKey4 = m_edit7.Mid(nStart,nLen-nStart);
nLen = m_edit8.GetLength();
nStart = 0;
nPos = m_edit8.Find(",",nStart);
enKey1 = m_edit8.Mid(nStart,nPos-nStart);
nStart = nPos+1;
nPos = m_edit8.Find(",",nStart);
enKey2 = m_edit8.Mid(nStart,nPos-nStart);
nStart = nPos+1;
nPos = m_edit8.Find(",",nStart);
enKey3 = m_edit8.Mid(nStart,nPos-nStart);
nStart = nPos+1;
enKey4 = m_edit8.Mid(nStart,nLen-nStart);
m_ThesisInfoSet.m_chkey1 = chKey1;
m_ThesisInfoSet.m_chkey2 = chKey2;
m_ThesisInfoSet.m_chkey3 = chKey3;
m_ThesisInfoSet.m_chkey4 = chKey4;
m_ThesisInfoSet.m_enkey1 = enKey1;
m_ThesisInfoSet.m_enkey2 = enKey2;
m_ThesisInfoSet.m_enkey3 = enKey3;
m_ThesisInfoSet.m_enkey4 = enKey4;
m_ThesisInfoSet.m_teacher = m_edit4;
m_ThesisInfoSet.m_description = m_edit9;
m_ThesisInfoSet.m_score = atof(m_edit6);
m_ThesisInfoSet.Update();//更新记录
m_ThesisInfoSet.Close();//关闭数据库,写入了一条新的记录
// m_edit7 = m_ThesisInfoSet.m_chkey1 +" "+ m_ThesisInfoSet.m_chkey2 +" "+ m_ThesisInfoSet.m_chkey3 +" "+ m_ThesisInfoSet.m_chkey4;
// m_edit8 = m_ThesisInfoSet.m_enkey1 +" "+ m_ThesisInfoSet.m_enkey2 +" "+ m_ThesisInfoSet.m_enkey3 +" "+ m_ThesisInfoSet.m_enkey4;
UpdateData(false);
CDialog::OnOK();
}
BOOL CChangeAndDel::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CString strScore;
CString strKeyword1,strKeyword2;
m_StuInfoSet.Open(AFX_DB_USE_DEFAULT_TYPE);
m_StuInfoSet.MoveFirst();
do
{
if( m_StuInfoSet.m_stuid == m_stuid )
break;
m_StuInfoSet.MoveNext();
}while(!m_StuInfoSet.IsEOF());
m_ThesisInfoSet.Open(AFX_DB_USE_DEFAULT_TYPE);
m_ThesisInfoSet.MoveFirst();
do
{
if(m_ThesisInfoSet.m_stuid == m_stuid)
break;
m_ThesisInfoSet.MoveNext();
}while(!m_ThesisInfoSet.IsEOF());
m_edit1 = m_StuInfoSet.m_stuid;
m_edit2 = m_StuInfoSet.m_gradeclass;
m_edit3 = m_StuInfoSet.m_stuname;
m_edit4 = m_ThesisInfoSet.m_teacher;
m_edit5 = m_ThesisInfoSet.m_name;
m_edit10 = m_ThesisInfoSet.m_type;
strScore.Format("%0.2f", m_ThesisInfoSet.m_score);
m_edit6 = strScore;
m_edit7 = m_ThesisInfoSet.m_chkey1 +","+ m_ThesisInfoSet.m_chkey2 +","+ m_ThesisInfoSet.m_chkey3 +","+ m_ThesisInfoSet.m_chkey4;
m_edit8 = m_ThesisInfoSet.m_enkey1 +","+ m_ThesisInfoSet.m_enkey2 +","+ m_ThesisInfoSet.m_enkey3 +","+ m_ThesisInfoSet.m_enkey4;
m_edit9 = m_ThesisInfoSet.m_description;
m_ThesisInfoSet.Close();
m_StuInfoSet.Close();//关闭数据库
UpdateData(false);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CChangeAndDel::OnButton1()
{
// TODO: Add your control notification handler code here
m_flag = 1;
m_StuInfoSet.Open(AFX_DB_USE_DEFAULT_TYPE);
m_StuInfoSet.MoveFirst();
do
{
if( m_StuInfoSet.m_stuid == m_edit1 )
break;
m_StuInfoSet.MoveNext();
}while(!m_StuInfoSet.IsEOF());
// m_StuInfoSet.Open(AFX_DB_USE_DEFAULT_TYPE);
m_StuInfoSet.Delete();
// m_StuInfoSet.m_stuid = StuNo;
// m_StuInfoSet.Update();//更新记录
m_StuInfoSet.Close();//关闭数据库,写入了一条新的记录
m_ThesisInfoSet.Open(AFX_DB_USE_DEFAULT_TYPE);
m_ThesisInfoSet.MoveFirst();
do
{
if(m_ThesisInfoSet.m_stuid == m_edit1)
break;
m_ThesisInfoSet.MoveNext();
}while(!m_ThesisInfoSet.IsEOF());
// m_ThesisInfoSet.Open(AFX_DB_USE_DEFAULT_TYPE);
m_ThesisInfoSet.Delete();
// m_ThesisInfoSet.m_stuid = StuNo;
// m_ThesisInfoSet.Update();//更新记录
m_ThesisInfoSet.Close();//关闭数据库,写入了一条新的记录
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -