VERSION 5.00
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomct2.OCX"
Begin VB.Form frmSell 
   Caption         =   "ยอดการขาย"
   ClientHeight    =   5250
   ClientLeft      =   225
   ClientTop       =   570
   ClientWidth     =   11265
   LinkTopic       =   "Form9"
   ScaleHeight     =   5250
   ScaleWidth      =   11265
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command4 
      Caption         =   "ค้นหา"
      Height          =   735
      Left            =   7680
      TabIndex        =   6
      Top             =   240
      Width           =   1335
   End
   Begin MSComCtl2.DTPicker dt2 
      Height          =   495
      Left            =   5160
      TabIndex        =   5
      Top             =   480
      Width           =   1815
      _ExtentX        =   3201
      _ExtentY        =   873
      _Version        =   393216
      Format          =   95092737
      CurrentDate     =   42058
   End
   Begin VB.CommandButton Command3 
      Caption         =   "ทั้งหมด"
      Height          =   495
      Left            =   9600
      TabIndex        =   3
      Top             =   360
      Width           =   1215
   End
   Begin MSComCtl2.DTPicker dt1 
      BeginProperty DataFormat 
         Type            =   0
         Format          =   "dd/MM/yyyy"
         HaveTrueFalseNull=   0
         FirstDayOfWeek  =   0
         FirstWeekOfYear =   0
         LCID            =   1054
         SubFormatType   =   0
      EndProperty
      Height          =   495
      Left            =   2520
      TabIndex        =   2
      Top             =   480
      Width           =   2055
      _ExtentX        =   3625
      _ExtentY        =   873
      _Version        =   393216
      Format          =   95092737
      CurrentDate     =   42058
   End
   Begin VB.CommandButton cmdesc 
      Caption         =   "ย้อนกลับ"
      Height          =   495
      Left            =   5160
      TabIndex        =   1
      Top             =   4560
      Width           =   1215
   End
   Begin MSDataGridLib.DataGrid DataGrid1 
      Height          =   3015
      Left            =   480
      TabIndex        =   0
      Top             =   1320
      Width           =   10335
      _ExtentX        =   18230
      _ExtentY        =   5318
      _Version        =   393216
      AllowUpdate     =   -1  'True
      HeadLines       =   1
      RowHeight       =   15
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   222
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   222
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "สรุปยอดการขาย"
      ColumnCount     =   2
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1054
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1054
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
   Begin VB.Label Label2 
      Caption         =   "รวมยอดขาย"
      Height          =   255
      Left            =   7200
      TabIndex        =   8
      Top             =   4680
      Width           =   1095
   End
   Begin VB.Line Line1 
      X1              =   4680
      X2              =   5040
      Y1              =   720
      Y2              =   720
   End
   Begin VB.Label Label1 
      Caption         =   "เลือกเวลาเริ่ม และสิ้นสุด"
      Height          =   255
      Left            =   480
      TabIndex        =   7
      Top             =   600
      Width           =   1935
   End
   Begin VB.Label lbtotal 
      Height          =   375
      Left            =   8520
      TabIndex        =   4
      Top             =   4560
      Width           =   1575
   End
End
Attribute VB_Name = "frmSell"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs_sell As ADODB.Recordset
Dim dt As Date
Dim a As ADODB.Recordset
Private Sub cmdesc_Click()
Unload Me
frmOn.Show

End Sub


Private Sub Command3_Click()
 Set a = New ADODB.Recordset
   a.ActiveConnection = conn
   a.CursorLocation = adUseClient
    a.CursorType = adOpenDynamic
    a.LockType = adLockReadOnly
   a.Source = "SELECT * FROM dailyrecord "
    a.Open
Set DataGrid1.DataSource = a
Set rs = New ADODB.Recordset
rs.Open "SELECT sum(total) as total FROM dailyrecord", conn, 3, 3

lbtotal = rs("total")
Set rs = Nothing
End Sub



Private Sub Command4_Click()
Call Dbase
 Set rs_sell = New ADODB.Recordset
   rs_sell.ActiveConnection = conn
   rs_sell.CursorLocation = adUseClient
    rs_sell.CursorType = adOpenDynamic
    rs_sell.LockType = adLockReadOnly
   rs_sell.Source = "SELECT * FROM dailyrecord where purchase_date Between  '" & Me.dt1 & "' and '" & Me.dt2 & "*'"
    rs_sell.Open
Set DataGrid1.DataSource = rs_sell
   If rs_sell.EOF Then     'ตรวจสอบว่าพบข้อมูลหรือไม่ถ้าไม่พบทำบรรทัดถัดไป
                MsgBox "ไม่พบข้อมูลที่ต้องการ", vbExclamation + vbOKOnly, "แจ้งเตือน"
                lbtotal = 0
                Exit Sub
                End If
Set rs = New ADODB.Recordset
rs.Open "SELECT sum(total) as total FROM dailyrecord WHERE purchase_date Between  '" & Me.dt1 & "' AND '" & Me.dt2 & "'", conn, 3, 3
lbtotal = rs("total")
Set rs = Nothing
End Sub
    
Private Sub Form_Load()
Dim sum As Integer
sum = 0
'Call Dbase
'sum = sum + rs_sell("total")
'rs.Open "SELECT sum(total) as total FROM dailyrecord WHERE purchase_date Between  '" & Me.dt1 & "' AND '" & Me.dt2 & "'", conn, 3, 3
'lbtotal = rs("total")
End Sub

