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

📄 flydragon.cpp

📁 一个VC写的关于数据库操作的实用例子。可供学习
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// FlyDragon.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "FlyDragon.h"

#include "MainFrm.h"
#include "FlyDragonDoc.h"
#include "FlyDragonView.h"
#include "Splash.h"
#include "Odbc.h"
#include "Pick.h"

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

/////////////////////////////////////////////////////////////////////////////
// CFlyDragonApp

BEGIN_MESSAGE_MAP(CFlyDragonApp, CWinApp)
	//{{AFX_MSG_MAP(CFlyDragonApp)
	ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
		// 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
	// Standard file based document commands
	ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
	ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
	// Standard print setup command
	ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFlyDragonApp construction

CFlyDragonApp::CFlyDragonApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CFlyDragonApp object

CFlyDragonApp theApp;
COdbc gw_odbc;
_chan gw_schan[MAX_NUM];
CString gw_path;
int gw_num;
char * head;

/////////////////////////////////////////////////////////////////////////////
// CFlyDragonApp initialization

BOOL CFlyDragonApp::InitInstance()
{
	// CG: The following block was added by the Splash Screen component.
	HANDLE m_hMutex=CreateMutex(NULL,TRUE, m_pszAppName); 
	if(GetLastError()==ERROR_ALREADY_EXISTS) 
	{ 
		return FALSE; 
	}
\	{\		CCommandLineInfo cmdInfo;\		ParseCommandLine(cmdInfo);\\		CSplashWnd::EnableSplashScreen(cmdInfo.m_bShowSplash);\	}
	AfxEnableControlContainer();

	AfxInitRichEdit();
	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	// Change the registry key under which our settings are stored.
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization.
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));

	LoadStdProfileSettings();  // Load standard INI file options (including MRU)

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.

	CSingleDocTemplate* pDocTemplate;
	pDocTemplate = new CSingleDocTemplate(
		IDR_MAINFRAME,
		RUNTIME_CLASS(CFlyDragonDoc),
		RUNTIME_CLASS(CMainFrame),       // main SDI frame window
		RUNTIME_CLASS(CFlyDragonView));
	AddDocTemplate(pDocTemplate);

	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	// Dispatch commands specified on the command line
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;

	// The one and only window has been initialized, so show and update it.
	m_pMainWnd->ShowWindow(SW_MAXIMIZE);
	m_pMainWnd->UpdateWindow();

	return TRUE;
}


/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
		// No message handlers
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

// App command to run the dialog
void CFlyDragonApp::OnAppAbout()
{
	CAboutDlg aboutDlg;
	aboutDlg.DoModal();
}

/////////////////////////////////////////////////////////////////////////////
// CFlyDragonApp message handlers


BOOL CFlyDragonApp::PreTranslateMessage(MSG* pMsg)
{
	// CG: The following lines were added by the Splash Screen component.	if (CSplashWnd::PreTranslateAppMessage(pMsg))		return TRUE;	return CWinApp::PreTranslateMessage(pMsg);
}
//数据提取线程
UINT PickData(LPVOID param)
{
	CString sql,uu;
	CString ing;
	CString str,add;
	int index=0,still=0,m_count=0,chError = 0 ,nPrePos=0;
	
	char buffer[200];
	char buf[20];
	CString VClass;
	CString helo;
	CString VNo,City,VColor,YLFee,FJFee,YGFee,YLFDate,FJFDate,YGDate,VTYPE,VMaster,Weight,Seat,RDate,VNote;
	CString YZDW,DWXZ,CLZL,ZFBL,SFYY,CFT,YU;
	CString Iyear;
	CString temp;
	CString tep;
	CString piaohao;
	CString VC;
	int l_yy = 0;
	int p_yy = 0;
	double fee = 0;
	CTime time;
	char	chValue[20];
	int date = 0;
	int bl;
	
	CRecordset rr;
	
	int remain;
	int l_Date;
	CPick * pPick = (CPick*)param;

	//计算总记录数
	while(!pPick->rs.IsEOF())
	{
		m_count++;
		pPick->rs.MoveNext();
	}
	//设定进度条
	pPick->m_progre1.SetPos(0);
	pPick->m_progre1.SetRange32(0,m_count);
	pPick->m_progre1.SetStep(1);
	::SetDlgItemInt(pPick->m_hWnd,IDC_NUM,m_count,TRUE);
	
	pPick->rs.MoveFirst();

	time = CTime::GetCurrentTime();
	still = 0;
	RDate = time.Format("%m-%d-%Y");
	helo = "CTOD(\'" + RDate + "\')";
	//循环取得结果
	while(!pPick->rs.IsEOF() && pPick->m_bConnect)
	{
		VNo.Empty();
		ing = "车牌号码";
		pPick->GetName(&ing,&str,&index);
		pPick->rs.GetFieldValue(gw_schan[index].field,VNo);
		
		VColor.Empty();
		ing = "车牌颜色";
		VColor.Empty();
		if(pPick->GetName(&ing,&str,&index)== -1)
			pPick->rs.GetFieldValue(gw_schan[index].field,VColor);
		else
		{
			pPick->SQL(index,&uu);
			pPick->tiaojian(index,&str,&VNo,&VColor);
			uu += str;
			pPick->rc.Open(AFX_DB_USE_DEFAULT_TYPE,uu,0);
			pPick->rc.GetFieldValue(gw_schan[index].field,VColor);
			pPick->rc.Close();
		}
		if (VColor.IsEmpty()) VColor = " ";
	
		l_Date = GetPrivateProfileInt( "System", "DateTime", 12, gw_path );
		if(l_Date != 0)
		{
			VTYPE.Empty();
			ing = "车辆名称";
			pPick->GetValue(&ing,&VNo,&VColor,&VTYPE);
		
			ZFBL.Empty();
			ing = "征费比例";
			pPick->GetValue(&ing,&VNo,&VColor,&ZFBL);

			DWXZ.Empty();
			ing = "车主单位性质";
			pPick->GetValue(&ing,&VNo,&VColor,&DWXZ);
		}

		int nCount, ii;
		
		CString chLeft,chRight,chMid;
		CString strPreKey, strValue;
		
		memset( chValue, 0, sizeof(chValue) );
		GetPrivateProfileString( "System", "City", "A", chValue, sizeof(chValue), gw_path );
		City.Format ( "%s", chValue );
			
		memset(buf,0,20);
		YLFDate.Empty();
		piaohao.Empty();
		date = 0;
		ing = "养路费缴讫日期";//推算得出
		
		pPick->GetValue(&ing,&VNo,&VColor,&YLFDate);
		{
			CTime ct = CTime::GetCurrentTime ();

			int pos = YLFDate.Find("^");
			piaohao = YLFDate.Right(YLFDate.GetLength() - pos - 1 );
			piaohao = piaohao.Right(5);
			YLFDate = YLFDate.Left( pos );
			date = atoi(YLFDate);

			p_yy = ct.GetYear();
			Iyear.Empty();
			ing = "交费年份";
			pPick->GetValue(&ing,&VNo,&VColor,&Iyear);
			l_yy = atoi(Iyear);
			if(p_yy != l_yy)
			{
				if(date > 12)
					temp.Format("%d-%d-%d", date-12, 1, ct.GetYear()-1);
				else 
				{
					if(date != 0 )
					   temp.Format("%d-%d-%d", date, 1, ct.GetYear()-2);
					else 
						temp.Format("%d-%d-%d", 12, 1, ct.GetYear()-3);
				}
			}
			else
			{	
				if(l_Date != 0)
				{
					
				if(date == 0)					//No Charge at all
				{
					if(ZFBL.CompareNoCase("0") == 0 ) 	//the same month of last year
						temp = RDate;
					else
						temp.Format("%d-%d-%d", ct.GetMonth(), 1, ct.GetYear()-2);
				} else	if(date>12)						//Owe
					temp.Format( "%d-%d-%d",date-12,1,ct.GetYear());
				else 
					temp.Format( "%d-%d-%d",date,1,ct.GetYear() - 1);
				}
			}
			YLFDate = "CTOD(\'" + temp + "\')";
	}

		
		//附加费缴讫日期
		FJFDate.Empty();
		FJFDate = "CTOD(\'" + RDate +  "\')";
		if(City == "R")
		{
			ing = "附加费缴讫日期";
			pPick->GetValue(&ing,&VNo,&VColor,&FJFDate);
			{
				CTime ct = CTime::GetCurrentTime ();
				int pos = FJFDate.Find("^");

				FJFDate = FJFDate.Left( pos );
				date = atoi(FJFDate);
				if(p_yy != l_yy )
				{
					if(date > 12)
						temp.Format("%d-%d-%d", date-12, 1, ct.GetYear()-1);
					else 
					{
						if(date != 0 )
						   temp.Format("%d-%d-%d", date, 1, ct.GetYear()-2);
						else 
							temp.Format("%d-%d-%d", 12, 1, ct.GetYear()-3);
					}

				}
				else
				{
					if(date == 0)					//No Charge at all
					{
						if(ZFBL.CompareNoCase("0") == 0 ) 	//the same month of last year
							temp = RDate;
						else
							temp.Format("%d-%d-%d", ct.GetMonth(), 1, ct.GetYear()-2);
					} else	if(date>12)						//Owe
						temp.Format( "%d-%d-%d",date-12,1,ct.GetYear());

⌨️ 快捷键说明

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