supplyadd.cpp

来自「本人工作中的一个软件开发实例。里面包含了数据库」· C++ 代码 · 共 184 行

CPP
184
字号
// SupplyAdd.cpp : implementation file
//

#include "stdafx.h"
#include "oil.h"
#include "SupplyAdd.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSupplyAdd dialog


CSupplyAdd::CSupplyAdd(CWnd* pParent /*=NULL*/)
	: CDialog(CSupplyAdd::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSupplyAdd)
	m_strCarNO = _T("");
	m_nReal = 0;
	m_nSet = 0;
	m_nSupply = _T("");
	m_bChecked = FALSE;
	//}}AFX_DATA_INIT
}


void CSupplyAdd::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSupplyAdd)
	DDX_Text(pDX, IDC_EDIT_CARNO, m_strCarNO);
	DDX_Text(pDX, IDC_EDIT_REAL, m_nReal);
	DDX_Text(pDX, IDC_EDIT_SET, m_nSet);
	DDX_Text(pDX, IDC_EDIT_SUPPLY, m_nSupply);
	DDX_Check(pDX, IDC_CHECK_PRINT, m_bChecked);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSupplyAdd, CDialog)
	//{{AFX_MSG_MAP(CSupplyAdd)
	ON_CBN_SELCHANGE(IDC_COMBO_CUSTOMER, OnSelchangeComboCustomer)
	ON_CBN_SELCHANGE(IDC_COMBO_BILL, OnSelchangeComboBill)
	ON_CBN_SELCHANGE(IDC_COMBO_ISSER, OnSelchangeComboIsser)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSupplyAdd message handlers

void CSupplyAdd::OnOK() 
{
	// TODO: Add extra validation here
	switch(m_nDoWhat)
	{
	case ADD:
		
		break;
	case EDIT:

		break;
	default:
		AfxMessageBox("错误操作类型");
		break;
	}
	
	CDialog::OnOK();
}

//关闭窗口
void CSupplyAdd::OnCancel() 
{
	// TODO: Add extra cleanup here	
	CDialog::OnCancel();
}

//打开窗口时,初始化窗口
BOOL CSupplyAdd::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	switch(m_nDoWhat)
	{
	case ADD:
		{
		//更新客户列表
		CString m_strTemp;
		CComboBox * m_pComboBox=(CComboBox *)GetDlgItem(IDC_COMBO_CUSTOMER);
        InitCustomerComboBox(m_pComboBox);
		((CComboBox *)m_pComboBox)->SetCurSel(0);
		int index=((CComboBox *)m_pComboBox)->GetCurSel();
		m_pComboBox->GetLBText(index,m_strTemp);
		
		//更新提油单列表
		m_pComboBox=(CComboBox *)GetDlgItem(IDC_COMBO_BILL);
		CString sql="select TydID \
			         from tiyoudan as a,customer as b \
					 where a.customerid=b.customerid and customername='"+m_strTemp+"'";
		ReadtoComBoBox(m_pComboBox,sql);
		((CComboBox *)m_pComboBox)->SetCurSel(0);
/*		index=((CComboBox *)m_pComboBox)->GetCurSel();
		m_pComboBox->GetLBText(index,m_strTemp);
		((CComboBox *)m_pComboBox)->GetLBText(0,m_strTemp);

        //更新发油单列表
        m_pComboBox=(CComboBox *)GetDlgItem(IDC_COMBO_ISSER);
		sql="select FydID \
			 from fayoudan as a ,tiyoudan as b \
			 where a.tydid=b.tydid and b.tydid='"+m_strTemp+"'";
        ReadtoComBoBox(m_pComboBox,sql);
        ((CComboBox *)m_pComboBox)->SetCurSel(0);
*/		}
		break;

	case EDIT:
		break;

	default:
		AfxMessageBox("错误操作类型");
	}
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

//更改客户时自动更新提油单
void CSupplyAdd::OnSelchangeComboCustomer() 
{
	// TODO: Add your control notification handler code here
	    //得到客户资料
		CString m_strTemp;
		CComboBox * m_pComboBox=(CComboBox *)GetDlgItem(IDC_COMBO_CUSTOMER);
		int index=((CComboBox *)m_pComboBox)->GetCurSel();
		m_pComboBox->GetLBText(index,m_strTemp);
		
		//更新提油单列表
		m_pComboBox=(CComboBox *)GetDlgItem(IDC_COMBO_BILL);
		CString sql="select TydID \
			         from tiyoudan as a,customer as b \
					 where a.customerid=b.customerid and customername='"+m_strTemp+"'";
		ReadtoComBoBox(m_pComboBox,sql);
		((CComboBox *)m_pComboBox)->SetCurSel(0);
		index=((CComboBox *)m_pComboBox)->GetCurSel();
		m_pComboBox->GetLBText(index,m_strTemp);

        //更新发油单列表
        m_pComboBox=(CComboBox *)GetDlgItem(IDC_COMBO_ISSER);
		sql="select FydID \
			 from fayoudan as a ,tiyoudan as b \
			 where a.tydid=b.tydid and b.tydid='"+m_strTemp+"'";
        ReadtoComBoBox(m_pComboBox,sql);
        ((CComboBox *)m_pComboBox)->SetCurSel(0);
}

//当客记改变时,自动更新提油凭单
void CSupplyAdd::OnSelchangeComboBill() 
{
	// TODO: Add your control notification handler code here
        CString m_strTemp;
		CComboBox * m_pComboBox=(CComboBox *)GetDlgItem(IDC_COMBO_BILL);
		int index=((CComboBox *)m_pComboBox)->GetCurSel();
		m_pComboBox->GetLBText(index,m_strTemp);

        //更新发油单列表
        m_pComboBox=(CComboBox *)GetDlgItem(IDC_COMBO_ISSER);
		CString sql="select FydID \
			 from fayoudan as a ,tiyoudan as b \
			 where a.tydid=b.tydid and b.tydid='"+m_strTemp+"'";
        ReadtoComBoBox(m_pComboBox,sql);
        ((CComboBox *)m_pComboBox)->SetCurSel(0);
}

//发油单变化时自动更新发油资料
void CSupplyAdd::OnSelchangeComboIsser() 
{
	// TODO: Add your control notification handler code here
	
}

⌨️ 快捷键说明

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