⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dlgrj.cpp

📁 这是一个管理信息系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// 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(this->m_bRj)
	sql.Format("SELECT Sum([tabxsthdj]![sl]) AS sumsl, \
		Sum(tabxsthdj.je) AS sumje, \
		tabxsthdj.yp_id AS yp_id,tabypinfo.yp_name \
		FROM tabxsthdj, tabxsthph, tabypinfo \
		WHERE ((([tabxsthph]![xsth_ph])=[tabxsthdj]![xsth_ph]) \
		AND (([tabxsthph]![rq])=#%s#) AND \
		(([tabxsthdj]![yp_id])=[tabypinfo]![yp_id])) \
		GROUP BY tabxsthdj.yp_id,tabypinfo.yp_name \
		",this->m_strRq);
	else
	sql.Format("SELECT Sum([tabxsthdj]![sl]) AS sumsl, \
		Sum(tabxsthdj.je) AS sumje, \
		tabxsthdj.yp_id AS yp_id,tabypinfo.yp_name \
		FROM tabxsthdj, tabxsthph, tabypinfo \
		WHERE [tabxsthph]![xsth_ph]=[tabxsthdj]![xsth_ph] \
		AND [tabxsthph]![rq]>=#%s# AND [tabxsthph]![rq]<#%s# AND \
		[tabxsthdj]![yp_id]=[tabypinfo]![yp_id] \
		GROUP BY tabxsthdj.yp_id,tabypinfo.yp_name\
		",this->m_strRqDown,this->m_strRqUp);
	return sql;

}
CString CDlgRj::PrepareRKSQL()
{
	CString sql;
	if(this->m_bRj)
	sql.Format("SELECT Sum([tabrkdj]![sl]) AS sumsl, \
		Sum(tabrkdj.je) AS sumje, \
		tabrkdj.yp_id AS yp_id,tabypinfo.yp_name \
		FROM tabrkdj, tabrkph, tabypinfo \
		WHERE ((([tabrkph]![rk_ph])=[tabrkdj]![rk_ph]) \
		AND (([tabrkph]![rq])=#%s#) AND \
		(([tabrkdj]![yp_id])=[tabypinfo]![yp_id])) \
		GROUP BY tabrkdj.yp_id,tabypinfo.yp_name \
		",this->m_strRq);
	else
	sql.Format("SELECT Sum([tabrkdj]![sl]) AS sumsl, \
		Sum(tabrkdj.je) AS sumje, \
		tabrkdj.yp_id AS yp_id,tabypinfo.yp_name \
		FROM tabrkdj, tabrkph, tabypinfo \
		WHERE [tabrkph]![rk_ph]=[tabrkdj]![rk_ph] \
		AND [tabrkph]![rq]>=#%s# AND [tabrkph]![rq]<#%s# AND \
		[tabrkdj]![yp_id]=[tabypinfo]![yp_id] \
		GROUP BY tabrkdj.yp_id,tabypinfo.yp_name\
		",this->m_strRqDown,this->m_strRqUp);
	return sql;
}
CString CDlgRj::PrepareRKTHSQL()
{
	CString sql;
	if(this->m_bRj)
	sql.Format("SELECT Sum([tabrkthdj]![sl]) AS sumsl, \
		Sum(tabrkthdj.je) AS sumje, \
		tabrkthdj.yp_id AS yp_id,tabypinfo.yp_name \
		FROM tabrkthdj, tabrkthph, tabypinfo \
		WHERE ((([tabrkthph]![rkth_ph])=[tabrkthdj]![rkth_ph]) \
		AND (([tabrkthph]![rq])=#%s#) AND \
		(([tabrkthdj]![yp_id])=[tabypinfo]![yp_id])) \
		GROUP BY tabrkthdj.yp_id,tabypinfo.yp_name \
		",this->m_strRq);
	else
	sql.Format("SELECT Sum([tabrkthdj]![sl]) AS sumsl, \
		Sum(tabrkthdj.je) AS sumje, \
		tabrkthdj.yp_id AS yp_id,tabypinfo.yp_name \
		FROM tabrkthdj, tabrkthph, tabypinfo \
		WHERE [tabrkthph]![rkth_ph]=[tabrkthdj]![rkth_ph] \
		AND [tabrkthph]![rq]>=#%s# AND [tabrkthph]![rq]<#%s# AND \
		[tabrkthdj]![yp_id]=[tabypinfo]![yp_id] \
		GROUP BY tabrkthdj.yp_id,tabypinfo.yp_name\
		",this->m_strRqDown,this->m_strRqUp);
	return sql;
}

int CDlgRj::RefreshXSList(int i)
{
	CString sql;
	sql=this->PrepareXSSQL();
	afxDump<<"\n"<<sql;
	if(!m_runsql.CheckSQLResult(sql))
	{
		m_list.SetRedraw(true);	
		return --i;
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -