📄 forthview.cpp
字号:
// ForthView.cpp : implementation of the CForthView class
//
#include "stdafx.h"
#include "Forth.h"
#include "ForthDoc.h"
#include "ForthView.h"
#include "AdministratorSet.h"
#include "BookSet.h"
#include "BorrowSet.h"
#include "PowerSet.h"
#include "PunishSet.h"
#include "ReaderSet.h"
#include "LoginDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CForthView
IMPLEMENT_DYNCREATE(CForthView, CListView)
BEGIN_MESSAGE_MAP(CForthView, CListView)
//{{AFX_MSG_MAP(CForthView)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CListView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CListView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CListView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CForthView construction/destruction
CForthView::CForthView()
{
// TODO: add construction code here
}
CForthView::~CForthView()
{
}
BOOL CForthView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.style&=~LVS_TYPEMASK;
cs.style|=LVS_REPORT;
return CListView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CForthView drawing
void CForthView::OnDraw(CDC* pDC)
{
CForthDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
void CForthView::OnInitialUpdate()
{
CListView::OnInitialUpdate();
// TODO: You may populate your ListView with items by directly accessing
// its list control through a call to GetListCtrl().
}
/////////////////////////////////////////////////////////////////////////////
// CForthView printing
BOOL CForthView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CForthView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CForthView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CForthView diagnostics
#ifdef _DEBUG
void CForthView::AssertValid() const
{
CListView::AssertValid();
}
void CForthView::Dump(CDumpContext& dc) const
{
CListView::Dump(dc);
}
CForthDoc* CForthView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CForthDoc)));
return (CForthDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CForthView message handlers
void CForthView::SeeBook(CString cs)
{
CListCtrl&m_ListCtrl=GetListCtrl();
m_ListCtrl.DeleteAllItems();
CBookSet book;
book.Open();
CODBCFieldInfo field;
for(int i=0;i<book.m_nFields;i++)
{
book.GetODBCFieldInfo(i,field);
m_ListCtrl.InsertColumn(i,field.m_strName,LVCFMT_LEFT,100);
}
int item=0;
CString str;
char chr='%';
book.Close();
book.m_strFilter.Format("BookId like '%c%s%c'",chr,cs,chr);
book.Open();
while(!book.IsEOF())
{
m_ListCtrl.InsertItem(item,str);
m_ListCtrl.SetItemText(item,0,book.m_BookId);
m_ListCtrl.SetItemText(item,1,book.m_BookName);
m_ListCtrl.SetItemText(item,2, book.m_Author);
m_ListCtrl.SetItemText(item,3,book.m_Press);
str.Format("%d",book.m_Price);
m_ListCtrl.SetItemText(item,4,str);
str.Format("%d",book.m_TotalAmount);
m_ListCtrl.SetItemText(item,5,str);
str.Format("%d",book.m_NowAmount);
m_ListCtrl.SetItemText(item,6, str);
item++;
book.MoveNext();
}
book.Close();
}
void CForthView::AddBook(CString author, CString bookId, CString BookName, int nowAmount, CString press, int totalAmount)
{
CBookSet book;
book.Open();
book.AddNew();
book.m_Author=author;
book.m_BookId=bookId;
book.m_BookName=BookName;
book.m_NowAmount=nowAmount;
book.m_Press=press;
book.m_TotalAmount=totalAmount;
if(book.CanUpdate())
book.Update();
if(book.IsOpen())
book.Close();
}
void CForthView::SeePunish(CString cs)
{
CListCtrl&m_ListCtrl=GetListCtrl();
m_ListCtrl.DeleteAllItems();
CPunishSet punish;
punish.Open();
CODBCFieldInfo field;
for(int i=0;i<punish.m_nFields;i++)
{
punish.GetODBCFieldInfo(i,field);
m_ListCtrl.InsertColumn(i,field.m_strName,LVCFMT_LEFT,100);
}
int item=0;
CString str;
char chr='%';
punish.Close();
punish.m_strFilter.Format("PunishId like '%c%s%c'",chr,cs,chr);
punish.Open();
while(!punish.IsEOF())
{
//course.m_cname ="abc";
//course.GetFieldValue(i,str);
//course.Delete();
str.Format("%d",punish.m_PunishMoney);
m_ListCtrl.InsertItem(item,str);
m_ListCtrl.SetItemText(item,0,punish.m_PunishId);
m_ListCtrl.SetItemText(item,1,str);
m_ListCtrl.SetItemText(item,2, punish.m_ReaderId);
m_ListCtrl.SetItemText(item,3, punish.m_BookId);
item++;
punish.MoveNext();
}
punish.Close();
}
void CForthView::SeeReader(CString cs)
{
CListCtrl&m_ListCtrl=GetListCtrl();
m_ListCtrl.DeleteAllItems();
CReaderSet reader;
reader.Open();
CODBCFieldInfo field;
for(int i=0;i<reader.m_nFields;i++)
{
reader.GetODBCFieldInfo(i,field);
m_ListCtrl.InsertColumn(i,field.m_strName,LVCFMT_LEFT,100);
}
int item=0;
CString str;
char chr='%';
reader.Close();
reader.m_strFilter.Format("ReadId like '%c%s%c'",chr,cs,chr);
reader.Open();
while(!reader.IsEOF())
{
//course.m_cname ="abc";
//course.GetFieldValue(i,str);
//course.Delete();
str.Format("%d",reader.m_NowBorrowNumber);
m_ListCtrl.InsertItem(item,str);
m_ListCtrl.SetItemText(item,0,reader.m_ReadId);
m_ListCtrl.SetItemText(item,1,reader.m_ReaderName );
m_ListCtrl.SetItemText(item,2, reader.m_Sex);
m_ListCtrl.SetItemText(item,3,reader.m_Address);
m_ListCtrl.SetItemText(item,4,reader.m_IdNumber );
m_ListCtrl.SetItemText(item,5,reader.m_TelNumber);
m_ListCtrl.SetItemText(item,6, str);
m_ListCtrl.SetItemText(item,7,reader.m_type );
item++;
reader.MoveNext();
}
reader.Close();
}
void CForthView::SeeBorrow(CString cs)
{
CListCtrl&m_ListCtrl=GetListCtrl();
m_ListCtrl.DeleteAllItems();
CBorrowSet borrow;
borrow.Open();
CODBCFieldInfo field;
for(int i=0;i<borrow.m_nFields;i++)
{
borrow.GetODBCFieldInfo(i,field);
m_ListCtrl.InsertColumn(i,field.m_strName,LVCFMT_LEFT,100);
}
int item=0;
CString str;
char chr='%';
borrow.Close();
borrow.m_strFilter.Format("BorrowId like '%c%s%c'",chr,cs,chr);
borrow.Open();
while(!borrow.IsEOF())
{
m_ListCtrl.InsertItem(item,str);
m_ListCtrl.SetItemText(item,0,borrow.m_BorrowId);
m_ListCtrl.SetItemText(item,1,borrow.m_ReaderId);
m_ListCtrl.SetItemText(item,2, borrow.m_BookId);
item++;
borrow.MoveNext();
}
borrow.Close();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -