home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 May / VPR9705A.ISO / VPR_DATA / PROGRAM / CBTRIAL / SETUP / DATA.Z / QRYCUST.CPP < prev    next >
C/C++ Source or Header  |  1997-02-14  |  3KB  |  85 lines

  1. //---------------------------------------------------------------------------
  2. // Borland C++Builder
  3. // Copyright (c) 1987, 1997 Borland International Inc.  All Rights Reserved.
  4. //---------------------------------------------------------------------------
  5. //---------------------------------------------------------------------------
  6. #include <vcl\vcl.h>
  7. #pragma hdrstop
  8.  
  9. #include "qrycust.h"
  10. #include "pickdate.h"
  11. //---------------------------------------------------------------------------
  12. #pragma resource "*.dfm"
  13. TQueryCustDlg *QueryCustDlg;
  14. //---------------------------------------------------------------------------
  15. void TQueryCustDlg::SetFromDate(TDateTime NewDate)
  16. {
  17.   FromEdit->Text = DateToStr(NewDate);
  18. }
  19. //---------------------------------------------------------------------------
  20. void TQueryCustDlg::SetToDate(TDateTime NewDate)
  21. {
  22.   ToEdit->Text = DateToStr(NewDate);
  23. }
  24.  
  25. //---------------------------------------------------------------------------
  26. TDateTime TQueryCustDlg::GetFromDate()
  27. {
  28.   if (FromEdit->Text.c_str())
  29.      return StrToDate(FromEdit->Text);
  30.   else
  31.      return 0;
  32. }
  33. //---------------------------------------------------------------------------
  34. TDateTime TQueryCustDlg::GetToDate()
  35. {
  36.   if (ToEdit->Text.c_str())
  37.      return StrToDate(ToEdit->Text);
  38.   else
  39.      return 0;
  40. }
  41. //---------------------------------------------------------------------------
  42. __fastcall TQueryCustDlg::TQueryCustDlg(TComponent* Owner)
  43.     : TForm(Owner)
  44. {
  45.   Msglab->Caption = "Customers with LastInvoiceDate ranging:";
  46.   FromDate = EncodeDate(95, 01, 01);
  47.   ToDate = Now();
  48. }
  49. //---------------------------------------------------------------------------
  50. void __fastcall TQueryCustDlg::OkBtnClick(TObject *Sender)
  51. {
  52.   TDateTime Test;
  53.   try
  54.   {
  55.     Test = StrToDate(FromEdit->Text); // validate date strings
  56.     Test = StrToDate(ToEdit->Text);
  57.     if (((int)ToDate != 0) && (ToDate < FromDate))
  58.     {
  59.       ShowMessage("\"TO\" date cannot be less than \"FROM\" date");
  60.       ModalResult = mrNone;
  61.     }
  62.     else ModalResult = mrOk;
  63.   }
  64.   catch(EConvertError * ece)
  65.   {
  66.     ShowMessage("  Invalid date specified");
  67.     ModalResult = mrNone;
  68.   }
  69. }
  70. //---------------------------------------------------------------------------
  71. void __fastcall TQueryCustDlg::PopupCalBtnFromClick(TObject *Sender)
  72. {
  73.   BrDateForm->Date = StrToDate(FromEdit->Text);  //start with current date }
  74.   if (BrDateForm->ShowModal() == mrOk)
  75.      FromEdit->Text = DateToStr(BrDateForm->Date);
  76. }
  77. //---------------------------------------------------------------------------
  78. void __fastcall TQueryCustDlg::PopupCalToBtnClick(TObject *Sender)
  79. {
  80.   BrDateForm->Date = StrToDate(ToEdit->Text);   //start with current date }
  81.   if (BrDateForm->ShowModal() == mrOk)
  82.     ToEdit->Text = DateToStr(BrDateForm->Date);
  83. }
  84. //---------------------------------------------------------------------------
  85.