VERSION 5.00
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmProduct 
   Caption         =   "Product"
   ClientHeight    =   5850
   ClientLeft      =   120
   ClientTop       =   420
   ClientWidth     =   8760
   LinkTopic       =   "Form6"
   ScaleHeight     =   5850
   ScaleWidth      =   8760
   StartUpPosition =   3  'Windows Default
   Begin VB.TextBox Text3 
      Height          =   405
      Left            =   4320
      TabIndex        =   7
      Text            =   "Text3"
      Top             =   7200
      Width           =   1215
   End
   Begin VB.TextBox Text2 
      Height          =   405
      Left            =   2880
      TabIndex        =   6
      Text            =   "Text2"
      Top             =   7200
      Width           =   975
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   1080
      TabIndex        =   5
      Text            =   "Text1"
      Top             =   7200
      Width           =   975
   End
   Begin VB.Timer Timer1 
      Interval        =   1
      Left            =   480
      Top             =   840
   End
   Begin VB.CommandButton cmdesc 
      Caption         =   "ย้อนกลับ"
      Height          =   615
      Left            =   7080
      TabIndex        =   4
      Top             =   4920
      Width           =   1335
   End
   Begin VB.CommandButton Command3 
      Caption         =   "ลบ"
      Height          =   615
      Left            =   5040
      TabIndex        =   3
      Top             =   4920
      Width           =   1455
   End
   Begin VB.CommandButton Command2 
      Caption         =   "แก้ไข"
      Height          =   615
      Left            =   3000
      TabIndex        =   2
      Top             =   4920
      Width           =   1455
   End
   Begin VB.CommandButton cmdadd 
      Caption         =   "เพิ่ม"
      Height          =   615
      Left            =   840
      TabIndex        =   1
      Top             =   4920
      Width           =   1575
   End
   Begin MSDataGridLib.DataGrid DataGrid1 
      Height          =   4095
      Left            =   360
      TabIndex        =   0
      Top             =   480
      Width           =   8175
      _ExtentX        =   14420
      _ExtentY        =   7223
      _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
End
Attribute VB_Name = "frmProduct"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim glbPosition As String
Dim ctr As Integer
Private Sub cmdadd_Click()
Text2.Text = ""
frmInputProduct.Show vbModal
End Sub

Private Sub Command2_Click()
If Text1.Text = "" Then
MsgBox "ไม่มีรายการที่เลือก!", vbExclamation + vbOKOnly, "แจ้งเตือน"
Exit Sub
End If
Text2.Text = Text1.Text
frmInputProduct.cmdsave.Caption = "Update"
frmInputProduct.Show vbModal
End Sub

Private Sub Command3_Click()
Dim repp As Integer
Dim Cancel As Integer
If Text1.Text = "" Then
MsgBox "ไม่มีรายการที่เลือก!", vbExclamation + vbOKOnly, "แจ้งเตือน"
Exit Sub
End If

repp = MsgBox("คุณต้องการลบข้อมูลหรือไม่?", vbExclamation + vbYesNo)
If repp = vbNo Then
    Cancel = 1
End If
If repp = vbYes Then
    Set rs = New ADODB.Recordset
    rs.Open "Delete from [tbl_product] where [barcodeno]='" & Text1.Text & "'", conn, 3, 3
    Timer1.Enabled = True
    MsgBox "ลบข้อมูลเรียบร้อยแล้วค่ะ!", vbInformation
    Set rs = Nothing
End If
End Sub

Private Sub cmdesc_Click()
Unload Me
frmOn.Show

End Sub


Private Sub Form_Load()
Call Dbase
Set rs_user = New ADODB.Recordset
rs_user.Open "Select [barcodeno],[ProductName],[CategoryName],[price],[Quantity] from [tbl_product] order by [barcodeno] asc", conn, 3, adLockReadOnly
Set DataGrid1.DataSource = rs_user
DataGrid1.Columns(0).Width = 1500
DataGrid1.Columns(1).Width = 2000
Set Text1.DataSource = rs_user
Text1.DataField = "barcodeno"
Set Text3.DataSource = rs_user
Text3.DataField = "productname"
End Sub


Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Set rs_user = Nothing
End Sub


Private Sub Timer1_Timer()
Form_Load
Timer1.Enabled = False
End Sub



