📄 ustomerinfosetdlg.cpp
字号:
// ustomerInfoSetDlg.cpp : implementation file
//
#include "stdafx.h"
#include "CustomerManage.h"
#include "CustomerManageDoc.h"
#include "CustomerManageView.h"
#include "MainFrm.h"
#include "ustomerInfoSetDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CustomerInfoSetDlg dialog
CustomerInfoSetDlg::CustomerInfoSetDlg(CWnd* pParent /*=NULL*/)
: CDialog(CustomerInfoSetDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CustomerInfoSetDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
bIsAdd = false;
bIsModify = false;
m_pADOSet.CreateInstance(__uuidof(Recordset));
}
void CustomerInfoSetDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CustomerInfoSetDlg)
DDX_Control(pDX, IDC_DELETE_CUSTOMERINFO, m_ok);
DDX_Control(pDX, IDCANCEL, m_cancel);
DDX_Control(pDX, IDC_BUTTON_UP, m_up);
DDX_Control(pDX, IDC_BUTTON_SEARCH_INFO, m_search);
DDX_Control(pDX, IDC_BUTTON_SAVE_CUSTOMER_INFO, m_save);
DDX_Control(pDX, IDC_BUTTON_MODIFY_CUSOTMER_INFO, m_modify);
DDX_Control(pDX, IDC_BUTTON_DOWN, m_down);
DDX_Control(pDX, IDC_BUTTON_ADD_CUSTOMER_INFO, m_add);
DDX_Control(pDX, IDC_COMBO_ADD_CUSTOMER_INFO_TYPE, m_type);
DDX_Control(pDX, IDC_COMBO_ADD_CUSTOMER_INFO_TRACT, m_addtract);
DDX_Control(pDX, IDC_COMBO_CUSTOMER_TRACT, m_tract);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CustomerInfoSetDlg, CDialog)
//{{AFX_MSG_MAP(CustomerInfoSetDlg)
ON_WM_PAINT()
ON_BN_CLICKED(IDC_BUTTON_SEARCH_INFO, OnButtonSearchInfo)
ON_WM_CLOSE()
ON_BN_CLICKED(IDC_BUTTON_ADD_CUSTOMER_INFO, OnButtonAddCustomerInfo)
ON_BN_CLICKED(IDC_BUTTON_MODIFY_CUSOTMER_INFO, OnButtonModifyCusotmerInfo)
ON_BN_CLICKED(IDC_BUTTON_SAVE_CUSTOMER_INFO, OnButtonSaveCustomerInfo)
ON_BN_CLICKED(IDC_DELETE_CUSTOMERINFO, OnDeleteCustomerinfo)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CustomerInfoSetDlg message handlers
void CustomerInfoSetDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CRect rcClient;
GetClientRect(&rcClient);
bar.DrawLeft(&dc,CRect(0,0,10,rcClient.bottom));
bar.DrawTop(&dc,CRect(0,0,rcClient.right,10));
bar.DrawRight(&dc,CRect(rcClient.right-10,0,rcClient.right,rcClient.bottom));
bar.DrawBottom(&dc,CRect(0,rcClient.bottom-10,rcClient.right,rcClient.bottom));
// Do not call CDialog::OnPaint() for painting messages
}
BOOL CustomerInfoSetDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
SetCtrlBkColor();
InitialComTract();
InitialComAddTract();
InitialComAddType();
m_save.EnableWindow(false);
m_up.EnableWindow(false);
m_down.EnableWindow(false);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CustomerInfoSetDlg::InitialComTract()
{
int Index = 0;
CString strSQL;
_RecordsetPtr m_pADOSet;
try
{
m_pADOSet.CreateInstance(__uuidof(Recordset));
strSQL = "select ID,所属地域 from CustomerTract";
m_pADOSet = theApp.ADOConn->Execute(strSQL.AllocSysString(),NULL,adCmdText);
while(!m_pADOSet->adoEOF)
{
Index = m_tract.AddString((LPCSTR)(_bstr_t)m_pADOSet->GetCollect("所属地域"));
m_tract.SetItemData(Index,m_pADOSet->GetCollect("ID").iVal);
m_pADOSet->MoveNext();
}
m_pADOSet->Close();
Index = m_tract.AddString("全部");
m_tract.SetItemData(Index,-1);
m_tract.SetCurSel(0);
}
catch(_com_error e)
{
MessageBox(e.Description(),MB_OK);
return;
}
}
void CustomerInfoSetDlg::InitialComAddTract()
{
int Index = 0;
CString strSQL;
_RecordsetPtr m_pADOSet;
try
{
m_pADOSet.CreateInstance(__uuidof(Recordset));
strSQL = "select ID,所属地域 from CustomerTract";
m_pADOSet = theApp.ADOConn->Execute(strSQL.AllocSysString(),NULL,adCmdText);
while(!m_pADOSet->adoEOF)
{
Index = m_addtract.AddString((LPCSTR)(_bstr_t)m_pADOSet->GetCollect("所属地域"));
m_addtract.SetItemData(Index,m_pADOSet->GetCollect("ID").iVal);
m_pADOSet->MoveNext();
}
m_pADOSet->Close();
m_addtract.SetCurSel(0);
}
catch(_com_error e)
{
MessageBox(e.Description(),MB_OK);
return;
}
}
void CustomerInfoSetDlg::InitialComAddType()
{
int Index = 0;
CString strSQL;
_RecordsetPtr m_pADOSet;
try
{
m_pADOSet.CreateInstance(__uuidof(Recordset));
strSQL = "select ID,客户类型 from CustomerType";
m_pADOSet = theApp.ADOConn->Execute(strSQL.AllocSysString(),NULL,adCmdText);
while(!m_pADOSet->adoEOF)
{
Index = m_type.AddString((LPCSTR)(_bstr_t)m_pADOSet->GetCollect("客户类型"));
m_type.SetItemData(Index,m_pADOSet->GetCollect("ID").iVal);
m_pADOSet->MoveNext();
}
m_pADOSet->Close();
m_type.SetCurSel(0);
}
catch(_com_error e)
{
MessageBox(e.Description(),MB_OK);
return;
}
}
void CustomerInfoSetDlg::OnButtonSearchInfo()
{
// TODO: Add your control notification handler code here
ClearCtrlData();
ClearCustomer();
CString sValue;
CString strSQL;
int Tract;
GetDlgItem(IDC_EDIT_CUSTOMER_NAME)->GetWindowText(sValue);
if(sValue == "")
{
MessageBox("请你填写查询条件",MB_OK);
return;
}
Tract = m_tract.GetItemData(m_tract.GetCurSel());
if(Tract == -1)
{
strSQL.Format("select C.*,T.客户类型,R.所属地域 from CustomerInfo C \
,CustomerType T,CustomerTract R where C.所属地域=R.ID \
and C.客户类型=T.ID and C.姓名='%s'", \
sValue);
}
else
{
strSQL.Format("select C.*,T.客户类型,R.所属地域 from CustomerInfo C \
,CustomerType T,CustomerTract R where C.所属地域=R.ID \
and C.客户类型=T.ID and C.所属地域=%d and C.姓名='%s'", \
Tract,sValue);
}
try
{
if(m_pADOSet->State == adStateOpen)
{
m_pADOSet->Close();
}
//m_pADOSet = theApp.ADOConn->Execute(strSQL.AllocSysString(),NULL,adCmdText);
m_pADOSet->Open(strSQL.AllocSysString(),theApp.ADOConn.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
if(m_pADOSet->adoEOF)
{
MessageBox("当前没有你要找的记录",MB_OK);
return;
}
else
{
m_pADOSet->MoveFirst();
m_CustomerInfo.Address = m_pADOSet->GetCollect("地址").bstrVal;
m_CustomerInfo.IP = m_pADOSet->GetCollect("IP").bstrVal;
// m_CustomerInfo.Gateway = m_pADOSet->GetCollect("网关").bstrVal;
m_CustomerInfo.MAC = m_pADOSet->GetCollect("MAC").bstrVal;
m_CustomerInfo.Name = m_pADOSet->GetCollect("姓名").bstrVal;
m_CustomerInfo.Phone = m_pADOSet->GetCollect("电话").bstrVal;
m_CustomerInfo.Short = m_pADOSet->GetCollect("简称").bstrVal;
m_CustomerInfo.Tract = m_pADOSet->GetCollect("R.所属地域").bstrVal;
m_CustomerInfo.Type = m_pADOSet->GetCollect("T.客户类型").bstrVal;
// m_CustomerInfo.sNO = m_pADOSet->GetCollect("掩码").bstrVal;
m_CustomerInfo.Remark = m_pADOSet->GetCollect("备注").bstrVal;
m_CustomerInfo.Felltime = m_pADOSet->GetCollect("到期时间");
m_CustomerInfo.Jointime = m_pADOSet->GetCollect("入网时间");
m_CustomerInfo.ID = m_pADOSet->GetCollect("ID").iVal;
ID = m_CustomerInfo.ID;
SetCustomerInfo();
m_pADOSet->MoveNext();
if(m_pADOSet->BOF)
{
m_up.EnableWindow(true);
}
else
{
m_up.EnableWindow(false);
}
if(m_pADOSet->adoEOF)
{
m_down.EnableWindow(false);
}
else
{
m_down.EnableWindow(true);
}
}
}
catch(_com_error e)
{
MessageBox(e.Description(),MB_OK);
return;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -