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

📄 dlgsp.cpp

📁 我自己整理的一些VC源代码
💻 CPP
字号:
// DlgSP.cpp : implementation file
//

#include "stdafx.h"
#include "SellMan.h"
#include "DlgSP.h"

#include "TabXC.h"
#include "TabDL.h"
#include "TabSJ.h"
#include "TabCS.h"
#include "TabSP.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDlgSP dialog
extern _ConnectionPtr connection;
extern BOOL bConnected;

CDlgSP::CDlgSP(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgSP::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgSP)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	m_nOperType = MODE_APPEND;
}


void CDlgSP::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgSP)
	DDX_Control(pDX, IDC_ED_SPYKDJ, m_ed_spykdj);
	DDX_Control(pDX, IDC_ED_SPYHDJ, m_ed_spyhdj);
	DDX_Control(pDX, IDC_ED_SPXJDJ, m_ed_spxjdj);
	DDX_Control(pDX, IDC_ED_SPXCDJ, m_ed_spxcdj);
	DDX_Control(pDX, IDC_ED_SPSPMC, m_ed_spspmc);
	DDX_Control(pDX, IDC_ED_SPSPHM, m_ed_spsphm);
	DDX_Control(pDX, IDC_ED_SPLSJQ, m_ed_splsjq);
	DDX_Control(pDX, IDC_ED_SPJKDJ, m_ed_spjkdj);
	DDX_Control(pDX, IDC_ED_SPDJDJ, m_ed_spdjdj);
	DDX_Control(pDX, IDC_ED_SPBZXX, m_ed_spbzxx);
	DDX_Control(pDX, IDC_CB_SPSPGG, m_cb_spspgg);
	DDX_Control(pDX, IDC_CB_SPJLDW, m_cb_spjldw);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgSP, CDialog)
	//{{AFX_MSG_MAP(CDlgSP)
	ON_BN_CLICKED(IDC_BT_NEXT, OnBtNext)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgSP message handlers

BOOL CDlgSP::OnInitDialog() 
{
	CDialog::OnInitDialog();

	CTabCS tabcs;
	
	try
	{
		tabcs.Open( "where csbmbm = 'SP' and cszdmc = 'SPCPGG'" );
		while( tabcs.IsOpen() && !tabcs.IsEOF() )
		{
			m_cb_spspgg.SetItemData( m_cb_spspgg.AddString( tabcs.CSQZMS.GetValue() ), atol( tabcs.CSSZQZ.GetValue() ) );
			tabcs.MoveNext();
		}

		tabcs.Open( "where csbmbm = 'SP' and cszdmc = 'SPJLDW'" );
		while( tabcs.IsOpen() && !tabcs.IsEOF() )
		{
			m_cb_spjldw.SetItemData( m_cb_spjldw.AddString( tabcs.CSQZMS.GetValue() ), atol( tabcs.CSSZQZ.GetValue() ) );
			tabcs.MoveNext();
		}

		if( m_nOperType == MODE_MODIFY )
		{
			m_ed_spykdj.SetWindowText( strspykdj );
			m_ed_spyhdj.SetWindowText( strspyhdj );
			m_ed_spxjdj.SetWindowText( strspxjdj );
			m_ed_spxcdj.SetWindowText( strspxcdj );
			m_ed_spspmc.SetWindowText( strspspmc );
			m_ed_spsphm.SetWindowText( strspsphm );
			m_ed_splsjq.SetWindowText( strsplsjq );
			m_ed_spjkdj.SetWindowText( strspjkdj );
			m_ed_spdjdj.SetWindowText( strspdjdj );
			m_ed_spbzxx.SetWindowText( strspbzxx );
			m_cb_spspgg.SelectString( 0, strspspgg );
			m_cb_spjldw.SelectString( 0, strspjldw );
		}
		else
		{
			m_cb_spspgg.SetCurSel( 0 );
			m_cb_spjldw.SetCurSel( 0 );
		}
	}
	catch( _com_error &e )
	{
		AfxMessageBox( e.ErrorMessage() );
	}
	catch( ... )
	{
	}
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDlgSP::OnOK() 
{
	BOOL bRet = FALSE;
	CTabSP tabsp;
	CString strTmp;
	_RecordsetPtr recordset;
	HRESULT hr;
	Fields * fields = NULL;
	VARIANT var_value;
	char szSQL[250];
	strspbzxx = " ";

	m_ed_spykdj.GetWindowText( strspykdj );
	m_ed_spyhdj.GetWindowText( strspyhdj );
	m_ed_spxjdj.GetWindowText( strspxjdj );
	m_ed_spxcdj.GetWindowText( strspxcdj );
	m_ed_spspmc.GetWindowText( strspspmc );
	m_ed_spsphm.GetWindowText( strspsphm );
	m_ed_splsjq.GetWindowText( strsplsjq );
	m_ed_spjkdj.GetWindowText( strspjkdj );
	m_ed_spdjdj.GetWindowText( strspdjdj );
	m_ed_spbzxx.GetWindowText( strspbzxx );
	//m_cb_spspgg.GetWindowText( strspspgg );
	//m_cb_spjldw.GetWindowText( strspjldw );
	strspspgg.Format( "%d", (long)m_cb_spspgg.GetItemData( m_cb_spspgg.GetCurSel() ) );
	strspjldw.Format( "%d", (long)m_cb_spjldw.GetItemData( m_cb_spjldw.GetCurSel() ) );

	if( strspsphm.IsEmpty() )
	{
		AfxMessageBox( "产品编号不能为空!" );
		return;
	}

	if( strspspmc.IsEmpty() )
	{
		AfxMessageBox( "产品名称不能为空!" );
		return;
	}

	if( strspdjdj.IsEmpty() )
	{
		AfxMessageBox( "地区代理价不能为空!" );
		return;
	}

	if( strspxcdj.IsEmpty() )
	{
		AfxMessageBox( "县代理价不能为空!" );
		return;
	}

	if( strspxjdj.IsEmpty() )
	{
		AfxMessageBox( "乡代理价不能为空!" );
		return;
	}

	if( strspjkdj.IsEmpty() )
	{
		AfxMessageBox( "金卡单价不能为空!" );
		return;
	}

	if( strspykdj.IsEmpty() )
	{
		AfxMessageBox( "银卡单价不能为空!" );
		return;
	}

	if( strspyhdj.IsEmpty() )
	{
		AfxMessageBox( "优惠卡单价不能为空!" );
		return;
	}

	if( strsplsjq.IsEmpty() )
	{
		AfxMessageBox( "零售价不能为空!" );
		return;
	}

	try
	{
		if( m_nOperType == MODE_MODIFY )
		{
			//tabsp.SPSPID.strValue = strspspid;
			memset( szSQL, 0, 250 );
			sprintf( szSQL, "WHERE SPSPID = %s", strspspid );
            tabsp.Open( szSQL );
			if ( tabsp.IsOpen() )
			{
				tabsp.SPSPHM.strValue = strspsphm;
				tabsp.SPSPMC.strValue = strspspmc;
				strTmp.Format( "%ld", (long)m_cb_spspgg.GetItemData( m_cb_spspgg.GetCurSel() ) );
				tabsp.SPSPGG.strValue = strTmp;
				strTmp.Format( "%ld", (long)m_cb_spjldw.GetItemData( m_cb_spjldw.GetCurSel() ) );
				tabsp.SPJLDW.strValue = strTmp;
				strTmp.Format( "%.f", atof( strspdjdj ) * 100 );
				tabsp.SPDJDJ.strValue = strTmp;
				strTmp.Format( "%.f", atof( strspxcdj ) * 100 );
				tabsp.SPXCDJ.strValue = strTmp;
				strTmp.Format( "%.f", atof( strspxjdj ) * 100 );
				tabsp.SPXJDJ.strValue = strTmp;
				strTmp.Format( "%.f", atof( strspjkdj ) * 100 );
				tabsp.SPJKDJ.strValue = strTmp;
				strTmp.Format( "%.f", atof( strspykdj ) * 100 );
				tabsp.SPYKDJ.strValue = strTmp;
				strTmp.Format( "%.f", atof( strspyhdj ) * 100 );
				tabsp.SPYHDJ.strValue = strTmp;
				strTmp.Format( "%.f", atof( strsplsjq ) * 100 );
				tabsp.SPLSJQ.strValue = strTmp;
				tabsp.SPJLZT.strValue = "1";
				tabsp.SPBZXX.strValue = strspbzxx;
				tabsp.UpdateRecord();
				bRet = TRUE;
			}
			
		}
		else
		{
			/*hr = recordset.CreateInstance( _uuidof( Recordset ) );
			if( SUCCEEDED(hr) )
			{
				_bstr_t query( "select max( spspid ) + 1 from sp" );
				hr = recordset->Open( query, _variant_t((IDispatch*)connection, true), 
					adOpenDynamic, adLockUnspecified/*adLockOptimistic, adCmdText );
				if( SUCCEEDED(hr) )
				{
					recordset->get_Fields( &fields );
					fields->Item[ (long)0 ]->get_Value( &var_value );
					strspspid = VariantToString( var_value );
					if( strspspid.IsEmpty() ) strspspid = "1";
				}
			}*/
			strspspid = tabsp.GetNextID( "SPSPID" );
			tabsp.SPSPID.strValue = strspspid;
			tabsp.SPSPHM.strValue = strspsphm;
			tabsp.SPSPMC.strValue = strspspmc;
			strTmp.Format( "%ld", (long)m_cb_spspgg.GetItemData( m_cb_spspgg.GetCurSel() ) );
			tabsp.SPSPGG.strValue = strTmp;
			strTmp.Format( "%ld", (long)m_cb_spjldw.GetItemData( m_cb_spjldw.GetCurSel() ) );
			tabsp.SPJLDW.strValue = strTmp;
			strTmp.Format( "%.f", atof( strspdjdj ) * 100 );
			tabsp.SPDJDJ.strValue = strTmp;
			strTmp.Format( "%.f", atof( strspxcdj ) * 100 );
			tabsp.SPXCDJ.strValue = strTmp;
			strTmp.Format( "%.f", atof( strspxjdj ) * 100 );
			tabsp.SPXJDJ.strValue = strTmp;
			strTmp.Format( "%.f", atof( strspjkdj ) * 100 );
			tabsp.SPJKDJ.strValue = strTmp;
			strTmp.Format( "%.f", atof( strspykdj ) * 100 );
			tabsp.SPYKDJ.strValue = strTmp;
			strTmp.Format( "%.f", atof( strspyhdj ) * 100 );
			tabsp.SPYHDJ.strValue = strTmp;
			strTmp.Format( "%.f", atof( strsplsjq ) * 100 );
			tabsp.SPLSJQ.strValue = strTmp;
			tabsp.SPJLZT.strValue = "1";
			tabsp.SPBZXX.strValue = strspbzxx;
			tabsp.AppendRecord();
			bRet = TRUE;
		}
	}
	catch( _com_error &e )
	{
		AfxMessageBox( e.ErrorMessage() );
	}
	catch( ... )
	{
	}
	
	if( bRet ) CDialog::OnOK();
	else CDialog::OnCancel();
}

void CDlgSP::OnBtNext() 
{
	NextDlgCtrl();
}

⌨️ 快捷键说明

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