VERSION 5.00 Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX" Object = "{00025600-0000-0000-C000-000000000046}#4.6#0"; "CRYSTL32.OCX" Begin VB.Form frmrep_journ_serv Appearance = 0 'Flat BackColor = &H00C0FFC0& BorderStyle = 1 'Fixed Single Caption = "พิมพ์รายชื่อวารสารสำหรับการสำรวจ" ClientHeight = 8520 ClientLeft = 1050 ClientTop = 1815 ClientWidth = 11910 BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H80000008& LinkTopic = "Form1" MDIChild = -1 'True PaletteMode = 1 'UseZOrder ScaleHeight = 8520 ScaleWidth = 11910 WindowState = 2 'Maximized Begin Crystal.CrystalReport report1 Left = 2040 Top = 6480 _ExtentX = 741 _ExtentY = 741 _Version = 262150 End Begin VB.Frame Frame1 BackColor = &H00FFFFC0& Height = 5655 Left = 1440 TabIndex = 0 Top = 480 Width = 8895 Begin MSComCtl2.MonthView MonthView1 Height = 2370 Left = 4200 TabIndex = 1 Top = 2640 Visible = 0 'False Width = 2700 _ExtentX = 4763 _ExtentY = 4180 _Version = 393216 ForeColor = -2147483640 BackColor = -2147483633 Appearance = 1 MonthBackColor = 12640511 StartOfWeek = 24379394 TitleBackColor = 16711680 TitleForeColor = 16777215 TrailingForeColor= 8421504 CurrentDate = 38159 End Begin VB.CommandButton cmdcan Appearance = 0 'Flat BackColor = &H00C0FFFF& Caption = "Clear Date" 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 = 6600 Style = 1 'Graphical TabIndex = 11 Top = 3960 Width = 1575 End Begin VB.CommandButton cmdprint Appearance = 0 'Flat BackColor = &H00C0FFFF& Caption = "Print" 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 = 3840 Style = 1 'Graphical TabIndex = 10 Top = 4560 Width = 2055 End Begin VB.CommandButton cmdexit Appearance = 0 'Flat BackColor = &H00C0FFFF& 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 = 6600 MaskColor = &H00FFFF00& Style = 1 'Graphical TabIndex = 9 Top = 4560 Width = 1575 End Begin VB.Frame Frame2 BackColor = &H00FFFFC0& Height = 975 Left = 1800 TabIndex = 6 Top = 1440 Width = 5415 Begin VB.OptionButton opttype BackColor = &H00FFFFC0& Caption = "Option2" ForeColor = &H000000C0& Height = 375 Index = 1 Left = 3360 TabIndex = 8 Top = 360 Width = 1695 End Begin VB.OptionButton opttype BackColor = &H00FFFFC0& Caption = "Option1" ForeColor = &H000000C0& Height = 375 Index = 0 Left = 1080 TabIndex = 7 Top = 360 Width = 1695 End End Begin VB.TextBox txtstart BackColor = &H00C0FFFF& ForeColor = &H00FF0000& Height = 375 Left = 4200 Locked = -1 'True TabIndex = 5 Text = "Text1" Top = 2880 Width = 1575 End Begin VB.TextBox txtstop BackColor = &H00C0FFFF& ForeColor = &H00FF0000& Height = 375 Left = 4200 Locked = -1 'True TabIndex = 4 Text = "Text2" Top = 3360 Width = 1575 End Begin VB.CommandButton Cmd_datestart BackColor = &H00FF8080& Caption = "..." Height = 375 Left = 5880 Style = 1 'Graphical TabIndex = 3 Top = 2880 Width = 375 End Begin VB.CommandButton Cmd_datestop BackColor = &H00FF8080& Caption = "..." Height = 375 Left = 5880 Style = 1 'Graphical TabIndex = 2 Top = 3360 Width = 375 End Begin VB.Label Label1 Alignment = 2 'Center Appearance = 0 'Flat BackColor = &H00FFFFC0& Caption = "Print Biliography" BeginProperty Font Name = "MS Sans Serif" Size = 16.5 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00C00000& Height = 615 Left = 720 TabIndex = 14 Top = 600 Width = 7215 End Begin VB.Label Label3 Alignment = 1 'Right Justify Appearance = 0 'Flat BackColor = &H00FFFFC0& Caption = "วันที่เริ่มต้น :" ForeColor = &H00C00000& Height = 375 Left = 2880 TabIndex = 13 Top = 2880 Width = 1095 End Begin VB.Label Label4 Alignment = 1 'Right Justify Appearance = 0 'Flat BackColor = &H00FFFFC0& Caption = "วันที่สิ้นสุด :" ForeColor = &H00C00000& Height = 375 Left = 2880 TabIndex = 12 Top = 3360 Width = 1095 End End End Attribute VB_Name = "frmrep_journ_serv" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim Conn As ADODB.Connection Dim conn1 As ADODB.Connection Dim magazinetb As ADODB.Recordset Dim tranfiletb As ADODB.Recordset Dim rep_jnsurvtb As ADODB.Recordset Dim txtdate As String Dim pasa_jn As String Private Sub Cmd_datestart_Click() txtdate = "start" MonthView1.Visible = True MonthView1.Value = Now() End Sub Private Sub Cmd_datestop_Click() txtdate = "stop" MonthView1.Visible = True MonthView1.Value = Now() End Sub Private Sub Cmdcan_Click() txtstart.Text = "" txtstop.Text = "" txtstart.SetFocus End Sub Private Sub Cmdexit_Click() Conn.Close Set Conn = Nothing conn1.Close Set conn1 = Nothing Unload Me End Sub Private Sub Cmdprint_Click() Dim datafound As Boolean conn1.Execute " delete * from rep_jn_servey;" datafound = False Set magazinetb = New ADODB.Recordset With magazinetb If .State = adStateOpen Then .Close .CursorLocation = adUseClient .Open "select pointer,magazine_name from magazine where receive_code='1' and left(pointer,1)='" & pasa_jn & "' order by pointer", Conn, adOpenForwardOnly, adLockReadOnly If Not .EOF Then Do While Not .EOF Set tranfiletb = New ADODB.Recordset With tranfiletb If .State = adStateOpen Then .Close .CursorLocation = adUseClient .Open "select indate,yearno,itemsno,DescriptionItem from tranfile where pointer='" & magazinetb.Fields(0).Value & "' order by magno desc", Conn, adOpenForwardOnly, adLockReadOnly Do While Not .EOF If DateValue(Format(.Fields(0).Value, "dd/mm/yyyy")) >= DateValue(Format(txtstart, "dd/mm/yyyy")) And DateValue(Format(.Fields(0).Value, "dd/mm/yyyy")) <= DateValue(Format(txtstop, "dd/mm/yyyy")) Then datafound = True Set rep_jnsurvtb = New ADODB.Recordset With rep_jnsurvtb If .State = adStateOpen Then .Close .CursorLocation = adUseClient .Open "select * from rep_jn_servey", conn1, adOpenForwardOnly, adLockOptimistic .AddNew .Fields(0).Value = magazinetb.Fields(1).Value .Fields(1).Value = Val(Trim(tranfiletb.Fields(1).Value)) .Fields(2).Value = Val(Trim(tranfiletb.Fields(2).Value)) .Fields(3).Value = tranfiletb.Fields(3).Value .Update .Close End With Set rep_jnsurvtb = Nothing End If tranfiletb.MoveNext Loop .Close End With magazinetb.MoveNext Loop If datafound = False Then MsgBox "ไม่พบข้อมูล ในช่วงเวลาที่ต้องการ กรุณาตรวจสอบอีกครั้ง", vbCritical + vbOKOnly, "Data Not Found" Else MsgBox "จัดเตรียมข้อมูล การจัดทำรายงานสำหรับสำรวจวารสาร เรียบร้อยแล้ว " + Chr(13) + "คลิก OK เพื่อแสดงรายงาน", vbInformation + vbOKOnly, "Data Complete" report1.Destination = 0 report1.DataFiles(0) = App.Path + "\" + "printmag.mdb" If pasa_jn = "J" Then report1.ReportFileName = App.Path + "\" + "rep_survey_en.rpt" Else report1.ReportFileName = App.Path + "\" + "rep_survey_th.rpt" End If report1.Action = 1 End If Else If datafound = False Then MsgBox "ไม่พบข้อมูล ในช่วงเวลาที่ต้องการ กรุณาตรวจสอบอีกครั้ง", vbCritical + vbOKOnly, "Data Not Found" End If End If .Close End With Set magazinetb = Nothing End Sub Private Sub Form_Load() Dim n As Integer Set Conn = New ADODB.Connection Conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _ & "SERVER=192.168.1.15;" _ & "DATABASE=magazine;" _ & "UID=chaiya;" _ & "PWD=;" _ & "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384 Conn.CursorLocation = adUseClient Conn.Mode = adModeUnknown Conn.Open Set conn1 = New ADODB.Connection With conn1 If .State = adStateOpen Then .Close .Mode = adModeUnknown .Open StrConn & ";Data Source=" & App.Path & "\" & "printmag.mdb" End With Label1.Caption = "พิมพ์รายชื่อวารสารสำหรับการสำรวจ" Label3.Caption = "วันเริ่มต้น" Label4.Caption = "วันสิ้นสุด" opttype(0).Caption = " ภาษาต่างประเทศ" opttype(1).Caption = " ภาษาไทย" opttype(0).Value = True txtstart.Text = "" txtstop.Text = "" MonthView1.Value = Now() End Sub Private Sub MonthView1_DateClick(ByVal DateClicked As Date) If txtdate = "start" Then txtstart = Format(DateClicked, "dd/mm/yyyy") If txtdate = "stop" Then txtstop = Format(DateClicked, "dd/mm/yyyy") MonthView1.Visible = False End Sub Private Sub opttype_Click(Index As Integer) If Index = 0 Then pasa_jn = "J" Else pasa_jn = "I" End If End Sub Private Sub txtstart_GotFocus() txtstart.SelStart = 0 txtstart.SelLength = Len(txtstart.Text) End Sub Private Sub txtstart_LostFocus() If txtstart = "" Or IsNull(txtstart) Then txtstart = Date End If txtstart.Text = Format(txtstart.Text, "dd/mm/yyyy") If Not IsDate(txtstart) Then MsgBox "Error in Start Date" Call Cmdcan_Click End If End Sub Private Sub txtstop_GotFocus() txtstop.SelStart = 0 txtstop.SelLength = Len(txtstop.Text) End Sub Private Sub txtstop_LostFocus() If txtstop = "" Or IsNull(txtstop) Then txtstop = Date End If txtstop.Text = Format(txtstop.Text, "dd/mm/yyyy") If Not IsDate(txtstop) Then MsgBox "Error in Stop Date" Call Cmdcan_Click End If End Sub