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

📄 userchangei.cpp

📁 实时监控
💻 CPP
📖 第 1 页 / 共 4 页
字号:
// UserChangeI.cpp : implementation file
//

#include "stdafx.h"
#include "../resource.h"
#include "reg.h"
#include "../utils/common.h"
#include "../utils/custom_msgs.h"
#include "../dvrmanager.h"
#include "LSetting.h"
#include "fileoperation.h"
#include "UserChangeI.h"

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif

IMPLEMENT_DYNCREATE(CUserChangeI, CPropertyPage)
IMPLEMENT_DYNCREATE(CLoginSet, CPropertyPage)
IMPLEMENT_DYNCREATE(CChannelMap, CPropertyPage)
IMPLEMENT_DYNCREATE(CSetUp, CPropertyPage)
IMPLEMENT_DYNCREATE(CAlarmServerSet, CPropertyPage)
IMPLEMENT_DYNCREATE(CAlarmServerLink, CPropertyPage)
IMPLEMENT_DYNCREATE(CParatSet, CPropertyPage)
/////////////////////////////////////////////////////////////////////////////
// CUserChangeI property page
extern CString m_login_client_name;
CUserChangeI::CUserChangeI() : CPropertyPage(CUserChangeI::IDD)
{
	//{{AFX_DATA_INIT(CUserChangeI)
	m_name = m_login_client_name;
	m_npass = _T("");
	m_configpass = _T("");
	m_bpass = _T("");
	m_description = _T("");
	m_address = _T("");
	m_email = _T("");
	m_telphone = _T("");
	//}}AFX_DATA_INIT
	m_brush.CreateSolidBrush(RGB(117, 200, 146));
}

CUserChangeI::~CUserChangeI()
{
}

void CUserChangeI::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CUserChangeI)
	DDX_Control(pDX, ID_GROUP1, m_grp1);
	DDX_Control(pDX, ID_GROUP2, m_grp2);
	DDX_Control(pDX, IDC_lable8, m_lable8);
	DDX_Control(pDX, IDC_lable7, m_lable7);
	DDX_Control(pDX, IDC_lable6, m_lable6);
	DDX_Control(pDX, IDC_lable5, m_lable5);
	DDX_Control(pDX, IDC_lable4, m_lable4);
	DDX_Control(pDX, IDC_lable3, m_lable3);
	DDX_Control(pDX, IDC_lable2, m_lable2);
	DDX_Control(pDX, IDC_lable1, m_lable1);
	DDX_Control(pDX, IDC_Update, m_update);
	DDX_Control(pDX, IDC_CANCEL, m_cancel);
	DDX_Text(pDX, IDC_Name, m_name);
	DDX_Text(pDX, IDC_Description, m_description);
	DDX_Text(pDX, IDC_address, m_address);
	DDX_Text(pDX, IDC_email, m_email);
	DDX_Text(pDX, IDC_telphone, m_telphone);
	DDX_Text(pDX, IDC_npass, m_npass);
	DDX_Text(pDX, IDC_configpass, m_configpass);
	DDX_Text(pDX, IDC_bpass, m_bpass);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CUserChangeI, CPropertyPage)
	//{{AFX_MSG_MAP(CUserChangeI)
	ON_BN_CLICKED(IDC_Update, OnUpdate)
	ON_BN_CLICKED(IDC_CANCEL, OnCancel)
	ON_WM_CTLCOLOR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CLoginSet property page

CLoginSet::CLoginSet() : CPropertyPage(CLoginSet::IDD)
{
	//{{AFX_DATA_INIT(CLoginSet)
	//}}AFX_DATA_INIT
	m_brush.CreateSolidBrush(RGB(117, 200, 146));
}

CLoginSet::~CLoginSet()
{
}

void CLoginSet::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CLoginSet)
	DDX_Control(pDX, IDC_del, m_del);
	DDX_Control(pDX, IDC_add, m_add);
	DDX_Control(pDX, IDC_SAVE_SET, m_saveset);
	DDX_Control(pDX, IDC_LOAD_SET, m_loadset);
	DDX_Control(pDX, IDC_MSFLEXGRID1, m_dbgrid);
	//}}AFX_DATA_MAP

	CString m_temstr;
    m_temstr.Format(IDS_AdDMINISTRATOR);
	if(!strcmp(m_login_client_name, m_temstr))
	{
		m_saveset.EnableWindow(TRUE);
		m_loadset.EnableWindow(TRUE);
	}
	else
	{
		m_saveset.EnableWindow(FALSE);
		m_loadset.EnableWindow(FALSE);
	}

	long m_row=m_dbgrid.GetRowSel();
	CString m_str=m_dbgrid.GetTextMatrix(m_row,1);
    m_del.EnableWindow(!m_str.IsEmpty());
}


BEGIN_MESSAGE_MAP(CLoginSet, CPropertyPage)
	//{{AFX_MSG_MAP(CLoginSet)
	ON_BN_CLICKED(IDC_add, Onadd)
	ON_BN_CLICKED(IDC_del, Ondel)
	ON_BN_CLICKED(IDC_SAVE_SET, Onsaveset)
	ON_BN_CLICKED(IDC_LOAD_SET, Onloadset)
	ON_WM_CTLCOLOR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CChannelMap property page
CChannelMap * CChannelMap::m_channelmap =NULL;
CChannelMap::CChannelMap() : CPropertyPage(CChannelMap::IDD)
{
	//{{AFX_DATA_INIT(CChannelMap)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	m_brush.CreateSolidBrush(RGB(117, 200, 146));
	m_channelmap = this ;
}

CChannelMap::~CChannelMap()
{
}

void CChannelMap::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CChannelMap)
	DDX_Control(pDX, IDC_del, m_del);
	DDX_Control(pDX, IDC_add, m_add);
	DDX_Control(pDX, IDC_MSFLEXGRID1, m_dbgrid);
    DDX_Control(pDX, ID_GROUP1, m_grp1);
	DDX_Control(pDX, IDC_lable7, m_lable7);
	DDX_Control(pDX, IDC_lable6, m_lable6);
	DDX_Control(pDX, IDC_lable5, m_lable5);
	DDX_Control(pDX, IDC_lable4, m_lable4);
	DDX_Control(pDX, IDC_lable3, m_lable3);
	DDX_Control(pDX, IDC_lable2, m_lable2);
	DDX_Control(pDX, IDC_lable1, m_lable1);
	DDX_Control(pDX, IDC_setup_name, m_setup_namectl);
	DDX_Control(pDX, IDC_dvrname, m_dvrnamectl);
	DDX_Control(pDX, IDC_channel, m_channelctl);
	DDX_Control(pDX, IDC_window, m_windowctl);
    DDX_Control(pDX, IDC_update1, m_update);
	DDX_Control(pDX, IDC_connect, m_connectctl);
	DDX_Control(pDX, IDC_nettype, m_nettypectl);
	DDX_Text(pDX, IDC_ip, m_ip);
	DDX_Text(pDX, IDC_setup_name, m_setup_name);
	DDX_Text(pDX, IDC_dvrname, m_dvrname);
	DDX_Text(pDX, IDC_channel, m_channel);
	DDX_Text(pDX, IDC_window, m_window);
	DDX_Text(pDX, IDC_connect, m_connect);
	DDX_Text(pDX, IDC_nettype, m_nettype);
	
	//}}AFX_DATA_MAP
	long m_row = m_dbgrid.GetRowSel();
	CString m_str = m_dbgrid.GetTextMatrix(m_row,1);
    m_del.EnableWindow(!m_str.IsEmpty());	
}


BEGIN_MESSAGE_MAP(CChannelMap, CPropertyPage)
	//{{AFX_MSG_MAP(CChannelMap)
	
	ON_BN_CLICKED(IDC_add, Onadd)
	ON_BN_CLICKED(IDC_del, Ondel)
	ON_BN_CLICKED(IDC_update1, Onupdate)
	ON_CBN_SETFOCUS(IDC_channel, OnSetfocuschannel)
	ON_CBN_SETFOCUS(IDC_window, OnSetfocuswindow)
	ON_CBN_SETFOCUS(IDC_dvrname, OnSetfocusdvrname)
	ON_CBN_SETFOCUS(IDC_setup_name, OnSetfocussetup)
	ON_CBN_SELCHANGE(IDC_setup_name, OnSelchangesetup)
	ON_CBN_SELCHANGE(IDC_dvrname, OnSelchangedvrname)
	ON_WM_CTLCOLOR()
	//}}AFX_MSG_MAP
	ON_MESSAGE(NTM_CHANNEL_MAP_UPDATE, UpdateMapchannel)
END_MESSAGE_MAP()

extern char m_popedom_directory[150];
extern char m_user_management_directory[150];
extern char m_remote_station_directory[150];
extern char m_channel_window_directory[150];
extern char m_scene_setup_directory[150];

extern char m_alarm_server_directory[150];
extern char	m_alarm_server_link_directory[150];

BOOL CUserChangeI::OnInitDialog()
{	
	CPropertyPage::OnInitDialog();
	init_label(m_lable1);
	init_label(m_lable2);
	init_label(m_lable3);
	init_label(m_lable4);
	init_label(m_lable5);
	init_label(m_lable6);
	init_label(m_lable7);
	init_label(m_lable8);

	Cfileoperation <User_Information> *m_fileoperation;
    m_file_length=m_fileoperation->openfile(m_user_management_directory,"ab+",m_user);

	for(int i=0;i<m_file_length;i++)
	{
		if(!strcmp(m_user[i].name,m_name))
	   {  
          m_description = m_user[i].description;
          m_address = m_user[i].address;
	      m_email = m_user[i].email;
	      m_telphone = m_user[i].telphone;
		}
	}
	UpdateData(false);

	return true;	
}


void CUserChangeI::OnUpdate() 
{
	UpdateData(true);
	if(strcmp(m_configpass,m_npass))
	{
		AfxMessageBox(IDS_DIFF_PASS);
		OnCancel();
		return ;
	}
	/*if(m_npass.IsEmpty())
	{
		AfxMessageBox(IDS_EMPTY_PASS);
		return;
	}*/
	 for(int k=0;k<m_telphone.GetLength();k++)
	{
		char dc=m_telphone.GetAt(k);
		if(dc>'9'||dc<'0')
		{
			AfxMessageBox(IDS_TELNUMBER);
			return;
		}
	}
    if(!m_email.IsEmpty()&&(m_email.Find("@")==-1))
	{
      	AfxMessageBox(IDS_EMAIL_ERROR);
		return ;
	}

    for(int i=0;i<m_file_length;i++)
	{
       if(!strcmp(m_user[i].name,m_name))
	   {  
		 if(!strcmp(m_user[i].password,m_bpass))
		 {
			 strcpy(m_user[i].password,m_npass);
			 strcpy(m_user[i].description,m_description);
             strcpy(m_user[i].address,m_address);
	         strcpy(m_user[i].email,m_email);
	         strcpy(m_user[i].telphone,m_telphone);
	 	     break;
		 }
		 else 
		 {
			 AfxMessageBox(IDS_OLD_PASS);
			 OnCancel();
			 return;
		 }
	   }   
	}
	OnSave();

	CString m_logfile;
    m_logfile.Format(IDS_SELF_INF);
	write_log_file(m_logfile);
	
}
void CUserChangeI::OnSave()
{

	Cfileoperation <User_Information> *m_fileoperation;
	m_fileoperation->savefilename(m_user_management_directory,"wb+",m_user,m_file_length);
	AfxMessageBox(IDS_CHANGE_PASS_OK);

}
void CUserChangeI::OnCancel() 
{
	for(int i=0;i<m_file_length;i++)
	{
		if(!strcmp(m_user[i].name,m_name))
	   {  
          m_description = m_user[i].description;
          m_address = m_user[i].address;
	      m_email = m_user[i].email;
	      m_telphone = m_user[i].telphone;
		}
	}
    m_npass = _T("");
	m_configpass = _T("");
	m_bpass = _T("");
	UpdateData(false);
	
}
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////

BOOL CLoginSet::OnInitDialog()
{	
	CPropertyPage::OnInitDialog();

	dbgrid();

	return true;	
}

void CLoginSet::dbgrid()
{
	UpdateData(true);
	Cfileoperation <Remote_Station_setting> *m_fileoperation;
    int m_length=m_fileoperation->openfile(m_remote_station_directory,"ab+",m_station);
	
    CString m_temstr;
	m_dbgrid.Clear();
    m_dbgrid.SetRow(0);
	m_dbgrid.SetCol(0);
	m_dbgrid.SetColAlignment(0 , 4);
	m_temstr.Format(IDS_NUMBER);
	m_dbgrid.SetText(m_temstr);
	m_dbgrid.SetCol(1);
	 m_dbgrid.SetColAlignment(1 , 4);
	m_temstr.Format(IDS_DVR_NAME);
	m_dbgrid.SetText(m_temstr);
	m_dbgrid.SetCol(2);
	 m_dbgrid.SetColAlignment(2 , 4);
	m_dbgrid.SetColWidth(2,1500);
	m_temstr.Format(IDS_DVR_IP);
	m_dbgrid.SetText(m_temstr);
	m_dbgrid.SetCol(3);
	 m_dbgrid.SetColAlignment(3 , 4);
	m_temstr.Format(IDS_DVR_PORT);
	m_dbgrid.SetText(m_temstr);
	m_dbgrid.SetCol(4);
	 m_dbgrid.SetColAlignment(4 , 4);
	m_temstr.Format(IDS_DVR_LOGIN_USER);
	m_dbgrid.SetText(m_temstr);
	m_dbgrid.SetCol(5);
	 m_dbgrid.SetColAlignment(5 , 4);
	m_temstr.Format(IDS_DVR_LOGIN_PASS);
	m_dbgrid.SetText(m_temstr);
	
	int m_rownub=0;
	for(int m=0;m<m_length;m++)
	{
	  if(strcmp(m_station[m].name,m_login_client_name)) continue;
	  char m_dc[10];
	  m_rownub++;
	  if(m_rownub>19)
	  m_dbgrid.SetRows(m_rownub+1);
	  m_dbgrid.SetRow(m_rownub);
      m_dbgrid.SetCol(0);
      m_dbgrid.SetText(itoa(m_rownub,m_dc,10));
	  m_dbgrid.SetCol(1);
      m_dbgrid.SetText(m_station[m].dvrname);
	  m_dbgrid.SetCol(2);
      m_dbgrid.SetText(m_station[m].ip);
	  m_dbgrid.SetCol(3);
      m_dbgrid.SetText(itoa(m_station[m].port,m_dc,10));
	  m_dbgrid.SetCol(4);
      m_dbgrid.SetText(m_station[m].logindvrname);
	  m_dbgrid.SetCol(5);
      m_dbgrid.SetText("*******");
	}
}

void CLoginSet::Onsaveset()
{
	char curdirec[100];
	GetCurrentDirectory(100, curdirec);
	CString str;
	CFileDialog fd(FALSE, "dat", NULL, OFN_HIDEREADONLY,
		"*.dat|", this);

	if( IDOK != fd.DoModal() )
		return ;

	save_compound_file(fd.GetPathName());
	SetCurrentDirectory(curdirec);
}

void CLoginSet::Onloadset() 
{
	char curdirec[100];
	GetCurrentDirectory(100, curdirec);
	CString str;
	CFileDialog fd(TRUE, NULL, NULL, OFN_HIDEREADONLY,
		"*.dat|", this);

	if( IDOK != fd.DoModal() )
		return ;

	CString m_str;
	m_str = fd.GetPathName();
	if(m_str.IsEmpty())
		return;

	load_compound_file(m_str);
	dbgrid();
	SetCurrentDirectory(curdirec);
}

void CLoginSet::Onadd() 
{
	CLSetting setting;
	setting.m_control=false;
	int m_result=setting.DoModal();
	if(m_result==IDOK) 	dbgrid();
	
}

void CLoginSet::Ondel() 
{
	long m_row=m_dbgrid.GetRowSel();
	CString m_str;
	CLSetting setting;
    m_str=m_dbgrid.GetTextMatrix(m_row,1);
	setting.m_dvrname=m_str;

    Remote_Station_setting m_station_p;
    strcpy(m_station_p.dvrname,m_str);

	CRightLogin::the_one()->SendMessage(NTM_CMD_LOGIN_DELETE, (WPARAM) &m_station_p);
	setting.delfile();
	dbgrid();

	CChannelMap * p_channel = CChannelMap::m_channelmap;
	if(p_channel && p_channel->m_hWnd)
	   p_channel->PostMessage(NTM_CHANNEL_MAP_UPDATE, 0 ,0 );
}

BEGIN_EVENTSINK_MAP(CLoginSet, CPropertyPage)
    //{{AFX_EVENTSINK_MAP(CLoginSet)
	ON_EVENT(CLoginSet, IDC_MSFLEXGRID1, -601 /* DblClick */, OnDblClickMsflexgrid1, VTS_NONE)
	ON_EVENT(CLoginSet, IDC_MSFLEXGRID1, -600 /* DblClick */, OnClickMsflexgrid1, VTS_NONE)
	//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

void CLoginSet::OnClickMsflexgrid1() 
{
	UpdateData(true);
}
void CLoginSet::OnDblClickMsflexgrid1() 
{
	long m_row=m_dbgrid.GetRowSel();
	CLSetting setting;
	CString m_dvrname;
	setting.m_control=true;
	m_dvrname=setting.m_dvrname=m_dbgrid.GetTextMatrix(m_row,1);
	if(!strcmp(m_dvrname,"")) return;
	setting.m_ip=m_dbgrid.GetTextMatrix(m_row,2);
    setting.m_port=atoi(m_dbgrid.GetTextMatrix(m_row,3));
	setting.m_loginuser=m_dbgrid.GetTextMatrix(m_row,4);

⌨️ 快捷键说明

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