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

📄 step2.cpp

📁 一个汽车销售系统(分期付款,车辆管理,客户管理)
💻 CPP
字号:
// Step2.cpp : 实现文件
//

#include "stdafx.h"
#include "carm.h"
#include "Step2.h"
#include ".\step2.h"


// CStep2 对话框

IMPLEMENT_DYNAMIC(CStep2, CPropertyPage)
CStep2::CStep2()
	: CPropertyPage(CStep2::IDD)
	, m_carnum(_T(""))
	, m_loan(_T(""))
	, m_bank(_T(""))
	, m_ryear(_T(""))
	, m_rmonth(_T(""))
	, m_rday(_T(""))
	, m_rmmoney(_T(""))
	, m_rmday(_T(""))
	, m_insure(_T(""))
	, m_insurey(_T(""))
	, m_insurem(_T(""))
	, m_insured(_T(""))
	, m_searcher(_T(""))
	, m_carID(_T(""))
	, m_purchase(FALSE)
{
	
}

CStep2::~CStep2()
{
}

void CStep2::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_EDIT2, m_carnum);
	DDX_Text(pDX, IDC_EDIT3, m_payf);
	DDX_Text(pDX, IDC_EDIT4, m_loan);
	DDX_Text(pDX, IDC_EDIT5, m_bank);
	DDX_Text(pDX, IDC_EDIT6, m_ryear);
	DDX_CBString(pDX, IDC_COMBO2, m_rmonth);
	DDX_CBString(pDX, IDC_COMBO4, m_rday);
	DDX_Text(pDX, IDC_EDIT7, m_rmmoney);
	DDX_CBString(pDX, IDC_COMBO3, m_rmday);
	DDX_Text(pDX, IDC_EDIT9, m_insure);
	DDX_Text(pDX, IDC_EDIT8, m_insurey);
	DDX_CBString(pDX, IDC_COMBO6, m_insurem);
	DDX_CBString(pDX, IDC_COMBO7, m_insured);
	DDX_Text(pDX, IDC_EDIT11, m_searcher);
	DDX_Control(pDX, IDC_LIST2, m_carlist);
	DDX_CBString(pDX, IDC_COMBO1, m_carID);
	DDX_Check(pDX, IDC_CHECK1, m_purchase);
}


BEGIN_MESSAGE_MAP(CStep2, CPropertyPage)
	ON_CBN_DROPDOWN(IDC_COMBO1, OnCbnDropdownCombo1)
	ON_CBN_CLOSEUP(IDC_COMBO1, OnCbnCloseupCombo1)
	ON_BN_CLICKED(IDC_CHECK1, OnBnClickedCheck1)
END_MESSAGE_MAP()


// CStep2 消息处理程序

BOOL CStep2::OnSetActive()
{
	// TODO: 在此添加专用代码和/或调用基类
	CPropertySheet* pParent=(CPropertySheet*)GetParent(); 
	pParent->SetWizardButtons(PSWIZB_FINISH|PSWIZB_BACK); 
	GetDlgItem(IDC_EDIT2)->EnableWindow(false);
	GetDlgItem(IDC_EDIT3)->EnableWindow(false);
	GetDlgItem(IDC_EDIT4)->EnableWindow(false);
	GetDlgItem(IDC_EDIT5)->EnableWindow(false);
	GetDlgItem(IDC_EDIT6)->EnableWindow(false);
	GetDlgItem(IDC_EDIT7)->EnableWindow(false);
	GetDlgItem(IDC_EDIT8)->EnableWindow(false);
	GetDlgItem(IDC_EDIT9)->EnableWindow(false);
	GetDlgItem(IDC_COMBO1)->EnableWindow(false);
	GetDlgItem(IDC_EDIT11)->EnableWindow(false);
	GetDlgItem(IDC_COMBO2)->EnableWindow(false);
	GetDlgItem(IDC_COMBO3)->EnableWindow(false);
	GetDlgItem(IDC_COMBO4)->EnableWindow(false);
	GetDlgItem(IDC_COMBO6)->EnableWindow(false);
	GetDlgItem(IDC_COMBO7)->EnableWindow(false);
	return CPropertyPage::OnSetActive();
}

void CStep2::OnCbnDropdownCombo1()
{
	CComboBox *pCombo = (CComboBox *)GetDlgItem(IDC_COMBO1);
	if(pCombo->GetCount() != 0)
		return;
	pCombo->ResetContent();
	CString sql = "select * from 车 where 库存 = '1'";
	_RecordsetPtr pRst = g_ADOConn.GetRecordSet(_bstr_t(sql));

	while (!pRst -> adoEOF)
	{
		pCombo->AddString(STR(pRst->GetCollect("车编号")));
		pRst ->MoveNext();
	}
	pCombo->SelectString(-1,m_carID);
}

void CStep2::OnCbnCloseupCombo1()
{
	CComboBox *pCombo = (CComboBox *)GetDlgItem(IDC_COMBO1);
	int num; 
	if((num = pCombo->GetCurSel()) == CB_ERR)
		return;
	pCombo->GetLBText(num,m_carID);

	CString sql = "select * from 车 where 车编号 = '";
	sql += m_carID;
	sql += "'";
	_RecordsetPtr pRst = g_ADOConn.GetRecordSet((_bstr_t)sql);
	long limit = pRst->GetFields()->Count;

	if(pRst->adoEOF)
	{
		::AfxMessageBox("未找到相符的项");
		return;
	}
	if(m_carlist.GetItemCount() != 0)
	{
		m_carlist.DeleteAllItems();
		for(long x = 0;x < 5;x++)
		{
			m_carlist.DeleteColumn(0);
		}
	}
			
		
	for (long x = 0; x < limit; x++)
	{
		m_carlist.InsertColumn(x,(char *) pRst->GetFields()->Item[x]->Name,LVCFMT_LEFT,100,-1);
	}		
	int i = 0;
	while(!pRst->adoEOF)
	{	
			
		m_carlist.InsertItem(i,"");
		for(long x = 0;x < limit;x++)
		{
			_variant_t var = pRst->GetCollect(_variant_t(long(x)));
			CString str = "";
			if(var.vt != VT_NULL)
				str = STR(var);
			m_carlist.SetItemText(i,x,str);
				
		}
		pRst->MoveNext();
		i++;
	}
}

void CStep2::OnBnClickedCheck1()
{
	m_purchase = !m_purchase;
	if(m_purchase)
	{
		GetDlgItem(IDC_EDIT2)->EnableWindow(true);
		GetDlgItem(IDC_EDIT3)->EnableWindow(1);
		GetDlgItem(IDC_EDIT4)->EnableWindow(1);
		GetDlgItem(IDC_EDIT5)->EnableWindow(1);
		GetDlgItem(IDC_EDIT6)->EnableWindow(1);
		GetDlgItem(IDC_EDIT7)->EnableWindow(1);
		GetDlgItem(IDC_EDIT8)->EnableWindow(1);
		GetDlgItem(IDC_EDIT9)->EnableWindow(1);
		GetDlgItem(IDC_COMBO1)->EnableWindow(1);
		GetDlgItem(IDC_EDIT11)->EnableWindow(1);
		GetDlgItem(IDC_COMBO2)->EnableWindow(1);
		GetDlgItem(IDC_COMBO3)->EnableWindow(1);
		GetDlgItem(IDC_COMBO4)->EnableWindow(1);
		GetDlgItem(IDC_COMBO6)->EnableWindow(1);
		GetDlgItem(IDC_COMBO7)->EnableWindow(1);
	}
	else
	{
		GetDlgItem(IDC_EDIT2)->EnableWindow(false);
		GetDlgItem(IDC_EDIT3)->EnableWindow(false);
		GetDlgItem(IDC_EDIT4)->EnableWindow(false);
		GetDlgItem(IDC_EDIT5)->EnableWindow(false);
		GetDlgItem(IDC_EDIT6)->EnableWindow(false);
		GetDlgItem(IDC_EDIT7)->EnableWindow(false);
		GetDlgItem(IDC_EDIT8)->EnableWindow(false);
		GetDlgItem(IDC_EDIT9)->EnableWindow(false);
		GetDlgItem(IDC_COMBO1)->EnableWindow(false);
		GetDlgItem(IDC_EDIT11)->EnableWindow(false);
		GetDlgItem(IDC_COMBO2)->EnableWindow(false);
		GetDlgItem(IDC_COMBO3)->EnableWindow(false);
		GetDlgItem(IDC_COMBO4)->EnableWindow(false);
		GetDlgItem(IDC_COMBO6)->EnableWindow(false);
		GetDlgItem(IDC_COMBO7)->EnableWindow(false);
	}
}

⌨️ 快捷键说明

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