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

📄 dialogusers.cpp

📁 进销存管理系统介绍了企业的现状以及进销存数据管理系统的特点、功能和使用对象
💻 CPP
字号:
// DialogUsers.cpp : implementation file
//

#include "stdafx.h"
#include "a1.h"
#include "DialogUsers.h"
#include "myfunction.h"
#include "Crypt.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDialogUsers dialog


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


void CDialogUsers::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDialogUsers)
	DDX_Control(pDX, IDC_EDIT3, m_editMM2);
	DDX_Control(pDX, IDC_EDIT2, m_editMM1);
	DDX_Control(pDX, IDC_EDIT1, m_editName);
	DDX_Control(pDX, IDC_COMBO1, m_comboPurview);
	//}}AFX_DATA_MAP
}


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

/////////////////////////////////////////////////////////////////////////////
// CDialogUsers message handlers

BOOL CDialogUsers::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	LRunSql m_runsql;
	CString sql;
	_variant_t value;
/*	int i=0;
	sql.Format("select * from tabpurview");
	if(!m_runsql.CheckSQLResult(sql))
	{
		this->EndDialog(0);	
		return false;
	}
	while(!m_runsql.m_recordset->adoEOF)
	{
		value=m_recordset->GetCollect("admi_purview");
		this->m_comboPureview.InsertString(i,(char*)(_bstr_t)value);
		m_runsql.m_recordset->MoveNext();
		i++;
	}*/
	this->m_comboPurview.InsertString(0,"超级用户");
	this->m_comboPurview.InsertString(1,"管理员");
	this->m_comboPurview.InsertString(2,"标准用户");
	this->m_comboPurview.InsertString(3,"一般用户");
	this->m_comboPurview.SetCurSel(3);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDialogUsers::OnOK() 
{
	HWND hwnd=this->GetFocus()->GetSafeHwnd();
	if(hwnd==this->m_editName.GetSafeHwnd())
	{
		this->m_editMM1.SetFocus();
		return;
	}
	else if(hwnd==this->m_editMM1.GetSafeHwnd())
	{
		this->m_editMM2.SetFocus();
		return;
	}
	else if(hwnd==this->m_editMM2.GetSafeHwnd())
	{
		this->m_comboPurview.SetFocus();
		return;
	}
	
	CString m_sNewPW1,m_sNewPW2;
	this->m_editMM1.GetWindowText(m_sNewPW1);
	this->m_editMM2.GetWindowText(m_sNewPW2);
	LRunSql m_runsql;
	CString sql;
	CString name;
	int purview=m_comboPurview.GetCurSel();
	this->m_editName.GetWindowText(name);
	if(name=="")
	{
		MessageBox("用户名不可为空");
		m_editName.SetFocus();
		return;	
	}

	if(m_sNewPW1!=m_sNewPW2)
	{
		MessageBox("请确认密码相同");
		m_editMM2.SetFocus();

		return;
	}
	else
	{
		try{
	sql.Format("select * from tabpurview where admi_name = '%s'"
		,name);
	if(m_runsql.CheckSQLResult(sql))
	{
		MessageBox("请换一个用户名,该用户名已被注册");
		return;	
	}
	CString s_password=CCrypt::Encrypt(m_sNewPW2);

	sql.Format("insert into tabpurview(admi_name,admi_password,admi_purview) values('%s','%s',%d)"
		,name,s_password,purview);
	m_runsql.RunSQL(sql);

		}
	catch(_com_error& e)
	{
		AfxMessageBox(e.ErrorMessage());
		return ;	
	}
	MessageBox("成功添加新用户!","医药管理系统");
	this->m_strName=name;
	this->m_comboPurview.GetWindowText(m_strPurview);

	}	
	CDialog::OnOK();
}

⌨️ 快捷键说明

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