'===============================================================================
'    ReestrPPmain.txt
'===============================================================================
'===============================================================================
'         
' ReestrPPNew.txt
'===============================================================================
sub Init_Period
with self
 .Left = 233
 .Top = 141
 .BorderStyle = "bsDialog"
 .Caption = "  "
 .ClientHeight = 110
 .ClientWidth = 291
 .Color = "clBtnFace"
 .Font.Charset = 204
 .Font.Color = "clWindowText"
 .Font.Height = -11
 .Font.Name = "MS Sans Serif"
 .Font.Style = ""
 .OldCreateOrder = False
 .PixelsPerInch = 96
 self.add "Panel1", "TPanel"
 with Panel1
  .Left = 0
  .Top = 75
  .Width = 271
  .Height = 35
  .Align = "alBottom"
  .BevelInner = "bvRaised"
  .BevelOuter = "bvLowered"
  .TabOrder = 0
  Panel1.add "BitBtn1", "TBitBtn",TRUE
 with BitBtn1
   .Left = 184
   .Top = 5
   .Width = 81
   .Height = 25
   .Caption = ""
   .TabOrder = 0
   .Kind = "bkCancel"
   end with
  Panel1.add "OKBtn", "TBitBtn",TRUE
 with OKBtn
   .Left = 104
   .Top = 5
   .Width = 73
   .Height = 25
   .TabOrder = 1
   .Caption="OK"
   .Kind="bkOk"
   end with
  end with
 self.add "GroupBox1", "TGroupBox"
 with GroupBox1
  .Left = 0
  .Top = 0
  .Width = 271
  .Height = 75
  .Align = "alClient"
  .Caption = ""
  .Font.Charset = 204
  .Font.Color = "clWindowText"
  .Font.Height = -11
  .Font.Name = "MS Sans Serif"
  .Font.Style = "fsBold"
  .ParentFont = False
  .TabOrder = 1
  GroupBox1.add "Label1", "TLabel"
 with Label1
   .Left = 24
   .Top = 22
   .Width = 133
   .Height = 13
   .Caption = "  "
   .Font.Charset = 204
   .Font.Color = "clWindowText"
   .Font.Height = -11
   .Font.Name = "MS Sans Serif"
   .Font.Style = ""
   .ParentFont = False
   end with
  GroupBox1.add "Label2", "TLabel"
 with Label2
   .Left = 14
   .Top = 49
   .Width = 151
   .Height = 13
   .Caption = "  "
   .Font.Charset = 204
   .Font.Color = "clWindowText"
   .Font.Height = -11
   .Font.Name = "MS Sans Serif"
   .Font.Style = ""
   .ParentFont = False
   end with
  GroupBox1.add "BegDate", "TDBDateTimeEditEh"
 with BegDate
   .Left = 169
   .Top = 21
   .Width = 97
   .Height = 19
   .Flat = True
   .Kind = "dtkDateEh"
   .TabOrder = 0
   .Visible = True
   .EditButton.Style="ebsEllipsisEh"
   end with
  GroupBox1.add "EndDate", "TDBDateTimeEditEh"
 with EndDate
   .Left = 170
   .Top = 46
   .Width = 95
   .Height = 19
   .Flat = True
   .Kind = "dtkDateEh"
   .TabOrder = 1
   .EditButton.Style="ebsEllipsisEh"
   .Visible = True
   end with
  end with
 end with
end sub
'******************************************************************************
'  
'******************************************************************************
Dim pos
Dim DtBegin '  
Dim DtEnd   '  
pos=0
dateVyp = date()
pDate = date()

' Cancel
sub BitBtn1_onClick
self.Close
end sub

 '  OK
sub OKBtn_onClick
if (IsNull(BegDate.Value)=true) then
 MsgBox "   ",0," BARS"
exit sub
end if

if (IsNull(EndDate.Value)=true) then
 MsgBox "   ",0," BARS"
exit sub
end if

DtBegin = BegDate.Value
DtEnd = EndDate.Value
call mainPeriod ()
end sub

sub mainPeriod ()

self.Add "Period","TForm"

'    
  set FS=CreateObject("Scripting.FileSystemObject")
  tt=FS.GetFolder("macroses")
  set fs=nothing
  Period.CREATEFORMBYDFM(tt & "\ReestrPP.dfm")
  QueryRPP=Period.controls("RPPIBQuery1")
  set Database=MainForm.Controls("Database")
  QueryRPP.Database=Database
  QueryRPP.Active=false
  QueryRPP.Sql.Clear
'  QueryRPP.Sql.Add "SELECT cast(MADEDATE as date) as madedat, NUMBER, SCHETPLAT, SCHETPOLUCH, FIRMPOLUCH, SUMMA, NAZNPLAT FROM MAINTABLE where ordertypecode='PLP' and (checkgd between 4 and 99) "
  tt ="SELECT cast(MADEDATE as date) as madedat, NUMBER, SCHETPLAT, SCHETPOLUCH, FIRMPOLUCH, SUMMA, NAZNPLAT FROM MAINTABLE where ordertypecode='PLP' and (checkgd between 4 and 99) and (madedate between '"+cStr(DtBegin)+"' and '"+cStr(DtEnd)+"' ) order by madedate"
'  MsgBox tt
'  QueryRPP.Sql.Add "SELECT cast(MADEDATE as date) as madedat, NUMBER, SCHETPLAT, SCHETPOLUCH, FIRMPOLUCH, SUMMA, NAZNPLAT FROM MAINTABLE where ordertypecode='PLP' and (checkgd between 4 and 99) and (madedate between "+cStr(DtBegin)+" and "+cStr(DtEnd)+" )"
  QueryRPP.Sql.Add(tt)
  QueryRPP.Active=true
  if(QueryRPP.RecordCount>0)  then
   quickrep=period.controls("QuickRep")
   quickrep.DataSet=QueryRPP
   quickrep.previewmodal
   QueryRPP.Active=False
  else
  msgbox "    ",0," BARS"
  end if
 end sub

'  
sub main

 call Init_Period
 
end sub
