企业合通管理系统以企业合同为主线

源代码在线查看: bak.cpp

软件大小: 187 K
上传用户: a1102882595
关键词: 管理系统 合同
下载地址: 免注册下载 普通下载 VIP

相关代码

				// BAK.cpp : implementation file
				//
				
				#include "stdafx.h"
				#include "htglxt.h"
				#include "BAK.h"
				#include "ExternDllHeader.h"
				#include "DMain.h"
				#ifdef _DEBUG
				#define new DEBUG_NEW
				#undef THIS_FILE
				static char THIS_FILE[] = __FILE__;
				#endif
				extern CHtglxtApp theApp;
				/////////////////////////////////////////////////////////////////////////////
				// CBAK dialog
				
				
				CBAK::CBAK(CWnd* pParent /*=NULL*/)
					: CDialog(CBAK::IDD, pParent)
				{
					//{{AFX_DATA_INIT(CBAK)
					//}}AFX_DATA_INIT
				}
				
				
				void CBAK::DoDataExchange(CDataExchange* pDX)
				{
					CDialog::DoDataExchange(pDX);
					//{{AFX_DATA_MAP(CBAK)
					DDX_Control(pDX, IDC_STATIP, m_StaTip);
					DDX_Control(pDX, IDC_STAFRAM, m_ButFram);
					DDX_Control(pDX, IDC_BUTTON2, m_Button);
					DDX_Control(pDX, IDC_STATIT, m_StaTit);
					DDX_Control(pDX, IDC_EDTPATH, m_EdtPach);
					//}}AFX_DATA_MAP
				}
				
				
				BEGIN_MESSAGE_MAP(CBAK, CDialog)
					//{{AFX_MSG_MAP(CBAK)
					ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
					ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
					//}}AFX_MSG_MAP
				END_MESSAGE_MAP()
				
				/////////////////////////////////////////////////////////////////////////////
				// CBAK message handlers
				
				void CBAK::OnButton2() 
				{
					CString sPach,sSQL,sName;
					m_EdtPach.GetWindowText(sPach);
					if(sPach.IsEmpty())
					{
						MessageBox("请输入备份文件的路径和名称!","系统提示",MB_OK|MB_ICONSTOP);
						m_EdtPach.SetFocus();
					}
					m_StaTit.ShowWindow(SW_SHOW);
					this->UpdateWindow();
					if(m_sCaption=="数据备份")
					{
						sSQL.Format("BACKUP DATABASE htglxt TO DISK='%s'",sPach);	
						if(rst.Open(sSQL,adCmdText)==false)
						{
							MessageBox("您输入路径不完整或文件夹不存在!请输入完整的路径及文件名!","系统提示",MB_OK|MB_ICONSTOP);
							return;
						}
					}
					else
					{	
						ado.Close();
						cnn=NULL;
						if(ado.SetConnection("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=master;Data Source=(local)")==false)	
							return;
						cnn=ado.GetConnection();
						sSQL.Format( "RESTORE DATABASE htglxt FROM DISK = '%s'",sPach);
						if(rst.Open(sSQL,adCmdText)==false)
							return;
						ado.Close();
						cnn=NULL;
						this->UpdateWindow();
						if(ado.SetConnection("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=htglxt;Data Source=(local)")==false)
						{
							this->m_StaTit.SetWindowText("恢复失败!请重新运行系统!");
							return ;
						}
						cnn=ado.GetConnection();
					}
					this->UpdateWindow();
					this->m_StaTit.ShowWindow(SW_HIDE);
					CString sMsg;
					if(m_sCaption=="数据备份")
					{
						sMsg.Format("%s成功!",m_sCaption.Right(4));
						MessageBox(sMsg,"系统提示",MB_OK|MB_ICONINFORMATION);			
					}
					else
					{
						sMsg.Format("%s成功!需要重新启动才可以生效!",m_sCaption.Right(4));
						MessageBox(sMsg,"系统提示",MB_OK|MB_ICONINFORMATION);			
						CDMain * Parent =(CDMain*)this->GetParent();
						this->OnCancel();
						try{
							Parent->Close();
							theApp.m_pMainWnd->DestroyWindow();
						}
						catch(...)
						{
						}
					}
				}
				BOOL CBAK::OnInitDialog() 
				{
					CDialog::OnInitDialog();
					this->SetWindowText(m_sCaption);
					CString tooltiptext;
					tooltiptext=m_sCaption.Right(4);
					this->m_ButFram.SetWindowText("数据"+tooltiptext);
					this->m_StaTip.SetWindowText(tooltiptext+"路径:");
					this->m_Button.SetWindowText("开始"+tooltiptext+"(&B)");
					this->m_StaTit.SetWindowText("正在"+tooltiptext+"数据,请稍后...");
				
					return TRUE;  // return TRUE unless you set the focus to a control
					              // EXCEPTION: OCX Property Pages should return FALSE
				}
				void CBAK::OnButton1() 
				{
					CString sPach,sDate;
					CTime ttime;
					ttime=ttime.GetCurrentTime();
					sDate=CTimeToCString(ttime);
					if(m_sCaption=="数据备份")
					{
						sPach=ShowPath();
					int b=sPach.GetLength();
					if(sPach.GetLength()						sPach=sPach+sDate+"BAK.DB";
					else
						sPach=sPach+"\\"+sDate+"BAK.DB";
					}
					else
					{
						char szFile[]="合同管理系统备份文件(*.db)|*.db||";
						CFileDialog dlg(true,"DB","",OFN_HIDEREADONLY,szFile,this);
						dlg.DoModal();
						sPach=dlg.GetPathName();
					}
					m_EdtPach.SetWindowText(sPach);
				}
				
							

相关资源