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

📄 managerlogindlg.cpp

📁 VC++ 开发的一个大型进销存管理系统,并附带有Visio的数据库开发模型,商品采用分类管理.但是各位同仁需要注意,本系统的开发过程是基于VC++6.0 SQL Server2000的基础之上开发的.
💻 CPP
字号:
// ManagerLoginDlg.cpp : implementation file
//

#include "stdafx.h"
#include "QGZX_InfoPlat.h"
#include "ManagerLoginDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CManagerLoginDlg dialog


CManagerLoginDlg::CManagerLoginDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CManagerLoginDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CManagerLoginDlg)
	//}}AFX_DATA_INIT
	m_strAccount = "";
	m_strPassword = "";
	m_nPower = 5;
	m_ds = new CData();

}

CManagerLoginDlg::~CManagerLoginDlg()
{
	delete m_ds;
}

void CManagerLoginDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CManagerLoginDlg)
	DDX_Control(pDX, IDC_COMBO_ACCOUNT, m_comboAccount);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CManagerLoginDlg, CDialog)
	//{{AFX_MSG_MAP(CManagerLoginDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CManagerLoginDlg message handlers

void CManagerLoginDlg::OnOK() 
{
	// TODO: Add extra validation here
//******************获取一个控件的大小**236********************65 392	
/*	CRect rcWnd;   
	CWnd *pWnd = GetDlgItem(IDC_STATIC_TEST);   
	pWnd->GetWindowRect(&rcWnd);   
	CString str_tmp1;
	str_tmp1.Format("%d,%d",rcWnd.bottom-rcWnd.top,rcWnd.right - rcWnd.left);
	::AfxMessageBox(str_tmp1);*/
//********************************************************************
//************************获取点的象素值*******************
/*	CDC *pDC = GetDC();
	COLORREF crl;
	crl = pDC->GetPixel(1,1);
	int r = GetRValue(crl);
	int g = GetGValue(crl);
	int b = GetBValue(crl);
	CString str_tmp1;
	str_tmp1.Format("%d ,%d ,%d",r,g,b);
	::AfxMessageBox(str_tmp1);*/
//*****************************************************
	CString ManagerAccount, Password;	//获取登录帐号和密码
	CString strSQL;
	GetDlgItemText(IDC_COMBO_ACCOUNT,ManagerAccount);
	GetDlgItemText(IDC_EDIT_PASSWORD,Password);
	strSQL.Format("Select * From _tSysManager Where ManagerAccount = '%s' and Password = '%s'",
		ManagerAccount,Password);
//	::AfxMessageBox(strSQL);
	m_ds->ExecuteSQL(strSQL);
	if(m_ds->GetRecordCount() != 0)
	{
		this->m_strAccount = ManagerAccount;
		this->m_strPassword = Password;
		this->m_nPower = m_ds->GetAsInteger("Power");
		this->m_strManagerName = m_ds->GetAsString("ManagerName");
		CDialog::OnOK();
	}
	else
	{
		CDialog::OnCancel();
	}

//	CString str_tmp1 = m_ds->GetAsString("ManagerAccount");
//	CString str_tmp2 = m_ds->GetAsString("ManagerAccount");
}

void CManagerLoginDlg::OnCancel() 
{
	// TODO: Add extra cleanup here
	CDialog::OnCancel();
}

BOOL CManagerLoginDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	if(m_ds->InitData() == FALSE)
	{
		MessageBox("错误:连接数据库失败。可能是数据库服务器己断开!\n\n系统即将退出!!!","系统提示", MB_ICONERROR | MB_OK);
		exit(1);
		//SendMessage(AfxGetMainWnd()->m_hWnd,   WM_CLOSE,   0,   0);)//代替exit(1);
	}
	//初始化ComboBox
	int nRecordCount = 0;
	CString str_tmp1;;
	m_ds->ExecuteSQL("Select * From _tSysManager");
	nRecordCount = m_ds->GetRecordCount();
	for(int i = 0; i < nRecordCount; i++)		//i从1计数,前面已经插入一项
	{
		str_tmp1 = m_ds->GetAsString("ManagerAccount");
		m_comboAccount.InsertString(i, str_tmp1);
		m_ds->MoveNext();
	}

	GetDlgItem(IDC_COMBO_ACCOUNT)->SetFocus();
	SetDlgItemText(IDC_COMBO_ACCOUNT,"admin");
	SetDlgItemText(IDC_EDIT_PASSWORD,"admin");

	//m_Password.SetFocus();
	//m_Password.SetSel(0,-1);
//***************************设置对话框透明度***********************
/*
	SetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE, 
		GetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE)^0x80000); 
	HINSTANCE hInst = LoadLibrary("User32.DLL"); 
	if(hInst) 
	{ 
		typedef BOOL (WINAPI *MYFUNC)(HWND,COLORREF,BYTE,DWORD); 
		MYFUNC fun = NULL; 
		//取得SetLayeredWindowAttributes函数指针 
		fun=(MYFUNC)GetProcAddress(hInst, "SetLayeredWindowAttributes"); 
		if(fun)fun(this->GetSafeHwnd(),0,190,2);		//改变190的值
		FreeLibrary(hInst); 
	} 
	*/
//**************************************************************


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

⌨️ 快捷键说明

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