}
database.Close(); }
2.列表框内容显示(以课程管理为例): BOOL CCouMangDlg::OnInitDialog() { }
void CCouMangDlg::show() {
m_ListCouMang.DeleteAllItems(); CDatabase database;
database.Open(\华北科技学院成绩管理\CDialog::OnInitDialog();
// TODO: Add extra initialization here CDatabase database;
database.Open(\华北科技学院成绩管理\m_ListCouMang.SetExtendedStyle(LVS_EX_FLATSB
|LVS_EX_FULLROWSELECT |LVS_EX_HEADERDRAGDROP |LVS_EX_ONECLICKACTIVATE |LVS_EX_GRIDLINES);
m_ListCouMang.InsertColumn(0,\课程号\m_ListCouMang.InsertColumn(1,\课程名\m_ListCouMang.InsertColumn(2,\教师号\m_ListCouMang.InsertColumn(3,\学时\m_ListCouMang.InsertColumn(4,\学分\show(); database.Close();
return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE
-29-
CRecordset set(&database);
set.Open(CRecordset::dynaset,_T(\课程\int i=0;
while(!set.IsEOF()) { } set.Close(); }
m_ListCouMang.InsertItem(i,\CString str1,str2,str3,str4,str5; set.GetFieldValue(\课程号\m_ListCouMang.SetItemText(i,0,str1); set.GetFieldValue(\课程名\m_ListCouMang.SetItemText(i,1,str2); set.GetFieldValue(\教师号\m_ListCouMang.SetItemText(i,2,str3); set.GetFieldValue(\学时\m_ListCouMang.SetItemText(i,3,str4); set.GetFieldValue(\学分\m_ListCouMang.SetItemText(i,4,str5); set.MoveNext(); i++;
3.添加记录: UpdateData(true);
// 确定所有输入有效 CString sWarning=\
if ( \课程号\
else if ( \课程名\
else if ( \教师号\
-30-
else if ( \学时\else if ( \学分\if ( \ {
sWarning += _T(\不能为空\
AfxMessageBox(sWarning, MB_ICONEXCLAMATION); return; }
CDatabase database;
database.Open(\华北科技学院成绩管理\CString sql; sql.Format(
\课程(课程号,课程名,教师号,学时,学分) \\
values('\try{ }
catch(CDBException e) { }
MessageBox(\添加失败!\return;
database.ExecuteSQL(sql);//执行sql语句 MessageBox(\添加成功!\
CString item;
database.Close(); show();
UpdateData(true);
4.修改记录: UpdateData(true);
CString str,sWarning=\
-31-
CDatabase database; //CString sWarning=\
if ( \课程号\
else if ( \课程名\
else if ( \教师号\else if ( \学时\else if ( \学分\if ( \ {
sWarning += _T(\不能为空\
AfxMessageBox(sWarning, MB_ICONEXCLAMATION); return; }
database.Open(\华北科技学院成绩管理\try{
str.Format(\课程 set 课程名='\课程号
='\
}
catch(CDBException e1) {
AfxMessageBox(\修改失败!\database.ExecuteSQL(str);
str.Format(\课程 set 教师号='\课程号='\database.ExecuteSQL(str);
str.Format(\课程 set 学时='\课程号='\database.ExecuteSQL(str);
str.Format(\课程 set 学分='\课程号='\database.ExecuteSQL(str); AfxMessageBox(\修改成功!\
-32-
}
database.Close(); show();
5.删除记录: UpdateData(true);
CString str,sWarning=\CDatabase database; //CString sWarning=\
if ( \课程号\if ( \ {
sWarning += _T(\不能为空\
AfxMessageBox(sWarning, MB_ICONEXCLAMATION); return; }
database.Open(\华北科技学院成绩管理\try{ }
catch(CDBException e1) {
AfxMessageBox(\删除失败!\
str.Format(\课程 where (课程号='\database.ExecuteSQL(str); AfxMessageBox(\删除成功!\
}
database.Close(); show();
5.查询记录:
UpdateData(TRUE);
// TODO: Add your control notification handler code here
-33-
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库数据库应用课程设计说明书 - 学生成绩管理系统(7)在线全文阅读。
相关推荐: