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

📄 custdlg.cpp

📁 GIS地理信息系统开发。大名鼎鼎的MAPX+C++软件开发
💻 CPP
字号:
// CustDlg.cpp : implementation file
//
/*
 * This sample application and corresponding sample code is provided for 
 * example purposes only.  It has not undergone rigorous testing and as 
 * such should not be shipped as part of a final application without 
 * extensive testing on the part of the organization releasing the 
 * end-user product. 
 */

#include "stdafx.h"
#include "MapTest.h"
#include "CustDlg.h"
#include <string.h>


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

/////////////////////////////////////////////////////////////////////////////
// CCustDlg dialog


CCustDlg::CCustDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CCustDlg::IDD, pParent)
{
	EnableAutomation();

	//{{AFX_DATA_INIT(CCustDlg)
	m_City = _T("");
	m_Company = _T("");
	m_Fname = _T("");
	m_State = _T("");
	m_Terr = _T("");
	m_Zip = _T("");
	m_Lname = _T("");
	m_Amt = _T("");
	//}}AFX_DATA_INIT
}

void CCustDlg::OnFinalRelease()
{
	// When the last reference for an automation object is released
	// OnFinalRelease is called.  The base class will automatically
	// deletes the object.  Add additional cleanup required for your
	// object before calling the base class.

	CDialog::OnFinalRelease();
}

void CCustDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CCustDlg)
	DDX_Text(pDX, IDC_CITY, m_City);
	DDX_Text(pDX, IDC_COMPANY, m_Company);
	DDX_Text(pDX, IDC_FNAME, m_Fname);
	DDX_Text(pDX, IDC_STATE, m_State);
	DDX_Text(pDX, IDC_TERR, m_Terr);
	DDX_Text(pDX, IDC_ZIP, m_Zip);
	DDX_Text(pDX, IDC_LNAME, m_Lname);
	DDX_Text(pDX, IDC_AMOUNT, m_Amt);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CCustDlg, CDialog)
	//{{AFX_MSG_MAP(CCustDlg)
	ON_EN_CHANGE(IDC_FNAME, OnChangeFname)
	ON_EN_CHANGE(IDC_LNAME, OnChangeLname)
	ON_EN_CHANGE(IDC_CITY, OnChangeCity)
	ON_EN_CHANGE(IDC_STATE, OnChangeState)
	ON_EN_CHANGE(IDC_ZIP, OnChangeZip)
	ON_EN_CHANGE(IDC_TERR, OnChangeTerr)
	ON_EN_CHANGE(IDC_COMPANY, OnChangeCompany)
	ON_EN_CHANGE(IDC_AMOUNT, OnChangeAmount)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

BEGIN_DISPATCH_MAP(CCustDlg, CDialog)
	//{{AFX_DISPATCH_MAP(CCustDlg)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()

// Note: we add support for IID_ICustDlg to support typesafe binding
//  from VBA.  This IID must match the GUID that is attached to the 
//  dispinterface in the .ODL file.

// {97520440-3384-11D2-936A-0060978C27AF}
static const IID IID_ICustDlg =
{ 0x97520440, 0x3384, 0x11d2, { 0x93, 0x6a, 0x0, 0x60, 0x97, 0x8c, 0x27, 0xaf } };

BEGIN_INTERFACE_MAP(CCustDlg, CDialog)
	INTERFACE_PART(CCustDlg, IID_ICustDlg, Dispatch)
END_INTERFACE_MAP()



/////////////////////////////////////////////////////////////////////////////
// CCustDlg message handlers

