📄 salarytabledlg.cpp
字号:
// SalaryTableDlg.cpp : implementation file
//
#include "stdafx.h"
#include "SalaryManagement.h"
#include "SalaryTableDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSalaryTableDlg dialog
BOOL CSalaryTableDlg::OnInitDialog(){ //重载初始化对话框的虚函数
CListCtrl *pList=(CListCtrl *)GetDlgItem(IDC_SALARYTABLE_LIST); //得到能控制列表控件的指针
//初始化列表控件
pList->InsertColumn(0,"职员号");
pList->InsertColumn(1,"姓名");
pList->InsertColumn(2,"职位");
pList->InsertColumn(3,"所在部门");
pList->InsertColumn(4,"基本工资");
pList->InsertColumn(5,"扣除");
pList->InsertColumn(6,"销售业绩奖");
pList->InsertColumn(7,"总工资");
//设置列表的宽度和风格
pList->SetExtendedStyle(LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT); //设置列表的风格 有网格线 全行选中
RECT ListRect; //得到列表控件的空间
pList->GetWindowRect(&ListRect);
int breadth=ListRect.right-ListRect.left; //得到列表控件的宽度
pList->SetColumnWidth(0,breadth/8); //设置每一列的宽度
pList->SetColumnWidth(1,breadth/8);
pList->SetColumnWidth(2,breadth/8);
pList->SetColumnWidth(3,breadth/8);
pList->SetColumnWidth(4,breadth/8);
pList->SetColumnWidth(5,breadth/8);
pList->SetColumnWidth(6,breadth/8);
pList->SetColumnWidth(7,breadth/8);
//////////////////////////////////////////////////////////////////////////
//时间
m_year=pDepartment->GetYear(); //得到此工资表的日期
m_month=pDepartment->GetMonth();
DisplaySalaryTable(); //显示工资表
CDialog::OnInitDialog();
return TRUE;
}
void CSalaryTableDlg::DisplaySalaryTable(){ //显示本月工资表
CListCtrl *pList=(CListCtrl *)GetDlgItem(IDC_SALARYTABLE_LIST); //建立一个控制列表控件资源的指针
pDepartment->GetDepartmentEmployee(); //得到此部门的全部职员基本信息
pDepartment->GetEmployeeSellamount(); //职员的销售额信息
pList->DeleteAllItems(); //删除原有的条目
int i=0;
int j=pDepartment->GetEmployeeNumber(); //j为此部门中职员的人数
while(i<j){ //得到这个部门的工资表
pList->InsertItem(i,"");
pList->SetItemText(i,0,(pDepartment->m_employee+i)->GetEmployeeID()); //职员号
pList->SetItemText(i,1,(pDepartment->m_employee+i)->GetEmployeeName()); //姓名
pList->SetItemText(i,2,(pDepartment->m_employee+i)->GetEmployeePosition()); //职位
pList->SetItemText(i,3,(pDepartment->m_employee+i)->GetEmployeeDepartment()); //部门
pList->SetItemText(i,4,(pDepartment->m_employee+i)->GetEmployeeBasis()); //基本工资
pList->SetItemText(i,5,(pDepartment->m_employee+i)->GetEmployeeDeduct()); //扣除
pList->SetItemText(i,6,(pDepartment->m_employee+i)->GetEmployeeBonus()); //销售业绩奖
pList->SetItemText(i,7,(pDepartment->m_employee+i)->GetEmployeeTotal()); //总工资
i++;
}
UpdateData(FALSE);
}
/*--------------------------------------------------------------------------------*/
CSalaryTableDlg::CSalaryTableDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSalaryTableDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSalaryTableDlg)
m_month = _T("");
m_year = _T("");
//}}AFX_DATA_INIT
}
void CSalaryTableDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSalaryTableDlg)
DDX_Text(pDX, IDC_SALARYTABLE_MONTH_EDIT, m_month);
DDV_MaxChars(pDX, m_month, 3);
DDX_Text(pDX, IDC_SALARYTABLE_YEAR_EDIT, m_year);
DDV_MaxChars(pDX, m_year, 4);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSalaryTableDlg, CDialog)
//{{AFX_MSG_MAP(CSalaryTableDlg)
ON_BN_CLICKED(IDC_SALARYTABLE_PRINT_BUTTON, OnSalarytablePrintButton)
ON_BN_CLICKED(IDC_SALARYTABLE_CANCEL_BUTTON, OnSalarytableCancelButton)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSalaryTableDlg message handlers
void CSalaryTableDlg::OnSalarytablePrintButton(){ //虚拟打印
MessageBox("(虚拟打印)打印成功","虚拟打印工资单",0);
EndDialog(IDOK);
}
void CSalaryTableDlg::OnSalarytableCancelButton(){ //取消
EndDialog(IDCANCEL);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -