📄 userset.cpp
字号:
// UserSet.cpp : 实现文件
//
#include "stdafx.h"
#include "MedicineSaleManages.h"
#include "UserSet.h"
#include ".\userset.h"
// CUserSet 对话框
IMPLEMENT_DYNAMIC(CUserSet, CDialog)
CUserSet::CUserSet(CWnd* pParent /*=NULL*/)
: CDialog(CUserSet::IDD, pParent)
{
}
CUserSet::~CUserSet()
{
}
void CUserSet::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST1, m_list1);
DDX_Control(pDX, IDC_LIST2, m_list2);
DDX_Control(pDX, IDC_CHECK1, m_check1);
DDX_Control(pDX, IDC_CHECK2, m_check2);
DDX_Control(pDX, IDC_COMBO1, m_combo1);
DDX_Control(pDX, IDC_CHECK3, m_check3);
DDX_Control(pDX, IDC_COMBO2, m_combo2);
DDX_Control(pDX, IDC_CHECKLOGIN, m_checklogin);
DDX_Control(pDX, IDC_CHECK4, m_check4);
DDX_Control(pDX, IDC_AUTOTIME, m_autotime);
}
BEGIN_MESSAGE_MAP(CUserSet, CDialog)
ON_BN_CLICKED(IDOK, OnBnClickedOk)
ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel)
ON_NOTIFY(NM_CLICK, IDC_LIST1, OnNMClickList1)
ON_NOTIFY(NM_CLICK, IDC_LIST2, OnNMClickList2)
ON_EN_SETFOCUS(IDC_USEROLDPASSWORD, OnEnSetfocusUseroldpassword)
ON_EN_SETFOCUS(IDC_USERNEWPASSWORD, OnEnSetfocusUsernewpassword)
ON_EN_SETFOCUS(IDC_USERNEWPASSWORD1, OnEnSetfocusUsernewpassword1)
ON_BN_CLICKED(IDC_JPEGBROWSE, OnBnClickedJpegbrowse)
ON_BN_CLICKED(IDC_CHECK2, OnBnClickedCheck2)
ON_BN_CLICKED(IDC_CHECK3, OnBnClickedCheck3)
ON_BN_CLICKED(IDC_CHECK4, OnBnClickedCheck4)
ON_EN_CHANGE(IDC_AUTOTIME, OnEnChangeAutotime)
END_MESSAGE_MAP()
// CUserSet 消息处理程序
void CUserSet::OnBnClickedOk()
{
CString useroldname,usernewname,useroldpassword,username1,useroldpassword1,usernewpassword,usernewpassword1,autotime,cn,en;
username1=useroldpassword1=useroldname=usernewname=usernewpassword=usernewpassword1=useroldpassword=autotime=cn=en=_T("");
GetDlgItemText(IDC_USEROLDNAME,useroldname);
GetDlgItemText(IDC_USERNEWNAME,usernewname);
GetDlgItemText(IDC_USEROLDPASSWORD,useroldpassword);
GetDlgItemText(IDC_USERNEWPASSWORD,usernewpassword);
GetDlgItemText(IDC_USERNEWPASSWORD1,usernewpassword1);
if(usernewname.IsEmpty())
{
AfxMessageBox("新用户名不能为空!");
GotoDlgCtrl(GetDlgItem(IDC_USERNEWNAME));
return;
}
if(usernewpassword.IsEmpty())
{
AfxMessageBox("密码不能为空!");
GotoDlgCtrl(GetDlgItem(IDC_USERNEWPASSWORD));
return;
}
if(usernewpassword.GetLength()<4)
{
AfxMessageBox("密码不能少于4位!");
GotoDlgCtrl(GetDlgItem(IDC_USERNEWPASSWORD));
return;
}
if(usernewpassword!=usernewpassword1)
{
AfxMessageBox("两次输入密码不一致!");
GotoDlgCtrl(GetDlgItem(IDC_USERNEWPASSWORD));
return;
}
if(m_check4.GetCheck())
{
GetDlgItemText(IDC_AUTOTIME,autotime);
if(autotime.IsEmpty())
{
AfxMessageBox("选择了网络自动校时,必须设置间隔时间值!");
GotoDlgCtrl(GetDlgItem(IDC_AUTOTIME));
return;
}
}
int r1,r2;
r1=r2=0;
int row1=m_list1.GetItemCount();
int row2=m_list2.GetItemCount();
for(int x=0;x<row1;x++)
if(m_list1.GetCheck(x))
r1=x+1;
for(int x=0;x<row2;x++)
if(m_list2.GetCheck(x))
r2=x+1;
BOOL setinput=FALSE;
if(r1==0 || r2==0)
{
if(AfxMessageBox("设置自己常用的输入法有利于快速录入信息,你还未\r\n进行设置,是否继续?",MB_YESNO|MB_ICONQUESTION)!=IDYES)
return;
}
else
setinput=TRUE;
if(theApp.GetAuto("autosavescreen"))
{
if(m_combo1.GetCurSel()<0)
{
AfxMessageBox("你选择了开启屏幕监控功能,但未设置监控间隔时间,必须设置!");
return;
}
if(!theApp.GetAuto("savedatabase"))
{
CString path=_T("");
GetDlgItemText(IDC_EDIT1,path);
if(path.IsEmpty())
{
AfxMessageBox("你选择了将监控信息保存至目录,但未设置保存目录,必须设置!");
return;
}
}
}
m_pRecordset.CreateInstance(__uuidof(Recordset));
try
{
CString strSQL="SELECT * FROM USERS";
m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(strSQL.GetLength()+1),
((CMedicineSaleManagesApp*)AfxGetApp())->m_pConn1.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
try
{
if(!m_pRecordset->BOF)
m_pRecordset->MoveFirst();
_variant_t var;
while(!m_pRecordset->adoEOF)
{
var = m_pRecordset->GetCollect("user");
username1 = (LPCSTR)_bstr_t(var);
var = m_pRecordset->GetCollect("password");
useroldpassword1 = (LPCSTR)_bstr_t(var);
m_pRecordset->MoveNext();
}
m_pRecordset->MoveFirst();
if(useroldname==username1 && useroldpassword==useroldpassword1)
{
m_pRecordset->PutCollect("user", _variant_t(usernewname));
m_pRecordset->PutCollect("password", _variant_t(usernewpassword));
if(setinput)
{
m_pRecordset->PutCollect("cn", _variant_t(m_list1.GetItemText(r1-1,0)));
m_pRecordset->PutCollect("en", _variant_t(m_list2.GetItemText(r2-1,0)));
}
if(m_check1.GetCheck())
m_pRecordset->PutCollect("auto", _variant_t(1));
else
m_pRecordset->PutCollect("auto", _variant_t(0));
if(m_check2.GetCheck())
m_pRecordset->PutCollect("autosavescreen", _variant_t(1));
else
m_pRecordset->PutCollect("autosavescreen", _variant_t(0));
if(m_check3.GetCheck())
m_pRecordset->PutCollect("savedatabase", _variant_t(1));
else
m_pRecordset->PutCollect("savedatabase", _variant_t(0));
if(m_check4.GetCheck())
{
m_pRecordset->PutCollect("autointernettime", _variant_t(1));
m_pRecordset->PutCollect("autogetinternettime", _variant_t(autotime));
}
else
{
m_pRecordset->PutCollect("autointernettime", _variant_t(0));
m_pRecordset->PutCollect("autogetinternettime", _variant_t("0"));
}
if(m_checklogin.GetCheck())
m_pRecordset->PutCollect("autologin", _variant_t(1));
else
m_pRecordset->PutCollect("autologin", _variant_t(0));
CString time_str=_T("");
m_combo1.GetLBText(m_combo1.GetCurSel(),time_str);
m_pRecordset->PutCollect("autosavetime", _variant_t(time_str));
CString bmp_str=_T("");
m_combo2.GetLBText(m_combo2.GetCurSel(),bmp_str);
m_pRecordset->PutCollect("bmp", _variant_t(bmp_str));
CString dir=_T("");
GetDlgItemText(IDC_EDIT1,dir);
m_pRecordset->PutCollect("savedir", _variant_t(dir));
m_pRecordset->Update();
m_pRecordset->Close();
m_pRecordset=NULL;
theApp.m_savetime=TRUE;
}
else
{
MessageBox("用户名或密码错误。","警告!!!",MB_OK|MB_ICONHAND);
return;
}
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
OnOK();
}
void CUserSet::OnBnClickedCancel()
{
OnCancel();
}
BOOL CUserSet::OnInitDialog()
{
CDialog::OnInitDialog();
DWORD style;
style=m_list1.GetExStyle(); //获取样式
style=(style|LVS_EX_GRIDLINES|LVS_EX_CHECKBOXES|LVS_OWNERDRAWFIXED) ; //设置样式LVS_EX_FULLROWSELECT|
m_list1.SetExtendedStyle(style); //应用样式
m_list2.SetExtendedStyle(style); //应用样式
CRect rect1,rect2;
m_list1.GetWindowRect(rect1);
m_list2.GetWindowRect(rect2);
m_list1.InsertColumn(0,"中文状态使用:",LVCFMT_LEFT,rect1.Width()-4);
m_list2.InsertColumn(0,"其它状态使用:",LVCFMT_LEFT,rect2.Width()-4);
theApp.GetInputSet();
CString imestr;
CInputLanguage ime;
for(int x=0;x<ime.ime_x;x++)
{
imestr.Format("%s",ime.m_pILHead->szName);
ime.m_pILHead=ime.m_pILHead->pNext;
m_list1.InsertItem(x,imestr);
m_list2.InsertItem(x,imestr);
if(imestr==theApp.cn_str)
m_list1.SetCheck(x,1);
if(imestr==theApp.en_str)
m_list2.SetCheck(x,1);
}
ime.Clear();
m_tooltip.Create(this,TTS_ALWAYSTIP);
m_tooltip.Activate(TRUE);
m_tooltip.AddTool(GetDlgItem(IDC_USEROLDNAME),IDS_USEROLDNAME);
m_tooltip.AddTool(GetDlgItem(IDC_USEROLDPASSWORD),IDS_USEROLDPASSWORD);
m_tooltip.AddTool(GetDlgItem(IDC_USERNEWNAME),IDS_USERNEWNAME);
m_tooltip.AddTool(GetDlgItem(IDC_USERNEWPASSWORD),IDS_USERNEWPASSWORD);
m_tooltip.AddTool(GetDlgItem(IDC_USERNEWPASSWORD1),IDS_USERNEWPASSWORD1);
m_tooltip.AddTool(GetDlgItem(IDC_LIST1),IDS_SETLIST1);
m_tooltip.AddTool(GetDlgItem(IDC_LIST2),IDS_SETLIST2);
m_tooltip.AddTool(GetDlgItem(IDOK),IDS_SETOK);
m_tooltip.AddTool(GetDlgItem(IDCANCEL),IDS_SETCANCEL);
m_tooltip.AddTool(GetDlgItem(IDC_CHECK1),IDS_CHECK1);
m_tooltip.AddTool(GetDlgItem(IDC_CHECK2),IDS_CHECK2);
m_tooltip.AddTool(GetDlgItem(IDC_CHECK3),IDS_CHECK3);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -