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

📄 ryxxdlg.cpp

📁 图书馆信息管理系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	ADOConn m_AdoConn;
	m_AdoConn.OnInitADOConn();
    
	m_AdoConn.m_pRecordset.CreateInstance(__uuidof(Recordset));
	try
	{		CString strSql;
		if(i)
	
		strSql.Format("SELECT * FROM %s","读者信息");
		else
		{	
			strSql="SELECT * FROM 读者信息 WHERE 读者类别=";
			strSql=strSql+"'"+m_RYCX+"'";
		}

		//rSql="SELECT DateA,Sum(MoneyA) as MoneySum FROM Budget group by DateA having DateA>=#2004-8-1# and DateA<=#2004-8-2#";
		m_AdoConn.m_pRecordset->Open(_variant_t(strSql),                // 查询DemoTable表中所有字段
		m_AdoConn.m_pConnection.GetInterfacePtr(),	 // 获取库接库的IDispatch指针
			adOpenDynamic,
			adLockOptimistic,
			adCmdText);
	}
	catch(_com_error *e)
	{
		AfxMessageBox(e->ErrorMessage());
	}  
	POSITION pos=m_list_ryxx.GetFirstSelectedItemPosition();
	if(pos==NULL)
		return;
	int nItem=m_list_ryxx.GetNextSelectedItem(pos);
	m_AdoConn.m_pRecordset->Move(nItem);
	CString s;

		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("读者姓名"));	
		}
		catch(...)
		{
			s="      ";
		}
		m_DZXM=s;
		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("读者编号"));
		}
		catch(...)
		{
			s="      ";
		}				
		m_DZBH=s;
		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("读者类别"));
		}
		catch(...)
		{
			s="      ";
		}				
		m_DZLB=s;
		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("工作单位"));
		}
		catch(...)
		{
			s="      ";
		}				
		m_GZDW=s;
		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("家庭地址"));
		}
		catch(...)
		{
			s="      ";
		}				
		m_JTDZ=s;
		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("电话号码"));
		}
		catch(...)
		{
			s="      ";
		}				
		m_DHHM=s;
		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("登记日期"));
		}
		catch(...)
		{
			s="      ";
		}				
		m_DJRQ=s;
		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("已借书数量"));
		}
		catch(...)
		{
			s="      ";
		}				
		m_YJSSL=s;
		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("性别"));
		}
		catch(...)
		{
			s="      ";
		}				
		m_XB=s;
		UpdateData(FALSE);
		CString str1,str2;
	str1="你确定要删除记录";
	
	str1=str1+m_DZXM+": "+m_DZLB;
	if(AfxMessageBox(str1,MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
	{
		m_AdoConn.m_pRecordset->Delete(adAffectCurrent);///删除当前记录
		UpdateData(false);
	}
	m_AdoConn.ExitConnect();


	//m_pRecordset->Delete(adAffectCurrent);///删除当前记录
	ShowDate();

	
}

void CRYXXDLG::OnRyxxQuery() 
{
	// TODO: Add your control notification handler code here
	CRyxxcxDlg cryxxcxdlg;
	

	//cryxxcxdlg.DoModal();
	//CRecordSearchDlg searchDlg;
	if(cryxxcxdlg.DoModal()==IDOK)
	{
		i=false;
	
	ADOConn m_AdoConn;
	m_AdoConn.OnInitADOConn();
    
	m_AdoConn.m_pRecordset.CreateInstance(__uuidof(Recordset));
	try
		{	
		CString strSql;
		CString str;
	m_RYCX=cryxxcxdlg.m_RYCX;
	str="SELECT * FROM 读者信息 WHERE 读者类别=";
	strSql=str+"'"+cryxxcxdlg.m_RYCX+"'";
		
		m_AdoConn.m_pRecordset->Open(_variant_t(strSql),                // 查询DemoTable表中所有字段
		m_AdoConn.m_pConnection.GetInterfacePtr(),	 // 获取库接库的IDispatch指针
			adOpenDynamic,
			adLockOptimistic,
			adCmdText);
		}
	catch(_com_error *e)
		{
		AfxMessageBox(e->ErrorMessage());
		}  
	
	
	m_list_ryxx.DeleteAllItems();
	
	
	///////////////////////////////////////////////
	if(!m_AdoConn.m_pRecordset->BOF)
		m_AdoConn.m_pRecordset->MoveFirst();
	else
	{
		AfxMessageBox("表内数据为空");
		return;
	}

	CString s;
	int iIndex=0;
	m_AdoConn.m_pRecordset->MoveFirst();
	while(!m_AdoConn.m_pRecordset->adoEOF)
	{
		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("读者姓名"));	
		}
		catch(...)
		{
			s="      ";
		}
		m_list_ryxx.InsertItem(iIndex,s,0);
		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("读者编号"));
		}
		catch(...)
		{
			s="      ";
		}				
		m_list_ryxx.SetItemText(iIndex,1,s);
		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("性别"));
		}
		catch(...)
		{
			s="      ";
		}				
		m_list_ryxx.SetItemText(iIndex,2,s);
		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("读者类别"));
		}
		catch(...)
		{
			s="      ";
		}				
		m_list_ryxx.SetItemText(iIndex,3,s);
		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("工作单位"));
		}
		catch(...)
		{
			s="      ";
		}				
		m_list_ryxx.SetItemText(iIndex,4,s);
		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("家庭地址"));
		}
		catch(...)
		{
			s="      ";
		}				
		m_list_ryxx.SetItemText(iIndex,5,s);
		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("电话号码"));
		}
		catch(...)
		{
			s="      ";
		}				
		m_list_ryxx.SetItemText(iIndex,6,s);
		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("登记日期"));
		}
		catch(...)
		{
			s="      ";
		}				
		m_list_ryxx.SetItemText(iIndex,7,s);
		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("已借书数量"));
		}
		catch(...)
		{
			s="      ";
		}				
		m_list_ryxx.SetItemText(iIndex,8,s);
		UpdateData(FALSE);
		m_AdoConn.m_pRecordset->MoveNext();
		iIndex++;
		
	}

	//////////////////////////////////////////
	m_AdoConn.ExitConnect();
}	
}

void CRYXXDLG::OnClickRyxxList(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	ADOConn m_AdoConn;
	m_AdoConn.OnInitADOConn();
    
	m_AdoConn.m_pRecordset.CreateInstance(__uuidof(Recordset));
	try
	{		CString strSql;
		if(i)
	
		strSql.Format("SELECT * FROM %s","读者信息");
		else
		{	
			strSql="SELECT * FROM 读者信息 WHERE 读者类别=";
			strSql=strSql+"'"+m_RYCX+"'";
		}
		//rSql="SELECT DateA,Sum(MoneyA) as MoneySum FROM Budget group by DateA having DateA>=#2004-8-1# and DateA<=#2004-8-2#";
		m_AdoConn.m_pRecordset->Open(_variant_t(strSql),                // 查询DemoTable表中所有字段
		m_AdoConn.m_pConnection.GetInterfacePtr(),	 // 获取库接库的IDispatch指针
			adOpenDynamic,
			adLockOptimistic,
			adCmdText);
	}
	catch(_com_error *e)
	{
		AfxMessageBox(e->ErrorMessage());
	}  
	POSITION pos=m_list_ryxx.GetFirstSelectedItemPosition();
	if(pos==NULL)
		return;
	int nItem=m_list_ryxx.GetNextSelectedItem(pos);
	m_AdoConn.m_pRecordset->Move(nItem);
	CString s;

		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("读者姓名"));	
		}
		catch(...)
		{
			s="      ";
		}
		m_DZXM=s;
		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("读者编号"));
		}
		catch(...)
		{
			s="      ";
		}				
		m_DZBH=s;
		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("读者类别"));
		}
		catch(...)
		{
			s="      ";
		}				
		m_DZLB=s;
		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("工作单位"));
		}
		catch(...)
		{
			s="      ";
		}				
		m_GZDW=s;
		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("家庭地址"));
		}
		catch(...)
		{
			s="      ";
		}				
		m_JTDZ=s;
		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("电话号码"));
		}
		catch(...)
		{
			s="      ";
		}				
		m_DHHM=s;
		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("登记日期"));
		}
		catch(...)
		{
			s="      ";
		}				
		m_DJRQ=s;
		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("已借书数量"));
		}
		catch(...)
		{
			s="      ";
		}				
		m_YJSSL=s;
		try
		{
			s=(LPCSTR)_bstr_t(m_AdoConn.m_pRecordset->GetCollect("性别"));
		}
		catch(...)
		{
			s="      ";
		}				
		m_XB=s;
		UpdateData(FALSE);
		
		


	//////////////////////////////////////////
	m_AdoConn.ExitConnect();
	
	
	*pResult = 0;
}

void CRYXXDLG::OnOK() 
{
	// TODO: Add extra validation here
	i=true;
	ShowDate();
	
	//CDialog::OnOK();
}

⌨️ 快捷键说明

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