📄 initdatadlg.cpp
字号:
// InitDataDlg.cpp : implementation file
//
#include "stdafx.h"
#include "BookManager.h"
#include "InitDataDlg.h"
#include "aLoginSet.h"
#include "GetbookSet.h"
#include "BookIMSet.h"
#include "StudentIMSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CInitDataDlg dialog
CInitDataDlg::CInitDataDlg(CWnd* pParent /*=NULL*/)
: CDialog(CInitDataDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CInitDataDlg)
m_admintable = FALSE;
m_bookintable = FALSE;
m_bookouttable = FALSE;
m_studenttable = FALSE;
//}}AFX_DATA_INIT
}
void CInitDataDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CInitDataDlg)
DDX_Control(pDX, IDC_admintable, m_ctr_admintable);
DDX_Check(pDX, IDC_admintable, m_admintable);
DDX_Check(pDX, IDC_bookintable, m_bookintable);
DDX_Check(pDX, IDC_bookouttable, m_bookouttable);
DDX_Check(pDX, IDC_studenttable, m_studenttable);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CInitDataDlg, CDialog)
//{{AFX_MSG_MAP(CInitDataDlg)
ON_BN_CLICKED(IDC_Initok, OnInitok)
ON_BN_CLICKED(IDC_Initcancel, OnInitcancel)
ON_BN_CLICKED(IDC_Initexit, OnInitexit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CInitDataDlg message handlers
void CInitDataDlg::OnInitok()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_admintable==FALSE&&m_bookintable==FALSE&&m_bookouttable==FALSE&&m_studenttable==FALSE)
{
MessageBox("请选择要初始化的表");
m_ctr_admintable.SetFocus();
return;
}
int k=MessageBox("确定要对选中的表进行初始化吗?","请选则操作",MB_OKCANCEL);
if(k==1)
{
if(m_admintable)
{
CString str1;
CaLoginSet recordset1;
str1="select * from adminIM";
if(!recordset1.Open(AFX_DB_USE_DEFAULT_TYPE,str1))
{
MessageBox("打开数据库失败!","数据库错误",MB_OK);
return;
}
while(!recordset1.IsEOF())
{
recordset1.Delete();
recordset1.MoveNext();
}
MessageBox("管理员信息表初始化成功!");
recordset1.Close();
m_admintable=FALSE;
UpdateData(FALSE);
}
if(m_bookintable)
{
CString str2;
CBookIMSet recordset2;
str2="select * from bookIM";
if(!recordset2.Open(AFX_DB_USE_DEFAULT_TYPE,str2))
{
MessageBox("打开数据库失败!","数据库错误",MB_OK);
return;
}
while(!recordset2.IsEOF())
{
recordset2.Delete();
recordset2.MoveNext();
}
MessageBox("教材入库信息表初始化成功!");
recordset2.Close();
m_bookintable=FALSE;
UpdateData(FALSE);
}
if(m_bookouttable)
{
CString str3;
CGetbookSet recordset3;
str3="select * from bookout";
if(!recordset3.Open(AFX_DB_USE_DEFAULT_TYPE,str3))
{
MessageBox("打开数据库失败!","数据库错误",MB_OK);
return;
}
while(!recordset3.IsEOF())
{
recordset3.Delete();
recordset3.MoveNext();
}
MessageBox("书记领取信息表初始化成功!");
recordset3.Close();
m_bookouttable=FALSE;
UpdateData(FALSE);
}
if(m_studenttable)
{
CString str4;
CStudentIMSet recordset4;
str4="select * from studentIM";
if(!recordset4.Open(AFX_DB_USE_DEFAULT_TYPE,str4))
{
MessageBox("打开数据库失败!","数据库错误",MB_OK);
return;
}
while(!recordset4.IsEOF())
{
recordset4.Delete();
recordset4.MoveNext();
}
MessageBox("学生信息表初始化成功!");
recordset4.Close();
m_studenttable=FALSE;
UpdateData(FALSE);
}
}
if(k==2)
{
m_admintable=FALSE;
m_bookintable=FALSE;
m_bookouttable=FALSE;
m_studenttable=FALSE;
m_ctr_admintable.SetFocus();
UpdateData(FALSE);
}
}
void CInitDataDlg::OnInitcancel()
{
// TODO: Add your control notification handler code here
m_admintable=FALSE;
m_bookintable=FALSE;
m_bookouttable=FALSE;
m_studenttable=FALSE;
m_ctr_admintable.SetFocus();
UpdateData(FALSE);
}
void CInitDataDlg::OnInitexit()
{
// TODO: Add your control notification handler code here
CDialog::OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -