📄 departqdlg.cpp
字号:
// DepartQdlg.cpp : implementation file
//
#include "stdafx.h"
#include "Student.h"
#include "DepartQdlg.h"
#include "DepartSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDepartQdlg dialog
CDepartQdlg::CDepartQdlg(CWnd* pParent /*=NULL*/)
: CDialog(CDepartQdlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDepartQdlg)
m_depart = _T("");
m_name = _T("");
//}}AFX_DATA_INIT
}
void CDepartQdlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDepartQdlg)
DDX_Control(pDX, IDC_LIST_DEPARTQ, m_stuQery_List);
DDX_Text(pDX, IDC_EDIT_DEPART_NO, m_depart);
DDV_MaxChars(pDX, m_depart, 4);
DDX_Text(pDX, IDC_EDIT_NAME, m_name);
DDV_MaxChars(pDX, m_name, 40);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDepartQdlg, CDialog)
//{{AFX_MSG_MAP(CDepartQdlg)
ON_BN_CLICKED(IDC_BTN_DELETE, OnBtnDelete)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDepartQdlg message handlers
void CDepartQdlg::OnBtnDelete()
{
// TODO: Add your control notification handler code here
}
////////////////////////////////////////////////////////////////////////
//以下为查询系的方法
void CDepartQdlg::OnOK()
{
UpdateData();
CDepartSet pdepart;
CString strSQL;
try{
if(!m_depart.IsEmpty()){
strSQL="select * from department where pdepart.Depart_no=m_depart";
}
else{
if(m_name.IsEmpty()){
AfxMessageBox("请输入要查询的系!");
return;}
strSQL="select * from department where pdept.Name=m_name";
}
//AfxMessageBox("打开数据库!");
if(!pdepart.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL))
{
AfxMessageBox("打开数据库失败!");
return;
}
m_stuQery_List.DeleteAllItems();//将表中原有的记录全部删掉
int i=0;
while(!pdepart.IsEOF())
{
m_stuQery_List.InsertItem(i,pdepart.m_Depart_no);
m_stuQery_List.SetItemText(i,1,pdepart.m_Name);
m_stuQery_List.SetItemText(i,2,pdepart.m_Phone);
m_stuQery_List.SetItemText(i,4,pdepart.m_College_no);
m_stuQery_List.SetItemText(i,3,pdepart.m_Depart_header);
m_stuQery_List.SetItemText(i,4,pdepart.m_Introduction);
i++;
pdepart.MoveNext();
}
pdepart.Close();
}
catch(CDBException *pe){
AfxMessageBox(pe->m_strError);
pe->Delete();
}
CDialog::OnOK();
}
void CDepartQdlg::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
/////////////////////////////////////////////////
//初始化列表
BOOL CDepartQdlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_stuQery_List.InsertColumn(0,"系编号");
m_stuQery_List.InsertColumn(1,"系名称");
m_stuQery_List.InsertColumn(2,"系办公电话");
m_stuQery_List.InsertColumn(3,"所属学院编号");
m_stuQery_List.InsertColumn(4,"系主任编号");
m_stuQery_List.InsertColumn(5,"系简介");
m_stuQery_List.SetColumnWidth(0,60);
m_stuQery_List.SetColumnWidth(1,80);
m_stuQery_List.SetColumnWidth(2,80);
m_stuQery_List.SetColumnWidth(3,80);
m_stuQery_List.SetColumnWidth(4,60);
m_stuQery_List.SetColumnWidth(5,140);
m_stuQery_List.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
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 + -