📄 searchmarketplan.cpp
字号:
// SearchMarketPlan.cpp : implementation file
//
#include "stdafx.h"
#include "ClientRelationship.h"
#include "SearchMarketPlan.h"
#include "MarketPlanForm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSearchMarketPlan dialog
CSearchMarketPlan::CSearchMarketPlan(CWnd* pParent /*=NULL*/)
: CDialog(CSearchMarketPlan::IDD, pParent)
{
//{{AFX_DATA_INIT(CSearchMarketPlan)
m_executeDateBegin = COleDateTime::GetCurrentTime();
m_executeDateEnd = COleDateTime::GetCurrentTime();
m_endDateBegin = COleDateTime::GetCurrentTime();
m_endDateEnd = COleDateTime::GetCurrentTime();
m_planTitle = _T("");
m_joinStaff = _T("");
//}}AFX_DATA_INIT
}
void CSearchMarketPlan::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSearchMarketPlan)
DDX_Control(pDX, IDC_joinStaff, m_joinStaffCombo);
DDX_Control(pDX, IDC_planTitle, m_planTitleCombo);
DDX_Control(pDX, IDC_LIST1, m_list);
DDX_DateTimeCtrl(pDX, IDC_executeDateBegin, m_executeDateBegin);
DDX_DateTimeCtrl(pDX, IDC_executeDateEnd, m_executeDateEnd);
DDX_DateTimeCtrl(pDX, IDC_endDateBegin, m_endDateBegin);
DDX_DateTimeCtrl(pDX, IDC_endDateEnd, m_endDateEnd);
DDX_CBString(pDX, IDC_planTitle, m_planTitle);
DDX_CBString(pDX, IDC_joinStaff, m_joinStaff);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSearchMarketPlan, CDialog)
//{{AFX_MSG_MAP(CSearchMarketPlan)
ON_BN_CLICKED(IDC_search, OnSearch)
ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSearchMarketPlan message handlers
void CSearchMarketPlan::OnSearch()
{
UpdateData(true);
CString strSQL;
_RecordsetPtr m_pRecordset;
HRESULT hTRes;
hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
strSQL="select * from marketPlan";
CString str;
str.Format("%d-%d-%d",m_executeDateBegin.GetYear(),m_executeDateBegin.GetMonth(),m_executeDateBegin.GetDay());
strSQL+=" where executeDate>'"+str+"' ";
str.Format("%d-%d-%d",m_executeDateEnd.GetYear(),m_executeDateEnd.GetMonth(),m_executeDateEnd.GetDay());
strSQL+=" and executeDate<'"+str+"' ";
str.Format("%d-%d-%d",m_endDateBegin.GetYear(),m_endDateBegin.GetMonth(),m_endDateBegin.GetDay());
strSQL+=" and endDate>'"+str+"' ";
str.Format("%d-%d-%d",m_endDateEnd.GetYear(),m_endDateEnd.GetMonth(),m_endDateEnd.GetDay());
strSQL+=" and endDate<'"+str+"' ";
if(m_planTitle!="")
{
strSQL+=" and planTitle='"+m_planTitle+"' ";
}
if(m_joinStaff!="")
{
strSQL+=" and joinStaff='"+m_joinStaff+"' ";
}
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CClientRelationshipApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
int i=0;
m_list.DeleteAllItems();
while(!(m_pRecordset->adoEOF))
{
m_list.InsertItem(i,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("marketPlanID")));
COleDateTime executeDate= m_pRecordset->GetCollect("executeDate");
str.Format("%d-%d-%d",executeDate.GetYear(),executeDate.GetMonth(),executeDate.GetDay());
m_list.SetItemText(i,1,str);
COleDateTime endDate= m_pRecordset->GetCollect("endDate");
str.Format("%d-%d-%d",endDate.GetYear(),endDate.GetMonth(),endDate.GetDay());
m_list.SetItemText(i,2,str);
m_list.SetItemText(i,3, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("joinStaff")));
m_list.SetItemText(i,4, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("planTitle")));
m_list.SetItemText(i,5, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("planStep")));
m_list.SetItemText(i,6, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("content")));
m_list.SetItemText(i,7, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("executeSummary")));
m_pRecordset->MoveNext();
i++;
}
m_pRecordset->Close();
}
void CSearchMarketPlan::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
{
CString str;
int flag=0;
POSITION pos = m_list.GetFirstSelectedItemPosition();
if(pos)
{
int nFirstSelItem = m_list.GetNextSelectedItem(pos);
str=m_list.GetItemText(nFirstSelItem,0);
}
CMarketPlanForm dlg;
dlg.m_marketPlanID=str;
dlg.is_search=1;
dlg.DoModal();
*pResult = 0;
}
BOOL CSearchMarketPlan::OnInitDialog()
{
CDialog::OnInitDialog();
DWORD style;
style=m_list.GetExStyle();
style=(style|LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT)&(~LVS_EX_CHECKBOXES) ;
m_list.SetExtendedStyle(style);
m_list.InsertColumn(0,"策划编号",LVCFMT_LEFT,100);
m_list.InsertColumn(1,"实施日期",LVCFMT_LEFT,100);
m_list.InsertColumn(2,"结束日期",LVCFMT_LEFT,100);
m_list.InsertColumn(3,"参与人员",LVCFMT_LEFT,100);
m_list.InsertColumn(4,"策划标题",LVCFMT_LEFT,100);
m_list.InsertColumn(5,"计划步骤",LVCFMT_LEFT,100);
m_list.InsertColumn(6,"主要内容",LVCFMT_LEFT,100);
m_list.InsertColumn(7,"实施总结",LVCFMT_LEFT,100);
CString strSQL;
_RecordsetPtr m_pRecordset;
HRESULT hTRes;
hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
strSQL="select distinct planTitle from marketPlan";
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CClientRelationshipApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
int i=0;
while(!(m_pRecordset->adoEOF))
{
m_planTitleCombo.InsertString(i,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("planTitle")));
m_pRecordset->MoveNext();
i++;
}
m_pRecordset->Close();
strSQL="select distinct joinStaff from marketPlan";
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CClientRelationshipApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
i=0;
while(!(m_pRecordset->adoEOF))
{
m_joinStaffCombo.InsertString(i,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("joinStaff")));
m_pRecordset->MoveNext();
i++;
}
m_pRecordset->Close();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -