home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.2#0"; "comctl32.ocx"
- Begin VB.Form Form2
- Caption = "Form2"
- ClientHeight = 4215
- ClientLeft = 1485
- ClientTop = 1380
- ClientWidth = 5580
- LinkTopic = "Form2"
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 4215
- ScaleWidth = 5580
- Begin VB.ComboBox FoundRecord
- Height = 315
- Left = 120
- Style = 2 'Dropdown List
- TabIndex = 7
- Top = 3480
- Width = 5295
- End
- Begin VB.TextBox MailBox
- Height = 375
- Left = 3120
- TabIndex = 13
- Top = 1800
- Width = 2295
- End
- Begin VB.TextBox NomeBox
- Height = 375
- Left = 3120
- TabIndex = 12
- Top = 1320
- Width = 2295
- End
- Begin VB.TextBox CognomeBox
- Height = 375
- Left = 3120
- TabIndex = 11
- Top = 840
- Width = 2295
- End
- Begin VB.PictureBox SSPanel1
- Align = 1 'Align Top
- BackColor = &H00C0C0C0&
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 400
- Underline = -1 'True
- Italic = -1 'True
- Strikethrough = -1 'True
- EndProperty
- Height = 615
- Left = 0
- ScaleHeight = 555
- ScaleWidth = 5520
- TabIndex = 0
- Top = 0
- Width = 5580
- Begin VB.PictureBox HelpButton
- AutoSize = -1 'True
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 400
- Underline = -1 'True
- Italic = -1 'True
- Strikethrough = -1 'True
- EndProperty
- Height = 495
- Left = 5040
- ScaleHeight = 435
- ScaleWidth = 435
- TabIndex = 5
- Top = 45
- Width = 495
- End
- Begin VB.PictureBox CloseButton
- AutoSize = -1 'True
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 400
- Underline = -1 'True
- Italic = -1 'True
- Strikethrough = -1 'True
- EndProperty
- Height = 495
- Left = 2160
- ScaleHeight = 435
- ScaleWidth = 435
- TabIndex = 4
- Top = 50
- Width = 495
- End
- Begin VB.PictureBox ViewButton
- AutoSize = -1 'True
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 400
- Underline = -1 'True
- Italic = -1 'True
- Strikethrough = -1 'True
- EndProperty
- Height = 495
- Left = 1440
- ScaleHeight = 435
- ScaleWidth = 435
- TabIndex = 3
- Top = 50
- Width = 495
- End
- Begin VB.PictureBox EditButton
- AutoSize = -1 'True
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 400
- Underline = -1 'True
- Italic = -1 'True
- Strikethrough = -1 'True
- EndProperty
- Height = 495
- Left = 720
- ScaleHeight = 435
- ScaleWidth = 435
- TabIndex = 2
- Top = 50
- Width = 495
- End
- Begin VB.PictureBox SearchButton
- AutoSize = -1 'True
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 400
- Underline = -1 'True
- Italic = -1 'True
- Strikethrough = -1 'True
- EndProperty
- Height = 495
- Left = 60
- ScaleHeight = 435
- ScaleWidth = 435
- TabIndex = 1
- Top = 50
- Width = 495
- End
- End
- Begin VB.PictureBox SSPanel2
- BackColor = &H00C0C0C0&
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 400
- Underline = -1 'True
- Italic = -1 'True
- Strikethrough = -1 'True
- EndProperty
- Height = 375
- Left = 600
- ScaleHeight = 315
- ScaleWidth = 2355
- TabIndex = 6
- Top = 840
- Width = 2415
- End
- Begin VB.PictureBox SSPanel4
- BackColor = &H00C0C0C0&
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 400
- Underline = -1 'True
- Italic = -1 'True
- Strikethrough = -1 'True
- EndProperty
- Height = 375
- Left = 600
- ScaleHeight = 315
- ScaleWidth = 2355
- TabIndex = 8
- Top = 1320
- Width = 2415
- End
- Begin VB.PictureBox SSPanel3
- BackColor = &H00C0C0C0&
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 400
- Underline = -1 'True
- Italic = -1 'True
- Strikethrough = -1 'True
- EndProperty
- Height = 375
- Left = 600
- ScaleHeight = 315
- ScaleWidth = 2355
- TabIndex = 9
- Top = 1800
- Width = 2415
- End
- Begin VB.PictureBox SSFrame1
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 400
- Underline = -1 'True
- Italic = -1 'True
- Strikethrough = -1 'True
- EndProperty
- Height = 1095
- Left = 120
- ScaleHeight = 1035
- ScaleWidth = 5235
- TabIndex = 14
- Top = 2280
- Width = 5295
- Begin VB.PictureBox TotalePanel
- BackColor = &H00C0C0C0&
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 400
- Underline = -1 'True
- Italic = -1 'True
- Strikethrough = -1 'True
- EndProperty
- Height = 375
- Left = 2400
- ScaleHeight = 315
- ScaleWidth = 2715
- TabIndex = 15
- Top = 480
- Width = 2775
- End
- End
- Begin ComctlLib.StatusBar StatusBar
- Align = 2 'Align Bottom
- Height = 375
- Left = 0
- TabIndex = 10
- Top = 3840
- Width = 5580
- _ExtentX = 9843
- _ExtentY = 661
- SimpleText = ""
- _Version = 327682
- BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7}
- NumPanels = 3
- BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7}
- Object.Tag = ""
- EndProperty
- BeginProperty Panel2 {0713E89F-850A-101B-AFC0-4210102A8DA7}
- Object.Tag = ""
- EndProperty
- BeginProperty Panel3 {0713E89F-850A-101B-AFC0-4210102A8DA7}
- Object.Tag = ""
- EndProperty
- EndProperty
- End
- Attribute VB_Name = "Form2"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- Public Archivio As Database
- Public FoundRecords As Recordset
- Dim TabellaContatti As Recordset
- Public IsAdding As Boolean
- Private Function CheckSelected() As Boolean
- If (FoundRecord.ListIndex = -1) And (FoundRecord.ListCount > 0) Then
- Beep
- MsgBox "Attenzione! Non
- stato selezionato nessun record dalla lista!", 16, "Contact Manager: Errore!"
- Form2.FoundRecord.SetFocus
- CheckSelected = False
- ElseIf Form2.FoundRecord.ListCount = 0 Then
- Beep
- MsgBox "Attenzione! Non
- stata rilevata alcuna corrispondenza con la chiave fornita. Lista
- vuota!", 16, "Contact Manager: Errore!"
- FoundRecord.SetFocus
- CheckSelected = False
- CheckSelected = True
- End If
- End Function
- Function CheckOptions() As Integer
- If CogButton.Value = 0 And NomButton.Value = 0 And MailButton.Value = 0 Then
- CheckOptions = 0
- Else
- If CogButton.Value = True Then CheckOptions = 1
- If NomButton.Value = True Then CheckOptions = 2
- If MailButton.Value = True Then CheckOptions = 3
- End If
- End Function
- Function CreateStatement() As String
- FoundRecord.Clear
- Dim Statement As String
- Dim WhereIn As Boolean
- Statement$ = "SELECT * FROM CONTATTI"
- If ComplexCheck.Value = False And ExMatchCheck.Value = False Then
- If CogButton.Value = True And Len(CognomeBox.Text) > 0 Then Statement$ = Statement$ + " WHERE COGNOME LIKE '" + CognomeBox.Text + "*'"
- If NomButton.Value = True Then Statement$ = Statement$ + " WHERE NOME LIKE '" + NomeBox.Text + "*'"
- If MailButton.Value = True Then Statement$ = Statement$ + " WHERE [E-MAIL] LIKE '" + MailBox.Text + "*'"
- CreateStatement = Statement$
- ElseIf ComplexCheck.Value = False And ExMatchCheck.Value = True Then
- If CogButton.Value = True And Len(CognomeBox.Text) > 0 Then
- If Len(CognomeBox.Text) < 30 Then CognomeBox.Text = CognomeBox.Text + Space(30 - Len(CognomeBox.Text))
- Statement$ = Statement$ + " WHERE COGNOME = '" + CognomeBox.Text + "'"
- End If
- If NomButton.Value = True Then
- If Len(NomeBox.Text) < 30 Then NomeBox.Text = NomeBox.Text + Space(30 - Len(NomeBox.Text))
- Statement$ = Statement$ + " WHERE NOME = '" + NomeBox.Text + "'"
- End If
- If MailButton.Value = True Then
- If Len(MailBox.Text) < 30 Then MailBox.Text = MailBox.Text + Space(30 - Len(MailBox.Text))
- Statement$ = Statement$ + " WHERE [E-MAIL] = '" + MailBox.Text + "'"
- End If
- CreateStatement = Statement$
- End If
- If ComplexCheck.Value = True And ExMatchCheck.Value = False Then
- WhereIn = False
- If Len(CognomeBox.Text) > 0 Then
- Statement$ = Statement$ + " WHERE COGNOME LIKE '" + CognomeBox.Text + "*'"
- WhereIn = True
- End If
- If Len(NomeBox.Text) > 0 Then
- If WhereIn Then
- Statement$ = Statement$ + " AND "
- Else
- Statement$ = Statement$ + " WHERE "
- WhereIn = True
- End If
- Statement$ = Statement$ + " NOME LIKE '" + NomeBox.Text + "*'"
- End If
- If Len(MailBox.Text) > 0 Then
- If WhereIn Then
- Statement$ = Statement$ + " AND "
- Else
- Statement$ = Statement$ + " WHERE "
- End If
- Statement$ = Statement$ + " [E-MAIL] LIKE '" + MailBox.Text + "*'"
- End If
- CreateStatement = Statement$
- End If
- End Function
- Public Sub InitDatabaseObject()
- Set Archivio = Workspaces(0).OpenDatabase(App.Path + "\CM.MDB")
- Form3.Hide
- Form2.Show
- End Sub
- Private Sub ShowData(EditingMode As Boolean)
- Dim NewStatement As String
- NewStatement = "SELECT * FROM CONTATTI WHERE COGNOME='" + Left$(FoundRecord.List(FoundRecord.ListIndex), 30) + "'"
- NewStatement = NewStatement + " AND NOME='" + Right$(FoundRecord.List(FoundRecord.ListIndex), 30) + "'"
- Set FoundRecords = Archivio.OpenRecordset(NewStatement, dbOpenTable)
- If FoundRecords.RecordCount > 0 Then
- Form1.NomeTxt.Text = FoundRecords("Nome")
- Form1.CognomeTxt.Text = FoundRecords("Cognome")
- Form1.IndirizzoText.Text = FoundRecords("Indirizzo")
- Form1.MailTxtBox.Text = FoundRecords("E-mail")
- Form1.CasaTxtBox.Text = FoundRecords("TelCasa")
- Form1.UfficioTxtBox.Text = FoundRecords("TelUff")
- Form1.CellulareTxtBox.Text = FoundRecords("TelCell")
- Form1.FaxTxtBox.Text = FoundRecords("TelFax")
- Form1.NascitaTxtBox.Text = FoundRecords("Nascita")
- Form1.NoteTxtBox.Text = FoundRecords("Note")
- If EditingMode Then
- Form1.CasaChk.Value = (Not (IsEmpty(FoundRecords("TelCasa")))) * -1
- Form1.UffChk.Value = (Not (IsEmpty(FoundRecords("TelUff")))) * -1
- Form1.CellChk.Value = (Not (IsEmpty(FoundRecords("TelCell")))) * -1
- Form1.FaxChk.Value = (Not (IsEmpty(FoundRecords("TelFax")))) * -1
- Form1.EMailChk.Value = (Not (IsEmpty(FoundRecords("E-mail")))) * -1
- Else
- Form1.CasaChk.Value = 2
- Form1.UffChk.Value = 2
- Form1.CellChk.Value = 2
- Form1.FaxChk.Value = 2
- Form1.EMailChk.Value = 2
- End If
- Form1.CasaChk.Enabled = EditingMode
- Form1.UffChk.Enabled = EditingMode
- Form1.CellChk.Enabled = EditingMode
- Form1.FaxChk.Enabled = EditingMode
- Form1.EMailChk.Enabled = EditingMode
- Form1.CasaTxtBox.Enabled = EditingMode
- Form1.UfficioTxtBox.Enabled = EditingMode
- Form1.CellulareTxtBox.Enabled = EditingMode
- Form1.FaxTxtBox.Enabled = EditingMode
- Form1.MailTxtBox.Enabled = EditingMode
- Form1.NomeTxt.Enabled = EditingMode
- Form1.CognomeTxt.Enabled = EditingMode
- Form1.IndirizzoText.Enabled = EditingMode
- Form1.NoteTxtBox.Enabled = EditingMode
- Form1.NascitaTxtBox.Enabled = EditingMode
- If EditingMode Then
- Form1.AnnullaButton.Caption = "Annulla"
- Else
- Form1.AnnullaButton.Caption = "Chiudi"
- End If
- Form1.OkButton.Enabled = EditingMode
- If Not (EditingMode) Then FoundRecords.Close
- Form2.Hide
- Form1.Show
- End If
- End Sub
- Private Sub CloseButton_Click()
- Archivio.Close
- Form2.Hide
- Form3.Show
- End Sub
- Private Sub CogButton_Click(Value As Integer)
- NomeBox.Enabled = False
- MailBox.Enabled = False
- NomeBox.Text = "(disabilitato)"
- MailBox.Text = "(disabilitato)"
- If CogButton.Value = False Then
- CognomeBox.Enabled = False
- CognomeBox.Text = "(disabilitato)"
- StatusBar.Panels(3).Text = "Nessun criterio selezionato"
- Else
- CognomeBox.Enabled = True
- CognomeBox.Text = ""
- StatusBar.Panels(3).Text = "Criterio: ricerca per cognome"
- End If
- End Sub
- Private Sub CognomeBox_Change()
- If AutoCheck.Value = True Then SearchButton_Click
- End Sub
- Private Sub ComplexCheck_Click(Value As Integer)
- If ComplexCheck.Value = True Then
- CogButton.Value = False
- CogButton.Enabled = False
- NomButton.Value = False
- NomButton.Enabled = False
- MailButton.Value = False
- MailButton.Enabled = False
- CognomeBox.Enabled = True
- NomeBox.Enabled = True
- MailBox.Enabled = True
- If CognomeBox.Text = "(disabilitato)" Then CognomeBox.Text = ""
- If NomeBox.Text = "(disabilitato)" Then NomeBox.Text = ""
- If MailBox.Text = "(disabilitato)" Then MailBox.Text = ""
- StatusBar.Panels(3).Text = "Ricerca complessa attivata"
- Else
- CogButton.Value = False
- CogButton.Enabled = True
- NomButton.Value = False
- NomButton.Enabled = True
- MailButton.Value = False
- MailButton.Enabled = True
- CognomeBox.Enabled = False
- NomeBox.Enabled = False
- MailBox.Enabled = False
- CognomeBox.Text = "(disabilitato)"
- NomeBox.Text = "(disabilitato)"
- MailBox.Text = "(disabilitato)"
- StatusBar.Panels(3).Text = "Nessun criterio selezionato"
- End If
- End Sub
- Private Sub EditButton_Click()
- If CheckSelected Then
- IsAdding = False
- ShowData (True)
- End If
- End Sub
- Private Sub ExMatchCheck_Click(Value As Integer)
- If ExMatchCheck.Value = True Then
- AutoCheck.Value = False
- AutoCheck.Enabled = False
- Else
- AutoCheck.Enabled = True
- End If
- End Sub
- Private Sub FoundRecord_Click()
- ViewButton.Outline = True
- End Sub
- Private Sub MailBox_Change()
- If AutoCheck.Value = True Then SearchButton_Click
- End Sub
- Private Sub MailButton_Click(Value As Integer)
- NomeBox.Enabled = False
- CognomeBox.Enabled = False
- NomeBox.Text = "(disabilitato)"
- CognomeBox.Text = "(disabilitato)"
- If MailButton.Value = False Then
- MailBox.Enabled = False
- MailBox.Text = "(disabilitato)"
- StatusBar.Panels(3).Text = "Nessun criterio selezionato"
- Else
- MailBox.Enabled = True
- MailBox.Text = ""
- StatusBar.Panels(3).Text = "Criterio: ricerca per E-mail"
- End If
- End Sub
- Private Sub NomButton_Click(Value As Integer)
- CognomeBox.Enabled = False
- MailBox.Enabled = False
- CognomeBox.Text = "(disabilitato)"
- MailBox.Text = "(disabilitato)"
- If NomButton.Value = False Then
- NomeBox.Enabled = False
- NomeBox.Text = "(disabilitato)"
- StatusBar.Panels(3).Text = "Nessun criterio selezionato"
- Else
- NomeBox.Enabled = True
- NomeBox.Text = ""
- StatusBar.Panels(3).Text = "Criterio: ricerca per nome"
- End If
- End Sub
- Private Sub NomeBox_Change()
- If AutoCheck.Value = True Then SearchButton_Click
- End Sub
- Private Sub SearchButton_Click()
- ViewButton.Outline = False
- If ComplexCheck.Value = 0 And CheckOptions = 0 Then
- Beep
- MsgBox "E' necessario selezionare un criterio di ricerca!", 16, "CM: Errore"
- Exit Sub
- End If
- Set FoundRecords = Archivio.OpenRecordset(CreateStatement, dbOpenSnapshot)
- If FoundRecords.RecordCount > 0 Then
- FoundRecords.MoveFirst
- While Not FoundRecords.EOF
- FoundRecord.AddItem (FoundRecords("Cognome") + FoundRecords("Nome"))
- FoundRecords.MoveNext
- Wend
- TotalePanel.Caption = "Occorrenze rilevate: " + Str$(FoundRecord.ListCount)
- Else
- TotalePanel.Caption = "Occorrenze rilevate: Nessuna"
- End If
- FoundRecords.Close
- End Sub
- Private Sub ViewButton_Click()
- If CheckSelected Then
- ShowData (False)
- End If
- End Sub
-