NetTimeSheet.cpp
上传用户:kklily621
上传日期:2013-06-25
资源大小:252k
文件大小:3k
开发平台:

Visual C++

  1. // NetTimeSheet.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "Property.h"
  5. #include "NetTimeSheet.h"
  6. //owner add
  7. #include "GuiRes.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. //=============================================================================================
  14. // CNetTimeSheet
  15. extern CAclFile m_AclFile;
  16. extern CPropertyApp theApp;
  17. IMPLEMENT_DYNAMIC(CNetTimeSheet, CPropertySheet)
  18. CNetTimeSheet::CNetTimeSheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
  19. :CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
  20. {
  21. }
  22. CNetTimeSheet::CNetTimeSheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
  23. :CPropertySheet(pszCaption, pParentWnd, iSelectPage)
  24. {
  25. }
  26. CNetTimeSheet::~CNetTimeSheet()
  27. {
  28. }
  29. BEGIN_MESSAGE_MAP(CNetTimeSheet, CPropertySheet)
  30. //{{AFX_MSG_MAP(CNetTimeSheet)
  31. ON_BN_CLICKED(ID_APPLY_NOW, OnApply)
  32. ON_BN_CLICKED(IDOK, OnOK)
  33. ON_BN_CLICKED(IDCANCEL, OnCancel)
  34. ON_WM_SYSCOMMAND()
  35. //}}AFX_MSG_MAP
  36. END_MESSAGE_MAP()
  37. //=============================================================================================
  38. // CNetTimeSheet message handlers
  39. BOOL CNetTimeSheet::OnInitDialog() 
  40. {
  41. BOOL bResult = CPropertySheet::OnInitDialog();
  42. SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), TRUE);
  43. InitDlgResource();
  44. return bResult;
  45. }
  46. /*---------------------------------------------------------------------------------------------
  47. initialize dialog's resource
  48. */
  49. void CNetTimeSheet::InitDlgResource()
  50. {
  51. SetDlgItemText(IDOK, GUI_BUTTON_OK);
  52. SetDlgItemText(IDCANCEL, GUI_BUTTON_CANCEL);
  53. SetDlgItemText(IDHELP, GUI_BUTTON_HELP);
  54. SetDlgItemText(ID_APPLY_NOW,GUI_BUTTON_APPLY);
  55. }
  56. void CNetTimeSheet::OnOK()
  57. {
  58. OnApply();
  59. CPropertySheet::EndDialog(IDOK);
  60. }
  61. void CNetTimeSheet::OnApply()
  62. {
  63. if(!GetDlgItem(ID_APPLY_NOW)->IsWindowEnabled())
  64. return;
  65. if(Apply() != 0)
  66. {
  67. AfxMessageBox(GUI_ACL_MESSAGE_SAVE_ACL_IP_TIME_ERROR);
  68. return;
  69. }
  70. if(!theApp.InitDllData())
  71. {
  72. AfxMessageBox(GUI_ACL_MESSAGE_INIT_DLL_DATA_ERROR);
  73. return;
  74. }
  75. EnableButton(FALSE);
  76. }
  77. BOOL CNetTimeSheet::OnCancel()
  78. {
  79. if(!GetDlgItem(ID_APPLY_NOW)->IsWindowEnabled())
  80. {
  81. CPropertySheet::EndDialog(IDCANCEL);
  82. return TRUE;
  83. }
  84. if(AfxMessageBox(GUI_ACL_MESSAGE_ACL_ASK_SAVE, MB_YESNO) == IDYES)
  85. {
  86. OnApply();
  87. CPropertySheet::EndDialog(IDCANCEL);
  88. return FALSE;
  89. }
  90. if(m_AclFile.ReadAcl() != XERR_SUCCESS)
  91. {
  92. AfxMessageBox(GUI_ACL_MESSAGE_ACL_READ_ERROR);
  93. return FALSE;
  94. }
  95. if(!theApp.InitDllData())
  96. {
  97. AfxMessageBox(GUI_ACL_MESSAGE_INIT_DLL_DATA_ERROR);
  98. return FALSE;
  99. }
  100. CPropertySheet::EndDialog(IDCANCEL);
  101. return TRUE;
  102. }
  103. int CNetTimeSheet::EnableButton(BOOL bEnable)
  104. {
  105. GetDlgItem(ID_APPLY_NOW)->EnableWindow(bEnable);
  106. return 0;
  107. }
  108. int CNetTimeSheet::Apply()
  109. {
  110. return m_AclFile.SaveAcl();
  111. }
  112. void CNetTimeSheet::OnSysCommand(UINT nID, LPARAM lParam) 
  113. {
  114. if(nID == SC_CLOSE)
  115. {
  116. OnCancel();
  117. return;
  118. }
  119. CPropertySheet::OnSysCommand(nID, lParam);
  120. }