home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Unleashed / Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso / source / chap35 / ordrhist.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-08-02  |  7.9 KB  |  243 lines

  1. VERSION 4.00
  2. Begin VB.Form OrderHistory 
  3.    Appearance      =   0  'Flat
  4.    BackColor       =   &H00C0C0C0&
  5.    Caption         =   "Order History"
  6.    ClientHeight    =   4635
  7.    ClientLeft      =   -45
  8.    ClientTop       =   660
  9.    ClientWidth     =   6360
  10.    BeginProperty Font 
  11.       name            =   "MS Sans Serif"
  12.       charset         =   1
  13.       weight          =   700
  14.       size            =   8.25
  15.       underline       =   0   'False
  16.       italic          =   0   'False
  17.       strikethrough   =   0   'False
  18.    EndProperty
  19.    ForeColor       =   &H80000008&
  20.    Height          =   5040
  21.    Left            =   -105
  22.    LinkTopic       =   "Form1"
  23.    ScaleHeight     =   4635
  24.    ScaleWidth      =   6360
  25.    Top             =   315
  26.    Width           =   6480
  27.    Begin VB.CommandButton Command1 
  28.       Appearance      =   0  'Flat
  29.       BackColor       =   &H80000005&
  30.       Caption         =   "Delete"
  31.       Height          =   615
  32.       Left            =   480
  33.       TabIndex        =   2
  34.       Top             =   3600
  35.       Width           =   1215
  36.    End
  37.    Begin VB.Data CustProdHist 
  38.       Appearance      =   0  'Flat
  39.       Caption         =   "CustProdHist"
  40.       Connect         =   ""
  41.       DatabaseName    =   "C:\VBPROJ\SAMS\VB4DB.MDB"
  42.       Exclusive       =   0   'False
  43.       Height          =   270
  44.       Left            =   1920
  45.       Options         =   0
  46.       ReadOnly        =   0   'False
  47.       RecordsetType   =   1  'Dynaset
  48.       RecordSource    =   "CustProdHist"
  49.       Top             =   3840
  50.       Visible         =   0   'False
  51.       Width           =   2535
  52.    End
  53.    Begin MSDBGrid.DBGrid OrderHistoryGrid 
  54.       Bindings        =   "ORDRHIST.frx":0000
  55.       Height          =   2055
  56.       Left            =   360
  57.       OleObjectBlob   =   "ORDRHIST.frx":0015
  58.       TabIndex        =   7
  59.       Top             =   240
  60.       Width           =   4935
  61.    End
  62.    Begin Threed.SSPanel Panel3D1 
  63.       Height          =   1095
  64.       Left            =   360
  65.       TabIndex        =   3
  66.       Top             =   2400
  67.       Width           =   5655
  68.       _version        =   65536
  69.       _extentx        =   9975
  70.       _extenty        =   1931
  71.       _stockprops     =   15
  72.       bevelwidth      =   3
  73.       borderwidth     =   0
  74.       Begin VB.TextBox dblAddQty 
  75.          Height          =   285
  76.          Left            =   3600
  77.          TabIndex        =   6
  78.          Top             =   240
  79.          Width           =   735
  80.       End
  81.       Begin VB.TextBox txtAddDesc 
  82.          Height          =   285
  83.          Left            =   1440
  84.          TabIndex        =   5
  85.          Top             =   240
  86.          Width           =   2175
  87.       End
  88.       Begin VB.TextBox txtAddDate 
  89.          Height          =   285
  90.          Left            =   120
  91.          TabIndex        =   4
  92.          Top             =   240
  93.          Width           =   1335
  94.       End
  95.       Begin VB.Label Label1 
  96.          Caption         =   "To add an order, enter data into the fields and press ""Add"""
  97.          Height          =   255
  98.          Left            =   240
  99.          TabIndex        =   8
  100.          Top             =   720
  101.          Width           =   5175
  102.       End
  103.       Begin Threed.SSCommand Command3D1 
  104.          Height          =   495
  105.          Left            =   4560
  106.          TabIndex        =   0
  107.          Top             =   120
  108.          Width           =   855
  109.          _version        =   65536
  110.          _extentx        =   1508
  111.          _extenty        =   873
  112.          _stockprops     =   78
  113.          caption         =   "&Add"
  114.          forecolor       =   0
  115.       End
  116.    End
  117.    Begin Threed.SSCommand btnDelTickets 
  118.       Height          =   615
  119.       Left            =   4680
  120.       TabIndex        =   1
  121.       Top             =   3600
  122.       Width           =   1215
  123.       _version        =   65536
  124.       _extentx        =   2143
  125.       _extenty        =   1085
  126.       _stockprops     =   78
  127.       caption         =   "&Close"
  128.       forecolor       =   0
  129.    End
  130. Attribute VB_Name = "OrderHistory"
  131. Attribute VB_Creatable = False
  132. Attribute VB_Exposed = False
  133. Option Explicit
  134. Private Sub btnDelTickets_Click()
  135.     Unload OrderHistory
  136. End Sub
  137. Private Sub Command1_Click()
  138. Dim response
  139.     response = MsgBox("Delete Order history entry?", 4, "Delete Record")
  140.     If (response = vbNo) Then
  141.         OrderHistoryGrid.SetFocus
  142.         Exit Sub
  143.     End If
  144.     On Error GoTo delerror
  145.     OrderHistoryGrid.SetFocus
  146.     'CustProdHist.Refresh
  147.     If CustProdHist.Recordset.RecordCount = 0 Then Exit Sub
  148.     CustProdHist.Recordset.DELETE
  149.     OrderHistoryGrid.Refresh
  150.     CustProdHist.Refresh
  151.     Exit Sub
  152. delerror:
  153.     OrderHistoryGrid.Refresh
  154.     CustProdHist.Refresh
  155.     Exit Sub
  156. End Sub
  157. Private Sub Command3D1_Click()
  158.     Dim buffer As String
  159.     Call UpdateCustProdHistRec
  160.     buffer = "Select * From CustProdHist Where CustomerNum = " & Str(Customer_number)
  161.     buffer = buffer & " Order By Date_Delivered DESC;"
  162.     CustProdHist.RecordSource = buffer
  163.     CustProdHist.Refresh
  164.     OrderHistoryGrid.Refresh
  165. End Sub
  166. Private Sub dblAddQty_KeyPress(KeyAscii As Integer)
  167. ' While not a Windows standard, the client
  168. ' prefers to use the enter key to move from field to field.
  169. ' This subroutine should trap the keypress and
  170. ' and process all "ENTER" keys as "TAB"
  171.     If KeyAscii = 13 Then
  172.         SendKeys "{tab}"
  173.         KeyAscii = 0
  174.     End If
  175. End Sub
  176. Private Sub Form_Activate()
  177.     ' Reset to the default  pointer when returning to this form.
  178.     MousePointer = 0
  179.     Dim buffer As String
  180.     buffer = "Select * From CustProdHist Where CustomerNum = " & Str(Customer_number)
  181.     buffer = buffer & " Order By Date_Delivered DESC;"
  182.     CustProdHist.RecordSource = buffer
  183.     CustProdHist.Refresh
  184.     OrderHistoryGrid.Refresh
  185. End Sub
  186. Private Sub Form_KeyPress(KeyAscii As Integer)
  187. ' While not a Windows standard, the client
  188. ' prefers to use the enter key to move from field to field.
  189. ' This subroutine should trap the keypress and
  190. ' and process all "ENTER" keys as "TAB"
  191.     If KeyAscii = 13 Then
  192.         SendKeys "{tab}"
  193.         KeyAscii = 0
  194.     End If
  195. End Sub
  196. Private Sub Form_Load()
  197.     'Center the form
  198.     Left = (Screen.Width - Width) / 2
  199.     TOP = (Screen.Height - Height) / 2
  200. End Sub
  201. Private Sub OrderHistoryGrid_GotFocus()
  202.     'If (CustProdHist.Recordset.RecordCount = 0) Then
  203.     '    ' The following DoEvents is necessary.
  204.     '    DoEvents
  205.     '    CustProdHist.Recordset.AddNew
  206.     '    CustProdHist.Recordset.Fields("CustomerNum") = Customer_number
  207.     '    CustProdHist.Recordset.Update
  208.     'End If
  209. End Sub
  210. Private Sub Timer1_Timer()
  211.     OrderHistoryGrid.Refresh
  212. End Sub
  213. Private Sub txtAddDate_KeyPress(KeyAscii As Integer)
  214. ' While not a Windows standard, the client
  215. ' prefers to use the enter key to move from field to field.
  216. ' This subroutine should trap the keypress and
  217. ' and process all "ENTER" keys as "TAB"
  218.     If KeyAscii = 13 Then
  219.         SendKeys "{tab}"
  220.         KeyAscii = 0
  221.     End If
  222. End Sub
  223. Private Sub txtAddDate_LostFocus()
  224.     Dim datecheck
  225.     datecheck = Format(txtAddDate.TEXT, "mm/dd/yy")
  226. End Sub
  227. Private Sub UpdateCustProdHistRec()
  228.         Dim SQLUpdateTable
  229.         Dim CustProdHistTbl As TABLE
  230.         
  231.         Set CustProdHistTbl = CustDB.OpenTable("CustProdHist")
  232.         CustProdHistTbl.AddNew
  233.         CustProdHistTbl.Fields("OrderNum") = 0
  234.         CustProdHistTbl.Fields("CustomerNum") = Customer_number
  235.         CustProdHistTbl.Fields("Date_Delivered") = Format(txtAddDate.TEXT, "mm/dd/yy")
  236.         CustProdHistTbl.Fields("product") = txtAddDesc.TEXT
  237.         CustProdHistTbl.Fields("Qty") = dblAddQty.TEXT
  238.         CustProdHistTbl.UPDATE
  239.         txtAddDesc.TEXT = ""
  240.         dblAddQty.TEXT = ""
  241.         txtAddDate.TEXT = ""
  242. End Sub
  243.