home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / mdidem / publish.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-02  |  6.6 KB  |  240 lines

  1. VERSION 2.00
  2. Begin Form Publish 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Publishers"
  5.    ClientHeight    =   1245
  6.    ClientLeft      =   3690
  7.    ClientTop       =   2460
  8.    ClientWidth     =   3990
  9.    Height          =   1935
  10.    Icon            =   PUBLISH.FRX:0000
  11.    Left            =   3630
  12.    LinkTopic       =   "Form1"
  13.    MDIChild        =   -1  'True
  14.    ScaleHeight     =   1245
  15.    ScaleWidth      =   3990
  16.    Top             =   1830
  17.    Width           =   4110
  18.    Begin TextBox PubName 
  19.       DataField       =   "Name"
  20.       DataSource      =   "Data1"
  21.       Height          =   285
  22.       Left            =   135
  23.       MaxLength       =   40
  24.       TabIndex        =   0
  25.       Top             =   315
  26.       Width           =   3615
  27.    End
  28.    Begin Data Data1 
  29.       Caption         =   "Data1"
  30.       Connect         =   ""
  31.       DatabaseName    =   ""
  32.       Exclusive       =   0   'False
  33.       Height          =   285
  34.       Left            =   2610
  35.       Options         =   0
  36.       ReadOnly        =   0   'False
  37.       RecordSource    =   "Publishers"
  38.       Top             =   720
  39.       Width           =   1140
  40.    End
  41.    Begin Label FormCommand 
  42.       Caption         =   "FormCommand"
  43.       Height          =   240
  44.       Left            =   1440
  45.       TabIndex        =   2
  46.       Top             =   765
  47.       Visible         =   0   'False
  48.       Width           =   1185
  49.    End
  50.    Begin Label Label1 
  51.       BackStyle       =   0  'Transparent
  52.       Caption         =   "Name"
  53.       Height          =   240
  54.       Index           =   0
  55.       Left            =   135
  56.       TabIndex        =   1
  57.       Top             =   135
  58.       Width           =   1005
  59.    End
  60.    Begin Menu FileMenu 
  61.       Caption         =   "&File"
  62.       Begin Menu OpenMenu 
  63.          Caption         =   "&Open"
  64.       End
  65.       Begin Menu SaveMenu 
  66.          Caption         =   "&Save"
  67.       End
  68.       Begin Menu NewMenu 
  69.          Caption         =   "&New"
  70.       End
  71.       Begin Menu CloseMenu 
  72.          Caption         =   "&Close"
  73.       End
  74.       Begin Menu sep 
  75.          Caption         =   "-"
  76.       End
  77.       Begin Menu ExitMenu 
  78.          Caption         =   "E&xit"
  79.       End
  80.    End
  81.    Begin Menu EditMenu 
  82.       Caption         =   "&Edit"
  83.       Begin Menu RestoreMenu 
  84.          Caption         =   "&Restore"
  85.       End
  86.       Begin Menu DeleteMenu 
  87.          Caption         =   "&Delete"
  88.       End
  89.    End
  90.    Begin Menu WindowMenu 
  91.       Caption         =   "&Window"
  92.       WindowList      =   -1  'True
  93.       Begin Menu WindowTileMenu 
  94.          Caption         =   "&Tile"
  95.       End
  96.       Begin Menu WindowCascadeMenu 
  97.          Caption         =   "&Cascade"
  98.       End
  99.       Begin Menu WindowArrangeIconsMenu 
  100.          Caption         =   "&Arrange Icons"
  101.       End
  102.    End
  103. Option Explicit
  104. Option Compare Text
  105. Const RecordType = "Publisher"
  106. Sub DeleteMenu_Click ()
  107. On Error GoTo DeleteError
  108. If MsgBox("Are you sure that you want to delete this " & LCase$(RecordType) & "?", MB_YesNo + MB_DefButton2) = IDYes Then
  109.     Data1.Recordset.Delete
  110.     Data1.Refresh
  111. End If
  112. Exit Sub
  113. DeleteError:
  114.     DataError Err, Error$
  115.     Exit Sub
  116. End Sub
  117. Sub ExitMenu_Click ()
  118. Unload MainMdi
  119. End Sub
  120. Sub Form_Load ()
  121. Height = 1935
  122. Width = 4110
  123. Data1.DatabaseName = gDatabaseName
  124. Data1.Refresh
  125. End Sub
  126. Sub FormCommand_Change ()
  127. Dim Cmd As String, Parameter As String
  128. Dim i As Integer
  129. If FormCommand = "" Then Exit Sub
  130. Cmd = Trim$(FormCommand) & " "
  131. i = InStr(Cmd, " ")
  132. Parameter = Trim$(Mid$(Cmd, i + 1))
  133. Cmd = Left$(Cmd, i - 1)
  134. Select Case Cmd
  135.     Case "FindFirst"
  136.         Data1.Recordset.FindFirst Parameter
  137. End Select
  138. FormCommand = ""
  139. End Sub
  140. Sub NewMenu_Click ()
  141. Data1.Recordset.AddNew
  142. End Sub
  143. Sub OpenMenu_Click ()
  144. OpenDialog.Show 1
  145. End Sub
  146. Sub RestoreMenu_Click ()
  147. Data1.UpdateControls
  148. End Sub
  149. Sub SaveMenu_Click ()
  150. On Error GoTo SaveMenuError
  151. If CheckData() Then
  152.     Data1.UpdateRecord
  153.     Data1.Recordset.Bookmark = Data1.Recordset.LastModified
  154. End If
  155. Exit Sub
  156. SaveMenuError:
  157.     Select Case Err
  158.         Case Else
  159.             DataError Err, Error$
  160.     End Select
  161.     Exit Sub
  162. End Sub
  163. Sub WindowArrangeIconsMenu_Click ()
  164. MainMdi.Arrange Arrange_Icons
  165. End Sub
  166. Sub WindowCascadeMenu_Click ()
  167. MainMdi.Arrange Cascade
  168. End Sub
  169. Sub WindowTileMenu_Click ()
  170. MainMdi.Arrange Tile_Horizontal
  171. End Sub
  172. Function CheckData () As Integer
  173. If PubName = "" Then
  174.     MsgBox "Unable to save record. Publisher name is blank."
  175.     CheckData = False
  176.     CheckData = True
  177. End If
  178. End Function
  179. Sub CloseMenu_Click ()
  180. Unload Me
  181. End Sub
  182. Sub Data1_Reposition ()
  183. If Data1.EditMode = Data_EditAdd Then
  184.     Caption = "Adding New Publisher"
  185. ElseIf Data1.Recordset.BOF Or Data1.Recordset.EOF Then
  186.     Caption = "No Publisher Records Found"
  187.     Caption = "Publisher #" & Data1.Recordset("PubID")
  188. End If
  189. End Sub
  190. Sub Data1_Validate (Action As Integer, Save As Integer)
  191. Select Case Action
  192.     Case Data_ActionDelete
  193.         ' this is due to a delete command
  194.         ' calling routine should confirm deletion
  195.      Case Data_ActionUpdate
  196.         ' make sure data is valid
  197.         If CheckData() Then
  198.             Save = True
  199.         Else
  200.             Action = Data_ActionCancel
  201.             Save = False
  202.         End If
  203.      Case Else
  204.         If Save Then
  205.             ' this is due to an implicit save command
  206.             ' make sure they actually want to save it
  207.             If MainMdi.WindowState = Minimized Then MainMdi.WindowState = Normal
  208.             If Me.WindowState = Minimized Then Me.WindowState = Normal
  209.             Me.Show
  210.             Select Case MsgBox("Do you want to save the changes to this " & RecordType & "?", MB_YesNoCancel)
  211.                 Case IDYes
  212.                     ' they want to save it
  213.                     ' make sure data is valid
  214.                     If Not CheckData() Then
  215.                         Action = Data_ActionCancel
  216.                         Save = False
  217.                     End If
  218.                 Case IDNo
  219.                     Save = False
  220.                 Case Else
  221.                     Save = False
  222.                     Action = Data_ActionCancel
  223.             End Select
  224.         End If
  225. End Select
  226. If Save Then
  227.     On Error GoTo ValidateError
  228.     ' perform the save manually
  229.     Save = False
  230.     Data1.UpdateRecord
  231.     Data1.Recordset.Bookmark = Data1.Recordset.LastModified
  232.     SendAll "Refresh Publisher"
  233. End If
  234. Exit Sub
  235. ValidateError:
  236.     DataError Err, Error$
  237.     Action = Data_ActionCancel
  238.     Exit Sub
  239. End Sub
  240.