VERSION 5.00 Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX" Begin VB.Form Adddealer BackColor = &H00FFFFC0& Caption = "เพิ่มผู้จัดพิมพ์" ClientHeight = 4965 ClientLeft = 60 ClientTop = 345 ClientWidth = 9315 LinkTopic = "Form1" MDIChild = -1 'True ScaleHeight = 4965 ScaleWidth = 9315 Begin VB.CommandButton Command3 BackColor = &H00C0C0FF& Caption = "Exit" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Left = 7440 Style = 1 'Graphical TabIndex = 15 Top = 4200 Width = 1575 End Begin MSDataListLib.DataList Listdealer Height = 3660 Left = 1560 TabIndex = 14 Top = 240 Visible = 0 'False Width = 7455 _ExtentX = 13150 _ExtentY = 6456 _Version = 393216 BackColor = 12640511 ForeColor = 12582912 BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty End Begin VB.CommandButton Command5 BackColor = &H00C0C0FF& Caption = "ADD" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Left = 1200 Style = 1 'Graphical TabIndex = 13 Top = 4200 Width = 1575 End Begin VB.CommandButton Command4 BackColor = &H00C0C0FF& Caption = "EDIT" Enabled = 0 'False BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Left = 2760 Style = 1 'Graphical TabIndex = 12 Top = 4200 Width = 1575 End Begin VB.CommandButton Command2 BackColor = &H00C0C0FF& Caption = "Cancel" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Left = 5880 Style = 1 'Graphical TabIndex = 11 Top = 4200 Width = 1575 End Begin VB.CommandButton Command1 BackColor = &H00C0C0FF& Caption = "Save" Enabled = 0 'False BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Left = 4320 Style = 1 'Graphical TabIndex = 5 Top = 4200 Width = 1575 End Begin VB.TextBox Text5 BackColor = &H00E0E0E0& BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00C00000& Height = 375 Left = 1560 Locked = -1 'True TabIndex = 4 Top = 3480 Width = 3855 End Begin VB.TextBox Text4 BackColor = &H00E0E0E0& BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00C00000& Height = 855 Left = 1560 Locked = -1 'True MultiLine = -1 'True ScrollBars = 2 'Vertical TabIndex = 3 Top = 2520 Width = 6135 End Begin VB.TextBox Text3 BackColor = &H00E0E0E0& BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00C00000& Height = 735 Left = 1560 Locked = -1 'True MultiLine = -1 'True ScrollBars = 2 'Vertical TabIndex = 2 Top = 1680 Width = 6135 End Begin VB.TextBox Text2 BackColor = &H00C0FFFF& BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00C00000& Height = 855 Left = 1560 MultiLine = -1 'True ScrollBars = 2 'Vertical TabIndex = 1 Top = 720 Width = 6975 End Begin VB.TextBox Text1 Alignment = 1 'Right Justify BackColor = &H00E0E0E0& BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00C00000& Height = 375 Left = 1560 Locked = -1 'True TabIndex = 6 Top = 240 Width = 1215 End Begin VB.Label Label5 Alignment = 1 'Right Justify BackColor = &H00FFFFC0& Caption = "ติดต่อกับคุณ" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00C00000& Height = 255 Left = 240 TabIndex = 10 Top = 3480 Width = 1215 End Begin VB.Label Label4 Alignment = 1 'Right Justify BackColor = &H00FFFFC0& Caption = "ที่อยู่ 2" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00C00000& Height = 255 Left = 720 TabIndex = 9 Top = 2520 Width = 735 End Begin VB.Label Label3 Alignment = 1 'Right Justify BackColor = &H00FFFFC0& Caption = "ที่อยู่ 1" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00C00000& Height = 255 Left = 720 TabIndex = 8 Top = 1680 Width = 735 End Begin VB.Label Label2 Alignment = 1 'Right Justify BackColor = &H00FFFFC0& Caption = "ชื่อสำนักพิมพ์" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00C00000& Height = 255 Left = 240 TabIndex = 7 Top = 720 Width = 1215 End Begin VB.Label Label1 Alignment = 1 'Right Justify BackColor = &H00FFFFC0& Caption = "รหัสสำนักพิมพ์" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00C00000& Height = 255 Left = 120 TabIndex = 0 Top = 240 Width = 1335 End End Attribute VB_Name = "Adddealer" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim add_dealer As New ADODB.Recordset Dim Conn As New ADODB.Connection Dim dealertab As New ADODB.Recordset Dim dealertab1 As New ADODB.Recordset Dim chk_buttom As String Private Sub Command1_Click() If MsgBox("ต้องการบันทึกข้อมูลหรือไม่", vbQuestion + vbOKCancel, "บันทึกข้อมูล") = vbOK Then With add_dealer If .State = adStateOpen Then .Close .CursorLocation = adUseClient If chk_buttom = "Add" Then .Open "select * from dealer ", Conn, adOpenForwardOnly, adLockOptimistic .AddNew .Fields(0) = Text1.Text .Fields(1) = Text2.Text .Fields(3) = Text3.Text .Fields(4) = Text4.Text .Fields(8) = Text5.Text .Update End If If chk_buttom = "Edit" Then .Open "select * from dealer where Publisher_Code='" & Text1.Text & "'", Conn, adOpenForwardOnly, adLockOptimistic If Not .EOF Then .Fields(1) = Text2.Text .Fields(3) = Text3.Text .Fields(4) = Text4.Text .Fields(8) = Text5.Text .Update End If End If .Close new_dealer = "F" MsgBox "บันทึกข้อมูล เรียบร้อยแล้ว", vbInformation + vbOKOnly, "Complete" Call Command2_Click End With 'namedealer = Text1.Text 'iddealer = Text2.Text 'Unload Me End If End Sub Private Sub Command2_Click() Text1.Text = "" Text2.Text = "" Text3.Text = "" Text4.Text = "" Text5.Text = "" Text3.Locked = True Text3.BackColor = &HE0E0E0 Text4.Locked = True Text4.BackColor = &HE0E0E0 Text5.Locked = True Text5.BackColor = &HE0E0E0 Command1.Enabled = False Command4.Enabled = False Command5.Enabled = True Text2.SetFocus End Sub Private Sub Command3_Click() Unload Me End Sub Private Sub Command4_Click() chk_buttom = "Edit" Text3.Locked = False Text3.BackColor = &HC0FFFF Text4.Locked = False Text4.BackColor = &HC0FFFF Text5.Locked = False Text5.BackColor = &HC0FFFF Command1.Enabled = True Command4.Enabled = False Command5.Enabled = False End Sub Private Sub Command5_Click() With add_dealer If .State = adStateOpen Then .Close .ActiveConnection = Conn .CursorType = adOpenForwardOnly .CursorLocation = adUseClient .Open "select * from dealer order by Publisher_Code " .MoveLast Text1.Text = Val(add_dealer.Fields(0).Value) + 1 .Close End With Command1.Enabled = True chk_buttom = "Add" Text3.Locked = False Text3.BackColor = &HC0FFFF Text4.Locked = False Text4.BackColor = &HC0FFFF Text5.Locked = False Text5.BackColor = &HC0FFFF Text2.SelStart = Len(Text2.Text) Text2.SetFocus 'Text2.Text = namedealer End Sub Private Sub Form_Load() Set Conn = New ADODB.Connection Conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _ & "SERVER=192.168.1.15;" _ & "DATABASE=magazine;" _ & "UID=chaiya;" _ & "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384 Conn.CursorLocation = adUseClient Conn.Mode = adModeUnknown Conn.Open End Sub Private Sub Form_Resize() If new_dealer = "T" Then Call Command5_Click End Sub Private Sub Listdealer_Click() Listdealer.Visible = False Command4.Enabled = True Command5.Enabled = False With dealertab1 If .State = adStateOpen Then .Close .CursorLocation = adUseClient .Open "select * from dealer Where publisher_code='" & Listdealer.BoundText & "'", Conn, adOpenForwardOnly, adLockReadOnly If Not .EOF Then Text1.Text = .Fields(0).Value Text2.Text = .Fields(1).Value If Not IsNull(.Fields(3).Value) Then Text3.Text = .Fields(3).Value If Not IsNull(.Fields(4).Value) Then Text4.Text = .Fields(4).Value If Not IsNull(.Fields(5).Value) Then Text5.Text = .Fields(8).Value End If End With Text2.Text = Listdealer.Text End Sub Private Sub Text2_DblClick() With dealertab If .State = adStateOpen Then .Close .CursorLocation = adUseClient .Open "select publisher_code,publisher_Name from dealer Where publisher_Name LIKE '%" & Text2.Text & "%'", Conn, adOpenForwardOnly, adLockReadOnly If Not .EOF Then Listdealer.Visible = True Set Listdealer.RowSource = dealertab Listdealer.ListField = "publisher_name" Listdealer.BoundColumn = "publisher_Code" End If End With End Sub