📄 editservermessagesdlg.cpp
字号:
// EditServerMessagesDlg.cpp : implementation file
//
#include "stdafx.h"
#include "PROJECTPMU.h"
#include "EditServerMessagesDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEditServerMessagesDlg dialog
CEditServerMessagesDlg::CEditServerMessagesDlg(CWnd* pParent /*=NULL*/)
: CDialog(CEditServerMessagesDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CEditServerMessagesDlg)
m_EnglishText_Edit = _T("");
m_ChineseText_Edit = _T("");
m_AudioEn_Edit = _T("");
m_AudioCh_Edit = _T("");
m_EnglishWave_Edit = _T("");
m_ChineseWave_Edit = _T("");
//}}AFX_DATA_INIT
}
void CEditServerMessagesDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEditServerMessagesDlg)
DDX_Text(pDX, IDC_EDIT1, m_EnglishText_Edit);
DDX_Text(pDX, IDC_EDIT2, m_ChineseText_Edit);
DDX_Text(pDX, IDC_EDIT3, m_AudioEn_Edit);
DDX_Text(pDX, IDC_EDIT4, m_AudioCh_Edit);
DDX_Text(pDX, IDC_EDIT5, m_EnglishWave_Edit);
DDX_Text(pDX, IDC_EDIT6, m_ChineseWave_Edit);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CEditServerMessagesDlg, CDialog)
//{{AFX_MSG_MAP(CEditServerMessagesDlg)
ON_BN_CLICKED(IDC_SaveButton, OnSaveButton)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEditServerMessagesDlg message handlers
BOOL CEditServerMessagesDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
//得到应用程序所在文件夹路径
CAdoRecordSet pRS;
if(NULL != GetModuleFileName(NULL,mDir_Path,256))
{
int n=strlen(mDir_Path);
for (int i=n; i>=0; i--)
{
if (mDir_Path[i] == '\\')
{
mDir_Path[i] = '\0';
break;
}
}
strcpy(mMDB_Path,mDir_Path);
strcat(mMDB_Path,"\\PIS.mdb"); // 数据库路径
}
//把需要修改的数据显示在文本框中
m_EnglishText_Edit=EnglishText;
m_ChineseText_Edit=ChineseText;
m_AudioEn_Edit=AudioDescriptionEn;
m_AudioCh_Edit=AudioDescriptionCh;
m_EnglishWave_Edit=EnglishWave;
m_ChineseWave_Edit=ChineseWave;
UpdateData(FALSE);//显示出来
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CEditServerMessagesDlg::OnSaveButton()
{
// TODO: Add your control notification handler code here
CString sEnglishText="",sChineseText="",sAudioDescriptionEn="",sAudioDescriptionCh="",\
sEnglishWave="",sChineseWave="",sqlupdate="",sqladd="";
CString str1, str2;
str1=m_EnglishText_Edit;
// AfxMessageBox(str1);
str2=m_ChineseText_Edit;
str1.TrimRight();
str2.TrimRight();
//读取文本框中的数据并赋值给定义的字符串
((CEdit *)GetDlgItem(IDC_EDIT1))->GetWindowText(sEnglishText);
// AfxMessageBox(sEnglishText);
((CEdit *)GetDlgItem(IDC_EDIT2))->GetWindowText(sChineseText);
((CEdit *)GetDlgItem(IDC_EDIT3))->GetWindowText(sAudioDescriptionEn);
((CEdit *)GetDlgItem(IDC_EDIT4))->GetWindowText(sAudioDescriptionCh);
((CEdit *)GetDlgItem(IDC_EDIT5))->GetWindowText(sEnglishWave);
((CEdit *)GetDlgItem(IDC_EDIT6))->GetWindowText(sChineseWave);
sqlupdate.Format("update ServerMessages set EnglishText='%s',ChineseText='%s',\
AudioDescriptionEn='%s',AudioDescriptionCh='%s',EnglishWave='%s',\
ChineseWave='%s' where (EnglishText='%s') and (ChineseText='%s')", \
sEnglishText,sChineseText,sAudioDescriptionEn,sAudioDescriptionCh,\
sEnglishWave,sChineseWave,str1,str2);//修改ServerMessages数据
sqladd.Format("insert into ServerMessages(EnglishText,ChineseText,AudioDescriptionEn,\
AudioDescriptionCh,EnglishWave,ChineseWave) values ('%s','%s','%s','%s','%s',\
'%s')",sEnglishText,sChineseText,sAudioDescriptionEn,sAudioDescriptionCh,\
sEnglishWave,sChineseWave);//添加ServerMessages数据
// AfxMessageBox(sqladd);
if (m_pConnection.ConnectAccess(mMDB_Path,"sri"))
{
if(m_bADD)//条件区分是修改数据还是添加数据
{
m_pConnection.Execute(sqladd);
// m_pConnection.Execute(sqladd1);
}
else
{
m_pConnection.Execute(sqlupdate);
}
// m_pConnection.Execute(sqlupdate1);
//m_pConnection.Execute(_bstr_t(sqlStr),adCmdText);
}
Sleep(500);//延时,等数据库更改后再执行下面语句
CEditServerMessagesDlg::OnOK();//将修改后的数据保存到上一个窗体中的控件中*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -