VERSION 5.00
Object = "{00028C01-0000-0000-0000-000000000046}#1.0#0"; "DBGRID32.OCX"
Begin VB.Form frmMain 
   Caption         =   "Делегации"
   ClientHeight    =   6165
   ClientLeft      =   165
   ClientTop       =   450
   ClientWidth     =   8070
   DrawWidth       =   3
   Icon            =   "frmMain.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   6165
   ScaleWidth      =   8070
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton btnFind 
      Caption         =   "Найти фирму"
      Height          =   375
      Left            =   960
      TabIndex        =   7
      Top             =   5640
      Width           =   1695
   End
   Begin VB.ComboBox Combo2 
      Height          =   315
      ItemData        =   "frmMain.frx":08CA
      Left            =   5400
      List            =   "frmMain.frx":08D4
      Style           =   2  'Dropdown List
      TabIndex        =   5
      Top             =   480
      Width           =   2415
   End
   Begin VB.Data datPrimaryRS 
      Caption         =   "Запись:"
      Connect         =   "Access"
      DatabaseName    =   "Localisation.mdb"
      DefaultCursorType=   0  'DefaultCursor
      DefaultType     =   2  'UseODBC
      Exclusive       =   0   'False
      Height          =   345
      Left            =   240
      Options         =   0
      ReadOnly        =   0   'False
      RecordsetType   =   1  'Dynaset
      RecordSource    =   "SELECT fldFirmName, fldProperties, fldStatus FROM tblFirm"
      Top             =   5040
      Width           =   7575
   End
   Begin MSDBGrid.DBGrid grdDataGrid 
      Bindings        =   "frmMain.frx":08FE
      Height          =   3975
      Left            =   240
      OleObjectBlob   =   "frmMain.frx":0919
      TabIndex        =   4
      Top             =   1080
      Width           =   7575
   End
   Begin VB.ComboBox Combo1 
      Height          =   315
      ItemData        =   "frmMain.frx":14B8
      Left            =   240
      List            =   "frmMain.frx":14C5
      Style           =   2  'Dropdown List
      TabIndex        =   3
      Top             =   480
      Width           =   4815
   End
   Begin VB.CommandButton btnContract 
      Caption         =   "Обязательства"
      Height          =   375
      Left            =   5280
      TabIndex        =   2
      Top             =   5640
      Width           =   1695
   End
   Begin VB.CommandButton btnInformation 
      Caption         =   "Регистрация фирм"
      Height          =   375
      Left            =   3120
      TabIndex        =   1
      Top             =   5640
      Width           =   1695
   End
   Begin VB.Label Label2 
      Caption         =   "Сортировать по"
      Height          =   255
      Left            =   5400
      TabIndex        =   6
      Top             =   240
      Width           =   1335
   End
   Begin VB.Label Label1 
      Caption         =   "Отобразить"
      Height          =   255
      Left            =   240
      TabIndex        =   0
      Top             =   240
      Width           =   975
   End
   Begin VB.Menu mnuA 
      Caption         =   "&Действия"
      Begin VB.Menu mnuInformation 
         Caption         =   "Регистрация фирмы..."
      End
      Begin VB.Menu mnuContract 
         Caption         =   "Обязательства..."
      End
      Begin VB.Menu mnuFind 
         Caption         =   "Поиск..."
         Shortcut        =   ^F
      End
      Begin VB.Menu mnuB 
         Caption         =   "-"
      End
      Begin VB.Menu mnuExit 
         Caption         =   "Выход"
         Shortcut        =   ^X
      End
   End
   Begin VB.Menu mnuAbout 
      Caption         =   "&О программе..."
   End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Sub Form_Load()
Combo1.ListIndex = 0
Combo2.ListIndex = 0
Set WS = DBEngine.Workspaces(0)
Set db = WS.OpenDatabase("Localisation.mdb")
Set RcSetFirm = db.OpenRecordset("tblFirm", dbOpenDynaset)
Set RcSetFirmList = db.OpenRecordset("tblFirm", dbOpenDynaset)
Set RcSetRepresentatives = db.OpenRecordset("tblRepresentatives", dbOpenDynaset)
Set RcSetContract = db.OpenRecordset("tblContract", dbOpenDynaset)
datPrimaryRS.Recordset.MoveNext
datPrimaryRS.Recordset.MovePrevious
End Sub

Private Sub btnFind_Click()
Dim strSeek As String, varBookmark, i As Long
varBookmark = RcSetFirm.Bookmark
RcSetFirm.MoveFirst
strSeek = InputBox("Введите строку для поиска", "Поиск")
For i = 0 To datPrimaryRS.Recordset.RecordCount - 1
    If strSeek = "" Then Exit Sub
    If InStr(1, RcSetFirm("fldFirmName"), strSeek, 1) <> 0 Then
        datPrimaryRS.Recordset.AbsolutePosition = i
        If MsgBox("Искать далее?", vbQuestion + vbYesNo) = vbNo Then Exit Sub
    End If
    RcSetFirm.MoveNext
Next i
MsgBox "Больше данных нет." + vbNewLine + "Конец списка.", vbOKOnly + vbExclamation
RcSetFirm.Bookmark = varBookmark
End Sub

Private Sub Combo2_Click()
If Combo2.ListIndex = 0 Then
    SQLSort = ""
End If
If Combo2.ListIndex = 1 Then
    SQLSort = " ORDER BY fldFirmName"
End If
datPrimaryRS.RecordSource = "SELECT fldFirmName, fldProperties, fldStatus FROM tblFirm" & SQLStatus & SQLSort
datPrimaryRS.Refresh
grdDataGrid.Refresh
End Sub

Private Sub btnInformation_Click()
frmInformation.Show 1
Call datPrimaryRS_Reposition
datPrimaryRS.Refresh
grdDataGrid.Refresh
End Sub

Private Sub btnContract_Click()
frmContract.Show 1
grdDataGrid.Refresh
End Sub

Private Sub mnuAbout_Click()
frmAbout.Show 1
End Sub

Private Sub datPrimaryRS_Reposition()
CurrentRecord = datPrimaryRS.Recordset.AbsolutePosition + 1
RecordQuantity = datPrimaryRS.Recordset.RecordCount
On Error Resume Next
datPrimaryRS.Caption = "Запись " & (CurrentRecord) & " из " & RecordQuantity
End Sub

Private Sub mnuInformation_Click()
    Call btnInformation_Click
End Sub

Private Sub mnuContract_Click()
    Call btnContract_Click
End Sub

Private Sub mnuFind_Click()
    Call btnFind_Click
End Sub

Private Sub mnuExit_Click()
    Unload Me
End Sub

Private Sub Form_Unload(Cancel As Integer)
    RcSetFirm.Close
    RcSetFirmList.Close
    RcSetRepresentatives.Close
    RcSetContract.Close
End Sub

Private Sub Combo1_Click()
Select Case Combo1.ListIndex
    Case 0
        SQLStatus = ""
    Case 1
        SQLStatus = " WHERE fldStatus = '+'"
    Case 2
        SQLStatus = " WHERE fldStatus = '-'"
End Select
datPrimaryRS.RecordSource = "SELECT fldFirmName, fldProperties, fldStatus FROM tblFirm" & SQLStatus & SQLSort
datPrimaryRS.Refresh
grdDataGrid.Refresh
End Sub

