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

📄 dlgadduser.cpp

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

#include "stdafx.h"
#include "SellMan.h"
#include "DlgAddUser.h"
#include "TabGH.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDlgAddUser dialog

extern _ConnectionPtr connection;
extern BOOL bConnected;

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


void CDlgAddUser::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgAddUser)
	DDX_Control(pDX, IDC_ED_PASSWD, m_ed_passwd);
	DDX_Control(pDX, IDC_ED_GHDLXM, m_ed_ghdlxm);
	DDX_Control(pDX, IDC_ED_GHYGXM, m_ed_ghygxm);
	DDX_Control(pDX, IDC_ED_CONPASS, m_ed_conpass);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgAddUser, CDialog)
	//{{AFX_MSG_MAP(CDlgAddUser)
	ON_BN_CLICKED(IDC_BT_SAVE, OnBtSave)
	ON_BN_CLICKED(IDC_BT_QUIT, OnBtQuit)
	ON_BN_CLICKED(IDC_BT_DEFAULT, OnBtDefault)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgAddUser message handlers

void CDlgAddUser::OnBtSave() 
{

	CString strTmp,strSQL;
	CTabGH tabgh;
	BOOL bRes = FALSE;
	
	m_ed_ghygxm.GetWindowText( strGHYGXM );
	m_ed_ghdlxm.GetWindowText( strGHDLXM );
	m_ed_passwd.GetWindowText( strGHYGMM );
	//m_ed_ghyghm.GetWindowText( strGHYGHM );
	strGHJLZT = "1";
	strGHSSBM = "0";
	strGHYGLB = "0";
	strGHYGDJ = "0";
	strGHBZXX = "0";

	m_ed_conpass.GetWindowText( strTmp );

	if ( strGHYGMM !=strTmp )
	{
		AfxMessageBox( "确认密码和登陆密码不一样,请重新输入。" );
		m_ed_passwd.SetFocus();
		return;
	}
	else if( strGHYGXM.IsEmpty() )
	{
		AfxMessageBox( "操作员姓名不能为空!" );
		m_ed_ghygxm.SetFocus();
		return;
	}
	else if( strGHDLXM.IsEmpty() )
	{
		AfxMessageBox( "登陆名不能为空!" );
		m_ed_ghdlxm.SetFocus();
		return;
	}
	else if ( strGHYGHM.IsEmpty() )
	{
		AfxMessageBox( "员工号码为空,该窗口将退出。" );
		CDialog::OnCancel();
	}

	if ( m_nOperType == MODE_APPEND )
	{
		try
		{
			tabgh.GHYGHM.strValue = strGHYGHM;
			tabgh.GHYGXM.strValue = strGHYGXM;
			tabgh.GHDLXM.strValue = strGHDLXM;
			tabgh.GHYGMM.strValue = strGHYGMM;
			tabgh.GHJLZT.strValue = strGHJLZT;
			tabgh.GHSSBM.strValue = strGHSSBM;
			tabgh.GHYGLB.strValue = strGHYGLB;
			tabgh.GHYGDJ.strValue = strGHYGDJ;
			tabgh.GHBZXX.strValue = strGHBZXX;

			tabgh.AppendRecord();
			bRes = TRUE;
		}
		catch ( _com_error &e )
		{
			AfxMessageBox( e.ErrorMessage() );
			return;
		}
	}
	else if ( m_nOperType == MODE_MODIFY )
	{
		/*
		try
		{
			strSQL.Format( "WHERE  GHYGHM = %s", strGHYGHM);
			tabgh.Open( strSQL );
			tabgh.GHYGHM.strValue = strGHYGHM;
			tabgh.GHYGXM.strValue = strGHYGXM;
			tabgh.GHDLXM.strValue = strGHDLXM;
			tabgh.GHYGMM.strValue = strGHYGMM;
			tabgh.GHJLZT.strValue = strGHJLZT;
		}
		catch ( _com_error & e )
		{
			AfxMessageBox( e.ErrorMessage() );
			return;
		}
		*/
	}
	
	if ( bRes == TRUE ) CDlgAddUser::OnOK();

}

void CDlgAddUser::OnBtQuit() 
{
	OnCancel();
}

BOOL CDlgAddUser::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	if ( m_nOperType == MODE_APPEND )
	{
		
		CTabGH tabgh;
		CString strTmp;
		_RecordsetPtr recordset;
		HRESULT hr;
		long count = 0;
		VARIANT var_value;
		Fields *fields = NULL;
		
		try
		{
			hr = recordset.CreateInstance( _uuidof(Recordset) );
			if( SUCCEEDED(hr) )
			{
				_bstr_t query( "SELECT MAX(GHYGHM) + 1 FROM GH" );
				hr = recordset->Open( query, _variant_t((IDispatch*)connection,true),
					adOpenForwardOnly, adLockUnspecified/*adLockPessimistic*/,adCmdText );
				if(SUCCEEDED(hr))
				{
					recordset->get_Fields( &fields );
					count = fields->GetCount();
					
					if( count > 0 )
					{
						fields->Item[ long(0) ]->get_Value( &var_value );
						strTmp = VariantToString( var_value );
						if ( strTmp.IsEmpty() ) strTmp.Format( "%d",1);
						strGHYGHM = strTmp;
					}
				}
			}
		}
		catch( _com_error &e )
		{
			AfxMessageBox( e.ErrorMessage() );
			return FALSE;
		}
	}
	else if ( m_nOperType == MODE_MODIFY )
	{
	}

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDlgAddUser::OnBtDefault() 
{
	keybd_event(9,0,0,0);
}

⌨️ 快捷键说明

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