home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / VISUAL_B / CODIGO_1 / BROWSE_1 / FRMCAT.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1993-07-19  |  9.8 KB  |  319 lines

  1. VERSION 2.00
  2. Begin Form frmCatalog 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Catalog Database"
  5.    ClientHeight    =   6444
  6.    ClientLeft      =   876
  7.    ClientTop       =   1296
  8.    ClientWidth     =   7284
  9.    ControlBox      =   0   'False
  10.    Height          =   6780
  11.    Left            =   828
  12.    LinkTopic       =   " "
  13.    MaxButton       =   0   'False
  14.    ScaleHeight     =   6444
  15.    ScaleWidth      =   7284
  16.    Top             =   1008
  17.    Width           =   7380
  18.    Begin CommandButton comExit 
  19.       Caption         =   "E&xit"
  20.       Height          =   252
  21.       Left            =   5880
  22.       TabIndex        =   18
  23.       Top             =   6120
  24.       Width           =   1332
  25.    End
  26.    Begin CommandButton comDelete 
  27.       Caption         =   "&Delete "
  28.       Height          =   372
  29.       Left            =   5760
  30.       TabIndex        =   17
  31.       Top             =   840
  32.       Width           =   1452
  33.    End
  34.    Begin CommandButton comNew 
  35.       Caption         =   "&Add New"
  36.       Height          =   372
  37.       Left            =   5760
  38.       TabIndex        =   16
  39.       Top             =   480
  40.       Width           =   1452
  41.    End
  42.    Begin CommandButton comUpdate 
  43.       Caption         =   "&Update"
  44.       Enabled         =   0   'False
  45.       Height          =   372
  46.       Left            =   5760
  47.       TabIndex        =   15
  48.       Top             =   120
  49.       Width           =   1452
  50.    End
  51.    Begin TextBox txtEdt 
  52.       DataField       =   "TYPE"
  53.       DataSource      =   "dtaCatalog"
  54.       Enabled         =   0   'False
  55.       Height          =   288
  56.       Index           =   6
  57.       Left            =   4200
  58.       MaxLength       =   4
  59.       TabIndex        =   14
  60.       Top             =   840
  61.       Width           =   1332
  62.    End
  63.    Begin TextBox txtEdt 
  64.       DataField       =   "CODE"
  65.       DataSource      =   "dtaCatalog"
  66.       Enabled         =   0   'False
  67.       Height          =   288
  68.       Index           =   5
  69.       Left            =   4200
  70.       MaxLength       =   4
  71.       TabIndex        =   12
  72.       Top             =   480
  73.       Width           =   1332
  74.    End
  75.    Begin TextBox txtEdt 
  76.       DataField       =   "GROUP"
  77.       DataSource      =   "dtaCatalog"
  78.       Enabled         =   0   'False
  79.       Height          =   288
  80.       Index           =   4
  81.       Left            =   4200
  82.       MaxLength       =   4
  83.       TabIndex        =   10
  84.       Top             =   120
  85.       Width           =   1332
  86.    End
  87.    Begin TextBox txtEdt 
  88.       DataField       =   "DESCR"
  89.       DataSource      =   "dtaCatalog"
  90.       Height          =   288
  91.       Index           =   3
  92.       Left            =   1800
  93.       MaxLength       =   50
  94.       TabIndex        =   8
  95.       Top             =   1320
  96.       Width           =   5412
  97.    End
  98.    Begin TextBox txtEdt 
  99.       DataField       =   "LIST"
  100.       DataSource      =   "dtaCatalog"
  101.       Height          =   288
  102.       Index           =   2
  103.       Left            =   1800
  104.       MaxLength       =   12
  105.       TabIndex        =   6
  106.       Top             =   840
  107.       Width           =   1332
  108.    End
  109.    Begin TextBox txtEdt 
  110.       DataField       =   "CATNO"
  111.       DataSource      =   "dtaCatalog"
  112.       Height          =   288
  113.       Index           =   1
  114.       Left            =   1800
  115.       MaxLength       =   15
  116.       TabIndex        =   4
  117.       Top             =   480
  118.       Width           =   1332
  119.    End
  120.    Begin TextBox txtEdt 
  121.       DataField       =   "SYSNO"
  122.       DataSource      =   "dtaCatalog"
  123.       Height          =   288
  124.       Index           =   0
  125.       Left            =   1800
  126.       MaxLength       =   6
  127.       TabIndex        =   2
  128.       Top             =   120
  129.       Width           =   1092
  130.    End
  131.    Begin TBrowse Brw 
  132.       BorderStyle     =   0  'None
  133.       DataSource      =   "dtaCatalog"
  134.       Height          =   4332
  135.       Left            =   120
  136.       TabIndex        =   0
  137.       Top             =   1680
  138.       Width           =   7092
  139.    End
  140.    Begin Data dtaCatalog 
  141.       Caption         =   "Catalog Table Data Control"
  142.       Connect         =   ""
  143.       DatabaseName    =   "C:\VB\CDK\BRWA\DEMO\DEMO.MDB"
  144.       Exclusive       =   0   'False
  145.       Height          =   252
  146.       Left            =   120
  147.       Options         =   0
  148.       ReadOnly        =   0   'False
  149.       RecordSource    =   "CATALOG"
  150.       Top             =   6120
  151.       Width           =   5532
  152.    End
  153.    Begin Label Label1 
  154.       Caption         =   "&Type:"
  155.       Height          =   252
  156.       Index           =   6
  157.       Left            =   3240
  158.       TabIndex        =   13
  159.       Top             =   840
  160.       Width           =   852
  161.    End
  162.    Begin Label Label1 
  163.       Caption         =   "C&ode:"
  164.       Height          =   252
  165.       Index           =   5
  166.       Left            =   3240
  167.       TabIndex        =   11
  168.       Top             =   480
  169.       Width           =   852
  170.    End
  171.    Begin Label Label1 
  172.       Caption         =   "&Group:"
  173.       Height          =   252
  174.       Index           =   4
  175.       Left            =   3240
  176.       TabIndex        =   9
  177.       Top             =   120
  178.       Width           =   852
  179.    End
  180.    Begin Label Label1 
  181.       Caption         =   "D&escription"
  182.       Height          =   252
  183.       Index           =   3
  184.       Left            =   120
  185.       TabIndex        =   7
  186.       Top             =   1320
  187.       Width           =   1572
  188.    End
  189.    Begin Label Label1 
  190.       Caption         =   "&List price:"
  191.       Height          =   252
  192.       Index           =   2
  193.       Left            =   120
  194.       TabIndex        =   5
  195.       Top             =   840
  196.       Width           =   1572
  197.    End
  198.    Begin Label Label1 
  199.       Caption         =   "&Catalog number:"
  200.       Height          =   252
  201.       Index           =   1
  202.       Left            =   120
  203.       TabIndex        =   3
  204.       Top             =   480
  205.       Width           =   1572
  206.    End
  207.    Begin Label Label1 
  208.       Caption         =   "&Number:"
  209.       Height          =   252
  210.       Index           =   0
  211.       Left            =   120
  212.       TabIndex        =   1
  213.       Top             =   120
  214.       Width           =   1572
  215.    End
  216. Option Explicit
  217. ' lInitialize is required as a one time flag,
  218. ' see form_activate() for details
  219. Dim lInitialize As Integer
  220. Sub Brw_EditValid (nCol As Integer, cField As String, lOk As Integer)
  221.    ' Edit validations, we need to check the primary key - SYSNO
  222.    ' and the list price
  223.    If nCol = 0 Then
  224.       ' SYSNO must be non-zero and positive
  225.       If Trim$(cField) = "" Or Val(cField) <= 0 Then
  226.          MsgBox "Wrong primary key!"
  227.          lOk = False
  228.       End If
  229.    ElseIf nCol = 5 Then
  230.       ' List price must be positive or zero
  231.       If Val(cField) < 0 Then
  232.          MsgBox "Wrong list price!"
  233.          lOk = False
  234.       End If
  235.    End If
  236. End Sub
  237. Sub comDelete_Click ()
  238.    ' delete current record
  239.    ' IMPORTANT: YOU MUST ISSUE THE REFRESH, OTHERWISE THE CONTROL WILL CRASH!
  240.    dtaCatalog.Recordset.Delete
  241.    dtaCatalog.Refresh
  242. End Sub
  243. Sub comExit_Click ()
  244.    ' pseudo-exit, we are just hidding ourselfs
  245.    Me.Hide
  246.    BrwDemo!comProducts.Enabled = True ' and re-enable the show button
  247. End Sub
  248. Sub comNew_Click ()
  249.    ' add a new record
  250.    dtaCatalog.Recordset.AddNew
  251.    ' set the read-only fields, we must preserve
  252.    ' database relations
  253.    txtEdt(4).Text = BrwDemo!dtaPrdGroup.Recordset.Fields("GROUP").Value
  254.    txtEdt(5).Text = BrwDemo!dtaPrdGroup.Recordset.Fields("CODE").Value
  255.    txtEdt(6).Text = BrwDemo!dtaPrdGroup.Recordset.Fields("TYPE").Value
  256. End Sub
  257. Sub comUpdate_Click ()
  258.    ' we must update explicitly after editing in one
  259.    ' of the text box bound controls
  260.    dtaCatalog.Recordset.Update
  261.    comUpdate.Enabled = False
  262. End Sub
  263. Sub Form_Activate ()
  264.    Dim cFind As String
  265.    ' We need to force the data control to refresh
  266.    ' after the form has been loaded (but not in
  267.    ' the form_load(), the objects are not yet initialized ).
  268.    ' This must be done also if the RecordSource
  269.    ' changes at run-time.
  270.    If Not lInitialize Then
  271.       lInitialize = True
  272.       cFind = "GROUP = '" + BrwDemo!dtaPrdGroup.Recordset.Fields("GROUP").Value + "' and "
  273.       cFind = cFind + "CODE = '" + BrwDemo!dtaPrdGroup.Recordset.Fields("CODE").Value + "' and "
  274.       cFind = cFind + "TYPE = '" + BrwDemo!dtaPrdGroup.Recordset.Fields("TYPE").Value + "'"
  275.       dtaCatalog.Recordset.FindFirst cFind
  276.    End If
  277. End Sub
  278. Sub Form_Load ()
  279.    ' set form position
  280.    Me.Top = 0: Me.Left = Screen.Width - Me.Width
  281.    ' initialize the browse control
  282.    Brw.Cols = 7            ' we need 7 columns
  283.    ' set column width for each
  284.    Brw.ColWidth(0) = 6
  285.    Brw.ColWidth(1) = 4
  286.    Brw.ColWidth(2) = 4
  287.    Brw.ColWidth(3) = 4
  288.    Brw.ColWidth(4) = 15
  289.    Brw.ColWidth(5) = 12
  290.    Brw.ColWidth(6) = 50
  291.    ' set header for each (if is not the default = field name)
  292.    Brw.Header(0) = "Sysno"
  293.    Brw.Header(1) = "Group"
  294.    Brw.Header(2) = "Code"
  295.    Brw.Header(3) = "Type"
  296.    Brw.Header(4) = "Catalog no"
  297.    Brw.Header(5) = "List price"
  298.    Brw.Header(6) = "Description"
  299.    ' set the data field for each column
  300.    Brw.ColField(0) = "SYSNO"
  301.    Brw.ColField(1) = "GROUP"
  302.    Brw.ColField(2) = "CODE"
  303.    Brw.ColField(3) = "TYPE"
  304.    Brw.ColField(4) = "CATNO"
  305.    Brw.ColField(5) = "LIST"
  306.    Brw.ColField(6) = "DESCR"
  307.    ' enable editing for the ones we want
  308.    Brw.ColEdit(0) = True
  309.    Brw.ColEdit(4) = True
  310.    Brw.ColEdit(5) = True
  311.    Brw.ColEdit(6) = True
  312.    Brw.LeftFrozen = 1     ' freeze the SYSNO to the left
  313.    Brw.SpcColor(5) = True ' set the LIST column to a special color
  314. End Sub
  315. Sub txtEdt_Change (Index As Integer)
  316.    ' enable the Update button if the user has changed something
  317.    If HasFocus(txtEdt(Index)) And Not comUpdate.Enabled Then comUpdate.Enabled = True
  318. End Sub
  319.