home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 April / Chip_1997-04_cd.bin / prezent / cb / data.z / QRYCUST.CPP < prev    next >
C/C++ Source or Header  |  1997-01-16  |  3KB  |  81 lines

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