📄 chaxunkechengdlg.cpp
字号:
// chaxunkechengDlg.cpp : implementation file
//
#include "stdafx.h"
#include "pmz.h"
#include "chaxunkechengDlg.h"
#include "pmzDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CString user_name;
/////////////////////////////////////////////////////////////////////////////
// chaxunkechengDlg dialog
chaxunkechengDlg::chaxunkechengDlg(CWnd* pParent /*=NULL*/)
: CDialog(chaxunkechengDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(chaxunkechengDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pdb=new CDatabase;
m_pdb->Open(NULL,FALSE,FALSE,mydb);
}
chaxunkechengDlg::~chaxunkechengDlg()
{m_pdb->Close();
delete m_pdb;
}
void chaxunkechengDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(chaxunkechengDlg)
DDX_Control(pDX, IDC_LIST1, m_pList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(chaxunkechengDlg, CDialog)
//{{AFX_MSG_MAP(chaxunkechengDlg)
ON_BN_CLICKED(IDOK, Ontuike)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// chaxunkechengDlg message handlers
BOOL chaxunkechengDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CListCtrl* m_pList = (CListCtrl*)GetDlgItem(IDC_LIST1);
DWORD dwStyle= GetWindowLong(m_pList->m_hWnd, GWL_STYLE);
SetWindowLong( m_pList->m_hWnd, GWL_STYLE, dwStyle | LVS_REPORT);
//设置ListCtrl可以整行选择和网格条纹
DWORD styles = m_pList->GetExtendedStyle();
m_pList->SetExtendedStyle(styles|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
m_pList->SetBkColor(RGB(0xFF, 0xFF, 0xE0));
m_pList->SetTextBkColor(RGB(0xFF, 0xFF, 0xE0));
//设置列的题头
m_pList->InsertColumn(1,"课程号",LVCFMT_CENTER,80);
m_pList->InsertColumn(2,"课程名",LVCFMT_CENTER,100);
//m_pList->InsertColumn(3,"开课时间",LVCFMT_CENTER,120);
//m_pList->InsertColumn(4,"开课地点",LVCFMT_CENTER,110);
m_pList->InsertColumn(3,"教师姓名",LVCFMT_CENTER,110);
m_pList->InsertColumn(4,"教师办公电话",LVCFMT_CENTER,120);
m_pList->InsertColumn(5,"开课院系",LVCFMT_CENTER,180);
CString str1="select * from SC_info where S_no='"+user_name+"' ";
m_pList->DeleteAllItems();
m_scprecordset=new SC_infodb(m_pdb);
m_scprecordset->Open(SC_infodb::snapshot,str1);
int i=0;
if(m_scprecordset->IsEOF())
{
return true;
}
else
{
m_scprecordset->MoveFirst();
while(!m_scprecordset->IsEOF())
{ CString strc=m_scprecordset->m_C_no;
CString str2="SELECT * FROM C_info where C_no='"+strc+"' ";
CString C_no,C_name,C_time,C_place,T_no;
m_cprecordset=new kecheng_infodb(m_pdb);
m_cprecordset->Open(kecheng_infodb::snapshot,str2);
CString strt=m_cprecordset->m_T_no;
CString str3="SELECT * FROM T_info where T_no='"+strt+"'";
CString T_name,T_officetel;
m_tprecordset=new T_infodb(m_pdb);
m_tprecordset->Open(T_infodb::snapshot,str3);
CString strd=m_tprecordset->m_department_no;
CString str4="SELECT * FROM department_info where department_no='"+strd+"'";
CString department_no;
m_dprecordset=new department_infodb(m_pdb);
m_dprecordset->Open(department_infodb::snapshot,str4);
C_no=m_cprecordset->m_C_no;
C_name=m_cprecordset->m_C_name;
//C_time=m_cprecordset->m_C_time;
//C_place=m_cprecordset->m_C_place;
T_name=m_tprecordset->m_T_name;
T_officetel=m_tprecordset->m_T_officetel;
department_no=m_dprecordset->m_department_name;
m_pList->InsertItem(i,C_no);
m_pList->SetItemText(i,1,C_name);
// m_pList->SetItemText(i,2,C_time);
// m_pList->SetItemText(i,3,C_place);
m_pList->SetItemText(i,2,T_name);
m_pList->SetItemText(i,3,T_officetel);
m_pList->SetItemText(i,4,department_no);
m_scprecordset->MoveNext();
i++;
}
}
delete m_scprecordset;
delete m_cprecordset;
delete m_tprecordset;
return true;
}
void chaxunkechengDlg::Ontuike()
{
int j;
j=m_pList.GetSelectionMark();
if(j<0)
{
AfxMessageBox("请在列表框点击选中要删除的记录!");
return;
}
else
{
if(AfxMessageBox("你确实要退课吗?",MB_YESNO)==IDYES)
{
CString str;
str=m_pList.GetItemText(j,0);
CString str1="delete from SC_info where S_no='"+user_name+"' and C_no= '"+str+"'";
m_pdb->ExecuteSQL(str1);
m_pList.DeleteItem(j);
AfxMessageBox("退课成功!");
}
else return;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -