📄 bookplace.cpp
字号:
// BookPlace.cpp : implementation file
//
#include "stdafx.h"
#include "Lib_Sys.h"
#include "BookPlace.h"
#include "PlaceSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBookPlace dialog
int m_total;
CBookPlace::CBookPlace(CWnd* pParent /*=NULL*/)
: CDialog(CBookPlace::IDD, pParent)
{
//{{AFX_DATA_INIT(CBookPlace)
m_Edit1 = _T("");
//}}AFX_DATA_INIT
}
void CBookPlace::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBookPlace)
DDX_Control(pDX, IDC_MSFLEXGRID1, m_msf);
DDX_Text(pDX, IDC_EDIT1, m_Edit1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBookPlace, CDialog)
//{{AFX_MSG_MAP(CBookPlace)
ON_BN_CLICKED(IDC_ADD, OnAdd)
ON_EN_SETFOCUS(IDC_EDIT1, OnSetfocusEdit1)
ON_BN_CLICKED(IDC_DEL, OnDel)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBookPlace message handlers
BOOL CBookPlace::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CPlaceSet m_Place;
CString str;
m_Place.Open();
m_total=0;
while(!m_Place.IsEOF())
{
m_Place.MoveNext();
m_Place.GetRecordCount();
}
m_total=m_Place.GetRecordCount()+1;
m_Place.MoveFirst();
m_msf.SetCols(2);
m_msf.SetRows(m_total);
m_msf.SetColWidth(0,720);
m_msf.SetRow(0);
m_msf.SetCol(1);
m_msf.SetText("图书位置");
m_msf.SetColWidth(1,1440);
int i=1;
while(!m_Place.IsEOF())
{
m_msf.SetRow(i);
m_msf.SetCol(0);
str.Format("位置 %d",i);
m_msf.SetText(str);
m_msf.SetCol(1);
m_msf.SetText(m_Place.m_BookPlace);
i++;
m_Place.MoveNext();
}
m_Place.Close();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BEGIN_EVENTSINK_MAP(CBookPlace, CDialog)
//{{AFX_EVENTSINK_MAP(CBookPlace)
ON_EVENT(CBookPlace, IDC_MSFLEXGRID1, 69 /* SelChange */, OnSelChangeMsflexgrid1, VTS_NONE)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
void CBookPlace::OnSelChangeMsflexgrid1()
{
// TODO: Add your control notification handler code here
GetDlgItem(IDC_ADD)->EnableWindow(false);
GetDlgItem(IDC_DEL)->EnableWindow(true);
m_Edit1=m_msf.GetText();
UpdateData(FALSE);
}
void CBookPlace::OnAdd()
{
// TODO: Add your control notification handler code here
UpdateData();
CString str;
CPlaceSet m_Place;
if(m_Edit1!="")
{
CPlaceSet m_Place;
m_Place.Open();
m_Place.AddNew();
m_Place.m_BookPlace=m_Edit1;
m_Place.Update();
m_Place.Requery();
m_Place.Close();
m_msf.SetRows(m_total+1);
m_msf.SetRow(m_total);
m_msf.SetCol(0);
str.Format("位置 %d",m_total);
m_msf.SetText(str);
m_msf.SetCol(1);
m_msf.SetText(m_Edit1);
m_total++;
MessageBox("已经成功增加!");
}
}
void CBookPlace::OnSetfocusEdit1()
{
// TODO: Add your control notification handler code here
GetDlgItem(IDC_ADD)->EnableWindow(true);
GetDlgItem(IDC_DEL)->EnableWindow(false);
m_Edit1="";
UpdateData(FALSE);
}
void CBookPlace::OnDel()
{
// TODO: Add your control notification handler code here
CPlaceSet m_Place;
// m_Place.m_strFilter="BookPlace='"+m_Edit1+"'";
m_Place.Open();
m_Place.MoveFirst();
while(m_Place.m_BookPlace!=m_Edit1)
m_Place.MoveNext();
// CRecordsetStatus status;
// m_Place.GetStatus(status);
m_Place.Delete();
m_Place.Close();
m_total--;
m_msf.SetCols(2);
m_msf.SetRows(1);
m_msf.SetRows(m_total);
m_msf.SetColWidth(0,720);
m_msf.SetRow(0);
m_msf.SetCol(1);
m_msf.SetText("图书位置");
m_msf.SetColWidth(1,1440);
int i=1;
CString str;
m_Place.Open();
m_Place.MoveFirst();
while(!m_Place.IsEOF())
{
m_Place.MoveNext();
m_Place.GetRecordCount();
}
m_total=m_Place.GetRecordCount()+1;
m_Place.MoveFirst();
while(!m_Place.IsEOF())
{
m_msf.SetRow(i);
m_msf.SetCol(0);
str.Format("位置 %d",i);
m_msf.SetText(str);
m_msf.SetCol(1);
m_msf.SetText(m_Place.m_BookPlace);
i++;
m_Place.MoveNext();
}
m_Place.Close();
MessageBox("已经成功删除!");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -