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

📄 makerestordatabase.cpp

📁 一个简易的医药销售管理系统源码
💻 CPP
字号:
// MakeRestorDatabase.cpp : 实现文件
//

#include "stdafx.h"
#include "MedicineSaleManages.h"
#include "MakeRestorDatabase.h"
#include ".\makerestordatabase.h"


// CMakeRestorDatabase 对话框

IMPLEMENT_DYNAMIC(CMakeRestorDatabase, CDialog)
CMakeRestorDatabase::CMakeRestorDatabase(CWnd* pParent /*=NULL*/)
	: CDialog(CMakeRestorDatabase::IDD, pParent)
	, make(FALSE)
{
}

CMakeRestorDatabase::~CMakeRestorDatabase()
{
}

void CMakeRestorDatabase::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_PROGRESS1, m_progress1);
}


BEGIN_MESSAGE_MAP(CMakeRestorDatabase, CDialog)
	ON_BN_CLICKED(IDOK, OnBnClickedOk)
	ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel)
	ON_BN_CLICKED(IDC_MAKEDATABASE, OnBnClickedMakedatabase)
	ON_BN_CLICKED(IDC_RESTORDATABASE, OnBnClickedRestordatabase)
END_MESSAGE_MAP()


// CMakeRestorDatabase 消息处理程序

void CMakeRestorDatabase::OnBnClickedOk()
{
}

void CMakeRestorDatabase::OnBnClickedCancel()
{
	// TODO: 在此添加控件通知处理程序代码
	OnCancel();
}

void CMakeRestorDatabase::OnBnClickedMakedatabase()
{
	CTreeFileView dlg;
	dlg.FileExName=_T(".mdb");
	if(dlg.DoModal()==IDOK && !(dlg.str_pathname.IsEmpty()) && dlg.str_pathname.Right(dlg.str_pathname.GetLength()-dlg.str_pathname.ReverseFind('\\')-1)==_T("MedicineSaleManages.mdb"))
	{
		m_progress1.SetRange(0,100);
		m_progress1.SetStep(50);
		char filepath[_MAX_PATH];
		::GetModuleFileName(NULL,filepath,_MAX_PATH);
		CString strpath;
		strpath.Format("%s",filepath);
		CString path;
		path=strpath.Left(strpath.ReverseFind('\\')+1);
		path+=dlg.str_pathname.Right(dlg.str_pathname.GetLength()-dlg.str_pathname.ReverseFind('\\')-1);
		m_progress1.StepIt();
		CopyFile(dlg.str_pathname,path,FALSE);
		if(theApp.makeaccessdatabase())
		{
			m_progress1.StepIt();
			AfxMessageBox("数据库连接成功!");
			make=TRUE;
			m_progress1.SetPos(0);
			CDialog::OnOK();
		}
		else
			AfxMessageBox("数据库连接失败!");
	}
	else
		AfxMessageBox("用户取消了选择或选择错误!");
}

void CMakeRestorDatabase::OnBnClickedRestordatabase()
{
	CTreeFileView dlg;
	dlg.FileExName=_T(".ztp");
	if(dlg.DoModal()==IDOK && !(dlg.str_pathname.IsEmpty()))
	{
		CFile file(dlg.str_pathname,CFile::modeRead);
		if(file.GetLength()*2>theApp.MyGetDiskFreeSpace(dlg.str_pathname.Left(3)))
		{
			AfxMessageBox("目标磁盘空间太小,不能完成还原!");
			file.Close();
			return;
		}
		else
			file.Close();
		CString message=_T("请在确认以下信息后单击[是]按钮开始还原数据!!!\r\n");
		message+="用如下文件恢复:\r\n";
		message+=dlg.str_pathname;
		if(AfxMessageBox(message,MB_YESNO|MB_ICONQUESTION)==IDYES)
		{
			theApp.BeginWaitCursor();
			m_progress1.SetRange(0,100);
			m_progress1.SetStep(25);
			char filepath[_MAX_PATH];
			::GetModuleFileName(NULL,filepath,_MAX_PATH);
			m_progress1.StepIt();
			CString strpath;
			strpath.Format("%s",filepath);
			CString path;
			path=strpath.Left(strpath.ReverseFind('\\')+1);
			path+=_T("MedicineSaleManages.mdb");
			LZARI Lzari;
			Lzari.UnCompress(dlg.str_pathname,dlg.str_pathname+_T("1"));
			m_progress1.StepIt();
			CopyFile(dlg.str_pathname+_T("1"),path,FALSE);
			m_progress1.StepIt();
			::remove(dlg.str_pathname+_T("1"));
			if(theApp.makeaccessdatabase())
			{
				m_progress1.StepIt();
				theApp.EndWaitCursor();
				make=TRUE;
				AfxMessageBox("数据恢复并连接成功!");
				m_progress1.SetPos(0);
				CDialog::OnOK();
			}
			else
				AfxMessageBox("数据恢复或连接失败!");
		}
	}
	else
		AfxMessageBox("用户取消了选择或还原!");
}

BOOL CMakeRestorDatabase::PreTranslateMessage(MSG* pMsg)
{
	m_tooltip.RelayEvent(pMsg);
	return CDialog::PreTranslateMessage(pMsg);
}

BOOL CMakeRestorDatabase::OnInitDialog()
{
	CDialog::OnInitDialog();
	m_tooltip.Create(this,TTS_ALWAYSTIP);
	m_tooltip.Activate(TRUE);
	m_tooltip.AddTool(GetDlgItem(IDC_MAKEDATABASE),IDS_MAKEDATABASE);
	m_tooltip.AddTool(GetDlgItem(IDC_PROGRESS1),IDS_PROGRESS1);
	m_tooltip.AddTool(GetDlgItem(IDC_RESTORDATABASE),IDS_RESTORDATABASE);
	return TRUE;
}

void CMakeRestorDatabase::WinHelp(DWORD dwData, UINT nCmd)
{
}

⌨️ 快捷键说明

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