Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

421 lines
11 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1999 - 1999
  6. //
  7. // File: dialogs.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. // Dialogs.cpp: implementation of the CDialogs class.
  11. //
  12. //////////////////////////////////////////////////////////////////////
  13. #include "stdafx.h"
  14. #include "resource.h"
  15. #include "Dialogs.h"
  16. #include "WindowsX.h"
  17. #ifdef _DEBUG
  18. #undef THIS_FILE
  19. static char THIS_FILE[]=__FILE__;
  20. #define new DEBUG_NEW
  21. #endif
  22. // {01B4A693-D970-11d1-8474-00104B211BE5}
  23. static const GUID HealthPlan1GUID =
  24. { 0x1b4a693, 0xd970, 0x11d1, { 0x84, 0x74, 0x0, 0x10, 0x4b, 0x21, 0x1b, 0xe5 } };
  25. // {01B4A694-D970-11d1-8474-00104B211BE5}
  26. static const GUID HealthPlan2GUID =
  27. { 0x1b4a694, 0xd970, 0x11d1, { 0x84, 0x74, 0x0, 0x10, 0x4b, 0x21, 0x1b, 0xe5 } };
  28. // {01B4A693-D970-11d1-8474-00104B211BE5}
  29. static const GUID InvestmentPlan1GUID =
  30. { 0x1b4a695, 0xd970, 0x11d1, { 0x84, 0x74, 0x0, 0x10, 0x4b, 0x21, 0x1b, 0xe5 } };
  31. // {01B4A694-D970-11d1-8474-00104B211BE5}
  32. static const GUID InvestmentPlan2GUID =
  33. { 0x1b4a696, 0xd970, 0x11d1, { 0x84, 0x74, 0x0, 0x10, 0x4b, 0x21, 0x1b, 0xe5 } };
  34. // {01B4A694-D970-11d1-8474-00104B211BE5}
  35. static const GUID InvestmentPlan3GUID =
  36. { 0x1b4a697, 0xd970, 0x11d1, { 0x84, 0x74, 0x0, 0x10, 0x4b, 0x21, 0x1b, 0xe5 } };
  37. //
  38. // Initialize the static plans for health enrollment.
  39. //
  40. HEALTHPLANDATA g_HealthPlans[ 2 ] =
  41. {
  42. { L"Plan 1, PPO", &HealthPlan1GUID },
  43. { L"Plan 2, Share Pay", &HealthPlan2GUID },
  44. };
  45. //
  46. // Initialize the static plans for health enrollment.
  47. //
  48. INVESTMENTPLANDATA g_InvestmentPlans[ 3 ] =
  49. {
  50. { L"Mild Growth Fund", &InvestmentPlan1GUID },
  51. { L"General Fund", &InvestmentPlan2GUID },
  52. { L"Extrememe Growth Fund", &InvestmentPlan3GUID },
  53. };
  54. //
  55. // Initialize the static plans for building information.
  56. //
  57. BUILDINGDATA g_Buildings[ 3 ] =
  58. {
  59. { L"Human Resources Building", L"Northwest Campus", 0x00000001 },
  60. { L"R. & D. Building", L"Northwest Campus", 0x00000002 },
  61. { L"Test Facilities", L"Off-Campus", 0x00000004 },
  62. };
  63. #ifdef _BENEFITS_DIALOGS
  64. //
  65. // Handler to initialize values in dialog. This should map data from the
  66. // employee to the dialog controls. In this case, all these values will be
  67. // persisted by the root node.
  68. //
  69. LRESULT CHealthEnrollDialog::OnInitDialog( UINT uiMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled )
  70. {
  71. UNUSED_ALWAYS( uiMsg );
  72. UNUSED_ALWAYS( wParam );
  73. UNUSED_ALWAYS( lParam );
  74. UNUSED_ALWAYS( fHandled );
  75. _ASSERTE( m_pEmployee != NULL );
  76. USES_CONVERSION;
  77. int nSel = 0;
  78. // Add a list of static plan names to the combo.
  79. CWindow wndCombo = GetDlgItem( IDC_COMBO_BENEFITPLAN );
  80. for ( int i = 0; i < sizeof( g_HealthPlans ) / sizeof( HEALTHPLANDATA ); i++ )
  81. {
  82. int nIndex = ComboBox_AddString( wndCombo, W2CT( g_HealthPlans[ i ].pstrName ) );
  83. if ( nIndex != CB_ERR )
  84. {
  85. //
  86. // Set the item data of this string.
  87. //
  88. ComboBox_SetItemData( wndCombo, nIndex, g_HealthPlans[ i ].pId );
  89. //
  90. // Determine if this matche's the employee's current plan so that
  91. // the current selection can be set.
  92. //
  93. if ( m_pEmployee->m_Health.PlanID == *g_HealthPlans[ i ].pId )
  94. nSel = nIndex;
  95. }
  96. }
  97. //
  98. // Set the current selection.
  99. //
  100. ComboBox_SetCurSel( wndCombo, nSel );
  101. return( TRUE );
  102. }
  103. //
  104. // Stores the data and attempts to enroll the given user in the specified
  105. // health plan.
  106. //
  107. LRESULT CHealthEnrollDialog::OnOK( WORD /*wNotifyCode*/, WORD /* wID */, HWND /*hWndCtl*/, BOOL& /*bHandled*/ )
  108. {
  109. ENROLLPARAMS EnrollParams;
  110. GUID* pIdPlan = NULL;
  111. //
  112. // Get prior enrollment.
  113. //
  114. EnrollParams.fEnrolled = IsDlgButtonChecked( IDC_CHK_PRIORCOVERAGE ) == BST_CHECKED;
  115. if ( EnrollParams.fEnrolled )
  116. {
  117. //
  118. // Get the prior enrollment information.
  119. //
  120. GetDlgItemText( IDC_EDIT_INSURANCECOMPANY, EnrollParams.szInsurerName, sizeof( EnrollParams.szInsurerName ) * sizeof( TCHAR ) );
  121. GetDlgItemText( IDC_EDIT_POLICYNUMBER, EnrollParams.szPolicyNumber, sizeof( EnrollParams.szInsurerName ) * sizeof( TCHAR ) );
  122. if ( EnrollParams.szInsurerName[ 0 ] == ' ' || EnrollParams.szPolicyNumber[ 0 ] == ' ' )
  123. {
  124. //
  125. // The dialog text must contain some characters.
  126. //
  127. MessageBox( _T( "The insurance company or policy number you entered is invalid." ) );
  128. }
  129. }
  130. //
  131. // Retrieve the selected enrollment plan.
  132. //
  133. CWindow wndCombo = GetDlgItem( IDC_COMBO_BENEFITPLAN );
  134. int nIndex = ComboBox_GetCurSel( wndCombo );
  135. if ( nIndex != CB_ERR )
  136. {
  137. //
  138. // Get the associated item data with the combobox entry.
  139. //
  140. pIdPlan = (GUID*) ComboBox_GetItemData( wndCombo, nIndex );
  141. //
  142. // Actually entroll the employee in the health plan.
  143. //
  144. if ( pIdPlan != NULL && Enroll( pIdPlan, &EnrollParams ) )
  145. {
  146. //
  147. // Store the plan to our employee.
  148. //
  149. memcpy( &m_pEmployee->m_Health.PlanID, pIdPlan, sizeof( GUID ) );
  150. //
  151. // Inform the user that we successfully enrolled the employee.
  152. //
  153. MessageBox( _T( "The employee was successfully registered." ) );
  154. ::EndDialog( m_hWnd, IDOK );
  155. }
  156. else
  157. {
  158. //
  159. // There was an error. Inform the user.
  160. //
  161. MessageBox( _T( "There was an error processing your enrollment info." ) );
  162. }
  163. }
  164. return( TRUE );
  165. }
  166. //
  167. // A stub function that could be used to enroll the employee.
  168. //
  169. BOOL CHealthEnrollDialog::Enroll( GUID* pPlan, PENROLLPARAMS pParams )
  170. {
  171. UNUSED_ALWAYS( pPlan );
  172. UNUSED_ALWAYS( pParams );
  173. // For demo purposes, this function does nothing but return success.
  174. // This is where one might make a request to a remote database, etc.
  175. return( TRUE );
  176. }
  177. //
  178. // Sets the initial values of the dialog to the employee's current
  179. // investment options.
  180. //
  181. LRESULT CRetirementEnrollDialog::OnInitDialog( UINT uiMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled )
  182. {
  183. UNUSED_ALWAYS( uiMsg );
  184. UNUSED_ALWAYS( wParam );
  185. UNUSED_ALWAYS( lParam );
  186. UNUSED_ALWAYS( fHandled );
  187. _ASSERTE( m_pEmployee != NULL );
  188. USES_CONVERSION;
  189. int nSel = 0;
  190. //
  191. // Set the edit control containing the benefit amount.
  192. //
  193. SetDlgItemInt( IDC_EDIT_CONTRIBUTION, m_pEmployee->m_Retirement.nContributionRate );
  194. //
  195. // Cycle through the benefit plans and add them to the combo selection.
  196. //
  197. // Add a list of static plan names to the combo.
  198. CWindow wndCombo = GetDlgItem( IDC_COMBO_INVESTMENTFUNDS );
  199. for ( int i = 0; i < sizeof( g_InvestmentPlans ) / sizeof( INVESTMENTPLANDATA ); i++ )
  200. {
  201. int nIndex = ComboBox_AddString( wndCombo, W2CT( g_InvestmentPlans[ i ].pstrName ) );
  202. if ( nIndex != CB_ERR )
  203. {
  204. //
  205. // Set the item data of this string.
  206. //
  207. ComboBox_SetItemData( wndCombo, nIndex, g_InvestmentPlans[ i ].pId );
  208. //
  209. // Determine if this matche's the employee's current plan so that
  210. // the current selection can be set.
  211. //
  212. if ( m_pEmployee->m_Health.PlanID == *g_InvestmentPlans[ i ].pId )
  213. nSel = nIndex;
  214. }
  215. }
  216. //
  217. // Set the current selection.
  218. //
  219. ComboBox_SetCurSel( wndCombo, nSel );
  220. return( TRUE );
  221. }
  222. //
  223. // Stores the data and attempts to enroll the given user in the specified
  224. // health plan.
  225. //
  226. LRESULT CRetirementEnrollDialog::OnOK( WORD /*wNotifyCode*/, WORD /* wID */, HWND /*hWndCtl*/, BOOL& /*bHandled*/ )
  227. {
  228. GUID* pIdPlan = NULL;
  229. //
  230. // Get the new enrollment amount.
  231. //
  232. int nNewRate = GetDlgItemInt( IDC_EDIT_CONTRIBUTION );
  233. //
  234. // Retrieve the selected enrollment plan.
  235. //
  236. CWindow wndCombo = GetDlgItem( IDC_COMBO_INVESTMENTFUNDS );
  237. int nIndex = ComboBox_GetCurSel( wndCombo );
  238. if ( nIndex != CB_ERR )
  239. {
  240. //
  241. // Get the associated item data with the combobox entry.
  242. //
  243. pIdPlan = (GUID*) ComboBox_GetItemData( wndCombo, nIndex );
  244. //
  245. // Actually entroll the employee in the health plan.
  246. //
  247. if ( pIdPlan != NULL && Enroll( pIdPlan, nNewRate ) )
  248. {
  249. //
  250. // Store the plan to our employee.
  251. //
  252. memcpy( &m_pEmployee->m_Retirement.PlanID, pIdPlan, sizeof( GUID ) );
  253. //
  254. // Inform the user that we successfully enrolled the employee.
  255. //
  256. MessageBox( _T( "The employee was successfully registered." ) );
  257. ::EndDialog( m_hWnd, IDOK );
  258. }
  259. else
  260. {
  261. //
  262. // There was an error. Inform the user.
  263. //
  264. MessageBox( _T( "There was an error processing your enrollment info." ) );
  265. }
  266. }
  267. return( TRUE );
  268. }
  269. //
  270. // A stub function that could be used to enroll the employee.
  271. //
  272. BOOL CRetirementEnrollDialog::Enroll( GUID* pPlan, int nNewRate )
  273. {
  274. UNUSED_ALWAYS( pPlan );
  275. UNUSED_ALWAYS( nNewRate );
  276. // For demo purposes, this function does nothing but return success.
  277. // This is where one might make a request to a remote database, etc.
  278. return( TRUE );
  279. }
  280. //
  281. // Sets the initial values of the dialog to the employee's current
  282. // investment options.
  283. //
  284. LRESULT CBuildingAccessDialog::OnInitDialog( UINT uiMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled )
  285. {
  286. UNUSED_ALWAYS( uiMsg );
  287. UNUSED_ALWAYS( wParam );
  288. UNUSED_ALWAYS( lParam );
  289. UNUSED_ALWAYS( fHandled );
  290. USES_CONVERSION;
  291. _ASSERTE( m_pEmployee != NULL );
  292. //
  293. // Cycle through the benefit plans and add them to the combo selection.
  294. //
  295. // Add a list of static plan names to the combo.
  296. CWindow wndCombo = GetDlgItem( IDC_COMBO_BUILDINGS );
  297. for ( int i = 0; i < sizeof( g_Buildings ) / sizeof( BUILDINGDATA ); i++ )
  298. {
  299. int nIndex = ComboBox_AddString( wndCombo, W2CT( g_Buildings[ i ].pstrName ) );
  300. if ( nIndex != CB_ERR )
  301. {
  302. //
  303. // Set the item data of this string.
  304. //
  305. ComboBox_SetItemData( wndCombo, nIndex, g_Buildings[ i ].dwId );
  306. }
  307. }
  308. //
  309. // Set the default current selection to the first item.
  310. //
  311. ComboBox_SetCurSel( wndCombo, 0 );
  312. return( TRUE );
  313. }
  314. //
  315. // Stores the data and attempts to enroll the given user in the specified
  316. // health plan.
  317. //
  318. LRESULT CBuildingAccessDialog::OnOK( WORD /*wNotifyCode*/, WORD /* wID */, HWND /*hWndCtl*/, BOOL& /*bHandled*/ )
  319. {
  320. //
  321. // Retrieve the selected enrollment plan.
  322. //
  323. CWindow wndCombo = GetDlgItem( IDC_COMBO_BUILDINGS );
  324. int nIndex = ComboBox_GetCurSel( wndCombo );
  325. if ( nIndex != CB_ERR )
  326. {
  327. DWORD dwBuildingId;
  328. //
  329. // Get the associated item data with the combobox entry.
  330. //
  331. dwBuildingId = ComboBox_GetItemData( wndCombo, nIndex );
  332. //
  333. // Actually entroll the employee in the health plan.
  334. //
  335. if ( GrantAccess( dwBuildingId ) )
  336. {
  337. //
  338. // Store the plan to our employee.
  339. //
  340. m_pEmployee->m_Access.dwAccess |= dwBuildingId;
  341. //
  342. // Inform the user that we successfully enrolled the employee.
  343. //
  344. MessageBox( _T( "The employee was successfully granted access." ) );
  345. ::EndDialog( m_hWnd, IDOK );
  346. }
  347. else
  348. {
  349. //
  350. // There was an error. Inform the user.
  351. //
  352. MessageBox( _T( "There was an error granting the employee access." ) );
  353. }
  354. }
  355. return( TRUE );
  356. }
  357. //
  358. // A stub function that could be used to enroll the employee.
  359. //
  360. BOOL CBuildingAccessDialog::GrantAccess( DWORD dwBuildingId )
  361. {
  362. UNUSED_ALWAYS( dwBuildingId );
  363. // For demo purposes, this function does nothing but return success.
  364. // This is where one might make a request to a remote database, etc.
  365. return( TRUE );
  366. }
  367. #endif