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

📄 meetingrecord.cpp

📁 这是一个企业办公管理系统。实现了文件的制作、修改、传递、、保存、销毁、存档等一系列操作。为windows系统认证模式
💻 CPP
字号:
// MeetingRecord.cpp : implementation file
//

#include "stdafx.h"
#include "Office.h"
#include "MeetingRecord.h"
#include "Meeting.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMeetingRecord dialog


CMeetingRecord::CMeetingRecord(CWnd* pParent /*=NULL*/)
	: CDialog(CMeetingRecord::IDD, pParent)
{
	//{{AFX_DATA_INIT(CMeetingRecord)
	m_name = _T("");
	m_meetingDate = COleDateTime::GetCurrentTime();
	m_president = _T("");
	m_beginTime = COleDateTime::GetCurrentTime();
	m_endTime = COleDateTime::GetCurrentTime();
	m_location = _T("");
	m_num = 0;
	m_subject = _T("");
	m_content = _T("");
	m_remark = _T("");
	//}}AFX_DATA_INIT
}


void CMeetingRecord::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMeetingRecord)
	DDX_Control(pDX, IDC_PRESIDENT, m_presidentCombo);
	DDX_Control(pDX, IDC_LIST, m_list);
	DDX_Text(pDX, IDC_NAME, m_name);
	DDX_DateTimeCtrl(pDX, IDC_MEETINGDATE, m_meetingDate);
	DDX_CBString(pDX, IDC_PRESIDENT, m_president);
	DDX_DateTimeCtrl(pDX, IDC_BEGINTIME, m_beginTime);
	DDX_DateTimeCtrl(pDX, IDC_ENDTIME, m_endTime);
	DDX_Text(pDX, IDC_LOCATION, m_location);
	DDX_Text(pDX, IDC_NUM, m_num);
	DDX_Text(pDX, IDC_SUBJECT, m_subject);
	DDX_Text(pDX, IDC_CONTENT, m_content);
	DDX_Text(pDX, IDC_REMARK, m_remark);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CMeetingRecord, CDialog)
	//{{AFX_MSG_MAP(CMeetingRecord)
	ON_BN_CLICKED(IDC_ADD, OnAdd)
	ON_BN_CLICKED(IDC_DELETE, OnDelete)
	ON_BN_CLICKED(IDC_MODIFY, OnModify)
	ON_BN_CLICKED(IDC_SAVE, OnSave)
	ON_BN_CLICKED(IDC_EXIT, OnExit)
	ON_NOTIFY(NM_CLICK, IDC_LIST, OnClickList)
//	ON_BN_CLICKED(IDC_CANCEL, OnCancel)
	ON_BN_CLICKED(IDC_CANCEL1, OnCancel1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMeetingRecord message handlers

void CMeetingRecord::OnAdd() 
{
	cwnd_list->EnableWindow(true);
	cwnd_name->EnableWindow(true);
	cwnd_meetingDate->EnableWindow(true);
	cwnd_president->EnableWindow(true);
	cwnd_beginTime->EnableWindow(true);
	cwnd_endTime->EnableWindow(true);
	cwnd_location->EnableWindow(true);
	cwnd_num->EnableWindow(true);
	cwnd_subject->EnableWindow(true);
	cwnd_content->EnableWindow(true);
	cwnd_remark->EnableWindow(true);

	cwnd_add->EnableWindow(false);
	cwnd_cancel->EnableWindow(true);
	cwnd_delete->EnableWindow(false);
	cwnd_modify->EnableWindow(false);
	cwnd_save->EnableWindow(true);
	cwnd_exit->EnableWindow(false);

	flag= 1;

	m_name = _T("");
	m_meetingDate = COleDateTime::GetCurrentTime();
	m_president = _T("");
	m_beginTime = COleDateTime::GetCurrentTime();
	m_endTime = COleDateTime::GetCurrentTime();
	m_location = _T("");
	m_num = 0;
	m_subject = _T("");
	m_content = _T("");
	m_remark = _T("");


	UpdateData(false);
	
}

void CMeetingRecord::OnDelete() 
{
	UpdateData(true); 

	CMeeting meeting;
	meeting.sqlDelete(m_subject);
	
	cwnd_list->EnableWindow(true);
	cwnd_name->EnableWindow(false);
	cwnd_meetingDate->EnableWindow(false);
	cwnd_president->EnableWindow(false);
	cwnd_beginTime->EnableWindow(false);
	cwnd_endTime->EnableWindow(false);
	cwnd_location->EnableWindow(false);
	cwnd_num->EnableWindow(false);
	cwnd_subject->EnableWindow(false);
	cwnd_content->EnableWindow(false);
	cwnd_remark->EnableWindow(false);

	cwnd_add->EnableWindow(true);
	cwnd_cancel->EnableWindow(false);
	cwnd_delete->EnableWindow(false);
	cwnd_modify->EnableWindow(false);
	cwnd_save->EnableWindow(false);
	cwnd_exit->EnableWindow(true);

	m_name = _T("");
	m_meetingDate = COleDateTime::GetCurrentTime();
	m_president = _T("");
	m_beginTime = COleDateTime::GetCurrentTime();
	m_endTime = COleDateTime::GetCurrentTime();
	m_location = _T("");
	m_num = 0;
	m_subject = _T("");
	m_content = _T("");
	m_remark = _T("");

	Refresh();

	UpdateData(false);
	
}

void CMeetingRecord::OnModify() 
{
	cwnd_list->EnableWindow(true);
	cwnd_name->EnableWindow(true);
	cwnd_meetingDate->EnableWindow(true);
	cwnd_president->EnableWindow(true);
	cwnd_beginTime->EnableWindow(true);
	cwnd_endTime->EnableWindow(true);
	cwnd_location->EnableWindow(true);
	cwnd_num->EnableWindow(true);
	cwnd_subject->EnableWindow(false);
	cwnd_content->EnableWindow(true);
	cwnd_remark->EnableWindow(true);

	cwnd_add->EnableWindow(false);
	cwnd_cancel->EnableWindow(true);
	cwnd_delete->EnableWindow(false);
	cwnd_modify->EnableWindow(false);
	cwnd_save->EnableWindow(true);
	cwnd_exit->EnableWindow(false);

	flag= 2;
	
}

void CMeetingRecord::OnSave() 
{
	UpdateData(true);
	cwnd_list->EnableWindow(true);
	cwnd_name->EnableWindow(false);
	cwnd_meetingDate->EnableWindow(false);
	cwnd_president->EnableWindow(false);
	cwnd_beginTime->EnableWindow(false);
	cwnd_endTime->EnableWindow(false);
	cwnd_location->EnableWindow(false);
	cwnd_num->EnableWindow(false);
	cwnd_subject->EnableWindow(false);
	cwnd_content->EnableWindow(false);
	cwnd_remark->EnableWindow(false);

	cwnd_add->EnableWindow(true);
	cwnd_cancel->EnableWindow(false);
	cwnd_delete->EnableWindow(true);
	cwnd_modify->EnableWindow(true);
	cwnd_save->EnableWindow(false);
	cwnd_exit->EnableWindow(true);

	if(flag==1)
	{
		CMeeting meeting;

		meeting.SetName(m_name);
		meeting.SetMeetingDate(m_meetingDate);
		meeting.SetLocation(m_location);
		meeting.SetBeginTime(m_beginTime);
		meeting.SetEndTime(m_endTime);
		meeting.SetPresident(m_president);
		meeting.SetNum(m_num);
		meeting.SetSubject(m_subject);
		meeting.SetContent(m_content);
		meeting.SetRemark(m_remark);

		meeting.sqlInsert();
	}
	else if(flag==2)
	{
		CMeeting meeting;

		meeting.SetName(m_name);
		meeting.SetMeetingDate(m_meetingDate);
		meeting.SetLocation(m_location);
		meeting.SetBeginTime(m_beginTime);
		meeting.SetEndTime(m_endTime);
		meeting.SetPresident(m_president);
		meeting.SetNum(m_num);
		meeting.SetSubject(m_subject);
		meeting.SetContent(m_content);
		meeting.SetRemark(m_remark);

		meeting.sqlUpdate(m_subject);
	}
	flag=0;
	Refresh();

	UpdateData(false);
	
}

/*void CMeetingRecord::OnCancel() 
{
	cwnd_list->EnableWindow(true);
	cwnd_name->EnableWindow(false);
	cwnd_meetingDate->EnableWindow(false);
	cwnd_president->EnableWindow(false);
	cwnd_beginTime->EnableWindow(false);
	cwnd_endTime->EnableWindow(false);
	cwnd_location->EnableWindow(false);
	cwnd_num->EnableWindow(false);
	cwnd_subject->EnableWindow(false);
	cwnd_content->EnableWindow(false);
	cwnd_remark->EnableWindow(false);

	cwnd_add->EnableWindow(true);
	cwnd_cancel->EnableWindow(false);
	cwnd_delete->EnableWindow(false);
	cwnd_modify->EnableWindow(false);
	cwnd_save->EnableWindow(false);
	cwnd_exit->EnableWindow(true);

	flag= 0;

	m_name = _T("");
	m_meetingDate = COleDateTime::GetCurrentTime();
	m_president = _T("");
	m_beginTime = COleDateTime::GetCurrentTime();
	m_endTime = COleDateTime::GetCurrentTime();
	m_location = _T("");
	m_num = 0;
	m_subject = _T("");
	m_content = _T("");
	m_remark = _T("");
	
}*/

void CMeetingRecord::OnExit() 
{
	this->OnCancel();
}

BOOL CMeetingRecord::OnInitDialog() 
{
	CDialog::OnInitDialog();

	DWORD style;
	style=m_list.GetExStyle();
	style=(style|LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT)&(~LVS_EX_CHECKBOXES) ;
	m_list.SetExtendedStyle(style);
	
	m_list.InsertColumn(0,"会议名称",LVCFMT_LEFT,100);
	m_list.InsertColumn(1,"会议日期",LVCFMT_LEFT,100);
	m_list.InsertColumn(2,"会议主题",LVCFMT_LEFT,100);
	
	_RecordsetPtr m_pRecordset;

	CString strSQL;
	strSQL="select * from meetingRecord";
	HRESULT hTRes;
	hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
	if (SUCCEEDED(hTRes))
	{
		hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
			((COfficeApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
			adOpenDynamic,adLockPessimistic,adCmdText);
		int i=0;
		
		while(!(m_pRecordset->adoEOF))
		{
			m_list.InsertItem(i,((COfficeApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("name")));
			m_list.SetItemText(i,1,((COfficeApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("meetingDate")));
			m_list.SetItemText(i,2,((COfficeApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("subject")));
			
			i++;
			if(!(m_pRecordset->adoEOF))
				m_pRecordset->MoveNext();
		}
	}
	
	cwnd_list= GetDlgItem(IDC_LIST);
	cwnd_name= GetDlgItem(IDC_NAME);
	cwnd_meetingDate= GetDlgItem(IDC_MEETINGDATE);
	cwnd_president= GetDlgItem(IDC_PRESIDENT);
	cwnd_beginTime= GetDlgItem(IDC_BEGINTIME);
	cwnd_endTime= GetDlgItem(IDC_ENDTIME);
	cwnd_location= GetDlgItem(IDC_LOCATION);
	cwnd_num= GetDlgItem(IDC_NUM);
	cwnd_subject= GetDlgItem(IDC_SUBJECT);
	cwnd_content= GetDlgItem(IDC_CONTENT);
	cwnd_remark= GetDlgItem(IDC_REMARK);

	cwnd_add= GetDlgItem(IDC_ADD);
	cwnd_cancel= GetDlgItem(IDC_CANCEL1);
	cwnd_delete= GetDlgItem(IDC_DELETE);
	cwnd_modify= GetDlgItem(IDC_MODIFY);
	cwnd_save= GetDlgItem(IDC_SAVE);
	cwnd_exit= GetDlgItem(IDC_EXIT);
	
	
	
	//为主持人组合框添加选项
	

	////////////////////////

	cwnd_list->EnableWindow(true);
	cwnd_name->EnableWindow(false);
	cwnd_meetingDate->EnableWindow(false);
	cwnd_president->EnableWindow(false);
	cwnd_beginTime->EnableWindow(false);
	cwnd_endTime->EnableWindow(false);
	cwnd_location->EnableWindow(false);
	cwnd_num->EnableWindow(false);
	cwnd_subject->EnableWindow(false);
	cwnd_content->EnableWindow(false);
	cwnd_remark->EnableWindow(false);

	cwnd_add->EnableWindow(true);
	cwnd_cancel->EnableWindow(false);
	cwnd_delete->EnableWindow(false);
	cwnd_modify->EnableWindow(false);
	cwnd_save->EnableWindow(false);
	cwnd_exit->EnableWindow(true);

	flag= 0;

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

void CMeetingRecord::OnClickList(NMHDR* pNMHDR, LRESULT* pResult) 
{
	UpdateData(true);
	POSITION pos = m_list.GetFirstSelectedItemPosition();
	if(pos)
	{
		int nFirstSelItem = m_list.GetNextSelectedItem(pos);
		m_subject=m_list.GetItemText(nFirstSelItem,2);
	}

	
	CMeeting meeting;
	meeting.GetData(m_subject);
	m_name = meeting.GetName();
	m_meetingDate = meeting.GetMeetingDate();
	m_president = meeting.GetPresident();
	m_beginTime = meeting.GetBeginTime();
	m_endTime = meeting.GetEndTime();
	m_location = meeting.GetLocation();
	m_num = meeting.GetNum();
	m_subject = meeting.GetSubject();
	m_content = meeting.GetContent();
	m_remark = meeting.GetRemark();	
	
	cwnd_add->EnableWindow(true);
	cwnd_cancel->EnableWindow(false);
	cwnd_delete->EnableWindow(true);
	cwnd_modify->EnableWindow(true);
	cwnd_save->EnableWindow(false);
	cwnd_exit->EnableWindow(true);
	
	*pResult = 0;
	UpdateData(false);
}

void CMeetingRecord::OnCancel1() 
{
	cwnd_list->EnableWindow(true);
	cwnd_name->EnableWindow(false);
	cwnd_meetingDate->EnableWindow(false);
	cwnd_president->EnableWindow(false);
	cwnd_beginTime->EnableWindow(false);
	cwnd_endTime->EnableWindow(false);
	cwnd_location->EnableWindow(false);
	cwnd_num->EnableWindow(false);
	cwnd_subject->EnableWindow(false);
	cwnd_content->EnableWindow(false);
	cwnd_remark->EnableWindow(false);

	cwnd_add->EnableWindow(true);
	cwnd_cancel->EnableWindow(false);
	cwnd_delete->EnableWindow(false);
	cwnd_modify->EnableWindow(false);
	cwnd_save->EnableWindow(false);
	cwnd_exit->EnableWindow(true);

	flag= 0;

	m_name = _T("");
	m_meetingDate = COleDateTime::GetCurrentTime();
	m_president = _T("");
	m_beginTime = COleDateTime::GetCurrentTime();
	m_endTime = COleDateTime::GetCurrentTime();
	m_location = _T("");
	m_num = 0;
	m_subject = _T("");
	m_content = _T("");
	m_remark = _T("");
	
}

void CMeetingRecord::Refresh()
{
	_RecordsetPtr m_pRecordset;

	m_list.DeleteAllItems();

	CString strSQL;
	strSQL="select * from meetingRecord";
	HRESULT hTRes;
	hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
	if (SUCCEEDED(hTRes))
	{
		hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
			((COfficeApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
			adOpenDynamic,adLockPessimistic,adCmdText);
		int i=0;
		
		while(!(m_pRecordset->adoEOF))
		{
			m_list.InsertItem(i,((COfficeApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("name")));
			m_list.SetItemText(i,1,((COfficeApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("meetingDate")));
			m_list.SetItemText(i,2,((COfficeApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("subject")));
			
			i++;
			if(!(m_pRecordset->adoEOF))
				m_pRecordset->MoveNext();
		}
	}
}

⌨️ 快捷键说明

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