confirmrouteinfodeldlg.cpp

来自「VC++6.0基于CAN协议的车辆控制」· C++ 代码 · 共 104 行

CPP
104
字号
// ConfirmRouteInfoDelDlg.cpp : implementation file
//

#include "stdafx.h"
#include "PROJECTPMU.h"
#include "ConfirmRouteInfoDelDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CConfirmRouteInfoDelDlg dialog


CConfirmRouteInfoDelDlg::CConfirmRouteInfoDelDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CConfirmRouteInfoDelDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CConfirmRouteInfoDelDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CConfirmRouteInfoDelDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CConfirmRouteInfoDelDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CConfirmRouteInfoDelDlg, CDialog)
	//{{AFX_MSG_MAP(CConfirmRouteInfoDelDlg)
	ON_BN_CLICKED(IDC_BUTTON1, OnConfirmButton)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CConfirmRouteInfoDelDlg message handlers

BOOL CConfirmRouteInfoDelDlg::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"); // 数据库路径
	}
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CConfirmRouteInfoDelDlg::OnConfirmButton() 
{
	// TODO: Add your control notification handler code here
	CString str1,str2,sqldelete;
	str1=CurrentStationEn;
	str2=CurrentStationCh;
	//AfxMessageBox(CurrentStationEn);
	str1.TrimLeft();
    str1.TrimRight();
    str2.TrimLeft();
    str2.TrimRight();
	
	if(m_pConnection.ConnectAccess(mMDB_Path,"sri"))
	{
		// 更新上一个站点的NextStationEn,NextStationCh内容
		CString SQLstr;
		SQLstr.Format("Update RouteInfo set NextStationEn='%s',NextStationCh='%s' \
			where TrainCode='%s' and NextStationEn='%s'and NextStationCh='%s' " \
			,NextStationEn,NextStationCh,TrainCode,CurrentStationEn,CurrentStationCh);
		m_pConnection.Execute(SQLstr);

		//删除
		sqldelete.Format("delete from RouteInfo where (CurrentStationEn='%s') and (CurrentStationCh='%s')",str1,str2);
	//	AfxMessageBox(sqldelete);
		m_pConnection.Execute(sqldelete);

		//m_RouteInfoList.DeleteAllItems();
	}
	Sleep(500);//延时,等数据库更改后再执行下面语句
	CConfirmRouteInfoDelDlg::OnOK();//将修改后的数据保存到上一个窗体中的控件中
	//m_pConnection.Close();

    //ReadDataFromDB();
}

⌨️ 快捷键说明

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