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

📄 dlgmeetset.cpp

📁 航空公司简单考勤系统:主要运用指纹管理深圳航空公司的会议签到管理系统
💻 CPP
字号:
// DlgMeetSet.cpp : implementation file
//

#include "stdafx.h"
#include "Demo_airline.h"
#include "DlgMeetSet.h"
#include "DlgMeetDefine.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDlgMeetSet property page
extern CDemo_airlineApp theApp;

IMPLEMENT_DYNCREATE(CDlgMeetSet, CPropertyPage)

CDlgMeetSet::CDlgMeetSet() : CPropertyPage(CDlgMeetSet::IDD)
{
	//{{AFX_DATA_INIT(CDlgMeetSet)
	//}}AFX_DATA_INIT
	m_strNodeName.Empty();
}

CDlgMeetSet::~CDlgMeetSet()
{
}

void CDlgMeetSet::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgMeetSet)
	DDX_Control(pDX, IDC_LIST_ATTIN, m_c_listAtting);
	DDX_Control(pDX, IDC_LIST_ATTED, m_c_listAtted);
	DDX_Control(pDX, IDC_TREE_DEPART, m_treeDepart);
	DDX_Control(pDX, IDC_TREE_MEET, m_treeMeet);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgMeetSet, CPropertyPage)
	//{{AFX_MSG_MAP(CDlgMeetSet)
	ON_BN_CLICKED(IDC_BTNMADD, OnBtnmadd)
	ON_NOTIFY(TVN_SELCHANGED, IDC_TREE_DEPART, OnDblclkTreeDepart)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgMeetSet message handlers

void CDlgMeetSet::OnBtnmadd() 
{
	CDlgMeetDefine dlg;
	if (IDOK == dlg.DoModal())
	{
       //m_treeMeet.InsertItem(TVIF_TEXT,dlg.m_strMeetNo, 0, 0, 0, 0, 0, m_hTreeMeet, NULL);
	}
}

BOOL CDlgMeetSet::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	m_pRecordMeet.CreateInstance(__uuidof(Recordset));
	m_pRecordEmp.CreateInstance(__uuidof(Recordset));

	m_oMeetingTree.FillMeetingTree(&m_treeMeet);
	m_oDepartmentTree.InitImageList(&m_treeDepart);
	m_oDepartmentTree.ReadDepartment(&m_treeDepart);

	DWORD dwStyle = GetWindowLong(m_c_listAtted.GetSafeHwnd(),GWL_STYLE);
	dwStyle |= LVS_REPORT;
	SetWindowLong(m_c_listAtted.GetSafeHwnd(),GWL_STYLE,dwStyle);
	m_c_listAtted.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_TRACKSELECT | LVS_EX_FULLROWSELECT );
    CRect rectList;
    m_c_listAtted.GetClientRect(&rectList);
	m_c_listAtted.InsertColumn(0,"编号",LVCFMT_CENTER,rectList.Width()/2);
	m_c_listAtted.InsertColumn(1,"编号",LVCFMT_CENTER,rectList.Width()/2);

	dwStyle = GetWindowLong(m_c_listAtting.GetSafeHwnd(),GWL_STYLE);
	dwStyle |= LVS_REPORT;
	SetWindowLong(m_c_listAtting.GetSafeHwnd(),GWL_STYLE,dwStyle);
	m_c_listAtting.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_TRACKSELECT | LVS_EX_FULLROWSELECT );
    m_c_listAtting.GetClientRect(&rectList);
	m_c_listAtting.InsertColumn(0,"编号",LVCFMT_CENTER,rectList.Width()/2);
	m_c_listAtting.InsertColumn(1,"编号",LVCFMT_CENTER,rectList.Width()/2);

	//m_treeMeet.InsertItem(TVIF_TEXT,"ddd", 0, 0, 0, 0, 0, m_hTreeMeet, NULL);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

//列举出数据库中所有的会议
void CDlgMeetSet::ListAllMeet()
{
	try
	{  
		CString strSql;
		strSql = "select * from Meeting order by MeetingNo asc";
		m_pRecordMeet->Open(strSql.AllocSysString(),
			                    theApp.m_pConnection.GetInterfacePtr(),
								adOpenDynamic,
								adLockOptimistic,
								adCmdText);

		m_pRecordMeet->MoveFirst();
		while(!m_pRecordMeet->adoEOF)
		{
          _variant_t var = m_pRecordMeet->GetCollect("MeetingNo");
		  if(VT_NULL != var.vt)
		  {
             m_treeMeet.InsertItem((LPCSTR)_bstr_t(var),m_hTreeMeet,TVI_SORT);
		  }
		  else 
			  continue;
		  m_pRecordMeet->MoveNext();
		}
	}
	catch(_com_error e)
	{
		e.Description();
	}
	
	m_pRecordMeet->Close();

}

void CDlgMeetSet::OnDblclkTreeDepart(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	m_c_listAtting.DeleteAllItems();
	char* pszDepartID = new char[10];
	memset(pszDepartID,0,10);

    LPNMTREEVIEW temp = (LPNMTREEVIEW)pNMHDR;
	HTREEITEM hTreeItem = temp->itemNew.hItem;

	m_oDepartmentTree.GetDepartmentID(&m_treeDepart,hTreeItem,pszDepartID);
	if(strlen(pszDepartID) == 0) 
		MessageBox("请选中具体的部门!");
	else
	{
		ListDepartEmp(pszDepartID);
	}

	delete []pszDepartID;
	*pResult = 0;
}

void CDlgMeetSet::ListDepartEmp(LPCTSTR lpszDepartID)
{
	try
	{
		CString strSql;
		strSql.Format("select * from Employee where DepartmentID = '%s'",lpszDepartID);
		m_pRecordEmp->Open(strSql.AllocSysString(),
			                    theApp.m_pConnection.GetInterfacePtr(),
								adOpenDynamic,
								adLockOptimistic,
								adCmdText);

		int nRow = m_c_listAtting.GetItemCount();

		while(!m_pRecordEmp->adoEOF)
		{
			CString strItem = _T("");
            LVITEM lvi;
			lvi.mask = LVIF_TEXT;
			lvi.iItem = nRow;
			lvi.iSubItem = 0;
			_variant_t var = m_pRecordEmp->GetCollect("EmployeeID");
			strItem = (LPCSTR)_bstr_t(var);
			lvi.pszText = (LPSTR)(LPCTSTR)strItem;
			m_c_listAtting.InsertItem(&lvi);
   
			lvi.iSubItem = 1;
		    var = m_pRecordEmp->GetCollect("EmployeeName");
			strItem = (LPCSTR)_bstr_t(var);
			lvi.pszText = (LPSTR)(LPCTSTR)strItem;
			m_c_listAtting.SetItem(&lvi);
            
			nRow++;
			m_pRecordEmp->MoveNext();
		}
		m_pRecordEmp->Close();

	}
	catch(_com_error e)
	{
		AfxMessageBox(e.ErrorMessage());
	}
}

⌨️ 快捷键说明

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