?? customermanageview.cpp
字號:
// CustomerManageView.cpp : implementation of the CCustomerManageView class
//
#include "stdafx.h"
#include "CustomerManage.h"
#include "CustomerManageDoc.h"
#include "CustomerManageView.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCustomerManageView
IMPLEMENT_DYNCREATE(CCustomerManageView, CFormView)
BEGIN_MESSAGE_MAP(CCustomerManageView, CFormView)
ON_WM_CONTEXTMENU()
//{{AFX_MSG_MAP(CCustomerManageView)
ON_WM_SIZE()
ON_CBN_SELCHANGE(IDC_COMBO_FIELD, OnSelchangeComboField)
ON_BN_CLICKED(IDC_BUTTON_SEARCH, OnButtonSearch)
ON_COMMAND(ID_CUSTOMER_TYPE_SET, OnCustomerTypeSet)
ON_COMMAND(ID_CUSTOMER_TRACT_SET, OnCustomerTractSet)
ON_COMMAND(ID_SET_CUSTOMER_INFO, OnSetCustomerInfo)
ON_MESSAGE(WM_INSERT_DATA_TO_TREECTRL,OnInsertDataToTreeCtrl)
ON_COMMAND(ID_DELETE_CURRENT_CUSTOMER, OnDeleteCurrentCustomer)
//}}AFX_MSG_MAP
// 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()
/////////////////////////////////////////////////////////////////////////////
// CCustomerManageView construction/destruction
CCustomerManageView::CCustomerManageView()
: CFormView(CCustomerManageView::IDD)
{
//{{AFX_DATA_INIT(CCustomerManageView)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// TODO: add construction code here
}
CCustomerManageView::~CCustomerManageView()
{
}
void CCustomerManageView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCustomerManageView)
DDX_Control(pDX, IDC_COMBO_CUSTOMER_TYPE, m_type);
DDX_Control(pDX, IDC_DATETIMEPICKER2, m_etimectrl);
DDX_Control(pDX, IDC_DATETIMEPICKER1, m_stimectrl);
DDX_Control(pDX, IDC_BUTTON_SEARCH, m_search);
DDX_Control(pDX, IDC_EDIT_VALUES, m_values);
DDX_Control(pDX, IDC_COMBO_CONDITION, m_condition);
DDX_Control(pDX, IDC_COMBO_FIELD, m_field);
DDX_Control(pDX, IDC_LIST_CUSTOMER, m_list);
//}}AFX_DATA_MAP
}
BOOL CCustomerManageView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CFormView::PreCreateWindow(cs);
}
void CCustomerManageView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
InitialListView();
InitialComField();
InitialComCondition();
InitialComType();
InsertListViewData();
m_stimectrl.ShowWindow(SW_HIDE);
m_etimectrl.ShowWindow(SW_HIDE);
m_type.ShowWindow(SW_HIDE);
}
/////////////////////////////////////////////////////////////////////////////
// CCustomerManageView printing
BOOL CCustomerManageView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CCustomerManageView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CCustomerManageView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
void CCustomerManageView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
// TODO: add customized printing code here
}
/////////////////////////////////////////////////////////////////////////////
// CCustomerManageView diagnostics
#ifdef _DEBUG
void CCustomerManageView::AssertValid() const
{
CFormView::AssertValid();
}
void CCustomerManageView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CCustomerManageDoc* CCustomerManageView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCustomerManageDoc)));
return (CCustomerManageDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCustomerManageView message handlers
void CCustomerManageView::OnSize(UINT nType, int cx, int cy)
{
CFormView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
CRect rect;
CRect rectCurrent;
this->GetClientRect(&rect);
rectCurrent = rect;
rectCurrent.bottom = 50;
rectCurrent.left = rect.left + 5;
rectCurrent.right = rect.right - 5;
if(GetDlgItem(IDC_STATIC_SEARCH_CONDITION))
GetDlgItem(IDC_STATIC_SEARCH_CONDITION)->MoveWindow(rectCurrent,true);
rectCurrent.right = rectCurrent.left + 200;
rectCurrent.top = rectCurrent.top + 20;
rectCurrent.bottom = rectCurrent.top + 20;
rectCurrent.left = rectCurrent.left + 4;
if(m_field.m_hWnd)
m_field.MoveWindow(rectCurrent,true);
CRect rect2;
rect2 = rectCurrent;
rect2.left = rect2.right;
rect2.right = rect.right - 55;
if(m_type.m_hWnd)
m_type.MoveWindow(rect2,true);
CRect rect1;
rect1 = rectCurrent;
rect1.left = rect1.right;
rect1.right = (int)(rect.Width() - 255)/2 + rect1.left;
if(m_stimectrl.m_hWnd)
m_stimectrl.MoveWindow(rect1,true);
rect1.left = rect1.right;
rect1.right = rect1.left + (int)(rect.Width() - 255)/2 - 7;
if(m_etimectrl.m_hWnd)
m_etimectrl.MoveWindow(rect1,true);
rectCurrent.left = rectCurrent.right;
rectCurrent.right = rectCurrent.left + 50;
if(m_condition.m_hWnd)
m_condition.MoveWindow(rectCurrent,true);
rectCurrent.left = rectCurrent.right;
rectCurrent.right = rect.right - 60;
if(m_values.m_hWnd)
m_values.MoveWindow(rectCurrent,true);
rectCurrent.left = rectCurrent.right;
rectCurrent.right = rect.right -12;
if(m_search.m_hWnd)
m_search.MoveWindow(rectCurrent,true);
rectCurrent.left = rect.left + 5;
rectCurrent.right = rect.right - 5;
rectCurrent.top = rect.top + 51;
rectCurrent.bottom = rect.bottom;
if(m_list.m_hWnd)
m_list.MoveWindow(rectCurrent,true);
}
void CCustomerManageView::InitialListView()
{
ListView_SetExtendedListViewStyle(m_list.m_hWnd,
LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|
LVS_EX_FLATSB|LVS_EX_HEADERDRAGDROP);
m_list.InsertColumn(0,"姓名",LVCFMT_LEFT,100);
m_list.InsertColumn(1,"簡稱",LVCFMT_LEFT,80);
m_list.InsertColumn(2,"電話",LVCFMT_LEFT,100);
m_list.InsertColumn(3,"地址",LVCFMT_LEFT,200);
m_list.InsertColumn(4,"IP",LVCFMT_LEFT,100);
// m_list.InsertColumn(5,"掩碼",LVCFMT_LEFT,100);
// m_list.InsertColumn(6,"網關",LVCFMT_LEFT,100);
m_list.InsertColumn(5,"MAC",LVCFMT_LEFT,100);
m_list.InsertColumn(6,"入網時間",LVCFMT_LEFT,150);
m_list.InsertColumn(7,"到期時間",LVCFMT_LEFT,150);
m_list.InsertColumn(8,"客戶類型",LVCFMT_LEFT,100);
m_list.InsertColumn(9,"所屬地域",LVCFMT_LEFT,80);
m_list.InsertColumn(10,"備注",LVCFMT_LEFT,300);
m_list.InsertColumn(11,"ID",LVCFMT_LEFT,0);
}
void CCustomerManageView::InitialComField()
{
m_field.AddString("姓名");
m_field.AddString("簡稱");
m_field.AddString("電話");
m_field.AddString("地址");
m_field.AddString("IP");
m_field.AddString("MAC");
m_field.AddString("入網時間");
m_field.AddString("到期時間");
m_field.AddString("客戶類型");
m_field.SetCurSel(0);
}
void CCustomerManageView::InitialComCondition()
{
m_condition.AddString("=");
m_condition.AddString("like");
m_condition.SetCurSel(0);
}
void CCustomerManageView::OnSelchangeComboField()
{
// TODO: Add your control notification handler code here
int Index = 0;
Index = m_field.GetCurSel();
if((Index == 6) || (Index == 7))
{
m_values.ShowWindow(SW_HIDE);
m_condition.ShowWindow(SW_HIDE);
m_stimectrl.ShowWindow(SW_SHOW);
m_etimectrl.ShowWindow(SW_SHOW);
m_type.ShowWindow(SW_HIDE);
}
else
{
if(Index == 8)
{
m_values.ShowWindow(SW_HIDE);
m_condition.ShowWindow(SW_HIDE);
m_stimectrl.ShowWindow(SW_HIDE);
m_etimectrl.ShowWindow(SW_HIDE);
m_type.ShowWindow(SW_SHOW);
}
else
{
m_values.ShowWindow(SW_SHOW);
m_condition.ShowWindow(SW_SHOW);
m_stimectrl.ShowWindow(SW_HIDE);
m_etimectrl.ShowWindow(SW_HIDE);
m_type.ShowWindow(SW_HIDE);
}
}
}
void CCustomerManageView::OnButtonSearch()
{
// TODO: Add your control notification handler code here
m_list.DeleteAllItems();
int Index = 0;
int nCount = 0;
_RecordsetPtr m_pADOSet;
try
{
CString strSQL = this->GetSearchCondition();
m_pADOSet.CreateInstance(__uuidof(Recordset));
m_pADOSet = theApp.ADOConn->Execute(strSQL.AllocSysString(),NULL,adCmdText);
while(!m_pADOSet->adoEOF)
{
Index = m_list.GetItemCount();
m_list.InsertItem(Index,"");
m_list.SetItemText(Index,0,(LPCSTR)(_bstr_t)m_pADOSet->GetCollect("姓名"));
m_list.SetItemText(Index,1,(LPCSTR)(_bstr_t)m_pADOSet->GetCollect("簡稱"));
m_list.SetItemText(Index,2,(LPCSTR)(_bstr_t)m_pADOSet->GetCollect("電話"));
m_list.SetItemText(Index,3,(LPCSTR)(_bstr_t)m_pADOSet->GetCollect("地址"));
m_list.SetItemText(Index,4,(LPCSTR)(_bstr_t)m_pADOSet->GetCollect("IP"));
//m_list.SetItemText(Index,5,(LPCSTR)(_bstr_t)m_pADOSet->GetCollect("掩碼"));
//m_list.SetItemText(Index,6,(LPCSTR)(_bstr_t)m_pADOSet->GetCollect("網關"));
m_list.SetItemText(Index,5,(LPCSTR)(_bstr_t)m_pADOSet->GetCollect("MAC"));
m_list.SetItemText(Index,6,(LPCSTR)(_bstr_t)m_pADOSet->GetCollect("入網時間"));
m_list.SetItemText(Index,7,(LPCSTR)(_bstr_t)m_pADOSet->GetCollect("到期時間"));
m_list.SetItemText(Index,8,(LPCSTR)(_bstr_t)m_pADOSet->GetCollect("T.客戶類型"));
m_list.SetItemText(Index,9,(LPCSTR)(_bstr_t)m_pADOSet->GetCollect("Y.所屬地域"));
m_list.SetItemText(Index,10,(LPCSTR)(_bstr_t)m_pADOSet->GetCollect("備注"));
m_list.SetItemText(Index,11,(LPCSTR)(_bstr_t)m_pADOSet->GetCollect("ID"));
m_pADOSet->MoveNext();
nCount++;
}
CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
if(pFrame != NULL)
pFrame->SendMessage(WM_SET_STATUES_INFO,0,(LPARAM)nCount);
m_pADOSet->Close();
}
catch(_com_error e)
{
MessageBox(e.Description(),MB_OK);
return;
}
}
void CCustomerManageView::InitialComType()
{
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -