📄 bookmanage.cpp
字号:
// BookManage.cpp : implementation file
//
#include "stdafx.h"
#include "libraryMS.h"
#include "BookManage.h"
#include "column.h"
#include "columns.h"
////////////////////////////////////////////
#include "datagrid.h"
#include "adodc.h"
#include "ADOConn.h"
#include "LogLibrary.h"
#include "Book.h"
#include "BookAdd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBookManage dialog
CBookManage::CBookManage(CWnd* pParent /*=NULL*/)
: CDialog(CBookManage::IDD, pParent)
{
//{{AFX_DATA_INIT(CBookManage)
m_QBook = _T("");
//}}AFX_DATA_INIT
}
void CBookManage::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBookManage)
DDX_Control(pDX, IDC_Condition, m_condition);
DDX_Control(pDX, IDC_DATAGRID, m_datagrid);
DDX_Control(pDX, IDC_ADODC, m_adodc);
DDX_Text(pDX, IDC_Book_EDIT, m_QBook);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBookManage, CDialog)
//{{AFX_MSG_MAP(CBookManage)
ON_BN_CLICKED(IDExit, OnExit)
ON_BN_CLICKED(IDDelete, OnDelete)
ON_BN_CLICKED(IDAdd, OnAdd)
ON_BN_CLICKED(IDChange, OnChange)
ON_BN_CLICKED(IDC_Query, OnQuery)
ON_BN_CLICKED(IDC_QueryAll, OnQueryAll)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBookManage message handlers
void CBookManage::OnExit()
{
// TODO: Add your control notification handler code here
OnOK();
}
void CBookManage::OnDelete()
{
// TODO: Add your control notification handler code here
CBook vBook;
vBook.SetTitleBook(m_datagrid.GetItem(0));
vBook.SetISBNBook(m_datagrid.GetItem(1));
vBook.SetAuthorBook(m_datagrid.GetItem(2));
CString str;
str="书名:"+vBook.GetTitleBook()+"\n"+"作者: "+vBook.GetAuthorBook()+"\n"+"ISBN: "+vBook.GetISBNBook()+"\n";
int nChoice = MessageBox(str,"确定要删除吗",MB_OKCANCEL|MB_ICONQUESTION);
if(nChoice == IDOK)
{
CLogLibrary Log_dlg;
Log_dlg.DoModal();
vBook.SetLogBook(Log_dlg.m_logMS);
MessageBox("删除进行");
vBook.sql_delete(vBook.GetISBNBook());
}
m_adodc.Refresh();
}
void CBookManage::OnAdd()
{
// TODO: Add your control notification handler code here
CBookAdd BookAdd_dlg;
BookAdd_dlg.ISBNFlg =0;
BookAdd_dlg.DoModal();
m_adodc.Refresh();
}
void CBookManage::OnChange()
{
//TODO: Add your control notification handler code here
CBookAdd BookAdd_dlg;
BookAdd_dlg.ISBNFlg = 1;
//if(m_datagrid.GetItem(1).IsEmpty())
//{
// MessageBox("请选择记录");
// return;
//}
// else
//{
BookAdd_dlg.vTitle=m_datagrid.GetItem(0);
BookAdd_dlg.vISBN= m_datagrid.GetItem(1);
BookAdd_dlg.vAuhor= m_datagrid.GetItem(2);
BookAdd_dlg.vPressName= m_datagrid.GetItem(3);
BookAdd_dlg.vCount= m_datagrid.GetItem(4);
BookAdd_dlg.vTypeBook =m_datagrid.GetItem(5);
BookAdd_dlg.vComment= m_datagrid.GetItem(6);
BookAdd_dlg.DoModal();
m_adodc.Refresh();
//}
}
BOOL CBookManage::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_condition.SetCurSel(0);
UpdateData(false);
/////////////////////////////////////////////////////////调节列表宽度
variant_t vIndex;
vIndex = long(0);
m_datagrid.GetColumns().GetItem(vIndex).SetWidth(200);
vIndex = long(1);
m_datagrid.GetColumns().GetItem(vIndex).SetWidth(80);
vIndex = long(2);
m_datagrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(3);
m_datagrid.GetColumns().GetItem(vIndex).SetWidth(82);
vIndex = long(4);
m_datagrid.GetColumns().GetItem(vIndex).SetWidth(40);
vIndex = long(5);
m_datagrid.GetColumns().GetItem(vIndex).SetWidth(30);
vIndex = long(6);
m_datagrid.GetColumns().GetItem(vIndex).SetWidth(40);
//////////////////////////////////////////////////////////////
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CBookManage::OnQuery()
{
// TODO: Add your control notification handler code here
UpdateData(true);
CString vAuthor;
m_QBook.TrimRight();
vAuthor = m_QBook+'%';
m_adodc.SetRecordSource("select Title as 书名, ISBN, Author as 作者, PressName as 出版社, TOT as 藏书量, TypeCode as 代码,Comment as 备注 from t_Book where Author = '"+vAuthor+"'");
m_adodc.Refresh();
}
void CBookManage::OnQueryAll()
{
// TODO: Add your control notification handler code here
UpdateData(true);
m_adodc.SetRecordSource("select Title as 书名, ISBN, Author as 作者, PressName as 出版社, TOT as 藏书量, TypeCode as 代码,Comment as 备注 from t_Book");
m_adodc.Refresh();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -