本文介绍了如何将c ++转换为c#... pls ..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

// BrowserView.cpp : implementation of the CBrowserView class
//
#include "stdafx.h"
#include "TMAPro.h"
#include "MainDoc.h"
#include "BrowserView.h"
#include "TableView.h"
#include "ConfigFrm.h"
#include "DlgFindLejer.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBrowserView
IMPLEMENT_DYNCREATE(CBrowserView, CTreeView)
BEGIN_MESSAGE_MAP(CBrowserView, CTreeView)
	//{{AFX_MSG_MAP(CBrowserView)
	ON_NOTIFY_REFLECT(TVN_SELCHANGED, OnSelchanged)
	ON_NOTIFY_REFLECT(NM_RCLICK, OnRclick)
	ON_NOTIFY_REFLECT(NM_CLICK, OnClick)
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CTreeView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CTreeView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CTreeView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBrowserView construction/destruction
CBrowserView::CBrowserView()
{
	// TODO: add construction code here
	m_bFilled = FALSE;
}
CBrowserView::~CBrowserView()
{
}
BOOL CBrowserView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs
	return CTreeView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CBrowserView drawing
void CBrowserView::OnDraw(CDC* pDC)
{
	CMainDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CBrowserView printing
BOOL CBrowserView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}
void CBrowserView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}
void CBrowserView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}
void CBrowserView::OnInitialUpdate()
{
	CTreeView::OnInitialUpdate();
	// TODO: You may populate your TreeView with items by directly accessing
	//  its tree control through a call to GetTreeCtrl().
	CTreeCtrl& ctrlTree = GetTreeCtrl();
	ModifyStyle(
		LVS_TYPEMASK,
		TVS_DISABLEDRAGDROP|
		TVS_SHOWSELALWAYS|
		TVS_LINESATROOT|
		TVS_HASLINES|
		TVS_HASBUTTONS
		);
	CImageList *pImageList = new CImageList();
	pImageList->Create(IDB_TREEIMAGE, 16, 8, COLORREF(RGB(0,128,128)));
	ctrlTree.SetImageList(pImageList, TVSIL_NORMAL);
}
/////////////////////////////////////////////////////////////////////////////
// CBrowserView diagnostics
#ifdef _DEBUG
void CBrowserView::AssertValid() const
{
	CTreeView::AssertValid();
}
void CBrowserView::Dump(CDumpContext& dc) const
{
	CTreeView::Dump(dc);
}
CMainDoc* CBrowserView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMainDoc)));
	return (CMainDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CBrowserView message handlers
void CBrowserView::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
	// TODO: Add your control notification handler code here
	OnItemSelectChanged();
	*pResult = 0;
}
void CBrowserView::OnItemSelectChanged()
{
	CString strWhere;
	CTreeCtrl& ctrlTree = GetTreeCtrl();
	CConfigFrame* pFWnd = (CConfigFrame*)this->GetParentFrame();
	CTableView *pRightView = pFWnd->GetRightPane();
	CMainApp *pApp = (CMainApp *)AfxGetApp();
	CListCtrl& ctrlList = pRightView->GetListCtrl();
	// Get selected module item
	HTREEITEM itmSel = ctrlTree.GetSelectedItem();
	if(itmSel == m_itemSumAllLedger)    //item from table_sumalllejer
	{
		m_strTableName = _T("TABLE_SUMALLLEJER");
		pRightView->m_strTransaction = _T("REPORT");
		pRightView->m_strTableName = _T("TABLE_SUMALLLEJER");
		pApp->Update_SumAllLejer(NULL);
		pApp->m_pSet->SQLFillListCtrlReport_Table(
			&ctrlList, "SELECT * FROM TABLE_SUMALLLEJER");
		pFWnd->m_strSQL = _T("SELECT * FROM TABLE_SUMALLLEJER");
	}
	else if(itmSel == m_itemSumAsset)   //item from table_aset
	{
		m_strTableName = _T("TABLE_ASET");
		pRightView->m_strTransaction = _T("REPORT");
		pRightView->m_strTableName = _T("TABLE_ASET");
		pApp->Update_SumAset(NULL);
		pApp->m_pSet->SQLFillListCtrlReport_Table(
			&ctrlList, "SELECT * FROM TABLE_ASET");
		pFWnd->m_strSQL = _T("SELECT * FROM TABLE_ASET");
	}
	else if(itmSel == m_itemSumCurAsset)	// sum all aset semasa
	{
		m_strTableName = _T("TABLE_ASETSEMASA");
		pRightView->m_strTransaction = _T("REPORT");
		pRightView->m_strTableName = _T("TABLE_ASETSEMASA");
		pApp->Update_SumAsetSemasa(NULL);
		pApp->m_pSet->SQLFillListCtrlReport_Table(
			&ctrlList, "SELECT * FROM TABLE_ASETSEMASA");
		pFWnd->m_strSQL = _T("SELECT * FROM TABLE_ASETSEMASA");
	}
	else if(itmSel == m_itemSumKumpWang)	// sum all kumpulan wang
	{
		m_strTableName = _T("TABLE_KUMPWANG");
		pRightView->m_strTransaction = _T("REPORT");
		pRightView->m_strTableName = _T("TABLE_KUMPWANG");
		pApp->Update_SumKumpWang(NULL);
		pApp->m_pSet->SQLFillListCtrlReport_Table(
			&ctrlList, "SELECT * FROM TABLE_KUMPWANG");
		pFWnd->m_strSQL = _T("SELECT * FROM TABLE_KUMPWANG");
	}
	else if(itmSel == m_itemSumLiability)	// sum all liabiliti
	{
		m_strTableName = _T("TABLE_LIABILITI");
		pRightView->m_strTransaction = _T("REPORT");
		pRightView->m_strTableName = _T("TABLE_LIABILITI");
		pApp->Update_SumLiabiliti(NULL);
		pApp->m_pSet->SQLFillListCtrlReport_Table(
			&ctrlList, "SELECT * FROM TABLE_LIABILITI");
		pFWnd->m_strSQL = _T("SELECT * FROM TABLE_LIABILITI");
	}
	else if(itmSel == m_itemSumCurLiability)	// sum all liabiliti semasa
	{
		m_strTableName = _T("TABLE_LIABILITISEMASA");
		pRightView->m_strTransaction = _T("REPORT");
		pRightView->m_strTableName = _T("TABLE_LIABILITISEMASA");
		pApp->Update_SumLiabilitiSemasa(NULL);
		pApp->m_pSet->SQLFillListCtrlReport_Table(
			&ctrlList, "SELECT * FROM TABLE_LIABILITISEMASA");
		pFWnd->m_strSQL = _T("SELECT * FROM TABLE_LIABILITISEMASA");
	}
	else if(itmSel == m_itemAsetTetap)		// List item aset tetap - jika ada list baru tamb di sini
	{
		CDlgFindLejer dlg;
		if(dlg.DoModal() == IDOK)
		{
			if(dlg.m_strWhere.IsEmpty())
				strWhere.Format("SELECT * FROM L1011 ORDER BY ID ASC");
			else
				strWhere.Format("SELECT * FROM L1011 WHERE %s ORDER BY ID ASC", dlg.m_strWhere);
			pApp->m_pSet->SQLFillListCtrlReport_Table(
				&pRightView->GetListCtrl(),
				strWhere);
			pFWnd->m_strSQL = strWhere;
		}
	}
	else if(itmSel == m_itemProjekRumah)		// List item projek perumahan
	{
		CDlgFindLejer dlg;
		if(dlg.DoModal() == IDOK)
		{
			if(dlg.m_strWhere.IsEmpty())
				strWhere.Format("SELECT * FROM L1016 ORDER BY ID ASC");
			else
				strWhere.Format("SELECT * FROM L1016 WHERE %s ORDER BY ID ASC", dlg.m_strWhere);
			pApp->m_pSet->SQLFillListCtrlReport_Table(
				&pRightView->GetListCtrl(),
				strWhere);
			pFWnd->m_strSQL = strWhere;
		}
	}
	else if(itmSel == m_itemProjekRumahAhli)		// List item projek perumahan anggota
	{
		CDlgFindLejer dlg;
		if(dlg.DoModal() == IDOK)
		{
			if(dlg.m_strWhere.IsEmpty())
				strWhere.Format("SELECT * FROM L1017 ORDER BY ID ASC");
			else
				strWhere.Format("SELECT * FROM L1017 WHERE %s ORDER BY ID ASC", dlg.m_strWhere);
			pApp->m_pSet->SQLFillListCtrlReport_Table(
				&pRightView->GetListCtrl(),
				strWhere);
			pFWnd->m_strSQL = strWhere;
		}
	}
	else if(itmSel == m_itemProjekInfra)		// List item infrastruktur
	{
		CDlgFindLejer dlg;
		if(dlg.DoModal() == IDOK)
		{
			if(dlg.m_strWhere.IsEmpty())
				strWhere.Format("SELECT * FROM L1018 ORDER BY ID ASC");
			else
				strWhere.Format("SELECT * FROM L1018 WHERE %s ORDER BY ID ASC", dlg.m_strWhere);
			pApp->m_pSet->SQLFillListCtrlReport_Table(
				&pRightView->GetListCtrl(),
				strWhere);
			pFWnd->m_strSQL = strWhere;
		}
	}
	else if(itmSel == m_itemPendapatan)		// List item hasil
	{
		CDlgFindLejer dlg;
		if(dlg.DoModal() == IDOK)
		{
			if(dlg.m_strWhere.IsEmpty())
				strWhere.Format("SELECT * FROM L2020 ORDER BY ID ASC");
			else
				strWhere.Format("SELECT * FROM L2020 WHERE %s ORDER BY ID ASC", dlg.m_strWhere);
			pApp->m_pSet->SQLFillListCtrlReport_Table(
				&pRightView->GetListCtrl(),
				strWhere);
			pFWnd->m_strSQL = strWhere;
		}
	}
	else if(itmSel == m_itemPerbelanjaan)   // list all perbelanjaan
	{
		CDlgFindLejer dlg;
		if(dlg.DoModal() == IDOK)
		{
			if(dlg.m_strWhere.IsEmpty())
				strWhere.Format("SELECT * FROM L1313 ORDER BY ID ASC");
			else
				strWhere.Format("SELECT * FROM L1313 WHERE %s ORDER BY ID ASC", dlg.m_strWhere);
			pApp->m_pSet->SQLFillListCtrlReport_Table(
				&pRightView->GetListCtrl(),
				strWhere);
			pFWnd->m_strSQL = strWhere;
		}
	}
	else if(itmSel == m_itemWangBank)    //list all aset semasa
	{
		CDlgFindLejer dlg;
		if(dlg.DoModal() == IDOK)
		{
			if(dlg.m_strWhere.IsEmpty())
				strWhere.Format("SELECT * FROM L1212 ORDER BY ID ASC");
			else
				strWhere.Format("SELECT * FROM L1212 WHERE %s ORDER BY ID ASC", dlg.m_strWhere);
			pApp->m_pSet->SQLFillListCtrlReport_Table(
				&pRightView->GetListCtrl(),
				strWhere);
			pFWnd->m_strSQL = strWhere;
		}
	}
	else if(itmSel == m_itemPenghutang)   // list all penghutang
	{
		CDlgFindLejer dlg;
		if(dlg.DoModal() == IDOK)
		{
			if(dlg.m_strWhere.IsEmpty())
				strWhere.Format("SELECT * FROM L1214 ORDER BY ID ASC");
			else
				strWhere.Format("SELECT * FROM L1214 WHERE %s ORDER BY ID ASC", dlg.m_strWhere);
			pApp->m_pSet->SQLFillListCtrlReport_Table(
				&pRightView->GetListCtrl(),
				strWhere);
			pFWnd->m_strSQL = strWhere;
		}
	}
	else if(itmSel == m_itemPelaburan)   // list all pelaburan - 22 Dis 06
	{
		CDlgFindLejer dlg;
		if(dlg.DoModal() == IDOK)
		{
			if(dlg.m_strWhere.IsEmpty())
				strWhere.Format("SELECT * FROM L1013 ORDER BY ID ASC");
			else
				strWhere.Format("SELECT * FROM L1013 WHERE %s ORDER BY ID ASC", dlg.m_strWhere);
			pApp->m_pSet->SQLFillListCtrlReport_Table(
				&pRightView->GetListCtrl(),
				strWhere);
			pFWnd->m_strSQL = strWhere;
		}
	}
	else if(itmSel == m_itemCagaran)   // list all cagaran - 22 Dis 06
	{
		CDlgFindLejer dlg;
		if(dlg.DoModal() == IDOK)
		{
			if(dlg.m_strWhere.IsEmpty())
				strWhere.Format("SELECT * FROM L1219 ORDER BY ID ASC");
			else
				strWhere.Format("SELECT * FROM L1219 WHERE %s ORDER BY ID ASC", dlg.m_strWhere);
			pApp->m_pSet->SQLFillListCtrlReport_Table(
				&pRightView->GetListCtrl(),
				strWhere);
			pFWnd->m_strSQL = strWhere;
		}
	}
	else if(itmSel == m_itemPemiutang)   // list all pemiutang - 22 Dis 06
	{
		CDlgFindLejer dlg;
		if(dlg.DoModal() == IDOK)
		{
			if(dlg.m_strWhere.IsEmpty())
				strWhere.Format("SELECT * FROM L2504 ORDER BY ID ASC");
			else
				strWhere.Format("SELECT * FROM L2504 WHERE %s ORDER BY ID ASC", dlg.m_strWhere);
			pApp->m_pSet->SQLFillListCtrlReport_Table(
				&pRightView->GetListCtrl(),
				strWhere);
			pFWnd->m_strSQL = strWhere;
		}
	}
	else
	{
		if((ctrlTree.GetItemText(ctrlTree.GetParentItem(itmSel)) == "All") ||
			(ctrlTree.GetItemText(ctrlTree.GetParentItem(itmSel)) == "Aset") ||
			(ctrlTree.GetItemText(ctrlTree.GetParentItem(itmSel)) == "Aset Semasa") ||
			(ctrlTree.GetItemText(ctrlTree.GetParentItem(itmSel)) == "Kumpulan Wang") ||
			(ctrlTree.GetItemText(ctrlTree.GetParentItem(itmSel)) == "Liabiliti") ||
			(ctrlTree.GetItemText(ctrlTree.GetParentItem(itmSel)) == "Liabiliti Semasa"))
		{
			CDlgFindLejer dlg;
			if(dlg.DoModal() == IDOK)
			{
				if(dlg.m_strWhere.IsEmpty())
					strWhere.Format("SELECT * FROM L%s ORDER BY ID ASC",
						ctrlTree.GetItemText(itmSel).Left(4));
				else
					strWhere.Format("SELECT * FROM L%s WHERE %s ORDER BY ID ASC",
						ctrlTree.GetItemText(itmSel).Left(4),
						dlg.m_strWhere);
				
				pApp->m_pSet->SQLFillListCtrlReport_Table(
					&pRightView->GetListCtrl(),
					strWhere);
				pFWnd->m_strSQL = strWhere;
			}
		}
		else if(ctrlTree.GetParentItem(itmSel) == m_itemAsetTetap)
		{
			strWhere.Format("SELECT * FROM L1011 \
				WHERE KodObjek = ''%s'' ORDER BY ID ASC",
				ctrlTree.GetItemText(itmSel).Left(3));
			pApp->m_pSet->SQLFillListCtrlReport_Table(
				&pRightView->GetListCtrl(),
				strWhere);
			pFWnd->m_strSQL = strWhere;
		}
		else if(ctrlTree.GetParentItem(itmSel) == m_itemProjekRumah)
		{
			strWhere.Format("SELECT * FROM L1016 \
				WHERE KodObjek = ''%s'' ORDER BY ID ASC",
				ctrlTree.GetItemText(itmSel).Left(3));
			pApp->m_pSet->SQLFillListCtrlReport_Table(
				&pRightView->GetListCtrl(),
				strWhere);
			pFWnd->m_strSQL = strWhere;
		}
		else if(ctrlTree.GetParentItem(itmSel) == m_itemProjekRumahAhli)
		{
			strWhere.Format("SELECT * FROM L1017 \
				WHERE KodObjek = ''%s'' ORDER BY ID ASC",
				ctrlTree.GetItemText(itmSel).Left(3));
			pApp->m_pSet->SQLFillListCtrlReport_Table(
				&pRightView->GetListCtrl(),
				strWhere);
			pFWnd->m_strSQL = strWhere;
		}
		else if(ctrlTree.GetParentItem(itmSel) == m_itemProjekInfra)
		{
			strWhere.Format("SELECT * FROM L1018 \
				WHERE KodObjek = ''%s'' ORDER BY ID ASC",
				ctrlTree.GetItemText(itmSel).Left(3));
			pApp->m_pSet->SQLFillListCtrlReport_Table(
				&pRightView->GetListCtrl(),
				strWhere);
			pFWnd->m_strSQL = strWhere;
		}
		else if(ctrlTree.GetParentItem(itmSel) == m_itemWangBank)
		{
			strWhere.Format("SELECT * FROM L1212 \
				WHERE KodObjek = ''%s'' ORDER BY ID ASC",
				ctrlTree.GetItemText(itmSel).Left(3));
			pApp->m_pSet->SQLFillListCtrlReport_Table(
				&pRightView->GetListCtrl(),
				strWhere);
			pFWnd->m_strSQL = strWhere;
		}
		else if(ctrlTree.GetParentItem(itmSel) == m_itemPerbelanjaan)
		{
			strWhere.Format("SELECT * FROM L1313 \
				WHERE KodObjek = ''%s'' ORDER BY ID ASC",
				ctrlTree.GetItemText(itmSel).Left(3));
			pApp->m_pSet->SQLFillListCtrlReport_Table(
				&pRightView->GetListCtrl(),
				strWhere);
			pFWnd->m_strSQL = strWhere;
		}
		else if(ctrlTree.GetParentItem(itmSel) == m_itemPendapatan)
		{
			strWhere.Format("SELECT * FROM L2020 \
				WHERE KodObjek = ''%s'' ORDER BY ID ASC",
				ctrlTree.GetItemText(itmSel).Left(3));
			pApp->m_pSet->SQLFillListCtrlReport_Table(
				&pRightView->GetListCtrl(),
				strWhere);
			pFWnd->m_strSQL = strWhere;
		}
		else if(ctrlTree.GetParentItem(itmSel) == m_itemPenghutang)		//add on 27 Jul 05
		{
			strWhere.Format("SELECT * FROM L1214 \
				WHERE KodObjek = ''%s'' ORDER BY ID ASC",
				ctrlTree.GetItemText(itmSel).Left(3));
			pApp->m_pSet->SQLFillListCtrlReport_Table(
				&pRightView->GetListCtrl(),
				strWhere);
			pFWnd->m_strSQL = strWhere;
		}
		else if(ctrlTree.GetParentItem(itmSel) == m_itemPelaburan)		//add on 19 Dis 06
		{
			strWhere.Format("SELECT * FROM L1013 \
				WHERE KodObjek = ''%s'' ORDER BY ID ASC",
				ctrlTree.GetItemText(itmSel).Left(3));
			pApp->m_pSet->SQLFillListCtrlReport_Table(
				&pRightView->GetListCtrl(),
				strWhere);
			pFWnd->m_strSQL = strWhere;
		}
		else if(ctrlTree.GetParentItem(itmSel) == m_itemCagaran)		//add on 19 Dis 06
		{
			strWhere.Format("SELECT * FROM L1219 \
				WHERE KodObjek = ''%s'' ORDER BY ID ASC",
				ctrlTree.GetItemText(itmSel).Left(3));
			pApp->m_pSet->SQLFillListCtrlReport_Table(
				&pRightView->GetListCtrl(),
				strWhere);
			pFWnd->m_strSQL = strWhere;
		}
		else if(ctrlTree.GetParentItem(itmSel) == m_itemPemiutang)		//add on 19 Dis 06
		{
			strWhere.Format("SELECT * FROM L2504 \
				WHERE KodObjek = ''%s'' ORDER BY ID ASC",
				ctrlTree.GetItemText(itmSel).Left(3));
			pApp->m_pSet->SQLFillListCtrlReport_Table(
				&pRightView->GetListCtrl(),
				strWhere);
			pFWnd->m_strSQL = strWhere;
		}
		else
		{
			m_strTableName = _T("");
			pRightView->m_strTableName = _T("");
			pRightView->ResetListControl();
			pFWnd->m_strSQL = _T("");
		}
	}
}
/////////////////////////LEJER KATEGORI-ALL/////////////////////////
void CBrowserView::FillLejerItems()
{
	CTreeCtrl& ctrlTree = GetTreeCtrl();
	CMainApp *pApp = (CMainApp *)AfxGetApp();
	if(pApp->m_database.IsOpen())
	{
		HTREEITEM itm = ctrlTree.GetChildItem(m_itemSumAllLedger);
		while(itm != NULL)
		{
			ctrlTree.DeleteItem(itm);
			itm = ctrlTree.GetChildItem(m_itemSumAllLedger);
		}
		CString strSQL, strLejer;
		HTREEITEM subLjr = TVI_LAST;
		
		strSQL.Format("SELECT CAST(LejerID as nvarchar(4)) + '' - '' + Nama FROM TABLE_KODLEJER ORDER BY LejerID ASC");
		pApp->m_pSet->ExecDirect(strSQL);
		
		while(!pApp->m_pSet->IsEOF())
		{
			pApp->m_pSet->GetFieldValue(0, strLejer);
			subLjr = ctrlTree.InsertItem(strLejer, m_itemSumAllLedger, subLjr);
			
			if(strLejer.Left(1) == _T("1"))
				ctrlTree.SetItemImage(subLjr, 2, 7);
			else if(strLejer.Left(1) == _T("2"))
				ctrlTree.SetItemImage(subLjr, 3, 7);
			else
				ctrlTree.SetItemImage(subLjr, 4, 7);
			pApp->m_pSet->MoveNext();
		}
		pApp->m_pSet->Close();
	}
}
///////////////////////////LEJER KATEGORI/////////////////////////
void CBrowserView::FillAsetItems()
{
	CTreeCtrl& ctrlTree = GetTreeCtrl();
	CMainApp *pApp = (CMainApp *)AfxGetApp();
	if(pApp->m_database.IsOpen())
	{
		HTREEITEM itm = ctrlTree.GetChildItem(m_itemSumAsset);
		while(itm != NULL)
		{
			ctrlTree.DeleteItem(itm);
			itm = ctrlTree.GetChildItem(m_itemSumAsset);
		}
		CString strSQL, strLejer;
		strSQL.Format("SELECT CAST(LejerID as nvarchar(4)) + '' - '' + Nama FROM TABLE_KODLEJER WHERE Kategori = ''ASET'' ORDER BY LejerID ASC");
		pApp->m_pSet->ExecDirect(strSQL);
		
		HTREEITEM subItem = TVI_LAST;
		while(!pApp->m_pSet->IsEOF())
		{
			pApp->m_pSet->GetFieldValue(0, strLejer);
			subItem = ctrlTree.InsertItem(strLejer, m_itemSumAsset, subItem);
			ctrlTree.SetItemImage(subItem, 2, 7);
			pApp->m_pSet->MoveNext();
		}
		pApp->m_pSet->Close();
	}
}
///////////////////////////LEJER KATEGORI/////////////////////////
void CBrowserView::FillAsetSemasaItems()
{
	CTreeCtrl& ctrlTree = GetTreeCtrl();
	CMainApp *pApp = (CMainApp *)AfxGetApp();
	if(pApp->m_database.IsOpen())
	{
		HTREEITEM itm = ctrlTree.GetChildItem(m_itemSumCurAsset);
		while(itm != NULL)
		{
			ctrlTree.DeleteItem(itm);
			itm = ctrlTree.GetChildItem(m_itemSumCurAsset);
		}
		CString strSQL, strLejer;
		strSQL.Format("SELECT CAST(LejerID as nvarchar(4)) + '' - '' + Nama FROM TABLE_KODLEJER WHERE Kategori = ''ASET SEMASA'' ORDER BY LejerID ASC");
		pApp->m_pSet->ExecDirect(strSQL);
		
		CString strObjek, strKod, strNama;
		HTREEITEM subItem = TVI_LAST;
		while(!pApp->m_pSet->IsEOF())
		{
			pApp->m_pSet->GetFieldValue(0, strLejer);
			subItem = ctrlTree.InsertItem(strLejer, m_itemSumCurAsset, subItem);
			ctrlTree.SetItemImage(subItem, 2, 7);
			pApp->m_pSet->MoveNext();
		}
		pApp->m_pSet->Close();
	}
}
///////////////////////////LEJER KATEGORI/////////////////////////
void CBrowserView::FillKumpWangItems()
{
	CTreeCtrl& ctrlTree = GetTreeCtrl();
	CMainApp *pApp = (CMainApp *)AfxGetApp();
	if(pApp->m_database.IsOpen())
	{
		HTREEITEM itm = ctrlTree.GetChildItem(m_itemSumKumpWang);
		while(itm != NULL)
		{
			ctrlTree.DeleteItem(itm);
			itm = ctrlTree.GetChildItem(m_itemSumKumpWang);
		}
		CString strSQL, strLejer;
		strSQL.Format("SELECT CAST(LejerID as nvarchar(4)) + '' - '' + Nama FROM TABLE_KODLEJER WHERE Kategori = ''KUMPULAN WANG ANGGOTA'' ORDER BY LejerID ASC");
		pApp->m_pSet->ExecDirect(strSQL);
		
		HTREEITEM subItem = TVI_LAST;
		while(!pApp->m_pSet->IsEOF())
		{
			pApp->m_pSet->GetFieldValue(0, strLejer);
			subItem = ctrlTree.InsertItem(strLejer, m_itemSumKumpWang, subItem);
			ctrlTree.SetItemImage(subItem, 2, 7);
			pApp->m_pSet->MoveNext();
		}
		pApp->m_pSet->Close();
	}
}
///////////////////////////LEJER KATEGORI/////////////////////////
void CBrowserView::FillLiabilitiItems()
{
	CTreeCtrl& ctrlTree = GetTreeCtrl();
	CMainApp *pApp = (CMainApp *)AfxGetApp();
	if(pApp->m_database.IsOpen())
	{
		HTREEITEM itm = ctrlTree.GetChildItem(m_itemSumLiability);
		while(itm != NULL)
		{
			ctrlTree.DeleteItem(itm);
			itm = ctrlTree.GetChildItem(m_itemSumLiability);
		}
		CString strSQL, strLejer;
		strSQL.Format("SELECT CAST(LejerID as nvarchar(4)) + '' - '' + Nama FROM TABLE_KODLEJER WHERE Kategori = ''LIABILITI'' ORDER BY LejerID ASC");
		pApp->m_pSet->ExecDirect(strSQL);
		
		HTREEITEM subItem = TVI_LAST;
		while(!pApp->m_pSet->IsEOF())
		{
			pApp->m_pSet->GetFieldValue(0, strLejer);
			subItem = ctrlTree.InsertItem(strLejer, m_itemSumLiability, subItem);
			ctrlTree.SetItemImage(subItem, 2, 7);
			pApp->m_pSet->MoveNext();
		}
		pApp->m_pSet->Close();
	}
}
///////////////////////////LEJER KATEGORI/////////////////////////
void CBrowserView::FillLiabilitiSemasaItems()
{
	CTreeCtrl& ctrlTree = GetTreeCtrl();
	CMainApp *pApp = (CMainApp *)AfxGetApp();
	if(pApp->m_database.IsOpen())
	{
		HTREEITEM itm = ctrlTree.GetChildItem(m_itemSumCurLiability);
		while(itm != NULL)
		{
			ctrlTree.DeleteItem(itm);
			itm = ctrlTree.GetChildItem(m_itemSumCurLiability);
		}
		CString strSQL, strLejer;
		strSQL.Format("SELECT CAST(LejerID as nvarchar(4)) + '' - '' + Nama FROM TABLE_KODLEJER WHERE Kategori = ''LIABILITI SEMASA'' ORDER BY LejerID ASC");
		pApp->m_pSet->ExecDirect(strSQL);
		
		HTREEITEM subItem = TVI_LAST;
		while(!pApp->m_pSet->IsEOF())
		{
			pApp->m_pSet->GetFieldValue(0, strLejer);
			subItem = ctrlTree.InsertItem(strLejer, m_itemSumCurLiability, subItem);
			ctrlTree.SetItemImage(subItem, 2, 7);
			pApp->m_pSet->MoveNext();
		}
		pApp->m_pSet->Close();
	}
}
///////////////////////////LEJER OBJEK/////////////////////////
void CBrowserView::FillBelanjaItems()		//list kategori perbelanjaan 
{
	CTreeCtrl& ctrlTree = GetTreeCtrl();
	CMainApp *pApp = (CMainApp *)AfxGetApp();
	if(pApp->m_database.IsOpen())
	{
		HTREEITEM itm = ctrlTree.GetChildItem(m_itemPerbelanjaan);
		while(itm != NULL)
		{
			ctrlTree.DeleteItem(itm);
			itm = ctrlTree.GetChildItem(m_itemPerbelanjaan);
		}
		CString strSQL, strObjek;
		strSQL.Format("SELECT CAST(ObjekID as nvarchar(3)) + '' - '' + Nama FROM TABLE_KODOBJEK WHERE Kategori = ''PERBELANJAAN'' ORDER BY ObjekID ASC");
		pApp->m_pSet->ExecDirect(strSQL);
		
		HTREEITEM subItem = TVI_LAST;
		while(!pApp->m_pSet->IsEOF())
		{
			pApp->m_pSet->GetFieldValue(0, strObjek);
			subItem = ctrlTree.InsertItem(strObjek, m_itemPerbelanjaan, subItem);
			ctrlTree.SetItemImage(subItem, 2, 7);
			pApp->m_pSet->MoveNext();
		}
		pApp->m_pSet->Close();
	}
}
///////////////////////////LEJER OBJEK/////////////////////////
void CBrowserView::FillHasilItems()		//list kategori pendapatan
{
	CTreeCtrl& ctrlTree = GetTreeCtrl();
	CMainApp *pApp = (CMainApp *)AfxGetApp();
	if(pApp->m_database.IsOpen())
	{
		HTREEITEM itm = ctrlTree.GetChildItem(m_itemPendapatan);
		while(itm != NULL)
		{
			ctrlTree.DeleteItem(itm);
			itm = ctrlTree.GetChildItem(m_itemPendapatan);
		}
		CString strSQL, strObjek;
		strSQL.Format("SELECT CAST(ObjekID as nvarchar(3)) + '' - '' + Nama FROM TABLE_KODOBJEK WHERE Kategori = ''PENDAPATAN'' ORDER BY ObjekID ASC");
		pApp->m_pSet->ExecDirect(strSQL);
		
		HTREEITEM subItem = TVI_LAST;
		while(!pApp->m_pSet->IsEOF())
		{
			pApp->m_pSet->GetFieldValue(0, strObjek);
			subItem = ctrlTree.InsertItem(strObjek, m_itemPendapatan, subItem);
			ctrlTree.SetItemImage(subItem, 2, 7);
			pApp->m_pSet->MoveNext();
		}
		pApp->m_pSet->Close();
	}
}
///////////////////////////LEJER OBJEK/////////////////////////
void CBrowserView::FillAsetTetapItems()		//list kategori aset tetap
{
	CTreeCtrl& ctrlTree = GetTreeCtrl();
	CMainApp *pApp = (CMainApp *)AfxGetApp();
	if(pApp->m_database.IsOpen())
	{
		HTREEITEM itm = ctrlTree.GetChildItem(m_itemAsetTetap);
		while(itm != NULL)
		{
			ctrlTree.DeleteItem(itm);
			itm = ctrlTree.GetChildItem(m_itemAsetTetap);
		}
		CString strSQL, strObjek;
		strSQL.Format("SELECT CAST(ObjekID as nvarchar(3)) + '' - '' + Nama FROM TABLE_KODOBJEK WHERE Kategori = ''ASET TETAP'' ORDER BY ObjekID ASC");
		pApp->m_pSet->ExecDirect(strSQL);
		
		HTREEITEM subItem = TVI_LAST;
		while(!pApp->m_pSet->IsEOF())
		{
			pApp->m_pSet->GetFieldValue(0, strObjek);
			subItem = ctrlTree.InsertItem(strObjek, m_itemAsetTetap, subItem);
			ctrlTree.SetItemImage(subItem, 2, 7);
			pApp->m_pSet->MoveNext();
		}
		pApp->m_pSet->Close();
	}
}

///////////////////////////LEJER OBJEK/////////////////////////
void CBrowserView::FillProjekInfraItems()
{
	CTreeCtrl& ctrlTree = GetTreeCtrl();
	CMainApp *pApp = (CMainApp *)AfxGetApp();
	if(pApp->m_database.IsOpen())
	{
		HTREEITEM itm = ctrlTree.GetChildItem(m_itemProjekInfra);
		while(itm != NULL)
		{
			ctrlTree.DeleteItem(itm);
			itm = ctrlTree.GetChildItem(m_itemProjekInfra);
		}
		CString strSQL, strObjek;
		strSQL.Format("SELECT CAST(ObjekID as nvarchar(3)) + '' - '' + Nama FROM TABLE_KODOBJEK WHERE Kategori = ''BELANJA PROJEK'' ORDER BY ObjekID ASC");
		pApp->m_pSet->ExecDirect(strSQL);
		
		HTREEITEM subItem = TVI_LAST;
		while(!pApp->m_pSet->IsEOF())
		{
			pApp->m_pSet->GetFieldValue(0, strObjek);
			subItem = ctrlTree.InsertItem(strObjek, m_itemProjekInfra, subItem);
			ctrlTree.SetItemImage(subItem, 2, 7);
			pApp->m_pSet->MoveNext();
		}
		pApp->m_pSet->Close();
	}
}
///////////////////////////LEJER OBJEK/////////////////////////
void CBrowserView::FillProjekRumahItems()
{
	CTreeCtrl& ctrlTree = GetTreeCtrl();
	CMainApp *pApp = (CMainApp *)AfxGetApp();
	if(pApp->m_database.IsOpen())
	{
		HTREEITEM itm = ctrlTree.GetChildItem(m_itemProjekRumah);
		while(itm != NULL)
		{
			ctrlTree.DeleteItem(itm);
			itm = ctrlTree.GetChildItem(m_itemProjekRumah);
		}
		CString strSQL, strObjek;
		strSQL.Format("SELECT CAST(ObjekID as nvarchar(3)) + '' - '' + Nama FROM TABLE_KODOBJEK WHERE Kategori = ''BELANJA PROJEK'' ORDER BY ObjekID ASC");
		pApp->m_pSet->ExecDirect(strSQL);
		
		HTREEITEM subItem = TVI_LAST;
		while(!pApp->m_pSet->IsEOF())
		{
			pApp->m_pSet->GetFieldValue(0, strObjek);
			subItem = ctrlTree.InsertItem(strObjek, m_itemProjekRumah, subItem);
			ctrlTree.SetItemImage(subItem, 2, 7);
			pApp->m_pSet->MoveNext();
		}
		pApp->m_pSet->Close();
	}
}

///////////////////////////LEJER OBJEK/////////////////////////
void CBrowserView::FillProjekRumahAhliItems()
{
	CTreeCtrl& ctrlTree = GetTreeCtrl();
	CMainApp *pApp = (CMainApp *)AfxGetApp();
	if(pApp->m_database.IsOpen())
	{
		HTREEITEM itm = ctrlTree.GetChildItem(m_itemProjekRumahAhli);
		while(itm != NULL)
		{
			ctrlTree.DeleteItem(itm);
			itm = ctrlTree.GetChildItem(m_itemProjekRumahAhli);
		}
		CString strSQL, strObjek;
		strSQL.Format("SELECT CAST(ObjekID as nvarchar(3)) + '' - '' + Nama FROM TABLE_KODOBJEK WHERE Kategori = ''BELANJA PROJEK'' ORDER BY ObjekID ASC");
		pApp->m_pSet->ExecDirect(strSQL);
		
		HTREEITEM subItem = TVI_LAST;
		while(!pApp->m_pSet->IsEOF())
		{
			pApp->m_pSet->GetFieldValue(0, strObjek);
			subItem = ctrlTree.InsertItem(strObjek, m_itemProjekRumahAhli, subItem);
			ctrlTree.SetItemImage(subItem, 2, 7);
			pApp->m_pSet->MoveNext();
		}
		pApp->m_pSet->Close();
	}
}
///////////////////////////LEJER OBJEK/////////////////////////
void CBrowserView::FillWangBankItems()
{
	CTreeCtrl& ctrlTree = GetTreeCtrl();
	CMainApp *pApp = (CMainApp *)AfxGetApp();
	if(pApp->m_database.IsOpen())
	{
		HTREEITEM itm = ctrlTree.GetChildItem(m_itemWangBank);
		while(itm != NULL)
		{
			ctrlTree.DeleteItem(itm);
			itm = ctrlTree.GetChildItem(m_itemWangBank);
		}
		CString strSQL, strObjek;
		strSQL.Format("SELECT CAST(ObjekID as nvarchar(3)) + '' - '' + Nama FROM TABLE_KODOBJEK Where Kategori = ''ASET SEMASA'' ORDER BY ObjekID ASC");
		pApp->m_pSet->ExecDirect(strSQL);
		
		HTREEITEM subItem = TVI_LAST;
		while(!pApp->m_pSet->IsEOF())
		{
			pApp->m_pSet->GetFieldValue(0, strObjek);
			subItem = ctrlTree.InsertItem(strObjek, m_itemWangBank, subItem);
			ctrlTree.SetItemImage(subItem, 2, 7);
			pApp->m_pSet->MoveNext();
		}
		pApp->m_pSet->Close();
	}
}
///////////////////////////LEJER OBJEK/////////////////////////
void CBrowserView::FillPenghutangItems()   //list kategori penghutang
{
	CTreeCtrl& ctrlTree = GetTreeCtrl();
	CMainApp *pApp = (CMainApp *)AfxGetApp();
	if(pApp->m_database.IsOpen())
	{
		HTREEITEM itm = ctrlTree.GetChildItem(m_itemPenghutang);
		while(itm != NULL)
		{
			ctrlTree.DeleteItem(itm);
			itm = ctrlTree.GetChildItem(m_itemPenghutang);
		}
		CString strSQL, strObjek;
		strSQL.Format("SELECT CAST(ObjekID as nvarchar(3)) + '' - '' + Nama FROM TABLE_KODOBJEK WHERE Kategori = ''PENGHUTANG'' ORDER BY ObjekID ASC");
		pApp->m_pSet->ExecDirect(strSQL);
		
		HTREEITEM subItem = TVI_LAST;
		while(!pApp->m_pSet->IsEOF())
		{
			pApp->m_pSet->GetFieldValue(0, strObjek);
			subItem = ctrlTree.InsertItem(strObjek, m_itemPenghutang, subItem);
			ctrlTree.SetItemImage(subItem, 2, 7);
			pApp->m_pSet->MoveNext();
		}
		pApp->m_pSet->Close();
	}
}
///////////////////////////LEJER OBJEK /////////////////////////
void CBrowserView::FillPelaburanItems()   //list kategori pelaburan
{
	CTreeCtrl& ctrlTree = GetTreeCtrl();
	CMainApp *pApp = (CMainApp *)AfxGetApp();
	if(pApp->m_database.IsOpen())
	{
		HTREEITEM itm = ctrlTree.GetChildItem(m_itemPelaburan);
		while(itm != NULL)
		{
			ctrlTree.DeleteItem(itm);
			itm = ctrlTree.GetChildItem(m_itemPelaburan);
		}
		CString strSQL, strObjek;
		strSQL.Format("SELECT CAST(ObjekID as nvarchar(3)) + '' - '' + Nama FROM TABLE_KODOBJEK WHERE Kategori = ''PELABURAN'' ORDER BY ObjekID ASC");
		pApp->m_pSet->ExecDirect(strSQL);
		
		HTREEITEM subItem = TVI_LAST;
		while(!pApp->m_pSet->IsEOF())
		{
			pApp->m_pSet->GetFieldValue(0, strObjek);
			subItem = ctrlTree.InsertItem(strObjek, m_itemPelaburan, subItem);
			ctrlTree.SetItemImage(subItem, 2, 7);
			pApp->m_pSet->MoveNext();
		}
		pApp->m_pSet->Close();
	}
}
///////////////////////////LEJER OBJEK /////////////////////////
void CBrowserView::FillCagaranItems()   //list kategori cagaran
{
	CTreeCtrl& ctrlTree = GetTreeCtrl();
	CMainApp *pApp = (CMainApp *)AfxGetApp();
	if(pApp->m_database.IsOpen())
	{
		HTREEITEM itm = ctrlTree.GetChildItem(m_itemCagaran);
		while(itm != NULL)
		{
			ctrlTree.DeleteItem(itm);
			itm = ctrlTree.GetChildItem(m_itemCagaran);
		}
		CString strSQL, strObjek;
		strSQL.Format("SELECT CAST(ObjekID as nvarchar(3)) + '' - '' + Nama FROM TABLE_KODOBJEK WHERE Kategori = ''CAGARAN'' ORDER BY ObjekID ASC");
		pApp->m_pSet->ExecDirect(strSQL);
		
		HTREEITEM subItem = TVI_LAST;
		while(!pApp->m_pSet->IsEOF())
		{
			pApp->m_pSet->GetFieldValue(0, strObjek);
			subItem = ctrlTree.InsertItem(strObjek, m_itemCagaran, subItem);
			ctrlTree.SetItemImage(subItem, 2, 7);
			pApp->m_pSet->MoveNext();
		}
		pApp->m_pSet->Close();
	}
}
///////////////////////////LEJER OBJEK /////////////////////////
void CBrowserView::FillPemiutangItems()   //list kategori pemiutang
{
	CTreeCtrl& ctrlTree = GetTreeCtrl();
	CMainApp *pApp = (CMainApp *)AfxGetApp();
	if(pApp->m_database.IsOpen())
	{
		HTREEITEM itm = ctrlTree.GetChildItem(m_itemPemiutang);
		while(itm != NULL)
		{
			ctrlTree.DeleteItem(itm);
			itm = ctrlTree.GetChildItem(m_itemPemiutang);
		}
		CString strSQL, strObjek;
		strSQL.Format("SELECT CAST(ObjekID as nvarchar(3)) + '' - '' + Nama FROM TABLE_KODOBJEK WHERE Kategori = ''PEMIUTANG'' ORDER BY ObjekID ASC");
		pApp->m_pSet->ExecDirect(strSQL);
		
		HTREEITEM subItem = TVI_LAST;
		while(!pApp->m_pSet->IsEOF())
		{
			pApp->m_pSet->GetFieldValue(0, strObjek);
			subItem = ctrlTree.InsertItem(strObjek, m_itemPemiutang, subItem);
			ctrlTree.SetItemImage(subItem, 2, 7);
			pApp->m_pSet->MoveNext();
		}
		pApp->m_pSet->Close();
	}
}
///////////////////////////LEJER OBJEK /////////////////////////
void CBrowserView::RefreshAllTreeItems()
{
	FillLejerItems();
	FillAsetItems();
	FillAsetSemasaItems();
	FillKumpWangItems();
	FillLiabilitiItems();
	FillLiabilitiSemasaItems();
	FillBelanjaItems();
	FillHasilItems();
	FillAsetTetapItems();
	FillProjekInfraItems();
	FillProjekRumahItems();
	FillProjekRumahAhliItems();
	FillWangBankItems();
	FillPenghutangItems();
	FillPelaburanItems();    
	FillCagaranItems();    
	FillPemiutangItems();  
	m_bFilled = TRUE;
}
void CBrowserView::OnRclick(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	CTreeCtrl& ctrlTree = GetTreeCtrl();
	HTREEITEM itmSel = ctrlTree.GetDropHilightItem();
	if(itmSel)
	{
		ctrlTree.SelectItem(itmSel);
		ctrlTree.UpdateData();
	}
	*pResult = 0;
}
void CBrowserView::OnClick(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	if(!m_bFilled)
			RefreshAllTreeItems();
	*pResult = 0;
}

推荐答案




这篇关于如何将c ++转换为c#... pls ..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 03:43