【VC开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了VC开源代码-DlgRj.cpp的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
// DlgRj.cpp : implementation file
//
#include "stdafx.h"
#include "a1.h"
#include "DlgRj.h"
#include "ScrollPrintView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgRj dialog
CDlgRj::CDlgRj(bool isrj,CWnd* pParent /*=NULL*/)
: CDialog(CDlgRj::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgRj)
m_iYue = -1;
//}}AFX_DATA_INIT
m_bRj=isrj;
this->m_iOldYue=-1;
m_draw=new CDrawJZ(this);
}
void CDlgRj::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgRj)
DDX_Control(pDX, IDC_LIST1, m_list);
DDX_Control(pDX, IDC_COMBO1, m_comboYue);
DDX_Control(pDX, IDC_DATETIMEPICKER1, m_tcRq);
DDX_CBIndex(pDX, IDC_COMBO1, m_iYue);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgRj, CDialog)
//{{AFX_MSG_MAP(CDlgRj)
ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATETIMEPICKER1, OnDatetimechangeDatetimepicker1)
ON_CBN_SELENDOK(IDC_COMBO1, OnSelendokCombo1)
ON_BN_CLICKED(IDC_BUTTON_PRINT, OnButtonPrint)
//}}AFX_MSG_MAP
ON_MESSAGE(MYMESSAGE_RQCHANGE,OnMyRqChange)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgRj message handlers
void CDlgRj::OnOK()
{
// TODO: Add extra validation here
// CDialog::OnOK();
}
void CDlgRj::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
BOOL CDlgRj::OnInitDialog()
{
CDialog::OnInitDialog();
InitWhiteFrame();
InitBaseInfo();
InitListView();
if(this->m_bRj)
{
this->SetWindowText("日结");
this->m_tcRq.ShowWindow(SW_SHOW);
this->m_comboYue.ShowWindow(SW_HIDE);
m_tcRq.SetFocus();
}
else
{
this->SetWindowText("月结");
this->m_tcRq.ShowWindow(SW_HIDE);
this->m_comboYue.ShowWindow(SW_SHOW);
m_comboYue.SetFocus();
}
return FALSE;
}
bool CDlgRj::InitWhiteFrame()
{
CRect rect;
this->GetClientRect(&rect);
rect.top+=10;
rect.bottom=400;
rect.left+=5;
rect.right-=5;
m_whiteframe.Create("日期:",WS_CHILD|WS_VISIBLE,rect,this);
return true;
}
bool CDlgRj::InitBaseInfo()
{
CTime t=CTime::GetCurrentTime();
m_tcRq.SetTime(&t);
if(m_bRj)
{m_tcRq.SetParent(&this->m_whiteframe);
m_tcRq.GetWindowText(m_strRq);
}
else
{
this->m_comboYue.SetParent(&this->m_whiteframe);
//&m_whiteframe
int i=t.GetYear();
CString a;
a.Format("%d",i);
}
return true;
}
bool CDlgRj::InitListView()
{
if(m_whiteframe.m_hWnd==NULL)return false;
CRect rect;
m_whiteframe.GetClientRect(&rect);
rect.top+=25;
rect.left+=2;
rect.right-=2;
rect.bottom-=2;
m_list.MoveWindow(&rect);
m_list.SetParent(&m_whiteframe);
// this->m_list.SetBkColor(::GetSysColor(COLOR_BTNFACE));
// m_list.SetTextBkColor(::GetSysColor(COLOR_BTNFACE));
this->m_list.ModifyStyle(LVS_EDITLABELS, 0L); //禁止标题编辑
m_list.ModifyStyle(0L, LVS_REPORT); //设为Report类型
m_list.ModifyStyle(0L, LVS_SHOWSELALWAYS); //始终高亮度被选中的表项
m_list.ModifyStyle(0L, LVS_NOSORTHEADER);
m_list.ModifyStyle( LVS_OWNERDRAWFIXED,0L);
m_list.SetExtendedStyle( LVS_EX_FULLROWSELECT | //允许整行选中
LVS_EX_GRIDLINES | //画出网格线
LVS_EX_FLATSB //扁平风格的滚动条
); // this->m_list.set
// CRect rect;
m_list.GetClientRect(&rect);
for(int k=0;k<6;k++)
{
m_list.InsertColumn(k,"");
}
m_list.SetColumnWidth(0,115);
m_list.SetColumnWidth(1,115);
m_list.SetColumnWidth(2,115);
m_list.SetColumnWidth(3,115);
m_list.SetColumnWidth(4,150);
m_list.SetColumnWidth(5,150);
for(int i=0;i<25;i++)
{
m_list.InsertItem(i,"");
for(int j=1;j<6;j++)
{
m_list.SetItemText(i,j,"");
}
}
if(m_bRj)
this->RefreshListView(CString(""));
else
{
CTime t=CTime::GetCurrentTime();
m_iYue=t.GetMonth();
CString yue;
yue.Format("%d",m_iYue);
CString next_yue;
next_yue.Format("%d",m_iYue+1);
CString y=t.Format("%Y");
if(this->m_iYue==12)
{
int l_y=atoi(y);
l_y++;
CString upy;
upy.Format("%d",l_y);
this->m_strRqUp=upy+'-'+'1'+'-'+'1';
}
else
{
m_strRqUp=y+'-'+next_yue+'-'+'1';
}
m_strRqDown=y+'-'+yue+'-'+'1';
m_iOldYue=m_iYue;
this->m_comboYue.SetCurSel(m_iYue-1);
this->RefreshListView(CString(""));
}
return true;
}
void CDlgRj::OnDatetimechangeDatetimepicker1(NMHDR* pNMHDR, LRESULT* pResult)
{
this->PostMessage(MYMESSAGE_RQCHANGE,0,0);
*pResult = 0;
}
BOOL CDlgRj::PreTranslateMessage(MSG* pMsg)
{
const HWND hwnd = (pMsg!=NULL)?pMsg->hwnd:NULL;
if(hwnd==NULL) goto a;
if(hwnd==this->m_tcRq.GetSafeHwnd()&&pMsg->message==WM_CHAR)
{
//if()
}
a:
return CDialog::PreTranslateMessage(pMsg);
}
void CDlgRj::OnMyRqChange()
{
CString str;
this->m_tcRq.GetWindowText(str);
if(str==this->m_strRq)
return ;
else
{
m_strRq=str;
this->RefreshListView(CString(""));
}
}
bool CDlgRj::RefreshListView(CString sql)
{
m_list.SetRedraw(false);
m_list.DeleteAllItems();
int i=0;
i=this->RefreshXSList(i)+1;
m_list.InsertItem(i,"");
i=this->RefreshRKList(i)+1;
m_list.InsertItem(i,"");
i=this->RefreshXSTHList(i)+1;
m_list.InsertItem(i,"");
this->RefreshRKTHList(i);
for(int j=0;j<6;j++)
this->m_list.SetColumnWidth(j,-2);
m_list.SetRedraw(true);
m_list.ShowWindow(SW_SHOW);
m_list.Invalidate();
return true;
}
CString CDlgRj::PrepareXSSQL()
{
CString sql;
if(this->m_bRj)
sql.Format("SELECT Sum([tabxsdj]![sl]) AS sumsl, \
Sum(tabxsdj.je) AS sumje, \
Sum(tabxsdj.profit) AS profit, \
tabxsdj.yp_id AS yp_id,tabypinfo.yp_name \
FROM tabxsdj, tabxsph, tabypinfo \
WHERE ((([tabxsph]![xs_ph])=[tabxsdj]![xs_ph]) \
AND (([tabxsph]![rq])=#%s#) AND \
(([tabxsdj]![yp_id])=[tabypinfo]![yp_id])) \
GROUP BY tabxsdj.yp_id,tabypinfo.yp_name \
",this->m_strRq);
else
sql.Format("SELECT Sum([tabxsdj]![sl]) AS sumsl, \
Sum(tabxsdj.je) AS sumje, \
Sum(tabxsdj.profit) AS profit, \
tabxsdj.yp_id AS yp_id,tabypinfo.yp_name \
FROM tabxsdj, tabxsph, tabypinfo \
WHERE [tabxsph]![xs_ph]=[tabxsdj]![xs_ph] \
AND [tabxsph]![rq]>=#%s# AND [tabxsph]![rq]<#%s# AND \
[tabxsdj]![yp_id]=[tabypinfo]![yp_id] \
GROUP BY tabxsdj.yp_id,tabypinfo.yp_name\
",this->m_strRqDown,this->m_strRqUp);
return sql;
}
CString CDlgRj::PrepareXSTHSQL()
{
CString sql;
if(thi
上一篇:
DlgRegularDll.cpp
下一篇:
最新参考文献中的标点符号