Source code of Windows XP (NT5)
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.

170 lines
4.9 KiB

  1. //Copyright (c) 1998 - 1999 Microsoft Corporation
  2. #include "precomp.h"
  3. LRW_DLG_INT CALLBACK
  4. CHRegisterMOLPDlgProc(
  5. IN HWND hwnd,
  6. IN UINT uMsg,
  7. IN WPARAM wParam,
  8. IN LPARAM lParam
  9. )
  10. {
  11. DWORD dwNextPage = 0;
  12. BOOL bStatus = TRUE;
  13. PageInfo *pi = (PageInfo *)LRW_GETWINDOWLONG( hwnd, LRW_GWL_USERDATA );
  14. switch (uMsg)
  15. {
  16. case WM_INITDIALOG:
  17. pi = (PageInfo *)((LPPROPSHEETPAGE)lParam)->lParam;
  18. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, (LRW_LONG_PTR)pi );
  19. SendDlgItemMessage(hwnd, IDC_TXT_AUTH_NUMBER, EM_SETLIMITTEXT, CH_MOLP_AUTH_NUMBER_LEN ,0);
  20. SendDlgItemMessage(hwnd, IDC_TXT_AGREEMENT_NUMBER, EM_SETLIMITTEXT, CH_MOLP_AGREEMENT_NUMBER_LEN,0);
  21. SendDlgItemMessage(hwnd, IDC_TXT_QUANTITY, EM_SETLIMITTEXT, CH_QTY_LEN,0);
  22. //
  23. //Set the properties of the up-down control
  24. //
  25. SendDlgItemMessage(hwnd, IDC_SPIN1, UDM_SETBUDDY, (WPARAM)(HWND)GetDlgItem(hwnd,IDC_TXT_QUANTITY),(LPARAM)0);
  26. SendDlgItemMessage(hwnd, IDC_SPIN1, UDM_SETRANGE, 0,(LPARAM) MAKELONG (9999, 1));
  27. PopulateProductComboBox(GetDlgItem(hwnd,IDC_CMD_PRODUCT_TYPE));
  28. break;
  29. case WM_DESTROY:
  30. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, NULL );
  31. break;
  32. case WM_NOTIFY:
  33. {
  34. LPNMHDR pnmh = (LPNMHDR)lParam;
  35. switch( pnmh->code )
  36. {
  37. case PSN_SETACTIVE:
  38. PropSheet_SetWizButtons( GetParent( hwnd ), PSWIZB_NEXT | PSWIZB_BACK);
  39. break;
  40. case PSN_WIZNEXT:
  41. {
  42. CString sProductCode;
  43. CString sProduct;
  44. CString sAgreementNumber;
  45. CString sCustomerName;
  46. CString sAuthNo;
  47. CString sQuantity;
  48. LPTSTR lpVal = NULL;
  49. TCHAR lpBuffer[ 128];
  50. DWORD dwRetCode;
  51. int nCurSel = -1;
  52. //
  53. //Read all the fields
  54. //
  55. lpVal = sAgreementNumber.GetBuffer(CH_MOLP_AGREEMENT_NUMBER_LEN+1);
  56. GetDlgItemText(hwnd,IDC_TXT_AGREEMENT_NUMBER,lpVal,CH_MOLP_AGREEMENT_NUMBER_LEN+1);
  57. sAgreementNumber.ReleaseBuffer(-1);
  58. lpVal = sAuthNo.GetBuffer(CH_MOLP_AUTH_NUMBER_LEN+1);
  59. GetDlgItemText(hwnd,IDC_TXT_AUTH_NUMBER,lpVal,CH_MOLP_AUTH_NUMBER_LEN+1);
  60. sAuthNo.ReleaseBuffer(-1);
  61. lpVal = sQuantity.GetBuffer(CH_QTY_LEN+2);
  62. GetDlgItemText(hwnd,IDC_TXT_QUANTITY, lpBuffer,CH_QTY_LEN+2);
  63. TCHAR *lpStart = lpBuffer;
  64. do
  65. {
  66. if (*lpStart != (TCHAR) ',')
  67. {
  68. *lpVal++ = *lpStart;
  69. }
  70. } while ( *lpStart++ );
  71. sQuantity.ReleaseBuffer(-1);
  72. nCurSel = ComboBox_GetCurSel(GetDlgItem(hwnd,IDC_CMD_PRODUCT_TYPE));
  73. lpVal = sProduct.GetBuffer(LR_PRODUCT_DESC_LEN+1);
  74. ComboBox_GetLBText(GetDlgItem(hwnd,IDC_CMD_PRODUCT_TYPE), nCurSel, lpVal);
  75. sProduct.ReleaseBuffer(-1);
  76. // Send Product Code instead of Desc -- 01/08/99
  77. lpVal = sProductCode.GetBuffer(16);
  78. GetProductCode(sProduct,lpVal);
  79. sProductCode.ReleaseBuffer(-1);
  80. sProductCode.TrimLeft(); sProductCode.TrimRight();
  81. sAgreementNumber.TrimLeft(); sAgreementNumber.TrimRight();
  82. sAuthNo.TrimLeft(); sAuthNo.TrimRight();
  83. sQuantity.TrimLeft(); sQuantity.TrimRight();
  84. if(
  85. sProduct.IsEmpty() ||
  86. sAgreementNumber.IsEmpty() ||
  87. sAuthNo.IsEmpty() ||
  88. sQuantity.IsEmpty()
  89. )
  90. {
  91. LRMessageBox(hwnd,IDS_ERR_FIELD_EMPTY);
  92. dwNextPage = IDD_CH_REGISTER_MOLP;
  93. goto NextDone;
  94. }
  95. if(
  96. !ValidateLRString(sProduct) ||
  97. !ValidateLRString(sAgreementNumber) ||
  98. !ValidateLRString(sAuthNo)
  99. )
  100. {
  101. LRMessageBox(hwnd,IDS_ERR_INVALID_CHAR);
  102. dwNextPage = IDD_CH_REGISTER_MOLP;
  103. goto NextDone;
  104. }
  105. if(_wtoi(sQuantity) < 1)
  106. {
  107. LRMessageBox(hwnd,IDS_ERR_INVALID_QTY);
  108. dwNextPage = IDD_CH_REGISTER_MOLP;
  109. goto NextDone;
  110. }
  111. GetGlobalContext()->GetLicDataObject()->sMOLPProductType = sProductCode; //sProduct;
  112. GetGlobalContext()->GetLicDataObject()->sMOLPProductDesc = sProduct;
  113. GetGlobalContext()->GetLicDataObject()->sMOLPAgreementNumber = sAgreementNumber;
  114. GetGlobalContext()->GetLicDataObject()->sMOLPAuthNumber = sAuthNo;
  115. GetGlobalContext()->GetLicDataObject()->sMOLPQty = sQuantity;
  116. // dwNextPage = IDD_PROCESSING;
  117. dwRetCode = ShowProgressBox(hwnd, ProcessThread, 0, 0, 0);
  118. dwNextPage = IDD_PROGRESS;
  119. LRPush(IDD_CH_REGISTER_MOLP);
  120. NextDone:
  121. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  122. bStatus = -1;
  123. }
  124. break;
  125. case PSN_WIZBACK:
  126. dwNextPage = LRPop();
  127. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  128. bStatus = -1;
  129. break;
  130. default:
  131. bStatus = FALSE;
  132. break;
  133. }
  134. }
  135. break;
  136. default:
  137. bStatus = FALSE;
  138. break;
  139. }
  140. return bStatus;
  141. }