void CCustDlg::OnOK() 
{
	CString messageString = "";

	UpdateData(true);
	CMapXLayer custLayer = m_pMap->GetLayers().Item("Us_custg");	
		//"custLayer" is set to be the customer layer on the main map
	CMapXFeature custFtr = custLayer.GetFeatureByID(custFtrID);
		//"custFtr" is set to be the customer represented by the custFtrID
		//we grabbed this value out before showing the customer dialog

	//***********************************************************************************
	//This next section checks to see if there were any changes to the edit boxes on the 
	//customer dialog.  If there were any changes, this section detects what has been 
	// changed, and makes the appropriate changes to the .tab file.
	//***********************************************************************************

	if (m_Lname != *m_pLname) {
		messageString += "\nYou are about to change the last name from \"";
		messageString += *m_pLname;
		messageString += "\" to \"";
		messageString += m_Lname;
		messageString += "\".\n";
	}
	if (m_Fname != *m_pFname) {
		messageString += "You are about to change the first name from \"";
		messageString += *m_pFname;
		messageString += "\" to \"";
		messageString += m_Fname;
		messageString += "\".\n";
	}
	if (m_City != *m_pCity) {
		messageString += "You are about to change the city from \"";
		messageString += *m_pCity;
		messageString += "\" to \"";
		messageString += m_City;
		messageString += "\".\n";
	}
	if (m_State != *m_pState){
		messageString += "You are about to change the state from \"";
		messageString += *m_pState;
		messageString += "\" to \"";
		messageString += m_State;
		messageString += "\".\n";
	}
	if (m_Zip != *m_pZip){
		messageString += "You are about to change the zip code from \"";
		messageString += *m_pZip;
		messageString += "\" to ";
		messageString += m_Zip;
		messageString += "\".\n";
	}
	if (m_Terr != *m_pTerr){
		messageString += "You are about to change the territory from \"";
		messageString += *m_pTerr;
		messageString += "\" to \"";
		messageString += m_Terr;
		messageString += "\".\n";
	}
	if (m_Company != *m_pCompany){
		messageString += "You are about to change the company from \"";
		messageString += *m_pCompany;
		messageString += "\" to \"";
		messageString += m_Company;
		messageString += "\".\n";
	}
	if (m_Amt != *m_pAmt){
		messageString += "You are about to change the amount from \"";
		messageString += *m_pAmt;
		messageString += "\" to \"";
		messageString += m_Amt;
		messageString += "\".";
	}

	if(messageString.IsEmpty())
		return;

	if(AfxMessageBox(messageString, MB_OKCANCEL) == IDCANCEL) {
		m_Lname = *m_pLname;
		m_Lname = *m_pFname;
		m_City = *m_pCity;
		m_State = *m_pState;
		m_Zip = *m_pZip;
		m_Terr = *m_pTerr;
		m_Company = *m_pCompany;
		m_Amt = *m_pAmt;
		UpdateData(false);
		return;
	}

	if (m_Lname != *m_pLname) {
		custLayer.SetKeyField("Lname");  //Change the keyfield of the cust layer to "Lname"
		custFtr.SetKeyValue(m_Lname);	//Place the newly changed value into the customer feature
	}
	if (m_Fname != *m_pFname) {
		custLayer.SetKeyField("Fname");
		custFtr.SetKeyValue(m_Fname);
	}
	if (m_City != *m_pCity) {
		custLayer.SetKeyField("City");
		custFtr.SetKeyValue(m_City);
	}
	if (m_State != *m_pState){
		custLayer.SetKeyField("State");
		custFtr.SetKeyValue(m_State);
	}
	if (m_Zip != *m_pZip){
		custLayer.SetKeyField("Zip");
		custFtr.SetKeyValue(m_Zip);
	}
	if (m_Terr != *m_pTerr){
		custLayer.SetKeyField("Terr");
		custFtr.SetKeyValue(m_Terr);
	}
	if (m_Company != *m_pCompany){
		custLayer.SetKeyField("Company");
		custFtr.SetKeyValue(m_Company);
	}
	if (m_Amt != *m_pAmt){
		custLayer.SetKeyField("Order_amt");
		custFtr.SetKeyValue(m_Amt);
	}
	custFtr.Update();
	CDialog::OnOK();
}

BOOL CCustDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
		
	ASSERT(m_pMap);

	try{
		CString layerName = m_pMap->GetLayers().Item(1).GetName();
	} catch (COleDispatchException *e) {
		e->ReportError();
		e->Delete();
	} catch (COleException *e) {
		e->ReportError();
		e->Delete();
	}

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}


void CCustDlg::EnableOK(bool Enable) {
	CWnd* OKButton = GetDlgItem(IDOK);
	OKButton->EnableWindow(Enable);
}

void CCustDlg::OnChangeFname() 
{
	EnableOK(true);
}

void CCustDlg::OnChangeLname() 
{
	EnableOK(true);
}

void CCustDlg::OnChangeCity() 
{
	EnableOK(true);
}

void CCustDlg::OnChangeState() 
{
	EnableOK(true);
}

void CCustDlg::OnChangeZip() 
{
	EnableOK(true);
}

void CCustDlg::OnChangeTerr() 
{
	EnableOK(true);
}

void CCustDlg::OnChangeCompany() 
{
	EnableOK(true);
}

void CCustDlg::OnChangeAmount() 
{
	EnableOK(true);
}

⌨️ 快捷键说明

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