📄 joinnotindutyformdlg.cpp
字号:
m_JoinNIDF_CList10.InsertColumn(4, "部门", LVCFMT_LEFT, 120);
m_JoinNIDF_CList10.InsertColumn(5, "职务", LVCFMT_LEFT, 80);
m_JoinNIDF_CList10.InsertColumn(6, "学历", LVCFMT_LEFT, 80);
m_JoinNIDF_CList10.InsertColumn(7, "专业", LVCFMT_LEFT, 120);
m_JoinNIDF_CList10.InsertColumn(8, "职称", LVCFMT_LEFT, 90);
m_JoinNIDF_CList10.InsertColumn(9, "入司时间", LVCFMT_LEFT, 110);
SYSTEMTIME SysTime = {0};
GetSystemTime(&SysTime);
WORD wYear = SysTime.wYear;
WORD wMonth = SysTime.wMonth;
WORD wDay = SysTime.wDay;
CString SQL;
CString strFields[] = {"ID", "IDCard", "Name", "Company", "Depart", "Duty", "Diploma", "Special", "TechPost", "JoinTime"};
SQL.Format("select Employee_BasicInfor_Table.employee_ID as ID, \
Employee_BasicInfor_Table.employee_IDCard as IDCard, \
Employee_BasicInfor_Table.employee_Name as Name, \
Employee_BasicInfor_Table.employee_HighestDiploma as Diploma, \
Employee_BasicInfor_Table.employee_JoinTime as JoinTime, \
Employee_BasicInfor_Table.employee_TechPost as TechPost, \
Employee_InActiveSer_Table.InActiveSer_Company as Company, \
Employee_InActiveSer_Table.InActiveSer_Department as Depart, \
Employee_InActiveSer_Table.InActiveSer_Duty as Duty, \
Employee_TrainExpe_Table.TrainExpe_Speciality1 as Special \
from Employee_BasicInfor_Table, Employee_InActiveSer_Table, Employee_TrainExpe_Table, CheckType_Table \
where Employee_BasicInfor_Table.employee_ID = CheckType_Table.employee_ID and \
Employee_BasicInfor_Table.employee_ID = Employee_InActiveSer_Table.employee_ID and \
Employee_BasicInfor_Table.employee_ID = Employee_TrainExpe_Table.employee_ID and \
Employee_BasicInfor_Table.employee_IDCard = CheckType_Table.employee_IDCard and \
Employee_BasicInfor_Table.employee_IDCard = Employee_InActiveSer_Table.employee_IDCard and \
Employee_BasicInfor_Table.employee_IDCard = Employee_TrainExpe_Table.employee_IDCard and \
((Employee_InActiveSer_Table.InActiveSer_InDueFormTime > #%d-%d-%d# and \
Employee_InActiveSer_Table.InActiveSer_InDueFormTime < dateadd('d', 3, #%d-%d-%d#) and \
CheckType_Table.IsTypeOne = '未打印1') or \
(Employee_InActiveSer_Table.InActiveSer_InDueFormTime < #%d-%d-%d# and \
CheckType_Table.IsTypeOne = '未打印1'))",
wYear, wMonth, wDay, wYear, wMonth, wDay, wYear, wMonth, wDay);
CADOOperation ADOdbo;
ADOdbo.OpenRecordset(SQL);
ADOdbo.GetFieldsToShow(strFields, 10, &m_JoinNIDF_CList10);
ADOdbo.CloseRecorset();
}
/*********************************************************************
函数说明: 路径设置
函数参数:
*********************************************************************/
void JoinNotInDutyFormDlg::OnJoinnidfBtnSetpath()
{
CFuncOper FunOper;
CString strNewPath;
strNewPath = FunOper.SettingSavePath(this, "请选择 保存 【转正审批表】的路径");
if (strNewPath.IsEmpty())
{
strNewPath = m_strSPath;
}
m_strSPath = strNewPath;
CString strPathMsg;
strPathMsg.Format("(当前保存路径为:%s)", strNewPath);
SetDlgItemText(IDC_JOINNIDF_STATIC_PATH, strPathMsg);
CADOOperation ADOdbo;
CString SQL;
SQL.Format("update AccessInfo_Table set Infos_Path = '%s' where Index_Path = '转正路径'", strNewPath);
ADOdbo.OpenRecordset(SQL);
ADOdbo.CloseRecorset();
}
/*********************************************************************
函数说明: 初始化保存路径的显示
函数参数:
*********************************************************************/
void JoinNotInDutyFormDlg::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();
m_strSPath = strRetPath[0];
CString strPathMsg;
strPathMsg.Format("(当前保存路径为:%s)", strRetPath[0]);
SetDlgItemText(IDC_JOINNIDF_STATIC_PATH, strPathMsg);
}
int g_n10Index = -1;
/*********************************************************************
函数说明: 单击响应
函数参数:
*********************************************************************/
void JoinNotInDutyFormDlg::OnClickJoinnidfList10(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
g_n10Index = lpnmlv->iItem;
m_nID = atoi(m_JoinNIDF_CList10.GetItemText(lpnmlv->iItem, 0));
m_strIDCard = m_JoinNIDF_CList10.GetItemText(lpnmlv->iItem, 1);
m_strName = m_JoinNIDF_CList10.GetItemText(lpnmlv->iItem, 2);
m_strCompany = m_JoinNIDF_CList10.GetItemText(lpnmlv->iItem, 3);
m_strDepart = m_JoinNIDF_CList10.GetItemText(lpnmlv->iItem, 4);
m_strDuty = m_JoinNIDF_CList10.GetItemText(lpnmlv->iItem, 5);
m_strDiploma = m_JoinNIDF_CList10.GetItemText(lpnmlv->iItem, 6);
m_strSpecial = m_JoinNIDF_CList10.GetItemText(lpnmlv->iItem, 7);
m_strTechPost = m_JoinNIDF_CList10.GetItemText(lpnmlv->iItem, 8);
m_strJoinTime = m_JoinNIDF_CList10.GetItemText(lpnmlv->iItem, 9);
CADOOperation ADOdbo;
CString SQL;
CString strField[] = {"IsTypeOne"};
CString strRet[1];
SQL.Format("select IsTypeOne from CheckType_Table \
where employee_ID = %d and employee_IDCard = '%s'", m_nID, m_strIDCard);
ADOdbo.OpenRecordset(SQL);
ADOdbo.GetFieldsValue(strField, 1, strRet, FALSE);
if (strRet[0] == "已打印1")
{
GetDlgItem(IDC_JOINNIDF_BTN_TYPE)->EnableWindow(FALSE);
*pResult = 0;
return;
}
GetDlgItem(IDC_JOINNIDF_BTN_TYPE)->EnableWindow(TRUE);
*pResult = 0;
}
/*********************************************************************
函数说明: 生成转正审批表
函数参数:
*********************************************************************/
void JoinNotInDutyFormDlg::OnJoinnidfBtnType()
{
if (g_n10Index < 0)
{
MessageBox("请在表单中选择一个项\t", NULL, MB_OK | MB_ICONEXCLAMATION);
}
else
{
CString strMsg;
strMsg.Format("确定生成【%s】的转正审批表吗?\t", m_strName);
if (IDYES == MessageBox(strMsg, "提示", MB_YESNO | MB_ICONEXCLAMATION))
{
MakeWordDocment();
CADOOperation ADOdbo;
CString SQL;
SQL.Format("update CheckType_Table set IsTypeOne = '%s' \
where employee_ID = %d and employee_IDCard = '%s' and employee_Name = '%s'",
"已打印1", m_nID, m_strIDCard, m_strName);
ADOdbo.OpenRecordset(SQL);
ADOdbo.CloseRecorset();
}
}
}
/*********************************************************************
函数说明: 生成Word文档——转正审批表
函数参数:
*********************************************************************/
void JoinNotInDutyFormDlg::MakeWordDocment()
{
BeginWaitCursor();
COleVariant vOpt((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
_Application_Word m_Application; // 应用程序对象
Documents_Word m_Documents; // 文档对象
Selection_Word m_Selection; // 选择对象
CFuncOper FunOper;
m_Documents.ReleaseDispatch();
m_Selection.ReleaseDispatch();
m_Application.m_bAutoRelease = TRUE;
if(!m_Application.CreateDispatch("Word.Application"))
{
MessageBox("创建 Word 服务失败!请确认您的系操中已安装了 Microsoft Office 组件\t", "失败",
MB_OK | MB_ICONEXCLAMATION);
exit(1);
}
CString strFile;
strFile = FunOper.GetProgramPath() + "\\DocsWord\\转正审批表(空).doc";
// 下面是定义 Variant 变量
COleVariant varFilePath(strFile);
COleVariant vTrue( (short)TRUE);
COleVariant vFalse((short)FALSE);
COleVariant varstrNull("");
COleVariant varZero((short)0);
COleVariant varTrue( short(1), VT_BOOL);
COleVariant varFalse(short(0), VT_BOOL);
m_Documents.AttachDispatch(m_Application.GetDocuments());
m_Documents.Open(varFilePath, varFalse, varFalse, varFalse, varstrNull, varstrNull,
varFalse, varstrNull, varstrNull,varTrue,varTrue,varTrue);
// 打开 word 文档
m_Selection.AttachDispatch(m_Application.GetSelection());
// Unit Count Extend
m_Selection.MoveDown(COleVariant((short)wdLine), COleVariant((short)1), COleVariant((short)0));
m_Selection.TypeText((LPCTSTR)m_strName);
m_Selection.MoveDown(COleVariant((short)wdLine), COleVariant((short)1), COleVariant((short)0));
m_Selection.TypeText((LPCTSTR)m_strDepart);
m_Selection.MoveDown(COleVariant((short)wdLine), COleVariant((short)1), COleVariant((short)0));
m_Selection.TypeText((LPCTSTR)m_strDiploma);
m_Selection.MoveDown(COleVariant((short)wdLine), COleVariant((short)1), COleVariant((short)0));
m_Selection.TypeText((LPCTSTR)m_strTechPost);
m_Selection.MoveRight(COleVariant((short)wdCharacter), COleVariant((short)1), COleVariant((short)0));
m_Selection.MoveUp(COleVariant((short)wdLine), COleVariant((short)3), COleVariant((short)0));
m_Selection.MoveRight(COleVariant((short)wdCharacter), COleVariant((short)3), COleVariant((short)0));
m_Selection.TypeText((LPCTSTR)m_strCompany);
m_Selection.MoveDown(COleVariant((short)wdLine), COleVariant((short)1), COleVariant((short)0));
m_Selection.TypeText((LPCTSTR)m_strDuty);
m_Selection.MoveDown(COleVariant((short)wdLine), COleVariant((short)1), COleVariant((short)0));
m_Selection.TypeText((LPCTSTR)m_strSpecial);
m_Selection.MoveDown(COleVariant((short)wdLine), COleVariant((short)1), COleVariant((short)0));
m_Selection.TypeText((LPCTSTR)m_strJoinTime);
// 保存文档
_Document_Word oActiveDoc;
oActiveDoc = m_Application.GetActiveDocument();
CString strSavePath;
strSavePath.Format(m_strSPath + "\\转正审批表_%s.doc", m_strName);
oActiveDoc.SaveAs(COleVariant(strSavePath), COleVariant((short)0), vFalse, COleVariant(""),
vTrue, COleVariant(""), vFalse, vFalse, vFalse, vFalse, vFalse);
m_Documents.ReleaseDispatch(); // 断开连接
m_Selection.ReleaseDispatch();
// 退出 word
m_Application.Quit(vOpt, vOpt, vOpt);
m_Application.Quit(vOpt, vOpt, vOpt);
m_Application.ReleaseDispatch();
EndWaitCursor();
CString strMsg;
strMsg.Format("【%s】的转正审批表生成成功!", m_strName);
MessageBox(strMsg, "提示", MB_ICONEXCLAMATION | MB_OK);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -