📄 dialoguser.cpp
字号:
// DialogUser.cpp : implementation file
//
#include "stdafx.h"
#include "USERSet.h"
#include "USER.h"
#include "DialogUser.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDialogUser dialog
CDialogUser::CDialogUser(CWnd* pParent /*=NULL*/)
: CDialog(CDialogUser::IDD, pParent)
{
//{{AFX_DATA_INIT(CDialogUser)
m_pUserEName = _T("");
m_pUserENametemp = _T("");
m_pUserCName = _T("");
m_pRadio = 0;
m_pRadiotemp=0;
m_UserMemo = _T("");
m_UserPassword = _T("");
m_UserPasswordR = _T("");
m_pMark = _T("");
m_pDuty = _T("");
m_pDepartmentStr = _T("");
m_pClassStr = _T("");
flag=0;
//}}AFX_DATA_INIT
}
void CDialogUser::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDialogUser)
DDX_Control(pDX, IDC_CLASS, m_pClass);
DDX_Control(pDX, IDC_DEPARTMENT, m_pDepartment);
DDX_Text(pDX, IDC_USERENAME, m_pUserEName);
DDX_Text(pDX, IDC_USERCNAME, m_pUserCName);
DDX_Radio(pDX, IDC_RADIOUSER, m_pRadio);
DDX_Text(pDX, IDC_USERMEMO, m_UserMemo);
DDX_Text(pDX, IDC_USERPASSWORD, m_UserPassword);
DDX_Text(pDX, IDC_USERPASSWORDR, m_UserPasswordR);
DDX_Text(pDX, IDC_MARK, m_pMark);
DDX_Text(pDX, IDC_DUTY, m_pDuty);
DDX_CBString(pDX, IDC_DEPARTMENT, m_pDepartmentStr);
DDX_CBString(pDX, IDC_CLASS, m_pClassStr);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDialogUser, CDialog)
//{{AFX_MSG_MAP(CDialogUser)
ON_BN_CLICKED(IDC_LOOK, OnLook)
ON_CBN_SELCHANGE(IDC_DEPARTMENT, OnSelchangeDepartment)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDialogUser message handlers
void CDialogUser::OnLook()
{
// TODO: Add your control notification handler code here
CFileDialog FileDialog(TRUE,"bmp","印章1",OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT|OFN_NOCHANGEDIR,
"印章 (*.bmp)|*.bmp|All Files (*.*)|*.*||");
FileDialog.m_ofn.lpstrTitle="打开";
char pstring[56];//="aaaaaaaaaaaaaaaaaaaaaaaaa";
DWORD length=56;
DWORD PP;
PP=GetCurrentDirectory(length,pstring);
CString p=pstring;
// p=p+"\\button";
FileDialog.m_ofn.lpstrInitialDir=p;
if(FileDialog.DoModal()==IDOK)
{
UpdateData();
m_pMark=FileDialog.GetPathName();
// GetDlgItem(IDC_MARK)->Invalidate();
UpdateData(0);
}
}
BOOL CDialogUser::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDialogUser::OnSelchangeDepartment()
{
// TODO: Add your control notification handler code here
CDatabase *pdb=new CDatabase();
pdb->Open("cnxf",0,0,_T("ODBC;UID=sa;PWD=;"),0);
CUSERSet *m_userSet=new CUSERSet(pdb);
m_userSet->Open();
CString strValue;
int l=m_pDepartment.GetCurSel();
m_pDepartment.GetLBText(l,strValue);
m_userSet->MoveFirst();
m_pClass.ResetContent();
CString string[100];
int k=0;
while(!m_userSet->IsEOF())
{
BOOL rt=FALSE;
if(m_userSet->m_userdepartment==strValue)
{
for(int j=0;j<k+1;j++)
{
if(m_userSet->m_usergroup==string[j])
{
rt=TRUE;
break;
}
}
if(!rt)
{
m_pClass.AddString(m_userSet->m_usergroup);
string[k+1]=m_userSet->m_usergroup;
k++;
}
}
m_userSet->MoveNext();
}
m_pClass.SetCurSel(0);
m_userSet->Close();
delete m_userSet;
pdb->Close();
delete pdb;
}
void CDialogUser::OnOK()
{
// TODO: Add extra validation here
UpdateData();
if(m_UserPassword!=m_UserPasswordR)
{
AfxMessageBox("请重新核对您的密码");
return;
}
if(m_pUserEName==""||m_pUserCName=="")
{
AfxMessageBox("用户名不能为空,请重新填写");
return;
}
CDatabase *pdb=new CDatabase();
pdb->Open("cnxf",0,0,_T("ODBC;UID=sa;PWD=;"),0);
CUSERSet *m_userSet=new CUSERSet(pdb);
m_userSet->Open();
// int temp1=0;
// int temp2=0;
if(m_userSet->GetRecordCount())
{
m_userSet->MoveFirst();
while(!m_userSet->IsEOF())
{
if(m_pRadio==0&&m_userSet->m_userrole==1&&flag==1)
{
AfxMessageBox("系统中只能有一个信访专责员");
return;
}
if(m_pRadio==0&&m_userSet->m_userrole==1&&flag==0)
{
// if(temp1==1)
// {
if(m_pRadiotemp!=0)
{
AfxMessageBox("系统中只能有一个信访专责员");
return;
}
// }
// temp1++;
}
if(m_userSet->m_userename==m_pUserEName&&flag==1)
{
AfxMessageBox("用户英文名不能相同,请重新输入!");
return;
}
if(m_userSet->m_userename==m_pUserEName&&flag==0)
{
// if(temp2==1)
// {
if(m_pUserENametemp!=m_pUserEName)
{
AfxMessageBox("用户英文名不能相同,请重新输入!");
return;
}
// }
// temp2++;
}
m_userSet->MoveNext();
}
}
m_userSet->Close();
delete m_userSet;
pdb->Close();
delete pdb;
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -