home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 10 / ioProg_10.iso / soft / corsovb / cm2.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-10-16  |  19.8 KB  |  554 lines

  1. VERSION 5.00
  2. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.2#0"; "comctl32.ocx"
  3. Begin VB.Form Form2 
  4.    Caption         =   "Form2"
  5.    ClientHeight    =   4215
  6.    ClientLeft      =   1485
  7.    ClientTop       =   1380
  8.    ClientWidth     =   5580
  9.    LinkTopic       =   "Form2"
  10.    PaletteMode     =   1  'UseZOrder
  11.    ScaleHeight     =   4215
  12.    ScaleWidth      =   5580
  13.    Begin VB.ComboBox FoundRecord 
  14.       Height          =   315
  15.       Left            =   120
  16.       Style           =   2  'Dropdown List
  17.       TabIndex        =   7
  18.       Top             =   3480
  19.       Width           =   5295
  20.    End
  21.    Begin VB.TextBox MailBox 
  22.       Height          =   375
  23.       Left            =   3120
  24.       TabIndex        =   13
  25.       Top             =   1800
  26.       Width           =   2295
  27.    End
  28.    Begin VB.TextBox NomeBox 
  29.       Height          =   375
  30.       Left            =   3120
  31.       TabIndex        =   12
  32.       Top             =   1320
  33.       Width           =   2295
  34.    End
  35.    Begin VB.TextBox CognomeBox 
  36.       Height          =   375
  37.       Left            =   3120
  38.       TabIndex        =   11
  39.       Top             =   840
  40.       Width           =   2295
  41.    End
  42.    Begin VB.PictureBox SSPanel1 
  43.       Align           =   1  'Align Top
  44.       BackColor       =   &H00C0C0C0&
  45.       BeginProperty Font 
  46.          Name            =   "MS Sans Serif"
  47.          Size            =   8.25
  48.          Charset         =   0
  49.          Weight          =   400
  50.          Underline       =   -1  'True
  51.          Italic          =   -1  'True
  52.          Strikethrough   =   -1  'True
  53.       EndProperty
  54.       Height          =   615
  55.       Left            =   0
  56.       ScaleHeight     =   555
  57.       ScaleWidth      =   5520
  58.       TabIndex        =   0
  59.       Top             =   0
  60.       Width           =   5580
  61.       Begin VB.PictureBox HelpButton 
  62.          AutoSize        =   -1  'True
  63.          BeginProperty Font 
  64.             Name            =   "MS Sans Serif"
  65.             Size            =   8.25
  66.             Charset         =   0
  67.             Weight          =   400
  68.             Underline       =   -1  'True
  69.             Italic          =   -1  'True
  70.             Strikethrough   =   -1  'True
  71.          EndProperty
  72.          Height          =   495
  73.          Left            =   5040
  74.          ScaleHeight     =   435
  75.          ScaleWidth      =   435
  76.          TabIndex        =   5
  77.          Top             =   45
  78.          Width           =   495
  79.       End
  80.       Begin VB.PictureBox CloseButton 
  81.          AutoSize        =   -1  'True
  82.          BeginProperty Font 
  83.             Name            =   "MS Sans Serif"
  84.             Size            =   8.25
  85.             Charset         =   0
  86.             Weight          =   400
  87.             Underline       =   -1  'True
  88.             Italic          =   -1  'True
  89.             Strikethrough   =   -1  'True
  90.          EndProperty
  91.          Height          =   495
  92.          Left            =   2160
  93.          ScaleHeight     =   435
  94.          ScaleWidth      =   435
  95.          TabIndex        =   4
  96.          Top             =   50
  97.          Width           =   495
  98.       End
  99.       Begin VB.PictureBox ViewButton 
  100.          AutoSize        =   -1  'True
  101.          BeginProperty Font 
  102.             Name            =   "MS Sans Serif"
  103.             Size            =   8.25
  104.             Charset         =   0
  105.             Weight          =   400
  106.             Underline       =   -1  'True
  107.             Italic          =   -1  'True
  108.             Strikethrough   =   -1  'True
  109.          EndProperty
  110.          Height          =   495
  111.          Left            =   1440
  112.          ScaleHeight     =   435
  113.          ScaleWidth      =   435
  114.          TabIndex        =   3
  115.          Top             =   50
  116.          Width           =   495
  117.       End
  118.       Begin VB.PictureBox EditButton 
  119.          AutoSize        =   -1  'True
  120.          BeginProperty Font 
  121.             Name            =   "MS Sans Serif"
  122.             Size            =   8.25
  123.             Charset         =   0
  124.             Weight          =   400
  125.             Underline       =   -1  'True
  126.             Italic          =   -1  'True
  127.             Strikethrough   =   -1  'True
  128.          EndProperty
  129.          Height          =   495
  130.          Left            =   720
  131.          ScaleHeight     =   435
  132.          ScaleWidth      =   435
  133.          TabIndex        =   2
  134.          Top             =   50
  135.          Width           =   495
  136.       End
  137.       Begin VB.PictureBox SearchButton 
  138.          AutoSize        =   -1  'True
  139.          BeginProperty Font 
  140.             Name            =   "MS Sans Serif"
  141.             Size            =   8.25
  142.             Charset         =   0
  143.             Weight          =   400
  144.             Underline       =   -1  'True
  145.             Italic          =   -1  'True
  146.             Strikethrough   =   -1  'True
  147.          EndProperty
  148.          Height          =   495
  149.          Left            =   60
  150.          ScaleHeight     =   435
  151.          ScaleWidth      =   435
  152.          TabIndex        =   1
  153.          Top             =   50
  154.          Width           =   495
  155.       End
  156.    End
  157.    Begin VB.PictureBox SSPanel2 
  158.       BackColor       =   &H00C0C0C0&
  159.       BeginProperty Font 
  160.          Name            =   "MS Sans Serif"
  161.          Size            =   8.25
  162.          Charset         =   0
  163.          Weight          =   400
  164.          Underline       =   -1  'True
  165.          Italic          =   -1  'True
  166.          Strikethrough   =   -1  'True
  167.       EndProperty
  168.       Height          =   375
  169.       Left            =   600
  170.       ScaleHeight     =   315
  171.       ScaleWidth      =   2355
  172.       TabIndex        =   6
  173.       Top             =   840
  174.       Width           =   2415
  175.    End
  176.    Begin VB.PictureBox SSPanel4 
  177.       BackColor       =   &H00C0C0C0&
  178.       BeginProperty Font 
  179.          Name            =   "MS Sans Serif"
  180.          Size            =   8.25
  181.          Charset         =   0
  182.          Weight          =   400
  183.          Underline       =   -1  'True
  184.          Italic          =   -1  'True
  185.          Strikethrough   =   -1  'True
  186.       EndProperty
  187.       Height          =   375
  188.       Left            =   600
  189.       ScaleHeight     =   315
  190.       ScaleWidth      =   2355
  191.       TabIndex        =   8
  192.       Top             =   1320
  193.       Width           =   2415
  194.    End
  195.    Begin VB.PictureBox SSPanel3 
  196.       BackColor       =   &H00C0C0C0&
  197.       BeginProperty Font 
  198.          Name            =   "MS Sans Serif"
  199.          Size            =   8.25
  200.          Charset         =   0
  201.          Weight          =   400
  202.          Underline       =   -1  'True
  203.          Italic          =   -1  'True
  204.          Strikethrough   =   -1  'True
  205.       EndProperty
  206.       Height          =   375
  207.       Left            =   600
  208.       ScaleHeight     =   315
  209.       ScaleWidth      =   2355
  210.       TabIndex        =   9
  211.       Top             =   1800
  212.       Width           =   2415
  213.    End
  214.    Begin VB.PictureBox SSFrame1 
  215.       BeginProperty Font 
  216.          Name            =   "MS Sans Serif"
  217.          Size            =   8.25
  218.          Charset         =   0
  219.          Weight          =   400
  220.          Underline       =   -1  'True
  221.          Italic          =   -1  'True
  222.          Strikethrough   =   -1  'True
  223.       EndProperty
  224.       Height          =   1095
  225.       Left            =   120
  226.       ScaleHeight     =   1035
  227.       ScaleWidth      =   5235
  228.       TabIndex        =   14
  229.       Top             =   2280
  230.       Width           =   5295
  231.       Begin VB.PictureBox TotalePanel 
  232.          BackColor       =   &H00C0C0C0&
  233.          BeginProperty Font 
  234.             Name            =   "MS Sans Serif"
  235.             Size            =   8.25
  236.             Charset         =   0
  237.             Weight          =   400
  238.             Underline       =   -1  'True
  239.             Italic          =   -1  'True
  240.             Strikethrough   =   -1  'True
  241.          EndProperty
  242.          Height          =   375
  243.          Left            =   2400
  244.          ScaleHeight     =   315
  245.          ScaleWidth      =   2715
  246.          TabIndex        =   15
  247.          Top             =   480
  248.          Width           =   2775
  249.       End
  250.    End
  251.    Begin ComctlLib.StatusBar StatusBar 
  252.       Align           =   2  'Align Bottom
  253.       Height          =   375
  254.       Left            =   0
  255.       TabIndex        =   10
  256.       Top             =   3840
  257.       Width           =   5580
  258.       _ExtentX        =   9843
  259.       _ExtentY        =   661
  260.       SimpleText      =   ""
  261.       _Version        =   327682
  262.       BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7} 
  263.          NumPanels       =   3
  264.          BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7} 
  265.             Object.Tag             =   ""
  266.          EndProperty
  267.          BeginProperty Panel2 {0713E89F-850A-101B-AFC0-4210102A8DA7} 
  268.             Object.Tag             =   ""
  269.          EndProperty
  270.          BeginProperty Panel3 {0713E89F-850A-101B-AFC0-4210102A8DA7} 
  271.             Object.Tag             =   ""
  272.          EndProperty
  273.       EndProperty
  274.    End
  275. Attribute VB_Name = "Form2"
  276. Attribute VB_GlobalNameSpace = False
  277. Attribute VB_Creatable = False
  278. Attribute VB_PredeclaredId = True
  279. Attribute VB_Exposed = False
  280. Option Explicit
  281. Public Archivio As Database
  282. Public FoundRecords As Recordset
  283. Dim TabellaContatti As Recordset
  284. Public IsAdding As Boolean
  285. Private Function CheckSelected() As Boolean
  286. If (FoundRecord.ListIndex = -1) And (FoundRecord.ListCount > 0) Then
  287.     Beep
  288.     MsgBox "Attenzione! Non 
  289.  stato selezionato nessun record dalla lista!", 16, "Contact Manager: Errore!"
  290.     Form2.FoundRecord.SetFocus
  291.     CheckSelected = False
  292. ElseIf Form2.FoundRecord.ListCount = 0 Then
  293.     Beep
  294.     MsgBox "Attenzione! Non 
  295.  stata rilevata alcuna corrispondenza con la chiave fornita. Lista 
  296.  vuota!", 16, "Contact Manager: Errore!"
  297.     FoundRecord.SetFocus
  298.     CheckSelected = False
  299.     CheckSelected = True
  300. End If
  301. End Function
  302. Function CheckOptions() As Integer
  303.     If CogButton.Value = 0 And NomButton.Value = 0 And MailButton.Value = 0 Then
  304.         CheckOptions = 0
  305.     Else
  306.         If CogButton.Value = True Then CheckOptions = 1
  307.         If NomButton.Value = True Then CheckOptions = 2
  308.         If MailButton.Value = True Then CheckOptions = 3
  309.     End If
  310. End Function
  311. Function CreateStatement() As String
  312.     FoundRecord.Clear
  313.     Dim Statement As String
  314.     Dim WhereIn As Boolean
  315.     Statement$ = "SELECT * FROM CONTATTI"
  316.     If ComplexCheck.Value = False And ExMatchCheck.Value = False Then
  317.         If CogButton.Value = True And Len(CognomeBox.Text) > 0 Then Statement$ = Statement$ + " WHERE COGNOME LIKE '" + CognomeBox.Text + "*'"
  318.         If NomButton.Value = True Then Statement$ = Statement$ + " WHERE NOME LIKE '" + NomeBox.Text + "*'"
  319.         If MailButton.Value = True Then Statement$ = Statement$ + " WHERE [E-MAIL] LIKE '" + MailBox.Text + "*'"
  320.         CreateStatement = Statement$
  321.     ElseIf ComplexCheck.Value = False And ExMatchCheck.Value = True Then
  322.         If CogButton.Value = True And Len(CognomeBox.Text) > 0 Then
  323.             If Len(CognomeBox.Text) < 30 Then CognomeBox.Text = CognomeBox.Text + Space(30 - Len(CognomeBox.Text))
  324.             Statement$ = Statement$ + " WHERE COGNOME = '" + CognomeBox.Text + "'"
  325.         End If
  326.         If NomButton.Value = True Then
  327.             If Len(NomeBox.Text) < 30 Then NomeBox.Text = NomeBox.Text + Space(30 - Len(NomeBox.Text))
  328.             Statement$ = Statement$ + " WHERE NOME = '" + NomeBox.Text + "'"
  329.         End If
  330.         If MailButton.Value = True Then
  331.             If Len(MailBox.Text) < 30 Then MailBox.Text = MailBox.Text + Space(30 - Len(MailBox.Text))
  332.             Statement$ = Statement$ + " WHERE [E-MAIL] = '" + MailBox.Text + "'"
  333.         End If
  334.         CreateStatement = Statement$
  335.     End If
  336.     If ComplexCheck.Value = True And ExMatchCheck.Value = False Then
  337.         WhereIn = False
  338.         If Len(CognomeBox.Text) > 0 Then
  339.             Statement$ = Statement$ + " WHERE COGNOME LIKE '" + CognomeBox.Text + "*'"
  340.             WhereIn = True
  341.         End If
  342.         If Len(NomeBox.Text) > 0 Then
  343.             If WhereIn Then
  344.                 Statement$ = Statement$ + " AND "
  345.             Else
  346.                 Statement$ = Statement$ + " WHERE "
  347.                 WhereIn = True
  348.             End If
  349.             Statement$ = Statement$ + " NOME LIKE '" + NomeBox.Text + "*'"
  350.         End If
  351.         If Len(MailBox.Text) > 0 Then
  352.             If WhereIn Then
  353.                 Statement$ = Statement$ + " AND "
  354.             Else
  355.                 Statement$ = Statement$ + " WHERE "
  356.             End If
  357.             Statement$ = Statement$ + " [E-MAIL] LIKE '" + MailBox.Text + "*'"
  358.         End If
  359.         CreateStatement = Statement$
  360.     End If
  361. End Function
  362. Public Sub InitDatabaseObject()
  363.     Set Archivio = Workspaces(0).OpenDatabase(App.Path + "\CM.MDB")
  364.     Form3.Hide
  365.     Form2.Show
  366. End Sub
  367. Private Sub ShowData(EditingMode As Boolean)
  368.     Dim NewStatement As String
  369.     NewStatement = "SELECT * FROM CONTATTI WHERE COGNOME='" + Left$(FoundRecord.List(FoundRecord.ListIndex), 30) + "'"
  370.     NewStatement = NewStatement + " AND NOME='" + Right$(FoundRecord.List(FoundRecord.ListIndex), 30) + "'"
  371.     Set FoundRecords = Archivio.OpenRecordset(NewStatement, dbOpenTable)
  372.     If FoundRecords.RecordCount > 0 Then
  373.         Form1.NomeTxt.Text = FoundRecords("Nome")
  374.         Form1.CognomeTxt.Text = FoundRecords("Cognome")
  375.         Form1.IndirizzoText.Text = FoundRecords("Indirizzo")
  376.         Form1.MailTxtBox.Text = FoundRecords("E-mail")
  377.         Form1.CasaTxtBox.Text = FoundRecords("TelCasa")
  378.         Form1.UfficioTxtBox.Text = FoundRecords("TelUff")
  379.         Form1.CellulareTxtBox.Text = FoundRecords("TelCell")
  380.         Form1.FaxTxtBox.Text = FoundRecords("TelFax")
  381.         Form1.NascitaTxtBox.Text = FoundRecords("Nascita")
  382.         Form1.NoteTxtBox.Text = FoundRecords("Note")
  383.         If EditingMode Then
  384.             Form1.CasaChk.Value = (Not (IsEmpty(FoundRecords("TelCasa")))) * -1
  385.             Form1.UffChk.Value = (Not (IsEmpty(FoundRecords("TelUff")))) * -1
  386.             Form1.CellChk.Value = (Not (IsEmpty(FoundRecords("TelCell")))) * -1
  387.             Form1.FaxChk.Value = (Not (IsEmpty(FoundRecords("TelFax")))) * -1
  388.             Form1.EMailChk.Value = (Not (IsEmpty(FoundRecords("E-mail")))) * -1
  389.         Else
  390.             Form1.CasaChk.Value = 2
  391.             Form1.UffChk.Value = 2
  392.             Form1.CellChk.Value = 2
  393.             Form1.FaxChk.Value = 2
  394.             Form1.EMailChk.Value = 2
  395.         End If
  396.         Form1.CasaChk.Enabled = EditingMode
  397.         Form1.UffChk.Enabled = EditingMode
  398.         Form1.CellChk.Enabled = EditingMode
  399.         Form1.FaxChk.Enabled = EditingMode
  400.         Form1.EMailChk.Enabled = EditingMode
  401.         Form1.CasaTxtBox.Enabled = EditingMode
  402.         Form1.UfficioTxtBox.Enabled = EditingMode
  403.         Form1.CellulareTxtBox.Enabled = EditingMode
  404.         Form1.FaxTxtBox.Enabled = EditingMode
  405.         Form1.MailTxtBox.Enabled = EditingMode
  406.         Form1.NomeTxt.Enabled = EditingMode
  407.         Form1.CognomeTxt.Enabled = EditingMode
  408.         Form1.IndirizzoText.Enabled = EditingMode
  409.         Form1.NoteTxtBox.Enabled = EditingMode
  410.         Form1.NascitaTxtBox.Enabled = EditingMode
  411.         If EditingMode Then
  412.             Form1.AnnullaButton.Caption = "Annulla"
  413.         Else
  414.             Form1.AnnullaButton.Caption = "Chiudi"
  415.         End If
  416.         Form1.OkButton.Enabled = EditingMode
  417.         If Not (EditingMode) Then FoundRecords.Close
  418.         Form2.Hide
  419.         Form1.Show
  420.     End If
  421. End Sub
  422. Private Sub CloseButton_Click()
  423.     Archivio.Close
  424.     Form2.Hide
  425.     Form3.Show
  426. End Sub
  427. Private Sub CogButton_Click(Value As Integer)
  428.     NomeBox.Enabled = False
  429.     MailBox.Enabled = False
  430.     NomeBox.Text = "(disabilitato)"
  431.     MailBox.Text = "(disabilitato)"
  432.     If CogButton.Value = False Then
  433.         CognomeBox.Enabled = False
  434.         CognomeBox.Text = "(disabilitato)"
  435.         StatusBar.Panels(3).Text = "Nessun criterio selezionato"
  436.     Else
  437.         CognomeBox.Enabled = True
  438.         CognomeBox.Text = ""
  439.         StatusBar.Panels(3).Text = "Criterio: ricerca per cognome"
  440.     End If
  441. End Sub
  442. Private Sub CognomeBox_Change()
  443.     If AutoCheck.Value = True Then SearchButton_Click
  444. End Sub
  445. Private Sub ComplexCheck_Click(Value As Integer)
  446.     If ComplexCheck.Value = True Then
  447.         CogButton.Value = False
  448.         CogButton.Enabled = False
  449.         NomButton.Value = False
  450.         NomButton.Enabled = False
  451.         MailButton.Value = False
  452.         MailButton.Enabled = False
  453.         CognomeBox.Enabled = True
  454.         NomeBox.Enabled = True
  455.         MailBox.Enabled = True
  456.         If CognomeBox.Text = "(disabilitato)" Then CognomeBox.Text = ""
  457.         If NomeBox.Text = "(disabilitato)" Then NomeBox.Text = ""
  458.         If MailBox.Text = "(disabilitato)" Then MailBox.Text = ""
  459.         StatusBar.Panels(3).Text = "Ricerca complessa attivata"
  460.     Else
  461.         CogButton.Value = False
  462.         CogButton.Enabled = True
  463.         NomButton.Value = False
  464.         NomButton.Enabled = True
  465.         MailButton.Value = False
  466.         MailButton.Enabled = True
  467.         CognomeBox.Enabled = False
  468.         NomeBox.Enabled = False
  469.         MailBox.Enabled = False
  470.         CognomeBox.Text = "(disabilitato)"
  471.         NomeBox.Text = "(disabilitato)"
  472.         MailBox.Text = "(disabilitato)"
  473.         StatusBar.Panels(3).Text = "Nessun criterio selezionato"
  474.     End If
  475. End Sub
  476. Private Sub EditButton_Click()
  477.     If CheckSelected Then
  478.         IsAdding = False
  479.         ShowData (True)
  480.     End If
  481. End Sub
  482. Private Sub ExMatchCheck_Click(Value As Integer)
  483.     If ExMatchCheck.Value = True Then
  484.         AutoCheck.Value = False
  485.         AutoCheck.Enabled = False
  486.     Else
  487.         AutoCheck.Enabled = True
  488.     End If
  489. End Sub
  490. Private Sub FoundRecord_Click()
  491.         ViewButton.Outline = True
  492. End Sub
  493. Private Sub MailBox_Change()
  494.     If AutoCheck.Value = True Then SearchButton_Click
  495. End Sub
  496. Private Sub MailButton_Click(Value As Integer)
  497.     NomeBox.Enabled = False
  498.     CognomeBox.Enabled = False
  499.     NomeBox.Text = "(disabilitato)"
  500.     CognomeBox.Text = "(disabilitato)"
  501.     If MailButton.Value = False Then
  502.         MailBox.Enabled = False
  503.         MailBox.Text = "(disabilitato)"
  504.         StatusBar.Panels(3).Text = "Nessun criterio selezionato"
  505.     Else
  506.         MailBox.Enabled = True
  507.         MailBox.Text = ""
  508.         StatusBar.Panels(3).Text = "Criterio: ricerca per E-mail"
  509.     End If
  510. End Sub
  511. Private Sub NomButton_Click(Value As Integer)
  512.     CognomeBox.Enabled = False
  513.     MailBox.Enabled = False
  514.     CognomeBox.Text = "(disabilitato)"
  515.     MailBox.Text = "(disabilitato)"
  516.     If NomButton.Value = False Then
  517.         NomeBox.Enabled = False
  518.         NomeBox.Text = "(disabilitato)"
  519.         StatusBar.Panels(3).Text = "Nessun criterio selezionato"
  520.     Else
  521.         NomeBox.Enabled = True
  522.         NomeBox.Text = ""
  523.         StatusBar.Panels(3).Text = "Criterio: ricerca per nome"
  524.     End If
  525. End Sub
  526. Private Sub NomeBox_Change()
  527.     If AutoCheck.Value = True Then SearchButton_Click
  528. End Sub
  529. Private Sub SearchButton_Click()
  530.     ViewButton.Outline = False
  531.     If ComplexCheck.Value = 0 And CheckOptions = 0 Then
  532.         Beep
  533.         MsgBox "E' necessario selezionare un criterio di ricerca!", 16, "CM: Errore"
  534.         Exit Sub
  535.     End If
  536.     Set FoundRecords = Archivio.OpenRecordset(CreateStatement, dbOpenSnapshot)
  537.     If FoundRecords.RecordCount > 0 Then
  538.         FoundRecords.MoveFirst
  539.         While Not FoundRecords.EOF
  540.             FoundRecord.AddItem (FoundRecords("Cognome") + FoundRecords("Nome"))
  541.             FoundRecords.MoveNext
  542.         Wend
  543.         TotalePanel.Caption = "Occorrenze rilevate: " + Str$(FoundRecord.ListCount)
  544.     Else
  545.         TotalePanel.Caption = "Occorrenze rilevate: Nessuna"
  546.     End If
  547.     FoundRecords.Close
  548. End Sub
  549. Private Sub ViewButton_Click()
  550.     If CheckSelected Then
  551.         ShowData (False)
  552.     End If
  553. End Sub
  554.