📄 attendancedlg.cpp
字号:
// attendanceDlg.cpp : implementation file
//
#include "stdafx.h"
#include "attendance.h"
#include "attendanceDlg.h"
#include "DlgProxy.h"
#include "DualListDialog.h"
#include "PageSetup.h"
#include "PrintSelect.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
/*
#define ID_FILE_OPEN WM_USER + 100
#define ID_FILE_SAVEAS WM_USER + 101
#define ID_PRINT WM_USER + 102
#define ID_PRINT_PREVIEW WM_USER + 103
*/
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
CButton m_ctrlMore;
CString m_sEmail;
CString m_sWWW;
CString m_sExplain;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
virtual BOOL OnInitDialog();
afx_msg void OnBtnMore();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
BOOL m_bToggleSize;
CRect m_rectFull;
CRect m_rectHalf;
void ToggleSize() ;
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
m_sEmail = _T("Email: ylguang@21cn.com");
m_sWWW = _T("http://www.vckbase.com/code/viewcode.asp?id=1471");
m_sExplain = _T("");
//}}AFX_DATA_INIT
m_sExplain.LoadString(IDS_EXPLAIN);//华文隶书
m_bToggleSize=FALSE;
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
DDX_Control(pDX, IDC_BTN_MORE, m_ctrlMore);
DDX_Text(pDX, IDC_EDT_EMAIL, m_sEmail);
DDX_Text(pDX, IDC_EDT_WWW, m_sWWW);
DDX_Text(pDX, IDC_STATIC_EXPLAIN, m_sExplain);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
ON_BN_CLICKED(IDC_BTN_MORE, OnBtnMore)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
// save our full size
GetWindowRect(&m_rectFull);
m_rectHalf=m_rectFull;
// calculate our half size based on bottom of "More" button
CRect rect;
m_ctrlMore.GetWindowRect(&rect);
m_rectHalf.bottom=rect.bottom+10; // + 10 for cosmetics
// toggle window size
ToggleSize();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CAboutDlg::OnBtnMore()
{
// TODO: Add your control notification handler code here
ToggleSize();
}
void CAboutDlg::ToggleSize()
{
CRect rect;
CString str;
if (m_bToggleSize)
{
str="<< 收拢吧";
rect=m_rectFull;
}
else
{
str="算法说明>>";
rect=m_rectHalf;
}
SetWindowPos(NULL,0,0,rect.Width(),rect.Height(),SWP_NOZORDER|SWP_NOMOVE);
m_ctrlMore.SetWindowText(str);
m_bToggleSize=!m_bToggleSize;
}
/////////////////////////////////////////////////////////////////////////////
// CAttendanceDlg dialog
IMPLEMENT_DYNAMIC(CAttendanceDlg, CDialog);
CAttendanceDlg::CAttendanceDlg(CWnd* pParent /*=NULL*/)
: CDialog(CAttendanceDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CAttendanceDlg)
m_sYearMonth = _T("");
m_dDayPay = 0.0;
m_iObtain = 0;
m_iPay = 2000;
m_iWorkDays = 0;
m_dFactWorks = 0.0;
m_iFactPay = 0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_pAutoProxy = NULL;
m_toolbarCtrl = NULL ;
m_iBottom = 0;
m_iLeft = 0;
m_iRight = 0;
m_iTop = 0;
m_iPrtSel = 0;
m_iCurItem = 0;
for(int i=0;i<=31;i++)
{
//sAttend[i].iDate=0;
//sAttend[i].iWeek=0;
sAttend[i].tAmOnDuty=0;
sAttend[i].tAmOffDuty=0;
sAttend[i].tPmOnDuty=0;
sAttend[i].tPmOffDuty=0;
sAttend[i].tWork=0;
}
sDuty.tAmOnDuty=0;
sDuty.tAmOffDuty=0;
sDuty.tPmOnDuty=0;
sDuty.tPmOffDuty=0;
sDuty.tWork=0;
m_iHoliday=-1;
m_iMonths=-1;
m_bFirst=true;
m_iTotalSel=0;
}
CAttendanceDlg::~CAttendanceDlg()
{
// If there is an automation proxy for this dialog, set
// its back pointer to this dialog to NULL, so it knows
// the dialog has been deleted.
if (m_pAutoProxy != NULL)
m_pAutoProxy->m_pDialog = NULL;
}
void CAttendanceDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAttendanceDlg)
DDX_Control(pDX, IDOK, m_BtnOk);
DDX_Control(pDX, IDC_FACTPAY, m_EdtFactPay);
DDX_Control(pDX, IDC_STATIC_YEAR, m_cYear);
DDX_Control(pDX, IDC_STATIC_MONTH, m_cMonth);
DDX_Control(pDX, IDC_WORKDAYS, m_EdtWorkDays);
DDX_Control(pDX, IDC_PAY, m_EdtPay);
DDX_Control(pDX, IDC_OBTAIN, m_EdtObtain);
DDX_Control(pDX, IDC_FACTWORKS, m_EDtFactWorks);
DDX_Control(pDX, IDC_DAYPAY, m_EdtDayPay);
DDX_Control(pDX, IDC_DUTY, m_ListDuty);
DDX_Control(pDX, IDC_TOTAL, m_ListTotal);
DDX_Control(pDX, IDC_ATTENDANCE, m_ListAttend);
DDX_Text(pDX, IDC_YEAR_MONTH, m_sYearMonth);
DDX_Text(pDX, IDC_DAYPAY, m_dDayPay);
DDV_MinMaxDouble(pDX, m_dDayPay, 0., 2000.);
DDX_Text(pDX, IDC_OBTAIN, m_iObtain);
DDV_MinMaxInt(pDX, m_iObtain, 0, 62000);
DDX_Text(pDX, IDC_PAY, m_iPay);
DDV_MinMaxInt(pDX, m_iPay, 0, 62000);
DDX_Text(pDX, IDC_WORKDAYS, m_iWorkDays);
DDV_MinMaxInt(pDX, m_iWorkDays, 0, 31);
DDX_Text(pDX, IDC_FACTWORKS, m_dFactWorks);
DDV_MinMaxDouble(pDX, m_dFactWorks, 0., 31.);
DDX_Text(pDX, IDC_FACTPAY, m_iFactPay);
DDV_MinMaxInt(pDX, m_iFactPay, 0, 62000);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAttendanceDlg, CDialog)
//{{AFX_MSG_MAP(CAttendanceDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_CLOSE()
ON_NOTIFY(LVN_COLUMNCLICK, IDC_DUTY, OnColumnclickDuty)
ON_BN_CLICKED(IDC_HOLIDAY, OnHoliday)
ON_EN_UPDATE(IDC_PAY, OnUpdatePay)
ON_BN_CLICKED(IDC_DELETE, OnDelete)
ON_NOTIFY(LVN_ITEMCHANGED, IDC_TOTAL, OnItemchangedTotal)
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
ON_COMMAND(ID_FILE_SAVEAS, OnFileSaveas)
ON_COMMAND(ID_PRINT_PREVIEW, OnPrintPreview)
ON_WM_CREATE()
ON_COMMAND(ID_PRINT, OnPrint)
ON_COMMAND(ID_PGSETUP, OnPgsetup)
ON_EN_UPDATE(IDC_FACTPAY, OnUpdateFactpay)
ON_COMMAND(ID_ABOUT, OnAbout)
//}}AFX_MSG_MAP
ON_NOTIFY_EX( TTN_NEEDTEXT, 0, NotifyFunction )
//ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
//ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAttendanceDlg message handlers
BOOL CAttendanceDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CAttendanceApp* app=(CAttendanceApp*)AfxGetApp();
// app->pDeskTop=GetDesktopWindow();
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
btn[0].iBitmap = 0 ;
btn[0].idCommand = ID_FILE_OPEN ;
btn[0].fsState = TBSTATE_ENABLED ;
btn[0].fsStyle = TBSTYLE_BUTTON ;
btn[0].dwData = 0 ;
btn[0].iString = 0;
btn[1].iBitmap = 1 ;
btn[1].idCommand = ID_FILE_SAVEAS ;
btn[1].fsState = TBSTATE_ENABLED ;
btn[1].fsStyle = TBSTYLE_BUTTON ;
btn[1].dwData = 0 ;
btn[1].iString = 1;
btn[2].iBitmap = 2 ;
btn[2].idCommand = ID_PGSETUP ;
btn[2].fsState = TBSTATE_ENABLED ;
btn[2].fsStyle = TBSTYLE_BUTTON ;
btn[2].dwData = 0 ;
btn[2].iString = 2;
btn[3].iBitmap = 3 ;
btn[3].idCommand = ID_PRINT ;
btn[3].fsState = TBSTATE_ENABLED ;
btn[3].fsStyle = TBSTYLE_BUTTON ;
btn[3].dwData = 0 ;
btn[3].iString = 3;
btn[4].iBitmap = 4 ;
btn[4].idCommand = ID_PRINT_PREVIEW ;
btn[4].fsState = TBSTATE_ENABLED ;
btn[4].fsStyle = TBSTYLE_BUTTON ;
btn[4].dwData = 0 ;
btn[4].iString = 4;
btn[5].iBitmap = 5 ;
btn[5].idCommand = ID_ABOUT ;
btn[5].fsState = TBSTATE_ENABLED ;
btn[5].fsStyle = TBSTYLE_BUTTON ;
btn[5].dwData = 0 ;
btn[5].iString = 5;
//Enable the Tool Tips with the following line
EnableToolTips(TRUE);
SetToolBarPosition(0);
/* CString s;
s.Format("%d年%2d月份月报 ", m_Time.GetYear(),m_Time.GetMonth());
char* ch = s.GetBuffer(s.GetLength());
m_cMonth.SetWindowText(ch);
s.Format("%d年度 年报 ", m_Time.GetYear());
ch = s.GetBuffer(s.GetLength());
m_cYear.SetWindowText(ch);
*/
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
//DWORD dwStyle = m_ListAttend.GetStyle();LVS_EX_FULLROWSELECT|
DWORD dwStyle = m_ListDuty.GetStyle();
dwStyle |= LVS_EX_GRIDLINES | LVS_SHOWSELALWAYS;
dwStyle &= !LVS_EX_TRACKSELECT;
m_ListDuty.SetExtendedStyle(dwStyle);
m_ListDuty.SetBkColor(RGB(240,247,233));
m_ListDuty.SetTextBkColor(RGB(240,247,233));
RECT rect;
m_ListDuty.GetClientRect(&rect);
LV_COLUMN lvc;
lvc.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH |LVCF_FMT;
lvc.fmt=LVCFMT_CENTER;
lvc.iSubItem = 0;
lvc.pszText = _T("Am 点到");
lvc.cx = 60;
m_ListDuty.InsertColumn(1,&lvc);
lvc.iSubItem = 1;
lvc.pszText = _T("午饭");
lvc.cx = 60;
m_ListDuty.InsertColumn(2,&lvc);
lvc.iSubItem = 2;
lvc.pszText = _T("Pm 点到");
lvc.cx = 60;
m_ListDuty.InsertColumn(3,&lvc);
lvc.iSubItem = 3;
lvc.pszText = _T("下班");
lvc.cx = 60;
m_ListDuty.InsertColumn(4,&lvc);
lvc.iSubItem = 4;
lvc.pszText = _T("晚间工作");
lvc.cx = 70;
m_ListDuty.InsertColumn(5,&lvc);
lvc.iSubItem = 5;
lvc.pszText = _T("结束");
lvc.cx = 70;
m_ListDuty.InsertColumn(6,&lvc);
lvc.iSubItem = 6;
lvc.pszText = _T("日工时");
lvc.cx = rect.right-6*60-20;
m_ListDuty.InsertColumn(7,&lvc);
dwStyle = m_ListAttend.GetStyle();
dwStyle |= LVS_EX_GRIDLINES |LVS_EX_FULLROWSELECT|LVS_SHOWSELALWAYS ;
m_ListAttend.SetExtendedStyle(dwStyle);
m_ListAttend.SetBkColor(RGB(240,247,233));
m_ListAttend.SetTextBkColor(RGB(240,247,233));
m_ListAttend.GetClientRect(&rect);
// LV_COLUMN lvc;
lvc.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH |LVCF_FMT;
lvc.fmt=LVCFMT_CENTER;
lvc.iSubItem = 0;
lvc.pszText = _T("日期");//NO.
lvc.cx = 40;
m_ListAttend.InsertColumn(1,&lvc);
lvc.iSubItem = 1;
lvc.pszText = _T("星期");//NO.
lvc.cx = 60;
m_ListAttend.InsertColumn(2,&lvc);
lvc.iSubItem = 2;
lvc.pszText = _T("Am 点到");
lvc.cx = 60;
m_ListAttend.InsertColumn(3,&lvc);
lvc.iSubItem = 3;
lvc.pszText = _T("午饭");
lvc.cx = 55;
m_ListAttend.InsertColumn(4,&lvc);
lvc.iSubItem = 4;
lvc.pszText = _T("Pm 点到");
lvc.cx = 60;
m_ListAttend.InsertColumn(5,&lvc);
lvc.iSubItem = 5;
lvc.pszText = _T("下班");
lvc.cx = 55;
m_ListAttend.InsertColumn(6,&lvc);
lvc.iSubItem = 6;
lvc.pszText = _T("晚间工作");
lvc.cx = 70;
m_ListAttend.InsertColumn(7,&lvc);
lvc.iSubItem = 7;
lvc.pszText = _T("结束");
lvc.cx = 60;
m_ListAttend.InsertColumn(8,&lvc);
lvc.iSubItem = 8;
lvc.pszText = _T("日工时");
lvc.cx = rect.right-40-7*60;
m_ListAttend.InsertColumn(9,&lvc);
//
dwStyle = m_ListTotal.GetStyle();
dwStyle |= LVS_EX_GRIDLINES |LVS_EX_FULLROWSELECT|LVS_SHOWSELALWAYS ;
m_ListTotal.SetExtendedStyle(dwStyle);
m_ListTotal.SetBkColor(RGB(240,247,233));
m_ListTotal.SetTextBkColor(RGB(240,247,233));
m_ListTotal.GetClientRect(&rect);
// LV_COLUMN lvc;
lvc.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH |LVCF_FMT;
lvc.fmt=LVCFMT_CENTER;
lvc.iSubItem = 0;
lvc.pszText = _T("月份");//NO.
lvc.cx = 40;
m_ListTotal.InsertColumn(1,&lvc);
lvc.iSubItem = 1;
lvc.pszText = _T("法定工作日");//NO.
lvc.cx = 80;
m_ListTotal.InsertColumn(2,&lvc);
lvc.iSubItem = 2;
lvc.pszText = _T("全勤工资");
lvc.cx = 75;
m_ListTotal.InsertColumn(3,&lvc);
lvc.iSubItem = 3;
lvc.pszText = _T("日均工资额");
lvc.cx = 85;
m_ListTotal.InsertColumn(4,&lvc);
lvc.iSubItem = 4;
lvc.pszText = _T("实出勤日");
lvc.cx = 75;
m_ListTotal.InsertColumn(5,&lvc);
lvc.iSubItem = 5;
lvc.pszText = _T("出勤工资");
lvc.cx = 75;
m_ListTotal.InsertColumn(6,&lvc);
lvc.iSubItem = 6;
lvc.pszText = _T("实发工资");
lvc.cx = rect.right-430;
m_ListTotal.InsertColumn(6,&lvc);
lvitem.pszText="";
lvitem.mask=LVIF_TEXT;
lvitem.iSubItem=0;
// CTime time=CTime::GetCurrentTime();
// CTimeSpan tm=time-m_Time;
m_iCurDate=m_Time.GetDay();
m_iMaxDate=m_iCurDate;
// CAttendanceApp* app=(CAttendanceApp*)AfxGetApp();
m_sOpenPath = app->m_pszHelpFilePath;
int index = m_sOpenPath.ReverseFind('\\');
m_sOpenPath = m_sOpenPath.Left(index);
m_sSavePath=m_sOpenPath;
m_sAttendFile="考勤"+m_Time.Format("%Y年");
m_sAttendFile+=".atd";
CString filename=m_sOpenPath+"\\"+m_sAttendFile;
m_sFileExt="atd";
CFile file;
if(file.Open(filename,CFile::modeRead)!=0)
{
CArchive ar(&file,CArchive::load);
CWaitCursor wait;
Serialize(ar); // save mem_sCfgFile
ar.Close();
file.Close();
m_sOpenPath=m_sSavePath;
}else
{
CString s = m_Time.Format("%Y");
char* ch = s.GetBuffer(s.GetLength());
int i = atoi(ch);
i--;
itoa(i,ch,10);
s = "考勤"+s;
s += "年";
s += ".atd";
filename=m_sOpenPath+"\\"+s;
if(file.Open(filename,CFile::modeRead)!=0)
{
CArchive ar(&file,CArchive::load);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -