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

📄 enroll.cpp

📁 《医学图象的远程传输系统》
💻 CPP
字号:
// Enroll.cpp : Defines the initialization routines for the DLL.
//

#include "stdafx.h"
#include "Enroll.h"

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

#include "EnrollInterface.h"
#include "PatientRecord.h"
#include "ImageRecord.h"
#include "PatientDlg.h"
#include "BrowseDlg.h"

//
//	Note!
//
//		If this DLL is dynamically linked against the MFC
//		DLLs, any functions exported from this DLL which
//		call into MFC must have the AFX_MANAGE_STATE macro
//		added at the very beginning of the function.
//
//		For example:
//
//		extern "C" BOOL PASCAL EXPORT ExportedFunction()
//		{
//			AFX_MANAGE_STATE(AfxGetStaticModuleState());
//			// normal function body here
//		}
//
//		It is very important that this macro appear in each
//		function, prior to any calls into MFC.  This means that
//		it must appear as the first statement within the 
//		function, even before any object variable declarations
//		as their constructors may generate calls into the MFC
//		DLL.
//
//		Please see MFC Technical Notes 33 and 58 for additional
//		details.
//

/////////////////////////////////////////////////////////////////////////////
// CEnrollApp

BEGIN_MESSAGE_MAP(CEnrollApp, CWinApp)
	//{{AFX_MSG_MAP(CEnrollApp)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEnrollApp construction

CEnrollApp::CEnrollApp()
{
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CEnrollApp object

CEnrollApp theApp;

int ENAddPatient()
{
#ifdef _DEBUG
	AfxMessageBox("This operator can not work in DEBUG mode!",MB_ICONWARNING);
	return -1;
#endif

	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	int NewId=0;
	CPatientDlg dlg(AfxGetApp()->m_pMainWnd);
	if (dlg.DoModal()==IDOK){
		CPatientRecord PRecord;
		PRecord.m_strSort="ID";
		PRecord.Open();
		if (!PRecord.IsEOF()){
			PRecord.MoveLast();
			NewId=PRecord.m_nID+1;
		}
		PRecord.AddNew();
		PRecord.m_nID=NewId;
		PRecord.m_sName=dlg.m_sName;
		PRecord.m_bGender=TRUE;
		PRecord.m_sAddress=dlg.m_sAddress;
		PRecord.m_sPhone=dlg.m_sPhone;
		PRecord.m_sDisease=dlg.m_sDisease;
		PRecord.m_tInTime=CTime::GetCurrentTime();
		PRecord.m_tOutTime=CTime::GetCurrentTime();
		PRecord.m_sMemo=dlg.m_sMemo;
		PRecord.Update();
		PRecord.Close();
		return NewId;
	}
	return -1;
}

int ENAddImage(const int ID,BYTE* ImgBuffer,const DWORD ImgSize)
{
#ifdef _DEBUG
	AfxMessageBox("This operator can not work in DEBUG mode!",MB_ICONWARNING);
	return -1;
#endif

	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	int NewIdx=0;
	CImageRecord IRecord;
	IRecord.m_strFilter.Format("ID=%d",ID);
	IRecord.m_strSort="Idx";
	IRecord.Open();
	if (!IRecord.IsEOF()){
		IRecord.MoveLast();
		NewIdx=IRecord.m_Idx+1;
	}
	IRecord.AddNew();
	IRecord.m_ID=ID;
	IRecord.m_Idx=NewIdx;
	IRecord.SetFieldNull(&IRecord.m_Image,FALSE); 
	//*************************
	//!!
	BYTE* BuffTmp=(BYTE*)::GlobalAlloc(GMEM_FIXED,ImgSize);
	if (!BuffTmp){
		IRecord.Close();
		return -1;
	}
	::CopyMemory(BuffTmp,ImgBuffer,ImgSize);
	IRecord.m_Image.m_hData=BuffTmp;
	//!!
	//*************************
	//IRecord.m_Image.m_hData=ImgBuffer;
	IRecord.SetFieldDirty(&IRecord.m_Image,TRUE);//refresh the image
	IRecord.m_Image.m_dwDataLength=ImgSize;
	IRecord.Update();
	IRecord.Close();
	//!!
	::GlobalFree(BuffTmp);
	return NewIdx;
}

void ENBrowse(){
#ifdef _DEBUG
	AfxMessageBox("This operator can not work in DEBUG mode!",MB_ICONWARNING);
	return;
#endif

	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	CBrowseDlg dlg;
	dlg.DoModal();
}

⌨️ 快捷键说明

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