📄 joinflowerinfodlg.cpp
字号:
// JoinFlowerInfoDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ministryperson.h"
#include "JoinFlowerInfoDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// JoinFlowerInfoDlg dialog
MakeWordsDoc MKWordDlg;
JoinFlowerInfoDlg::JoinFlowerInfoDlg(CWnd* pParent /*=NULL*/)
: CDialog(JoinFlowerInfoDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(JoinFlowerInfoDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void JoinFlowerInfoDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(JoinFlowerInfoDlg)
DDX_Control(pDX, IDC_JOIN_FLOWER_LIST, m_CEditList_JoinFloList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(JoinFlowerInfoDlg, CDialog)
//{{AFX_MSG_MAP(JoinFlowerInfoDlg)
ON_BN_CLICKED(IDC_JOIN_FLOWER_BTN_TYPE, OnJoinFlowerBtnType)
ON_MESSAGE(UM_LISTEDIT_DBCLICK, OnListEditDBClick)
ON_BN_CLICKED(IDC_JOIN_FLOWER_BTN_QUERY, OnJoinFlowerBtnQuery)
ON_NOTIFY(NM_CLICK, IDC_JOIN_FLOWER_LIST, OnClickJoinFlowerList)
ON_BN_CLICKED(IDC_JOIN_FLOWER_BTN_SETPATH, OnJoinFlowerBtnSetpath)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// JoinFlowerInfoDlg message handlers
BOOL JoinFlowerInfoDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
ShowJoinFlowerInfo();
InitSavePath();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
/*********************************************************************
函数说明: 清空数据表的显示
函数参数: void
*********************************************************************/
BOOL JoinFlowerInfoDlg::DeleteAllRows()
{
m_CEditList_JoinFloList.DeleteAllItems(); // 清空列表控件
return TRUE;
}
/*********************************************************************
函数说明: 设置列表控件一行的内容
函数参数:
*********************************************************************/
BOOL JoinFlowerInfoDlg::SetRow(int row, CString *strArray, int nCount)
{
m_CEditList_JoinFloList.InsertItem(row, strArray[0]); // 在列表控件中插入一行
for (int i = 1; i < nCount; i++)
{
m_CEditList_JoinFloList.SetItemText(row, i, strArray[i]); // 设置除第一行外的其他行
}
return TRUE;
}
/*********************************************************************
函数说明: 显示未转正的员工信息
函数参数:
*********************************************************************/
void JoinFlowerInfoDlg::ShowJoinFlowerInfo()
{
m_CEditList_JoinFloList.SetExtendedStyle(LVS_EX_FLATSB |
LVS_EX_GRIDLINES |
LVS_EX_FULLROWSELECT |
LVS_EX_ONECLICKACTIVATE);
m_CEditList_JoinFloList.InsertColumn(0, "编号", LVCFMT_LEFT, 40);
m_CEditList_JoinFloList.InsertColumn(1, "身份证", LVCFMT_LEFT, 150);
m_CEditList_JoinFloList.InsertColumn(2, "姓名", LVCFMT_LEFT, 60);
m_CEditList_JoinFloList.InsertColumn(3, "性别", LVCFMT_LEFT, 50);
m_CEditList_JoinFloList.InsertColumn(4, "转正时间", LVCFMT_LEFT, 90);
m_CEditList_JoinFloList.InsertColumn(5, "所属单位", LVCFMT_LEFT, 225);
m_CEditList_JoinFloList.InsertColumn(6, "所在岗位", LVCFMT_LEFT, 180);
SYSTEMTIME SysTime = {0};
GetSystemTime(&SysTime);
WORD wYear = SysTime.wYear;
WORD wMonth = SysTime.wMonth;
WORD wDay = SysTime.wDay;
MKWordDlg.m_strData.Format("%d-%d-%d", wYear, wMonth, wDay);
CString SQL;
CString strFields[] = {"F_ID", "F_IDCard", "F_Name", "F_Sex", "F_IDFTime", "F_Company", "F_Duty"};
SQL.Format("select Employee_BasicInfor_Table.employee_ID as F_ID, \
Employee_BasicInfor_Table.employee_IDCard as F_IDCard, \
Employee_BasicInfor_Table.employee_Name as F_Name, \
Employee_BasicInfor_Table.employee_Sex as F_Sex, \
Employee_InActiveSer_Table.InActiveSer_InDueFormTime as F_IDFTime, \
Employee_InActiveSer_Table.InActiveSer_Company as F_Company, \
Employee_InActiveSer_Table.InActiveSer_Duty as F_Duty \
from Employee_BasicInfor_Table, Employee_InActiveSer_Table \
where Employee_BasicInfor_Table.employee_ID = Employee_InActiveSer_Table.employee_ID and \
Employee_BasicInfor_Table.employee_IDCard = Employee_InActiveSer_Table.employee_IDCard and \
Employee_InActiveSer_Table.InActiveSer_InDueFormTime > #%d-%d-%d#", wYear, wMonth, wDay);
CADOOperation ADOdbo;
ADOdbo.OpenRecordset(SQL);
ADOdbo.ShowADOView(strFields, 7, this);
ADOdbo.CloseRecorset();
int nItemCount = m_CEditList_JoinFloList.GetItemCount();
for (int n = 0; n < nItemCount; n++)
{
CString strFields[] = {"employee_ID", "employee_IDCard"};
CString strRetValue[2];
strRetValue[0] = "NOID";
strRetValue[1] = "NOIDCard";
SQL.Format("select employee_ID, employee_IDCard from CheckType_Table \
where employee_ID = %d and employee_IDCard = '%s'",
atoi(m_CEditList_JoinFloList.GetItemText(n, 0)),
m_CEditList_JoinFloList.GetItemText(n, 1));
ADOdbo.OpenRecordset(SQL);
ADOdbo.GetFieldsValue(strFields, 2, strRetValue, FALSE);
ADOdbo.CloseRecorset();
if (strRetValue[0] == "NOID" && strRetValue[1] == "NOIDCard")
{
SQL.Format("insert into CheckType_Table values (%d, '%s', '%s', '%s', '%s')",
atoi(m_CEditList_JoinFloList.GetItemText(n, 0)),
m_CEditList_JoinFloList.GetItemText(n, 2),
m_CEditList_JoinFloList.GetItemText(n, 1), "未打印3", "未打印1");
ADOdbo.OpenRecordset(SQL);
ADOdbo.CloseRecorset();
}
}
}
/*********************************************************************
函数说明: 双击响应
函数参数:
*********************************************************************/
LRESULT JoinFlowerInfoDlg::OnListEditDBClick(WPARAM wParam, LPARAM lParam)
{
LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)wParam;
MKWordDlg.m_nID = atoi(m_CEditList_JoinFloList.GetItemText(lpnmlv->iItem, 0));
MKWordDlg.m_strIDCard = m_CEditList_JoinFloList.GetItemText(lpnmlv->iItem, 1);
MKWordDlg.m_strName = m_CEditList_JoinFloList.GetItemText(lpnmlv->iItem, 2);
MKWordDlg.m_strSex = m_CEditList_JoinFloList.GetItemText(lpnmlv->iItem, 3);
MKWordDlg.m_strJoinTime = m_CEditList_JoinFloList.GetItemText(lpnmlv->iItem, 4);
MKWordDlg.m_strCompany = m_CEditList_JoinFloList.GetItemText(lpnmlv->iItem, 5);
MKWordDlg.m_strDuty = m_CEditList_JoinFloList.GetItemText(lpnmlv->iItem, 6);
CADOOperation ADOdbo;
CString SQL;
CString strField[] = {"IsTypeThree"};
CString strRet[1];
SQL.Format("select IsTypeThree from CheckType_Table \
where employee_ID = %d and employee_IDCard = '%s'", MKWordDlg.m_nID, MKWordDlg.m_strIDCard);
ADOdbo.OpenRecordset(SQL);
ADOdbo.GetFieldsValue(strField, 1, strRet, FALSE);
if (strRet[0] == "已打印3")
{
CString strMsg;
strMsg.Format("【%s】的3份入职管理文档已打印过!\t", MKWordDlg.m_strName);
MessageBox(strMsg, "提示", MB_ICONEXCLAMATION | MB_OK);
GetDlgItem(IDC_JOIN_FLOWER_BTN_TYPE)->EnableWindow(FALSE);
return FALSE;
}
GetDlgItem(IDC_JOIN_FLOWER_BTN_TYPE)->EnableWindow(TRUE);
OnJoinFlowerBtnType();
return TRUE;
}
/*********************************************************************
函数说明: 时间筛选
函数参数:
*********************************************************************/
void JoinFlowerInfoDlg::OnJoinFlowerBtnQuery()
{
CString strTime;
GetDlgItemText(IDC_JOIN_FLOWER_DTP, strTime);
int nPointYM = strTime.Find("-", 0);
int wYear = atoi(strTime.Left(nPointYM));
int nPointMD = strTime.Find("-", nPointYM + 1);
int wDay = atoi(strTime.Right(strTime.GetLength() - nPointMD - 1));
int wMonth = atoi(strTime.Mid(nPointYM + 1, nPointMD - nPointYM - 1));
CString SQL;
CString strFields[] = {"F_ID", "F_IDCard", "F_Name", "F_Sex", "F_IDFTime", "F_Company", "F_Duty"};
SQL.Format("select Employee_BasicInfor_Table.employee_ID as F_ID, \
Employee_BasicInfor_Table.employee_IDCard as F_IDCard, \
Employee_BasicInfor_Table.employee_Name as F_Name, \
Employee_BasicInfor_Table.employee_Sex as F_Sex, \
Employee_InActiveSer_Table.InActiveSer_InDueFormTime as F_IDFTime, \
Employee_InActiveSer_Table.InActiveSer_Company as F_Company, \
Employee_InActiveSer_Table.InActiveSer_Duty as F_Duty \
from Employee_BasicInfor_Table, Employee_InActiveSer_Table \
where Employee_BasicInfor_Table.employee_ID = Employee_InActiveSer_Table.employee_ID and \
Employee_BasicInfor_Table.employee_IDCard = Employee_InActiveSer_Table.employee_IDCard and \
Employee_InActiveSer_Table.InActiveSer_InDueFormTime > #%d-%d-%d#", wYear, wMonth, wDay);
CADOOperation ADOdbo;
ADOdbo.OpenRecordset(SQL);
ADOdbo.ShowADOView(strFields, 7, this);
ADOdbo.CloseRecorset();
}
int g_nWordIndex = -1;
/*********************************************************************
函数说明: 单击响应
函数参数:
*********************************************************************/
void JoinFlowerInfoDlg::OnClickJoinFlowerList(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
g_nWordIndex = lpnmlv->iItem;
MKWordDlg.m_nID = atoi(m_CEditList_JoinFloList.GetItemText(lpnmlv->iItem, 0));
MKWordDlg.m_strIDCard = m_CEditList_JoinFloList.GetItemText(lpnmlv->iItem, 1);
MKWordDlg.m_strName = m_CEditList_JoinFloList.GetItemText(lpnmlv->iItem, 2);
MKWordDlg.m_strSex = m_CEditList_JoinFloList.GetItemText(lpnmlv->iItem, 3);
MKWordDlg.m_strJoinTime = m_CEditList_JoinFloList.GetItemText(lpnmlv->iItem, 4);
MKWordDlg.m_strCompany = m_CEditList_JoinFloList.GetItemText(lpnmlv->iItem, 5);
MKWordDlg.m_strDuty = m_CEditList_JoinFloList.GetItemText(lpnmlv->iItem, 6);
CADOOperation ADOdbo;
CString SQL;
CString strField[] = {"IsTypeThree"};
CString strRet[1];
SQL.Format("select IsTypeThree from CheckType_Table \
where employee_ID = %d and employee_IDCard = '%s'", MKWordDlg.m_nID, MKWordDlg.m_strIDCard);
ADOdbo.OpenRecordset(SQL);
ADOdbo.GetFieldsValue(strField, 1, strRet, FALSE);
if (strRet[0] == "已打印3")
{
GetDlgItem(IDC_JOIN_FLOWER_BTN_TYPE)->EnableWindow(FALSE);
*pResult = 0;
return;
}
GetDlgItem(IDC_JOIN_FLOWER_BTN_TYPE)->EnableWindow(TRUE);
*pResult = 0;
}
/*********************************************************************
函数说明: 打印按钮
函数参数:
*********************************************************************/
void JoinFlowerInfoDlg::OnJoinFlowerBtnType()
{
if (g_nWordIndex < 0)
{
MessageBox("请在表单中选择一个项\t", NULL, MB_OK | MB_ICONEXCLAMATION);
}
else
{
MKWordDlg.DoModal();
}
}
/*********************************************************************
函数说明: 路径设置
函数参数:
*********************************************************************/
void JoinFlowerInfoDlg::OnJoinFlowerBtnSetpath()
{
CFuncOper FunOper;
CString strNewPath;
strNewPath = FunOper.SettingSavePath(this, "请选择 保存 【报到通知单】的路径");
if (strNewPath.IsEmpty())
{
strNewPath = MKWordDlg.m_strSPath;
}
MKWordDlg.m_strSPath = strNewPath;
CString strPathMsg;
strPathMsg.Format("(当前保存路径为:%s)", strNewPath);
SetDlgItemText(IDC_STATIC_CURPATH, strPathMsg);
CADOOperation ADOdbo;
CString SQL;
SQL.Format("update AccessInfo_Table set Infos_Path = '%s' where Index_Path = '保存路径'", strNewPath);
ADOdbo.OpenRecordset(SQL);
ADOdbo.CloseRecorset();
}
/*********************************************************************
函数说明: 初始化保存路径的显示
函数参数:
*********************************************************************/
void JoinFlowerInfoDlg::InitSavePath()
{
CADOOperation ADOdbo;
CString SQL;
SQL.Format("select Infos_Path from AccessInfo_Table where Index_Path = '保存路径'");
ADOdbo.OpenRecordset(SQL);
CString strField[] = {"Infos_Path"};
CString strRetPath[1];
ADOdbo.GetFieldsValue(strField, 1, strRetPath, FALSE);
ADOdbo.CloseRecorset();
MKWordDlg.m_strSPath = strRetPath[0];
CString strPathMsg;
strPathMsg.Format("(当前保存路径为:%s)", strRetPath[0]);
SetDlgItemText(IDC_STATIC_CURPATH, strPathMsg);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -