📄 managesystemview.cpp
字号:
// ManageSystemView.cpp : implementation of the CManageSystemView class
//
#include "stdafx.h"
#include "ManageSystem.h"
#include "ManageSystemDoc.h"
#include "ManageSystemView.h"
#include "ProductSet.h"
#include "MemberSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define MEMSIMPLE 0
#define MEMDETAIL 1
#define PDTSIMPLE 2
#define PDTDETAIL 3
#define DELETEMEM 0
#define DELETEPDT 1
#define MODIFYMEM 0
#define MODIFYPDT 1
#define UPDATEPDT 0
#define UPDATEMEM 1
#define RESULT_SHOW 0
#define RESULT_HIDE 1
#define RECODE_FIRST 1
#define RECODE_PREVE 2
#define RECODE_NEXT 3
#define RECODE_LAST 4
#define SHOW_MEM 1
#define SHOW_PDT 2
#define LOGON_SHOW 0
#define LOGON_HIDE 1
/////////////////////
#define MEM_DETAIL 1
#define PDT_DETAIL 2
#define MEM_SIMPLE 3
#define PDT_SIMPLE 4
/////////////////////////////////////////////////////////////////////////////
// CManageSystemView
extern CProductSet* g_pSet;
extern bool g_isPLocked;
extern PRODUCTCLASS* g_ProductClass;
extern CMemberSet* g_mSet;
extern bool g_isMlocked;
IMPLEMENT_DYNCREATE(CManageSystemView, CFormView)
BEGIN_MESSAGE_MAP(CManageSystemView, CFormView)
//{{AFX_MSG_MAP(CManageSystemView)
ON_WM_SIZE()
//}}AFX_MSG_MAP
ON_MESSAGE(WM_SHOW_PRO_RESULT_SIMP,ShowPResultSimple)
ON_MESSAGE(WM_SHOW_MEM_RESULT_SIMP,ShowMResultSimple)
ON_MESSAGE(WM_SHOW_PRO_RESULT_DETAIL,ShowPResultDetail)
ON_MESSAGE(WM_SHOW_MEM_RESULT_DETAIL,ShowMResultDetail)
ON_MESSAGE(WM_CHANGEDIALOG,ChangeDialog)
ON_MESSAGE(WM_DELETESET,DeleteSet)
ON_MESSAGE(WM_MODIFYSET,ModifySet)
ON_MESSAGE(WM_DELETEFROMDETAIL,DeleteFromDetail)
ON_MESSAGE(WM_MODIFIRECORDE,ModifyRecord)
ON_MESSAGE(WM_RECORDE_MOVE,RecordeMove)
ON_MESSAGE(WM_LOGON,OnLogon)
ON_MESSAGE(WM_RECORD_ADD,RecordAdd)
ON_MESSAGE(WM_RECORD_MODIFY,RecordModify)
ON_MESSAGE(WM_RECORD_DELETE,RecordDelete)
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CManageSystemView construction/destruction
CManageSystemView::CManageSystemView()
: CFormView(CManageSystemView::IDD)
{
//{{AFX_DATA_INIT(CManageSystemView)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// TODO: add construction code here
}
CManageSystemView::~CManageSystemView()
{
}
void CManageSystemView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CManageSystemView)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BOOL CManageSystemView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CFormView::PreCreateWindow(cs);
}
void CManageSystemView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
m_RstSimp_Dlg.Create(IDD_RESULT_SIMPLE,this);
m_RstSimp_Dlg.ShowWindow(SW_SHOW);
m_PdtDetail_Dlg.Create(IDD_P_RESULT_DETAIL,this);
m_RstSimp_Dlg.ShowWindow(SW_HIDE);
m_MemDetail_Dlg.Create(IDD_M_RESULT_DETAIL,this);
m_MemDetail_Dlg.ShowWindow(SW_HIDE);
AutoSizeDlg();
}
/////////////////////////////////////////////////////////////////////////////
// CManageSystemView printing
BOOL CManageSystemView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CManageSystemView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CManageSystemView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
void CManageSystemView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
// TODO: add customized printing code here
}
/////////////////////////////////////////////////////////////////////////////
// CManageSystemView diagnostics
#ifdef _DEBUG
void CManageSystemView::AssertValid() const
{
CFormView::AssertValid();
}
void CManageSystemView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CManageSystemDoc* CManageSystemView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CManageSystemDoc)));
return (CManageSystemDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CManageSystemView message handlers
void CManageSystemView::OnSize(UINT nType, int cx, int cy)
{
CFormView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
AutoSizeDlg();
}
void CManageSystemView::ShowPResultSimple(WPARAM wParam ,LPARAM lParam)
{
if(lParam==RESULT_SHOW)
{
m_RstSimp_Dlg.ShowWindow(SW_SHOW);
m_PdtDetail_Dlg.ShowWindow(SW_HIDE);
m_MemDetail_Dlg.ShowWindow(SW_HIDE);
}
m_RstSimp_Dlg.m_List_Result_Simp.DeleteAllItems();
m_RstSimp_Dlg.AddProductColomn();
LVITEM lvi;
CString strItem;
m_iSetNum=0;
PRODUCTCLASS* temp;
while(!g_pSet->IsEOF())
{
// Insert the first item ,Set subitem 0---产品名称
lvi.mask = LVIF_TEXT;
strItem=g_pSet->m_prodt_name;
strItem.TrimRight();
lvi.iItem =m_iSetNum;
lvi.iSubItem = 0;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
m_RstSimp_Dlg.m_List_Result_Simp.InsertItem(&lvi);
//设置
m_RstSimp_Dlg.m_List_Result_Simp.SetItemData(m_iSetNum,m_iSetNum);
// Set subitem 1---产品类别
temp=g_ProductClass->next;
while(g_pSet->m_class_id!=temp->classid)
temp=temp->next;
strItem=temp->classname;
strItem.TrimRight();
lvi.iSubItem =1;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
m_RstSimp_Dlg.m_List_Result_Simp.SetItem(&lvi);
// Set subitem 2---供货地
strItem=g_pSet->m_provide_area;
strItem.TrimRight();
lvi.iSubItem =2;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
m_RstSimp_Dlg.m_List_Result_Simp.SetItem(&lvi);
// Set subitem 3---单价
strItem=g_pSet->m_unit_price;
strItem.TrimRight();
lvi.iSubItem =3;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
m_RstSimp_Dlg.m_List_Result_Simp.SetItem(&lvi);
// Set subitem 4---公司名
strItem=g_pSet->m_company_name;
strItem.TrimRight();
lvi.iSubItem =4;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
m_RstSimp_Dlg.m_List_Result_Simp.SetItem(&lvi);
// Set subitem 5---公司地址
strItem=g_pSet->m_company_addr;
strItem.TrimRight();
lvi.iSubItem =5;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
m_RstSimp_Dlg.m_List_Result_Simp.SetItem(&lvi);
// Set subitem 6---联系人
strItem=g_pSet->m_linkman;
strItem.TrimRight();
lvi.iSubItem =6;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
m_RstSimp_Dlg.m_List_Result_Simp.SetItem(&lvi);
// Set subitem 7---联系电话
strItem=g_pSet->m_comp_telephone;
strItem.TrimRight();
lvi.iSubItem =7;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
m_RstSimp_Dlg.m_List_Result_Simp.SetItem(&lvi);
g_pSet->MoveNext();
m_iSetNum++;
}
CString cTotal;
cTotal.Format("总共搜索到 %d 条记录",m_iSetNum);
m_RstSimp_Dlg.m_Tatal=cTotal;
g_isPLocked=false;
m_RstSimp_Dlg.UpdateData(false);
}
void CManageSystemView::ShowMResultSimple(WPARAM wParam ,LPARAM lParam)
{
if(lParam==RESULT_SHOW)
{
m_RstSimp_Dlg.ShowWindow(SW_SHOW);
m_PdtDetail_Dlg.ShowWindow(SW_HIDE);
m_MemDetail_Dlg.ShowWindow(SW_HIDE);
}
m_RstSimp_Dlg.m_List_Result_Simp.DeleteAllItems();
m_RstSimp_Dlg.AddMemberColomn();
LVITEM lvi;
CString strItem;
m_iSetNum=0;
while(!g_mSet->IsEOF())
{
// Insert the first item ,Set subitem 0---会员账号
lvi.mask = LVIF_TEXT;
strItem=g_mSet->m_user_name;
strItem.TrimRight();
lvi.iItem = m_iSetNum;
lvi.iSubItem = 0;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
m_RstSimp_Dlg.m_List_Result_Simp.InsertItem(&lvi);
//设置
m_RstSimp_Dlg.m_List_Result_Simp.SetItemData(m_iSetNum,m_iSetNum);
// Set subitem 1---登陆密码
strItem=g_mSet->m_mem_key;
strItem.TrimRight();
lvi.iSubItem =1;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
m_RstSimp_Dlg.m_List_Result_Simp.SetItem(&lvi);
// Set subitem 2---姓名
strItem=g_mSet->m_mem_name;
strItem.TrimRight();
lvi.iSubItem =2;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
m_RstSimp_Dlg.m_List_Result_Simp.SetItem(&lvi);
// Set subitem 3---年龄
int age=g_mSet->m_mem_age;
strItem.Format("%d",age);
lvi.iSubItem =3;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
m_RstSimp_Dlg.m_List_Result_Simp.SetItem(&lvi);
// Set subitem 4---性别
strItem=g_mSet->m_mem_sex;
strItem.TrimRight();
lvi.iSubItem =4;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
m_RstSimp_Dlg.m_List_Result_Simp.SetItem(&lvi);
// Set subitem 5---身份证号
strItem=g_mSet->m_mem_idcard;
strItem.TrimRight();
lvi.iSubItem =5;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
m_RstSimp_Dlg.m_List_Result_Simp.SetItem(&lvi);
// Set subitem 6---单位
strItem=g_mSet->m_mem_company;
strItem.TrimRight();
lvi.iSubItem =6;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
m_RstSimp_Dlg.m_List_Result_Simp.SetItem(&lvi);
// Set subitem 7---省
strItem=g_mSet->m_province;
strItem.TrimRight();
lvi.iSubItem =7;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
m_RstSimp_Dlg.m_List_Result_Simp.SetItem(&lvi);
// Set subitem 8---市
strItem=g_mSet->m_city;
strItem.TrimRight();
lvi.iSubItem =8;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
m_RstSimp_Dlg.m_List_Result_Simp.SetItem(&lvi);
// Set subitem 9---联系电话
strItem=g_mSet->m_mem_telephone;
strItem.TrimRight();
lvi.iSubItem =9;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
m_RstSimp_Dlg.m_List_Result_Simp.SetItem(&lvi);
// Set subitem 10---注册时间
CTime register_time;
register_time=g_mSet->m_register_time;
strItem=register_time.Format("%Y-%m-%d");
lvi.iSubItem =10;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
m_RstSimp_Dlg.m_List_Result_Simp.SetItem(&lvi);
g_mSet->MoveNext();
m_iSetNum++;
}
CString cTotal;
cTotal.Format("总共搜索到 %d 条记录",m_iSetNum);
m_RstSimp_Dlg.m_Tatal=cTotal;
g_isMlocked=false;
m_RstSimp_Dlg.UpdateData(false);
}
void CManageSystemView::ShowPResultDetail(WPARAM wParam ,LPARAM lParam)
{
if(m_iSetNum==0)
{
EmptyPResultDetail();
g_isPLocked=false;
m_RstSimp_Dlg.ShowWindow(SW_HIDE);
m_PdtDetail_Dlg.ShowWindow(SW_SHOW);
m_MemDetail_Dlg.ShowWindow(SW_HIDE);
return;
}
if(wParam==-2||lParam==-2)
{
EmptyPResultDetail();
g_isPLocked=false;
return;
}
else if(wParam!=-1||lParam!=-1)
{
m_RstSimp_Dlg.ShowWindow(SW_HIDE);
m_PdtDetail_Dlg.ShowWindow(SW_SHOW);
m_MemDetail_Dlg.ShowWindow(SW_HIDE);
g_pSet->MoveFirst();
g_pSet->Move(wParam);
}
//=================================================
m_PdtDetail_Dlg.m_nSetNum=m_iSetNum;
//=================================================
int stepnum,i;
bool FirstRecord=false,LastRecord=false;
stepnum=0;
g_pSet->MovePrev();
stepnum++;
while(g_pSet->IsDeleted())
{
if(g_pSet->IsBOF())
break;
else
{
g_pSet->MovePrev();
stepnum++;
}
}
if(g_pSet->IsBOF())
FirstRecord=true;
for(i=0;i<stepnum;i++)
g_pSet->MoveNext();
//------------------------------
stepnum=0;
g_pSet->MoveNext();
stepnum++;
while(g_pSet->IsDeleted())
{
if(g_pSet->IsEOF())
break;
else
{
g_pSet->MoveNext();
stepnum++;
}
}
if(g_pSet->IsEOF())
LastRecord=true;
for(i=0;i<stepnum;i++)
g_pSet->MovePrev();
if(FirstRecord==true&&LastRecord==true)
{
m_PdtDetail_Dlg.m_btnPPreve.EnableWindow(false);
m_PdtDetail_Dlg.m_btnPNext.EnableWindow(false);
}
else if(FirstRecord==true)
{
m_PdtDetail_Dlg.m_btnPPreve.EnableWindow(false);
m_PdtDetail_Dlg.m_btnPNext.EnableWindow(true);
}
else if(LastRecord==true)
{
m_PdtDetail_Dlg.m_btnPPreve.EnableWindow(true);
m_PdtDetail_Dlg.m_btnPNext.EnableWindow(false);
}
else
{
m_PdtDetail_Dlg.m_btnPPreve.EnableWindow(true);
m_PdtDetail_Dlg.m_btnPNext.EnableWindow(true);
}
//=================================================
m_PdtDetail_Dlg.m_Addr=g_pSet->m_company_addr;
m_PdtDetail_Dlg.m_Addr.TrimRight();
m_PdtDetail_Dlg.m_Amount.Format("%d",g_pSet->m_amount);
m_PdtDetail_Dlg.m_Amount.TrimRight();
PRODUCTCLASS* temp=g_ProductClass->next;
while(g_pSet->m_class_id!=temp->classid)
temp=temp->next;
m_PdtDetail_Dlg.m_cmbClassName.SelectString(-1,temp->classname);
m_PdtDetail_Dlg.m_Company=g_pSet->m_company_name;
m_PdtDetail_Dlg.m_Company.TrimRight();
m_PdtDetail_Dlg.m_LinkMan=g_pSet->m_linkman;
m_PdtDetail_Dlg.m_LinkMan.TrimRight();
m_PdtDetail_Dlg.m_Name=g_pSet->m_prodt_name;
m_PdtDetail_Dlg.m_Name.TrimRight();
m_PdtDetail_Dlg.m_Price=g_pSet->m_unit_price;
m_PdtDetail_Dlg.m_Price.TrimRight();
m_PdtDetail_Dlg.m_Produce=g_pSet->m_producing_area;
m_PdtDetail_Dlg.m_Produce.TrimRight();
m_PdtDetail_Dlg.m_Provide=g_pSet->m_provide_area;
m_PdtDetail_Dlg.m_Provide.TrimRight();
m_PdtDetail_Dlg.m_Resume=g_pSet->m_prodt_resume;
m_PdtDetail_Dlg.m_Resume.TrimRight();
m_PdtDetail_Dlg.m_Specification=g_pSet->m_specification;
m_PdtDetail_Dlg.m_Specification.TrimRight();
m_PdtDetail_Dlg.m_Telephone=g_pSet->m_comp_telephone;
m_PdtDetail_Dlg.m_Telephone.TrimRight();
CString picAddr=g_pSet->m_picture_addr;
picAddr.TrimRight();
m_PdtDetail_Dlg.m_strPicAddr=picAddr;
m_PdtDetail_Dlg.m_ctrPicture.RemoveDib();
m_PdtDetail_Dlg.m_ctrPicture.LoadDib(picAddr);
m_PdtDetail_Dlg.UpdateData(false);
g_isPLocked=false;
}
void CManageSystemView::ShowMResultDetail(WPARAM wParam ,LPARAM lParam)
{
if(m_iSetNum==0)
{
EmptyMResultDetail();
g_isMlocked=false;
m_RstSimp_Dlg.ShowWindow(SW_HIDE);
m_PdtDetail_Dlg.ShowWindow(SW_HIDE);
m_MemDetail_Dlg.ShowWindow(SW_SHOW);
return;
}
//==============================================
if(wParam==-2&&lParam==-2)
{
EmptyMResultDetail();
g_isMlocked=false;
return;
}
else if(wParam!=-1||lParam!=-1)
{
m_RstSimp_Dlg.ShowWindow(SW_HIDE);
m_PdtDetail_Dlg.ShowWindow(SW_HIDE);
m_MemDetail_Dlg.ShowWindow(SW_SHOW);
g_mSet->MoveFirst();
g_mSet->Move(wParam);
}
//=============================================
m_MemDetail_Dlg.m_nFlags=m_iSetNum;
//=============================================
int stepnum,i;
bool FirstRecord=false,LastRecord=false;
stepnum=0;
g_mSet->MovePrev();
stepnum++;
while(g_mSet->IsDeleted())
{
if(g_mSet->IsBOF())
break;
else
{
g_mSet->MovePrev();
stepnum++;
}
}
if(g_mSet->IsBOF())
FirstRecord=true;
for(i=0;i<stepnum;i++)
g_mSet->MoveNext();
//------------------------------
stepnum=0;
g_mSet->MoveNext();
stepnum++;
while(g_mSet->IsDeleted())
{
if(g_mSet->IsEOF())
break;
else
{
g_mSet->MoveNext();
stepnum++;
}
}
if(g_mSet->IsEOF())
LastRecord=true;
for(i=0;i<stepnum;i++)
g_mSet->MovePrev();
if(FirstRecord==true&&LastRecord==true)
{
m_MemDetail_Dlg.m_btnMPreve.EnableWindow(false);
m_MemDetail_Dlg.m_btnMNext.EnableWindow(false);
}
else if(FirstRecord==true)
{
m_MemDetail_Dlg.m_btnMPreve.EnableWindow(false);
m_MemDetail_Dlg.m_btnMNext.EnableWindow(true);
}
else if(LastRecord==true)
{
m_MemDetail_Dlg.m_btnMPreve.EnableWindow(true);
m_MemDetail_Dlg.m_btnMNext.EnableWindow(false);
}
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -