📄 dsystem.cpp
字号:
// DSystem.cpp : implementation file
//
#include "stdafx.h"
#include "yhjk.h"
#include "DSystem.h"
#include "yhjkDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDSystem dialog
CDSystem::CDSystem(CWnd* pParent /*=NULL*/)
: CDialog(CDSystem::IDD, pParent)
{
//{{AFX_DATA_INIT(CDSystem)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CDSystem::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDSystem)
DDX_Control(pDX, IDC_EDTNAME1, m_EdtName);
DDX_Control(pDX, IDC_EDTLAYERCODELENGTH, m_EdtLayerCodeLength);
DDX_Control(pDX, IDC_EDTACTCODELENGTH, m_EdtActCodeLength);
DDX_Control(pDX, IDC_EDTLAYER, m_EdtLayer);
DDX_Control(pDX, IDC_COMOUT, m_ComOut);
DDX_Control(pDX, IDC_BUT_SAVE, m_ButSave);
DDX_Control(pDX, IDC_BUT_CHANGE, m_ButChange);
DDX_Control(pDX, IDC_BUT_EXIT, m_ButExit);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDSystem, CDialog)
//{{AFX_MSG_MAP(CDSystem)
ON_BN_CLICKED(IDC_BUT_CHANGE, OnButChange)
ON_BN_CLICKED(IDC_BUT_SAVE, OnButSave)
ON_BN_CLICKED(IDC_BUT_EXIT, OnButExit)
ON_EN_CHANGE(IDC_EDTLAYER, OnChangeEdtlayer)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDSystem message handlers
void CDSystem::OnOK()
{
// TODO: Add extra validation here
//CDialog::OnOK();
}
void CDSystem::Display()
{
RxRecordset rst;
rst.Open("系统设置表");
CString sName,sLayers,sLayerCodeLength,sActCodeLength,sOutPut;
sName=rst.GetFieldValue("大厦名称");
sLayers=rst.GetFieldValue("楼层数");
sLayerCodeLength=rst.GetFieldValue("地址编码长度");
sActCodeLength=rst.GetFieldValue("动作编码长度");
sOutPut=rst.GetFieldValue("输出端口");
sOutPut="COM"+sOutPut;
this->m_EdtActCodeLength.SetWindowText(sActCodeLength);
this->m_EdtLayer.SetWindowText(sLayers);
this->m_EdtLayerCodeLength.SetWindowText(sLayerCodeLength);
this->m_EdtName.SetWindowText(sName);
this->m_ComOut.SetWindowText(sOutPut);
}
BOOL CDSystem::OnInitDialog()
{
CDialog::OnInitDialog();
Display();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDSystem::OnButChange()
{
this->Enabled(true);
m_EdtName.SetFocus();
}
void CDSystem::Enabled(bool bEnabled)
{
m_EdtName.EnableWindow(bEnabled);
m_EdtLayerCodeLength.EnableWindow(bEnabled);
m_EdtActCodeLength.EnableWindow(bEnabled);
m_EdtLayer.EnableWindow(bEnabled);
m_ComOut.EnableWindow(bEnabled);
m_ButSave.EnableWindow(bEnabled);
m_ButChange.EnableWindow(!bEnabled);
m_ButExit.EnableWindow(!bEnabled);
}
void CDSystem::OnButSave()
{
if(MessageBox("确定要保存修改吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
return;
CString sName,sLayers,sLayerCodeLength,sActCodeLength,sOutPut;
m_EdtName.GetWindowText(sName);
m_EdtLayerCodeLength.GetWindowText(sLayerCodeLength);
m_EdtActCodeLength.GetWindowText(sActCodeLength);
m_EdtLayer.GetWindowText(sLayers);
m_ComOut.GetWindowText(sOutPut);
sOutPut=sOutPut.Right(sOutPut.GetLength()-3);
CString sSQL;
sSQL.Format("UPDATE 系统设置表 SET 大厦名称='%s',楼层数=%s,地址编码长度=%s,动作编码长度=%s,输出端口=%s ",sName,sLayers,sLayerCodeLength,sActCodeLength,sOutPut);
RxRecordset rst;
rst.Open(sSQL,adCmdText);
this->Enabled(false);
this->m_ButExit.SetFocus();
sSQL.Format("DELETE FROM 处警参数设置表 ");
rst.Open(sSQL,adCmdText);
MessageBox("需要重新启动才能生效!系统即将关闭!","系统提示",MB_OK|MB_ICONEXCLAMATION);
this->OnCancel();
CMainDlg * Parent=(CMainDlg * )this->GetParent();
Parent->Close();
}
void CDSystem::OnButExit()
{
this->OnCancel();
}
void CDSystem::OnChangeEdtlayer()
{
CString sText,sTwoText,sLength;
m_EdtLayer.GetWindowText(sText);
sTwoText=TenToTwo(atoi(sText));
CString chr=sTwoText;
int i=0;
while(true)
{
if(chr.Mid(i,1)!="0")
break;
else
i++;
}
sTwoText=sTwoText.Right(sTwoText.GetLength()-i);
sLength.Format("%d",sTwoText.GetLength());
this->m_EdtLayerCodeLength.SetWindowText(sLength);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -