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

📄 dlgattendedit.cpp

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

#include "stdafx.h"
#include "Demo_airline.h"
#include "DlgAttendEdit.h"
#include "Demo_airline.h"
#include "DlgAttMan.h"

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

extern CDemo_airlineApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CDlgAttendEdit property page

IMPLEMENT_DYNCREATE(CDlgAttendEdit, CPropertyPage)

CDlgAttendEdit::CDlgAttendEdit() : CPropertyPage(CDlgAttendEdit::IDD)
{
	//{{AFX_DATA_INIT(CDlgAttendEdit)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}

CDlgAttendEdit::~CDlgAttendEdit()
{
}

void CDlgAttendEdit::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgAttendEdit)
	DDX_Control(pDX, IDC_LIST1, m_c_lcAttendMeetingPeople);
	DDX_Control(pDX, IDC_TREE_MEETTING, m_c_tcMeeting);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgAttendEdit, CPropertyPage)
	//{{AFX_MSG_MAP(CDlgAttendEdit)
	ON_NOTIFY(TVN_SELCHANGED, IDC_TREE_MEETTING, OnClickTreeMeeting)
	ON_BN_CLICKED(IDC_BTN_ATT, OnBtnAtt)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgAttendEdit message handlers

BOOL CDlgAttendEdit::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
    
    m_oMeetingTree.FillMeetingTree(&m_c_tcMeeting);
	
	DWORD dwStyle = GetWindowLong(m_c_lcAttendMeetingPeople.GetSafeHwnd(),GWL_STYLE);
	dwStyle |= LVS_REPORT;
	SetWindowLong(m_c_lcAttendMeetingPeople.GetSafeHwnd(),GWL_STYLE,dwStyle);
	m_c_lcAttendMeetingPeople.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_TRACKSELECT);
	
    CRect rectList;
	m_c_lcAttendMeetingPeople.GetClientRect(&rectList);
	
	m_c_lcAttendMeetingPeople.InsertColumn(0,"编号",LVCFMT_CENTER,rectList.Width()/6);
	m_c_lcAttendMeetingPeople.InsertColumn(1,"姓名",LVCFMT_CENTER,rectList.Width()/6);
	m_c_lcAttendMeetingPeople.InsertColumn(2,"性别",LVCFMT_CENTER,rectList.Width()/6);
	m_c_lcAttendMeetingPeople.InsertColumn(3,"民族",LVCFMT_CENTER,rectList.Width()/6);
	m_c_lcAttendMeetingPeople.InsertColumn(4,"参会类别",LVCFMT_CENTER,rectList.Width()/6);
	m_c_lcAttendMeetingPeople.InsertColumn(5,"分组",LVCFMT_CENTER,rectList.Width()/6);

    ListView_SetExtendedListViewStyle(m_c_lcAttendMeetingPeople.GetSafeHwnd(), 
        ListView_GetExtendedListViewStyle(m_c_lcAttendMeetingPeople.GetSafeHwnd())|LVS_EX_FULLROWSELECT);
    FillAttendMeetingPeople("1");

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

BOOL CDlgAttendEdit::FillAttendMeetingPeople(LPCTSTR lpszMeetingNo)
{
    // 填充与会人员列表
    int nIndex = 0;

    m_c_lcAttendMeetingPeople.DeleteAllItems();
    try 
    {
        _RecordsetPtr m_pRecordset;
        m_pRecordset.CreateInstance(_uuidof(Recordset)); 
        
        m_pRecordset->Open("select * from MeetingEmployeeRel order by EmployeeID", theApp.m_pConnection.GetInterfacePtr(), 
            adOpenDynamic, adLockOptimistic, adCmdText);
//        CString strCmd;
//        strCmd.Format("select * from MeetingEmployeeRel order by EmployeeNo where MeetingNo = '%s'", "1");
//        theApp.m_pConnection->Execute(strCmd.AllocSysString(), NULL, 0);
        
        //执行SQL语句得到一个记录集 
        m_pRecordset->MoveFirst(); 
        
        while(!m_pRecordset->adoEOF) 
            //遍历所有记录 
        { 
            CString strMeetingNo = (char*)(_bstr_t)(m_pRecordset->Fields->GetItem(_variant_t("MeetingNo"))->Value);
            CString strEmployeeNo = (char*)(_bstr_t)(m_pRecordset->Fields->GetItem(_variant_t("EmployeeID"))->Value);
            
            //得到字段BlockIndex的值 
            if(FALSE == strMeetingNo.IsEmpty() && FALSE == strEmployeeNo.IsEmpty()) 
            {
                if(strMeetingNo == lpszMeetingNo)
                {
                    _RecordsetPtr pSubRecordset;
                    pSubRecordset.CreateInstance(_uuidof(Recordset)); 
                    
                    pSubRecordset->Open("select * from Employee order by EmployeeID", theApp.m_pConnection.GetInterfacePtr(), 
                        adOpenDynamic, adLockOptimistic, adCmdText);
                    
                    //执行SQL语句得到一个记录集 
                    pSubRecordset->MoveFirst(); 
                    
                    while(!pSubRecordset->adoEOF) 
                        //遍历所有记录 
                    { 
                        CString strEmployeeID = (char*)(_bstr_t)(pSubRecordset->Fields->GetItem(_variant_t("EmployeeID"))->Value);
                        CString strEmployeeName = (char*)(_bstr_t)(pSubRecordset->Fields->GetItem(_variant_t("EmployeeName"))->Value);
                        CString strSex = (char*)(_bstr_t)(pSubRecordset->Fields->GetItem(_variant_t("Sex"))->Value);
                        CString strNationlity = (char*)(_bstr_t)(pSubRecordset->Fields->GetItem(_variant_t("Nationality"))->Value);
                        
                        if(FALSE == strEmployeeID.IsEmpty() && strEmployeeNo == strEmployeeID) 
                        {
                            if(FALSE == strEmployeeName.IsEmpty() && FALSE == strSex.IsEmpty() && FALSE == strNationlity.IsEmpty()) 
                            {
                                m_c_lcAttendMeetingPeople.InsertItem(nIndex, strEmployeeNo);
                                m_c_lcAttendMeetingPeople.SetItemText(nIndex, 1, strEmployeeName);
                                m_c_lcAttendMeetingPeople.SetItemText(nIndex, 2, strSex);
                                m_c_lcAttendMeetingPeople.SetItemText(nIndex, 3, strNationlity);
                                m_c_lcAttendMeetingPeople.SetItemText(nIndex, 4, "出席");
                                m_c_lcAttendMeetingPeople.SetItemText(nIndex, 5, "第一组");
                                nIndex++;
                            }
                        }   
                        pSubRecordset->MoveNext(); 
                    } 
                    pSubRecordset->Close(); 
                }
            }   
            m_pRecordset->MoveNext(); 
        } 
        
        m_pRecordset->Close(); 
    } 
    catch(_com_error e) //异常处理 
    { 
        AfxMessageBox(e.ErrorMessage()); 
    }
    
    return TRUE;
}

void CDlgAttendEdit::OnClickTreeMeeting(NMHDR* pNMHDR, LRESULT* pResult) 
{
	m_c_lcAttendMeetingPeople.DeleteAllItems();
	char* pszDepartID = new char[10];
	memset(pszDepartID,0,10);

    LPNMTREEVIEW temp = (LPNMTREEVIEW)pNMHDR;

	HTREEITEM hTreeItem = temp->itemNew.hItem;
    CString strMeetingNo = m_c_tcMeeting.GetItemText(hTreeItem);
	if(strlen(strMeetingNo) == 0) 
		MessageBox("请选中具体的会议!");
	else
	{
        FillAttendMeetingPeople(strMeetingNo);
	}

	delete []pszDepartID;

	*pResult = 0;
}

void CDlgAttendEdit::OnBtnAtt() 
{
   	CDlgAttMan dlg;
	dlg.DoModal();
}

⌨️ 快捷键说明

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