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

📄 dl.cpp

📁 成绩管理系统,用VC和SQL 2000开发
💻 CPP
字号:
// DL.cpp : implementation file
//

#include "stdafx.h"
#include "成绩管理系统.h"
#include "DL.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CString yhm,mm;
/////////////////////////////////////////////////////////////////////////////
// CDL dialog


CDL::CDL(CWnd* pParent /*=NULL*/)
	: CDialog(CDL::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDL)
	//}}AFX_DATA_INIT
}


void CDL::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDL)
//	DDX_Control(pDX, IDC_DL_YHM, m_YHM);
//	DDX_Control(pDX, IDC_DL_MM, m_MM);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDL, CDialog)
	//{{AFX_MSG_MAP(CDL)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDL message handlers

BOOL CDL::OnInitDialog() 
{
	CDialog::OnInitDialog();
/*	 ::CoInitialize(NULL);
	// TODO: Add extra initialization here
	try
{
  	m_DBCnt.CreateInstance(__uuidof(Connection));
  m_DBCnt->ConnectionString=
 "driver={SQL Server};server=(local);"
 "UID=user;PWD=123;"
 "database=StuGrade";
  m_DBCnt->Open("","","",-1);
}	
catch(_com_error& e)
{
	AfxMessageBox("无法连接数据库!");
	this->EndDialog(0);
}
Readyh();*/
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDL::OnOK() 
{
	// TODO: Add extra validation here
/*	
	CString strsql;
	m_YHM.GetWindowText(yhm);
    m_MM.GetWindowText(mm);
    if(yhm=="")
	{
         AfxMessageBox("请选择登陆用户名!");
		 return;
	}
	if(mm=="")
	{
         AfxMessageBox("请输入密码!");
		 return;
	}
       _variant_t holder;
	 	_RecordsetPtr prst=NULL; 
	   prst.CreateInstance(__uuidof(Recordset)); 
	    strsql.Format("select 密码 from v_yonghu where 用户名='%s'",yhm);     		  
		  prst=m_DBCnt->Execute(_bstr_t(strsql),NULL,adCmdText);	  
		  holder=prst->GetCollect("密码"); 
	if(atoi(mm)==holder.intVal)CDialog::OnOK();
	else 
	{
        AfxMessageBox("密码不正确,请重新输入!");
		m_MM.SetFocus();
		 return;
	}
*/
}

void CDL::Readyh()
{
	UpdateData();
	CString strsql;
 _variant_t holder;
	 	_RecordsetPtr prst=NULL; 
	   prst.CreateInstance(__uuidof(Recordset)); 
	    strsql.Format("select 用户名 from v_yonghu");     		  
		  prst=m_DBCnt->Execute(_bstr_t(strsql),NULL,adCmdText);
	int i=0;	  
   if(prst->adoEOF)return;
	 else 
	 {
		 prst->MoveFirst();
		 while(!prst->adoEOF)
		 {   
		  holder=prst->GetCollect("用户名"); 
		   m_YHM.InsertString(i,holder.vt==VT_NULL?"":(char*)(_bstr_t)holder);
	      i++;
		  prst->MoveNext(); 
		 }
	 }
}

⌨️ 快捷键说明

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