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

📄 st6.cpp

📁 自已做的简单的库存管理软件。包含员工信息管理等
💻 CPP
字号:
// st6.cpp : 定义应用程序的类行为。
//

#include "stdafx.h"
#include "st6.h"
#include "st6Dlg.h"
#include <string>
#include <cstring>
#include "MySqlConnect.h"
#include "Comcontrol.h"
#include "SerialControl.h"
#include "CMSComm.h"
#include "login.h"
#include "myhead.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

MySqlConnect sqlconnect;

CString str_username = _T("");
//CString str_class = _T("");
int iClass = 0;
CString str_database = _T("");
CString str_database_server = _T("");
// Cst6App

BEGIN_MESSAGE_MAP(Cst6App, CWinApp)
	ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()


// Cst6App 构造

Cst6App::Cst6App()
{
	// TODO: 在此处添加构造代码,
	// 将所有重要的初始化放置在 InitInstance 中
}


// 唯一的一个 Cst6App 对象

Cst6App theApp;


// Cst6App 初始化

BOOL Cst6App::InitInstance()
{
	// 如果一个运行在 Windows XP 上的应用程序清单指定要
	// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
	//则需要 InitCommonControlsEx()。否则,将无法创建窗口。
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// 将它设置为包括所有要在应用程序中使用的
	// 公共控件类。
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

     AfxOleInit();
	 

	CWinApp::InitInstance();

	AfxEnableControlContainer();

	// 标准初始化
	// 如果未使用这些功能并希望减小
	// 最终可执行文件的大小,则应移除下列
	// 不需要的特定初始化例程
	// 更改用于存储设置的注册表项
	// TODO: 应适当修改该字符串,
	// 例如修改为公司或组织名
	SetRegistryKey(_T("应用程序向导生成的本地应用程序"));


	

	CStdioFile f2;
	if( !f2.Open( STR_SET_FILE, CFile::modeRead ) ) 
	{
		
		Cst6Dlg dlg;
		m_pMainWnd = &dlg;
		INT_PTR nResponse = dlg.DoModal();
		if (nResponse == IDOK)
		{
			// TODO: 在此处放置处理何时用“确定”来关闭
			//  对话框的代码
		}
		else if (nResponse == IDCANCEL)
		{
			// TODO: 在此放置处理何时用“取消”来关闭
			//  对话框的代码
		}
		
		// 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序,
		//  而不是启动应用程序的消息泵。
	}
	else
	{
		CString str_db_server = _T("");
		CString str_db_name = _T("");
		CString str_db_user = _T("");
		CString str_db_password = _T("");

		CString   strLine = _T("");
		f2.ReadString(strLine);
		f2.Close();
		
		CString temp = _T(" ");
		int len = strLine.GetLength();
		CString str_tmp[16];
		for ( int i = 0; i < 16; i++ )
		{
			str_tmp[i] = _T("");
		}

		int j = 0;
		
		for ( int i = 0 ; i < len ; i ++ )
		{
			if ( strLine[i] != temp )
			{
				str_tmp[j] = str_tmp[j] + strLine[i];
			}
			else
			{
				j++;
			}
		}
		str_db_server = str_tmp[0];
		str_db_name = str_tmp[1];
		str_db_user = str_tmp[2];
		str_db_password = str_tmp[3];

		//MySqlConnect sqlconnect;
		
		if ( sqlconnect.InitSQLServer( str_db_server,str_db_name, str_db_user, str_db_password ) )
		{
			str_database = str_db_name;//record the DB name ,use for Backup/Restore
			str_database_server = str_db_server;

			CLogin login;
			m_pMainWnd = &login;
			INT_PTR nResponse = login.DoModal();
			if (nResponse == IDOK)
			{
				// TODO: 在此处放置处理何时用“确定”来关闭
				//  对话框的代码
			}
			else if (nResponse == IDCANCEL)
			{
				// TODO: 在此放置处理何时用“取消”来关闭
				//  对话框的代码
			}
		}
		else
		{
			AfxMessageBox(_T("配置文件出错!"));   
		}
			
	}
   

	return FALSE;
}


⌨️ 快捷键说明

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