// D:\zm\GeomativeV2.5\cpp\logging\CDialogLoggingParameterSetting.cpp : 实现文件 // #include "stdafx.h" #include "GeoMative.h" #include "logging\CDialogLoggingParameterSetting.h" #include "afxdialogex.h" #define LOGGING_MESSAGEBOX_TITLE _T("CDialogLoggingParameterSetting") // CDialogLoggingParameterSetting 对话框 IMPLEMENT_DYNAMIC(CDialogLoggingParameterSetting, CDialog) CDialogLoggingParameterSetting::CDialogLoggingParameterSetting(CWnd* pParent /*=NULL*/) : CDialog(CDialogLoggingParameterSetting::IDD, pParent) { } CDialogLoggingParameterSetting::~CDialogLoggingParameterSetting() { } void CDialogLoggingParameterSetting::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_COMBO_TASK_NAME_LIST, m_comTaskList); DDX_Control(pDX, IDC_COMBO_WAVEFORM, m_comWaveform); DDX_Control(pDX, IDC_COMBO_LOGGING_DIRECTION, m_comLoggingDirection); } BEGIN_MESSAGE_MAP(CDialogLoggingParameterSetting, CDialog) ON_BN_CLICKED(IDOK, &CDialogLoggingParameterSetting::OnBnClickedOk) ON_BN_CLICKED(IDCANCEL, &CDialogLoggingParameterSetting::OnBnClickedCancel) ON_CBN_SELCHANGE(IDC_COMBO_TASK_NAME_LIST, &CDialogLoggingParameterSetting::OnCbnSelchangeComboTaskNameList) END_MESSAGE_MAP() BOOL CDialogLoggingParameterSetting::OnInitDialog() { CDialog::OnInitDialog(); GetDlgItem(IDC_EDIT_TRACE)->SetWindowTextA(_T("0")); m_comWaveform.AddString(_T("0+0-")); m_comWaveform.SetCurSel(0); if (LANG_ZHCN == g_iUILanguage) { SetWindowTextA(_T("测量参数设置")); GetDlgItem(IDC_STATIC_TASK_NAME)->SetWindowTextA(_T("任务名*:")); GetDlgItem(IDC_STATIC_TEST_LOCATION)->SetWindowTextA(_T("测试地点:")); GetDlgItem(IDC_STATIC)->SetWindowTextA(_T("测井类型*")); GetDlgItem(IDC_CHECK_LONG_POTENTIAL_LOG)->SetWindowTextA(_T("长电位测井")); GetDlgItem(IDC_CHECK_SHORT_POTENTIAL_LOG)->SetWindowTextA(_T("短电位测井")); GetDlgItem(IDC_CHECK_GRADIENT_LOG)->SetWindowTextA(_T("梯度测井")); GetDlgItem(IDC_CHECK_SP_LOG)->SetWindowTextA(_T("SP测井")); GetDlgItem(IDC_STATIC_TRACE)->SetWindowTextA(_T("迭代次数:")); GetDlgItem(IDC_STATIC_WAVEFORM)->SetWindowTextA(_T("发射波形:")); GetDlgItem(IDC_STATIC_SAMPLING_INTERVAL)->SetWindowTextA(_T("采样间隔:")); GetDlgItem(IDC_STATIC_INITIAL_DEPTH)->SetWindowTextA(_T("初始深度*:")); GetDlgItem(IDC_STATIC_END_DEPTH)->SetWindowTextA(_T("结束深度*:")); GetDlgItem(IDC_STATIC_LOGGING_DIRECTION)->SetWindowTextA(_T("测井方向*:")); GetDlgItem(IDC_STATIC_LOGGING_INTERVAL)->SetWindowTextA(_T("测井间隔*:")); GetDlgItem(IDC_STATIC_INSTRUMENT_ZERO_LENGTH)->SetWindowTextA(_T("仪器零长*:")); GetDlgItem(IDC_STATIC_PERIOD)->SetWindowTextA(_T("周期*:")); GetDlgItem(IDOK)->SetWindowTextA(_T("确定")); GetDlgItem(IDCANCEL)->SetWindowTextA(_T("取消")); m_comLoggingDirection.AddString(_T("向上")); m_comLoggingDirection.AddString(_T("向下")); } else { m_comLoggingDirection.AddString(_T("up")); m_comLoggingDirection.AddString(_T("down")); } m_comLoggingDirection.SetCurSel(0); // TODO: 在此添加额外的初始化 m_mapTaskList = CLoggingDataOper::GetInstance()->QueryTaskListFromDB(); if (m_mapTaskList.size() > 0) { map::iterator iter = m_mapTaskList.begin(); for (; iter != m_mapTaskList.end(); iter++) { m_comTaskList.AddString(iter->second.szTaskName); } } m_comTaskList.SetCurSel(0); return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE } void CDialogLoggingParameterSetting::OnCbnSelchangeComboTaskNameList() { // TODO: 在此添加控件通知处理程序代码 int iCurSel = m_comTaskList.GetCurSel(); CString strTaskName; m_comTaskList.GetLBText(iCurSel, strTaskName); if (strTaskName.IsEmpty()) { return; } CString strText; STLoggingTaskInfo stLoggingInfo = CLoggingDataOper::GetInstance()->QueryTaskInfoByName(strTaskName); GetDlgItem(IDC_EDIT_TEST_LOCATION)->SetWindowTextA(stLoggingInfo.szLocation); //工作模式 if ((stLoggingInfo.byLogType & 0x01) == 0x01) { ((CButton*)GetDlgItem(IDC_CHECK_SP_LOG))->SetCheck(TRUE); } else { ((CButton*)GetDlgItem(IDC_CHECK_SP_LOG))->SetCheck(FALSE); } if ((stLoggingInfo.byLogType & 0x02) == 0x02) { ((CButton*)GetDlgItem(IDC_CHECK_LONG_POTENTIAL_LOG))->SetCheck(TRUE); } else { ((CButton*)GetDlgItem(IDC_CHECK_LONG_POTENTIAL_LOG))->SetCheck(FALSE); } if ((stLoggingInfo.byLogType & 0x04) == 0x04) { ((CButton*)GetDlgItem(IDC_CHECK_SHORT_POTENTIAL_LOG))->SetCheck(TRUE); } else { ((CButton*)GetDlgItem(IDC_CHECK_SHORT_POTENTIAL_LOG))->SetCheck(FALSE); } if ((stLoggingInfo.byLogType & 0x08) == 0x08) { ((CButton*)GetDlgItem(IDC_CHECK_GRADIENT_LOG))->SetCheck(TRUE); } else { ((CButton*)GetDlgItem(IDC_CHECK_GRADIENT_LOG))->SetCheck(FALSE); } strText.Empty(); strText.Format(_T("%d"), stLoggingInfo.byTrace); GetDlgItem(IDC_EDIT_TRACE)->SetWindowTextA(strText); m_comWaveform.SetCurSel(iCurSel); strText.Empty(); strText.Format(_T("%.2f"), stLoggingInfo.fSamplingInterval); GetDlgItem(IDC_EDIT_SAMPLING_INTERVAL)->SetWindowTextA(strText); strText.Empty(); strText.Format(_T("%.2f"), stLoggingInfo.fInitDepth); GetDlgItem(IDC_EDIT_INITIAL_DEPTH)->SetWindowTextA(strText); strText.Empty(); strText.Format(_T("%.2f"), stLoggingInfo.fEndDepth); GetDlgItem(IDC_EDIT_END_DEPTH)->SetWindowTextA(strText); m_comLoggingDirection.SetCurSel(stLoggingInfo.byLogDirection); strText.Empty(); strText.Format(_T("%.2f"), stLoggingInfo.fLoggingDistance); GetDlgItem(IDC_EDIT_LOGGING_INTERVAL)->SetWindowTextA(strText); strText.Empty(); strText.Format(_T("%.2f"), stLoggingInfo.fInstrumentZeroLength); GetDlgItem(IDC_EDIT_INSTRUMENT_ZERO_LENGTH)->SetWindowTextA(strText); strText.Empty(); strText.Format(_T("%.2f"), stLoggingInfo.fPeriod); GetDlgItem(IDC_EDIT_PERIOD)->SetWindowTextA(strText); } // CDialogLoggingParameterSetting 消息处理程序 void CDialogLoggingParameterSetting::OnBnClickedOk() { // TODO: 在此添加控件通知处理程序代码 CString strTaskName; int iCurSel = m_comTaskList.GetCurSel(); m_comTaskList.GetLBText(iCurSel, strTaskName); if (strTaskName.IsEmpty()) { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("任务名不能为空")); else MessageBoxEx(NULL, _T("Task name cannot be empty"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } CString strTestLocation; GetDlgItem(IDC_EDIT_TEST_LOCATION)->GetWindowTextA(strTestLocation); BYTE byLogTypes = 0; int iTemp = -1; iTemp = ((CButton*)GetDlgItem(IDC_CHECK_SP_LOG))->GetCheck(); if (iTemp > 0) { byLogTypes |= 1; } iTemp = ((CButton*)GetDlgItem(IDC_CHECK_LONG_POTENTIAL_LOG))->GetCheck(); if (iTemp > 0) { byLogTypes |= 2; } iTemp = ((CButton*)GetDlgItem(IDC_CHECK_SHORT_POTENTIAL_LOG))->GetCheck(); if (iTemp > 0) { byLogTypes |= 4; } iTemp = ((CButton*)GetDlgItem(IDC_CHECK_GRADIENT_LOG))->GetCheck(); if (iTemp > 0) { byLogTypes |= 8; } if (byLogTypes <= 0) { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("请选择测井类型")); else MessageBoxEx(NULL, _T("Please select the logging type"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } CString strTrace; GetDlgItem(IDC_EDIT_TRACE)->GetWindowTextA(strTrace); if (strTrace.IsEmpty()) { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("迭代次数不能为空")); else MessageBoxEx(NULL, _T("Number of iterations cannot be empty"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } int iWaveform = m_comWaveform.GetCurSel(); if (iWaveform < 0) { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("请选择发射波形")); else MessageBoxEx(NULL, _T("Please select the launch waveform"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } CString strSamplingInterval; GetDlgItem(IDC_EDIT_SAMPLING_INTERVAL)->GetWindowTextA(strSamplingInterval); if (strSamplingInterval.IsEmpty()) { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("采样间隔不能为空")); else MessageBoxEx(NULL, _T("Sampling interval must not be empty"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } CString strInitialDepth; GetDlgItem(IDC_EDIT_INITIAL_DEPTH)->GetWindowTextA(strInitialDepth); if (strInitialDepth.IsEmpty()) { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("初始深度不能为空")); else MessageBoxEx(NULL, _T("Initial depth cannot be empty"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } CString strEndDepth; GetDlgItem(IDC_EDIT_END_DEPTH)->GetWindowTextA(strEndDepth); if (strEndDepth.IsEmpty()) { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("结束深度不能为空")); else MessageBoxEx(NULL, _T("End depth cannot be empty"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } int iLogDir = m_comLoggingDirection.GetCurSel(); if (iLogDir < 0) { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("请选择测井方向")); else MessageBoxEx(NULL, _T("Please select the logging direction"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } CString strLoggingInterval; GetDlgItem(IDC_EDIT_LOGGING_INTERVAL)->GetWindowTextA(strLoggingInterval); if (strLoggingInterval.IsEmpty()) { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("测井间隔不能为空")); else MessageBoxEx(NULL, _T("Log interval must not be empty"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } CString strInstrumentZeroLength; GetDlgItem(IDC_EDIT_INSTRUMENT_ZERO_LENGTH)->GetWindowTextA(strInstrumentZeroLength); if (strInstrumentZeroLength.IsEmpty()) { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("仪器零长不能为空")); else MessageBoxEx(NULL, _T("Instrument zero length cannot be empty"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } CString strPeriod; GetDlgItem(IDC_EDIT_PERIOD)->GetWindowTextA(strPeriod); if (strPeriod.IsEmpty()) { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("周期不能为空")); else MessageBoxEx(NULL, _T("Period cannot be empty"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } //将数据希尔 BOOL bRes = CLoggingDataOper::GetInstance()->UpdateTaskInfoIntoDB(strTaskName, strTestLocation, byLogTypes, strTrace, iWaveform, strSamplingInterval, strInitialDepth, strEndDepth, iLogDir, strLoggingInterval, strInstrumentZeroLength, strPeriod); if (bRes) { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("修改任务信息成功")); else MessageBoxEx(NULL, _T("Update task information successful"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); } else { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("修改任务信息失败")); else MessageBoxEx(NULL, _T("Update task information failed"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); } m_stLoggingParam.byLogTypes = byLogTypes; m_stLoggingParam.byLogDirection = iLogDir; m_stLoggingParam.fSamplingInterval = atof(strSamplingInterval); m_stLoggingParam.fDepth = atof(strEndDepth) - atof(strInitialDepth); m_stLoggingParam.fLoggingDistance = atof(strLoggingInterval); m_stLoggingParam.fPeriod = atof(strPeriod); CDialog::OnOK(); } void CDialogLoggingParameterSetting::OnBnClickedCancel() { // TODO: 在此添加控件通知处理程序代码 CDialog::OnCancel(); } STLoggingParamSettingReq CDialogLoggingParameterSetting::GetLogParamSetting() { return m_stLoggingParam; }