1、四、 应用系统实现与测试 登陆界面系统界面文档基本信息日志管理文档类别单位列表五、部分代码/ ADO.cpp: implementation of the CADO class./#include stdafx.hADO.h#include #ifdef _DEBUG#undef THIS_FILEstatic char THIS_FILE=_FILE_;#define new DEBUG_NEW#endif/ Construction/Destructionint ConCount = 0;CADOConnection g_Connection;/全局数据库连接对象CADOConnectio
2、n * GetConnection() return &g_Connection;CADOConnection:CADOConnection() InitADO(); m_Connection.CreateInstance(ADODB.Connection);CADOConnection() if (IsOpen() m_Connection-Close(); m_Connection = NULL; UnInitADO();void CADOConnection:InitADO() if (ConCount+ = 0) CoInitialize(NULL);UnInitADO() if (-
3、ConCount = 0) CoUninitialize();BOOL CADOConnection:Open(CString ConStr) m_Connection-Open(_bstr_t)ConStr,adModeUnknown); return IsOpen();CString CADOConnection:GetSQLConStr(CString IP, CString DBName) CString Str; Str.Format(Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=
4、%s;Data Source=%s,DBName,IP); return Str;_ConnectionPtr CADOConnection:GetConnection() return m_Connection;IsOpen() long State;get_State(&State); if (State = adStateOpen) return true; return false;/CADODataSet:CADODataSet() m_DataSet.CreateInstance(ADODB.RecordsetCADODataSet() m_DataSet- m_DataSet =
5、 NULL;void CADODataSet:SetConnection(CADOConnection *pCon) m_Connection = pCon;int CADODataSet:GetRecordCount() return m_DataSet-GetRecordCount(); else return 0;BOOL CADODataSet:Open(CString SQLStr) /*/ m_DataSet-Open(_bstr_t(SQLStr), _variant_t(IDispatch*)g_Connection.GetConnection(), true), adOpen
6、Keyset, adLockOptimistic, adCmdText);FieldsPtr CADODataSet:GetFields() return m_DataSet-GetFields();Next() if (m_DataSet-adoEOF) return false;MoveNext(); return true;AddNew()AddNew();SetFieldValue(CString FieldName, _variant_t Value)PutCollect(_bstr_t)FieldName,Value);Save()Update();move(int nIndex)
7、MoveFirst();Move(nIndex);GetRecordNo()AbsolutePosition;Delete()Delete(adAffectCurrent);Open(CString SQLStr, int LockType) adOpenKeyset,(LockTypeEnum) LockType, adCmdText);/ CheckSum.cpp : implementation filePerson.hCheckSum.hstatic char THIS_FILE = _FILE_;/ CCheckSum dialogCCheckSum:CCheckSum(CWnd*
8、pParent /*=NULL*/) : CDialog(CCheckSum:IDD, pParent) /AFX_DATA_INIT(CCheckSum) m_emp = _T( m_mm = _T( m_yy = _T( /AFX_DATA_INITvoid CCheckSum:DoDataExchange(CDataExchange* pDX) CDialog:DoDataExchange(pDX); /AFX_DATA_MAP(CCheckSum) DDX_Control(pDX, IDC_LISTEMP, m_list); DDX_Control(pDX, IDC_CYY, m_cy
9、y); DDX_Control(pDX, IDC_CMM, m_cmm); DDX_Control(pDX, IDC_CEMP, m_cemp); DDX_CBString(pDX, IDC_CEMP, m_emp); DDX_CBString(pDX, IDC_CMM, m_mm); DDX_CBString(pDX, IDC_CYY, m_yy); /AFX_DATA_MAPBEGIN_MESSAGE_MAP(CCheckSum, CDialog) /AFX_MSG_MAP(CCheckSum) ON_CBN_CLOSEUP(IDC_CEMP, OnCloseupCemp) ON_CBN_
10、CLOSEUP(IDC_CYY, OnCloseupCyy) ON_CBN_CLOSEUP(IDC_CMM, OnCloseupCmm) /AFX_MSG_MAPEND_MESSAGE_MAP()/ CCheckSum message handlersBOOL CCheckSum:OnInitDialog() OnInitDialog(); int i = 0; m_list.InsertColumn(i,人员姓名 m_list.SetColumnWidth(i+,100);工作总天数迟到总天数早退总天数病假总天数事假总天数 m_list.SetExtendedStyle(LVS_EX_FUL
11、LROWSELECT|LVS_EX_GRIDLINES); int curyear,curmonth; CTime time(CTime:GetCurrentTime(); curyear = time.GetYear(); curmonth = time.GetMonth(); char value10; for (int y = 2000; y 2100 ;y+) _itoa(y,value,10); m_cyy.InsertString(y-2000,value); m_cyy.SetCurSel(curyear-2000); for (int n = 1 ; n=12 ;n+) _it
12、oa(n,value,10); m_cmm.InsertString(n-1,value); m_cmm.SetCurSel(curmonth-1); CADODataSet dataset; dataset.SetConnection(:GetConnection(); dataset.Open(Select * From tab_Employees m_cemp.InsertString(0,(全部) for (int index = 1 ; index Itememp_name-Value); dataset.Next(); m_cemp.SetCurSel(0); UpdateList
13、(); return TRUE; / return TRUE unless you set the focus to a control / EXCEPTION: OCX Property Pages should return FALSEUpdateList() m_list.DeleteAllItems(); this-UpdateData(); CString str,temp,where,datestr,StartDate,EndDate; StartDate = m_yy + - + m_mm + -1 ; EndDate.Format(DATEADD(month,1,%s),Sta
14、rtDate); datestr.Format( between and %s,StartDate,EndDate); temp += select emp.emp_name ,ROUND(isnull(works.workday,0),2); workday,ROUND(isnull(lates.lateday,0),2) lateday, ROUND(isnull(leaveearlys.leaveearlyday,0),2) leaveearlyday, ROUND(isnull(bjdays.bjday,0),2) bjday,ROUND(isnull(sjdays.sjday,0),
15、2) sjday from tab_Employees emp left join (select sum(DATEDIFF(second,ontime,offtime) / 60.0 / 60.0 / 8.0 as workday,name From tab_Check where checkdate %s group by name) works on emp.emp_name = works.name (select (sum(DATEPART(Hour,latetime) * 60 * 60 + sum(DATEPART(minute,latetime) * 60 + sum(DATE
16、PART(second,latetime) /60.0 /60.0 /8.0 as lateday,name From tab_Check where checkdate %s group by name) lates on emp.emp_name = lates.name (select (sum(DATEPART(Hour,leaveearly) * 60 * 60 + sum(DATEPART(minute,leaveearly) * 60 + sum(DATEPART(second,leaveearly) /60.0 /60.0 /8.0 as leaveearlyday,name
17、From tab_Check where checkdate %s group by name) leaveearlys on emp.emp_name = leaveearlys.name (select isnull(sum(DATEDIFF(second,onleave,offleave) / 60.0 / 60.0 / 8.0,0) as bjday,name From tab_Check where leave = 病假 and checkdate %s group by name) bjdays on emp.emp_name = bjdays.name (select isnul
18、l(sum(DATEDIFF(second,onleave,offleave) / 60.0 / 60.0 / 8.0,0) as sjday,name From tab_Check where 事假 sjdays on emp.emp_name = sjdays.name %s/*/ / where.Format( where emp.emp_name = ,m_emp); if (m_emp = ) str.Format(temp,datestr,datestr,datestr,datestr,datestr, str.Format(temp,datestr,datestr,datestr,datestr,datestr,where); dataset.Open(str,adLockUnspecified); for (int i = 0; i workdaylatedayleaveearlydaybjdaysjday /*/OnCloseupCemp() OnCloseupCyy() OnCloseupCmm() 六、课程设计心得体会这次历时两周的课程设计,对于我们来说确实收获了不少。第一天我们查找资料、了解有关的知识,相互探讨,了解文档管理系统的需求,做好需求分析后,开始系统的设计,画出E-R图,写出各个实体的属性。对于数据库的创建,虽然出现很多的问题,
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1