📄 menu_inputreminfodlg.cpp
字号:
CString strDuty;
if (m_strNewDuty.IsEmpty())
{
strDuty = m_strOldDuty;
}
else
{
strDuty = m_strNewDuty;
}
CADOOperation ADOdbo;
CString SQL;
SQL.Format("update Employee_InActiveSer_Table \
set InActiveSer_Company = '%s', InActiveSer_Department = '%s', InActiveSer_Duty = '%s' \
where employee_IDCard = '%s'",
m_strNewCompany, m_strNewDepart, strDuty, m_strIDCard);
ADOdbo.OpenRecordset(SQL);
ADOdbo.CloseRecorset();
}
if (!m_bMakeWord)
{
CString strMsg;
strMsg.Format("还未生成与员工【%s】调动相关的Word打印文档\n退出前,必须生成该文档,现在进行此操作嘛?\t", m_strName);
if (IDYES == MessageBox(strMsg, "提示", MB_YESNO | MB_ICONEXCLAMATION))
{
CADOOperation ADOdbo;
CFuncOper FunOper;
CString SQL;
CString strField[] = {"PersonAlter_EventNum"};
WORD wAlterT[3];
CString strEventNum[1];
FunOper.strTimeTowTime(m_strAlterTime, wAlterT);
SQL.Format("select PersonAlter_EventNum from Employee_PersonAlter_Table where \
employee_IDCard = '%s' and PersonAlter_AlterTime = #%d-%d-%d#",
m_strIDCard, wAlterT[0], wAlterT[1], wAlterT[2]);
ADOdbo.OpenRecordset(SQL);
ADOdbo.GetFieldsValue(strField, 1, strEventNum, FALSE);
ADOdbo.CloseRecorset();
m_strEventNum = strEventNum[0];
MakeAlterInfoWord1();
MakeAlterInfoWord2();
strMsg.Format("【%s】的【调动通知信】和【调动介绍信】生成成功!", m_strName);
MessageBox(strMsg, "提示", MB_ICONEXCLAMATION | MB_OK);
m_bMakeWord = TRUE; // 标志位,表示已经生成WORD文档了,在离开时就不用提示了
GetDlgItem(IDC_INPUTREM_BTN_WORD)->EnableWindow(FALSE);
}
return;
}
CDialog::OnCancel();
}
/*********************************************************************
函数说明: [按钮] 保存路径
函数参数:
*********************************************************************/
void Menu_InputRemInfoDlg::OnInputremBtnPath()
{
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_INPUTREM_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 Menu_InputRemInfoDlg::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_INPUTREM_STATIC_PATH, strPathMsg);
}
/*********************************************************************
函数说明: [按钮]生成 Word 文档
函数参数:
*********************************************************************/
void Menu_InputRemInfoDlg::OnInputremBtnWord()
{
CString strMsg;
strMsg.Format("确定要生成【%s】的调动相关的Word打印表吗?\t", m_strName);
if (IDYES == MessageBox(strMsg, "提示", MB_YESNO | MB_ICONEXCLAMATION))
{
CADOOperation ADOdbo;
CFuncOper FunOper;
CString SQL;
CString strField[] = {"PersonAlter_EventNum"};
WORD wAlterT[3];
CString strEventNum[1];
FunOper.strTimeTowTime(m_strAlterTime, wAlterT);
SQL.Format("select PersonAlter_EventNum from Employee_PersonAlter_Table where \
employee_IDCard = '%s' and PersonAlter_AlterTime = #%d-%d-%d#",
m_strIDCard, wAlterT[0], wAlterT[1], wAlterT[2]);
ADOdbo.OpenRecordset(SQL);
ADOdbo.GetFieldsValue(strField, 1, strEventNum, FALSE);
ADOdbo.CloseRecorset();
m_strEventNum = strEventNum[0];
MakeAlterInfoWord1();
MakeAlterInfoWord2();
CString strMsg;
strMsg.Format("【%s】的【调动通知信】和【调动介绍信】生成成功!", m_strName);
MessageBox(strMsg, "提示", MB_ICONEXCLAMATION | MB_OK);
m_bMakeWord = TRUE; // 标志位,表示已经生成WORD文档了,在离开时就不用提示了
GetDlgItem(IDC_INPUTREM_BTN_WORD)->EnableWindow(FALSE);
}
}
/*********************************************************************
函数说明: 生成 [调动通知] Word 文档
函数参数:
*********************************************************************/
void Menu_InputRemInfoDlg::MakeAlterInfoWord1()
{
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)2), COleVariant((short)0));
m_Selection.MoveRight(COleVariant((short)wdCharacter), COleVariant((short)14), COleVariant((short)0));
m_Selection.TypeText((LPCTSTR)m_strEventNum);
m_Selection.MoveDown(COleVariant((short)wdLine), COleVariant((short)1), COleVariant((short)0));
m_Selection.TypeText((LPCTSTR)m_strOldDepart);
m_Selection.HomeKey(COleVariant((short)wdLine), COleVariant((short)0));
m_Selection.MoveDown(COleVariant((short)wdLine), COleVariant((short)2), COleVariant((short)0));
m_Selection.MoveRight(COleVariant((short)wdCharacter), COleVariant((short)5), COleVariant((short)0));
m_Selection.TypeText((LPCTSTR)m_strName);
m_Selection.MoveDown(COleVariant((short)wdLine), COleVariant((short)4), COleVariant((short)0));
m_Selection.EndKey(COleVariant((short)wdLine), COleVariant((short)0));
CString PayOldEndT1;
PayOldEndT1 = FunOper.FormatDataToShow(m_strPayOldEndT);
m_Selection.TypeText((LPCTSTR)PayOldEndT1);
m_Selection.MoveDown(COleVariant((short)wdLine), COleVariant((short)2), COleVariant((short)0));
m_Selection.EndKey(COleVariant((short)wdLine), COleVariant((short)0));
CString AlterT1;
AlterT1 = FunOper.FormatDataToShow(m_strAlterTime);
m_Selection.TypeText((LPCTSTR)AlterT1);
m_Selection.MoveRight(COleVariant((short)wdCharacter), COleVariant((short)2), COleVariant((short)0));
m_Selection.MoveUp(COleVariant((short)wdLine), COleVariant((short)9), COleVariant((short)0));
m_Selection.MoveRight(COleVariant((short)wdCharacter), COleVariant((short)14), COleVariant((short)0));
m_Selection.TypeText((LPCTSTR)m_strEventNum);
m_Selection.MoveDown(COleVariant((short)wdLine), COleVariant((short)1), COleVariant((short)0));
m_Selection.TypeText((LPCTSTR)m_strOldDepart);
m_Selection.HomeKey(COleVariant((short)wdLine), COleVariant((short)0));
m_Selection.MoveDown(COleVariant((short)wdLine), COleVariant((short)2), COleVariant((short)0));
m_Selection.MoveRight(COleVariant((short)wdCharacter), COleVariant((short)5), COleVariant((short)0));
m_Selection.TypeText((LPCTSTR)m_strName);
m_Selection.MoveDown(COleVariant((short)wdLine), COleVariant((short)4), COleVariant((short)0));
m_Selection.EndKey(COleVariant((short)wdLine), COleVariant((short)0));
CString PayOldEndT2;
PayOldEndT2 = FunOper.FormatDataToShow(m_strPayOldEndT);
m_Selection.TypeText((LPCTSTR)PayOldEndT2);
m_Selection.MoveDown(COleVariant((short)wdLine), COleVariant((short)2), COleVariant((short)0));
m_Selection.EndKey(COleVariant((short)wdLine), COleVariant((short)0));
CString AlterT2;
AlterT2 = FunOper.FormatDataToShow(m_strAlterTime);
m_Selection.TypeText((LPCTSTR)AlterT2);
// 保存文档
_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();
}
/*********************************************************************
函数说明: 生成 [调动介绍信] Word 文档
函数参数:
*********************************************************************/
void Menu_InputRemInfoDlg::MakeAlterInfoWord2()
{
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.MoveRight(COleVariant((short)wdCharacter), COleVariant((short)9), COleVariant((short)0));
m_Selection.MoveDown(COleVariant((short)wdLine), COleVariant((short)1), COleVariant((short)0));
m_Selection.TypeText((LPCTSTR)m_strEventNum);
m_Selection.MoveDown(COleVariant((short)wdLine), COleVariant((short)2), 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_strOldDepart);
m_Selection.MoveDown(COleVariant((short)wdLine), COleVariant((short)1), COleVariant((short)0));
m_Selection.TypeText((LPCTSTR)m_strNewDepart);
m_Selection.MoveDown(COleVariant((short)wdLine), COleVariant((short)2), COleVariant((short)0));
m_Selection.EndKey(COleVariant((short)wdLine), COleVariant((short)0));
CString PayNewT = FunOper.FormatDataToShow(m_strPayNewBegT);
m_Selection.TypeText((LPCTSTR)PayNewT);
m_Selection.MoveDown(COleVariant((short)wdLine), COleVariant((short)3), COleVariant((short)0));
CString AlterTime = FunOper.FormatDataToShow(m_strAlterTime);
m_Selection.TypeText((LPCTSTR)AlterTime);
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.EndKey(COleVariant((short)wdLine), COleVariant((short)0));
m_Selection.MoveLeft(COleVariant((short)wdCharacter), COleVariant((short)1), COleVariant((short)0));
m_Selection.TypeText((LPCTSTR)m_strEventNum);
m_Selection.MoveDown(COleVariant((short)wdLine), COleVariant((short)1), COleVariant((short)0));
m_Selection.TypeText((LPCTSTR)m_strNewDepart);
int nLen = (m_strNewDepart.GetLength() / 2);
m_Selection.MoveLeft(COleVariant((short)wdCharacter), COleVariant((short)nLen), COleVariant((short)0));
m_Selection.TypeBackspace();
m_Selection.MoveRight(COleVariant((short)wdCharacter), COleVariant((short)nLen), COleVariant((short)0));
m_Selection.TypeText((LPCTSTR)(":"));
m_Selection.MoveDown(COleVariant((short)wdLine), COleVariant((short)1), COleVariant((short)0));
m_Selection.HomeKey(COleVariant((short)wdLine), COleVariant((short)0));
m_Selection.MoveRight(COleVariant((short)wdCharacter), COleVariant((short)14), COleVariant((short)0));
m_Selection.TypeText((LPCTSTR)m_strName);
m_Selection.MoveDown(COleVariant((short)wdLine), COleVariant((short)2), COleVariant((short)0));
CString AlterTime2 = FunOper.FormatDataToShow(m_strAlterTime);
m_Selection.TypeText((LPCTSTR)AlterTime2);
m_Selection.HomeKey(COleVariant((short)wdLine), COleVariant((short)0));
m_Selection.MoveDown(COleVariant((short)wdLine), COleVariant((short)2), COleVariant((short)0));
m_Selection.TypeText((LPCTSTR)m_strName);
m_Selection.MoveRight(COleVariant((short)wdCharacter), COleVariant((short)1), COleVariant((short)0));
m_Selection.TypeText((LPCTSTR)m_strSex);
m_Selection.MoveRight(COleVariant((short)wdCharacter), COleVariant((short)1), COleVariant((short)0));
m_Selection.TypeText((LPCTSTR)m_strOldDepart);
m_Selection.MoveDown(COleVariant((short)wdLine), COleVariant((short)6), COleVariant((short)0));
m_Selection.HomeKey(COleVariant((short)wdLine), COleVariant((short)0));
m_Selection.MoveRight(COleVariant((short)wdCharacter), COleVariant((short)5), COleVariant((short)0));
CString PayNewTime2 = FunOper.FormatDataToShow(m_strPayNewBegT);
m_Selection.TypeText((LPCTSTR)PayNewTime2);
// 保存文档
_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();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -