⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 keyanstatdlg.cpp

📁 陕西理工学院计算机系教师信息管理系统的设计与实现
💻 CPP
字号:
// KeYanStatDlg.cpp : implementation file
//

#include "stdafx.h"
#include "TeacherMIS.h"
#include "KeYanStatDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CKeYanStatDlg dialog


CKeYanStatDlg::CKeYanStatDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CKeYanStatDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CKeYanStatDlg)
	m_strNum = _T("");
	m_strTchID = _T("");
	m_strTchName = _T("");
	//}}AFX_DATA_INIT
	CString strConnection="File Name=TeacherMIS.udl";
	pDB=new CADODatabase;
	pDB->Open(strConnection);
	pRs=new CADORecordset(pDB);
}


void CKeYanStatDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CKeYanStatDlg)
	DDX_Control(pDX, IDC_LIST_KEYANSTAT, m_listKeYanStat);
	DDX_Control(pDX, IDC_BUTTON_QUERY, m_btnQuery);
	DDX_Text(pDX, IDC_EDIT_LUNWENNUM, m_strNum);
	DDX_Text(pDX, IDC_EDIT_TCHID, m_strTchID);
	DDX_Text(pDX, IDC_EDIT_TCHNAME, m_strTchName);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CKeYanStatDlg, CDialog)
	//{{AFX_MSG_MAP(CKeYanStatDlg)
	ON_BN_CLICKED(IDC_BUTTON_QUERY, OnButtonQuery)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CKeYanStatDlg message handlers

BOOL CKeYanStatDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_listKeYanStat.InsertColumn(0,"发表论文名称",LVCFMT_LEFT,250,-1);	
	m_listKeYanStat.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
}

void CKeYanStatDlg::RefreshList(CADORecordset &recordset)
{
	m_listKeYanStat.DeleteAllItems();
	if (!recordset.IsOpen())
        return;
	if (recordset.GetRecordCount()<=0)
		return;
	recordset.MoveFirst();
	CString strName;
	int indexofList=0;
	while(!(recordset.IsEOF()))
	{
		recordset.GetFieldValue("Expr1",strName);
		m_listKeYanStat.InsertItem(indexofList,strName);

		indexofList+=1;
		recordset.MoveNext();
	}
	recordset.MoveFirst();
}

void CKeYanStatDlg::OnButtonQuery() 
{
	// TODO: Add your control notification handler code here
   UpdateData(TRUE);
   if (m_strTchID.IsEmpty())
   {
	   MessageBox("没有输入查询姓名!");
	   return;
	}

   CKeYanStatDlg name;
   if (name.HaveID(m_strTchID)<0) 
   {
	   MessageBox("该教师没有科研信息!");
	   return;
    }
   CString strSQL1;
   strSQL1.Format("select * from VIEWTK where TchID='%s'",m_strTchID);  
   pRs->Open(strSQL1,CADORecordset.openQuery);
   RefreshList(*pRs);
   //List控件中首记录设为高亮状态
   m_listKeYanStat.SetFocus();
   m_listKeYanStat.SetItemState(0,LVIS_SELECTED,LVIS_SELECTED);

   CString strSQL;
// strSQL="select * from tbTeach where TchName like '%"+m_strTchName+"%'"; 
   strSQL.Format(_T("select * from tbKeYan where TchID='%s'"),m_strTchID);
   pRs->Open(strSQL,CADORecordset.openQuery);
 //pRs->Open("select TchName , COUNT(AllNum)  number  from tbTeach group by TchName ",CADORecordset.openQuery);
 //不能比较或排序 text、ntext 和 image 数据类型,除非使用 IS NULL 或 LIKE 运算符。

   RefreshList2(*pRs);

   UpdateData(FALSE);
}


void CKeYanStatDlg::RefreshList2(CADORecordset& recordset)
{
  	
    if (!recordset.IsOpen())
        return;
	if (recordset.GetRecordCount()<=0)
		return;
	recordset.MoveFirst();
	CString strName,thenumber;
    int number=0;
	while(!(recordset.IsEOF()))
	{
    number++;
   	recordset.MoveNext();
	}
	recordset.MoveFirst();
	m_strNum.Format("%d", number);

	//显示不出名字
    strName=("select TchName from VIEWTK where TchID='%s'",m_strTchID);
//	m_strTchName.Format("%s",strName);
	m_strTchName=strName;
	//
	CADORecordset* pRs=new CADORecordset(((CTeacherMISApp*)AfxGetApp())->pDB);
    strName.Format("select TchName from VIEWTK where TchID='%s'",m_strTchID);
	pRs->Open(strName,CADORecordset::openQuery);
	pRs->GetFieldValue("TchName",m_strTchName);
	pRs->Close();
	delete pRs;

}


int CKeYanStatDlg::HaveID(CString cID)
{
	CADORecordset* pRs=new CADORecordset(((CTeacherMISApp*)AfxGetApp())->pDB);
	CString strSQL;
	int m;
	strSQL.Format("select * from VIEWTK where TchID='%s'",cID);
	pRs->Open(strSQL,CADORecordset::openQuery);
	if(pRs->GetRecordCount()>=1)
		m=1;
	else m=-1;
	
	pRs->Close();
	delete pRs;
	return m;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -