codice:
Dim SplitLista() As String
Dim Button_click As String
Dim Tasto_Premuto As Integer
Dim Cat_prec As String
Dim Reg_Prec As String
Dim Pulsante As String
Private Sub Annulla_Click()
Annulla.Enabled = False
Salva.Enabled = False
Svuota_TextBox
CProvincia.Enabled = True
CRegione.Enabled = True
Categoria1.Enabled = True
List1.ListIndex = -1
End Sub
Private Sub Categoria1_Click()
Categoria_Patch = Categoria1.Text
Riempi_ComboBox_Regione
If Cat_prec <> Categoria1.Text Then List1.Clear
Cat_prec = Categoria1.Text
End Sub
Private Sub Check1_Click()
If Check1.Enabled = True And Check1.Value = 1 Then
Salvatagio = "Salva"
materiale_dimostrativo.Label4 = SplitLista(0)
materiale_dimostrativo.DataInizio.Text = DateTime.Date
materiale_dimostrativo.DataFine.Text = DateTime.Date + 7
materiale_dimostrativo.Show vbModal
End If
End Sub
Private Sub Citta_Change()
If Tasto_Premuto = 1 Then
Trova_Con_Qualsiasi_Textbox "Città", Form1.Citta.Text
Tasto_Premuto = 0
End If
End Sub
Private Sub Citta_KeyPress(KeyAscii As Integer)
Tasto_Premuto = 1
End Sub
Private Sub Cmd_Telefonata_Click()
Dim Inizio_Fne As String
Inizio_Fne = Cmd_Telefonata.Caption
Select Case Inizio_Fne
Case "Inizio telefonata"
Inserisci_nota.Inizio_Telefonata.Text = DateTime.Time
Inserisci_nota.Data_Telefonata.Text = DateTime.Date
Cmd_Telefonata.Caption = "Fine telefonata"
Inserisci_nota.Id_Cliente = SplitLista(0)
Memo.PresentazioneUtente.Show vbModal
Case "Fine telefonata"
Inserisci_nota.Fine_Telefonata.Text = DateTime.Time
Cmd_Telefonata.Caption = "Inizio telefonata"
Inserisci_nota.Caption = "Salva telefonata"
Salvatagio = "Salva"
Inserisci_nota.Show vbModal
End Select
End Sub
Private Sub Command1_Click()
On Error GoTo errore
Questionario.Label3.Caption = SplitLista(0)
Questionario.Show vbModal
Exit Sub
errore:
MsgBox "Selezionare un cliente"
End Sub
Private Sub CProvincia_Click()
Riempi_ListBox_Clienti_Per_Provincie
End Sub
Private Sub CRegione_Click()
Riempi_ComboBox_Provincia
If Reg_Prec <> CRegione.Text Then List1.Clear
Reg_Prec = CRegione.Text
'Riempi_ListBox_Clienti
End Sub
Private Sub Documenti_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then PopupMenu Menu_Doc
End Sub
Private Sub Elim_Contratto_Click()
Dim Righe As Integer
Righe = Form1.Documenti.Row
If Righe > -1 Then
If MsgBox("Eliminare il cliente selezionato!", vbYesNo) = vbNo Then Exit Sub
Apertura_db
cn.Open Stringa
rs.Open "DELETE FROM ScadenzaProdotto WHERE Id_Cliente = " & Form1.Documenti.TextMatrix(Righe, 0) & " and Fine = '" & Form1.Documenti.TextMatrix(Righe, 3) & " ' and ScadenzaContratto = '" & Form1.Documenti.TextMatrix(Righe, 4) & "' and Inizio ='" & Form1.Documenti.TextMatrix(Righe, 2) & "'", cn, 3, 3
cn.Close
Set cn = Nothing
Set rs = Nothing
If Righe = 1 Then
Documenti.TextMatrix(Righe, 0) = ""
Documenti.TextMatrix(Righe, 1) = ""
Documenti.TextMatrix(Righe, 2) = ""
Documenti.TextMatrix(Righe, 3) = ""
Documenti.TextMatrix(Righe, 4) = ""
Documenti.TextMatrix(Righe, 5) = ""
Documenti.TextMatrix(Righe, 6) = ""
Else
Documenti.RemoveItem Righe
End If
End If
End Sub
Private Sub Elimina_Click()
If (MsgBox("Eliminare cliente ID: " & SplitLista(0) & ", ragione sociale " & SplitLista(1), vbYesNo)) = vbYes Then
Elimina_cliente (SplitLista(0))
If CProvincia.ListIndex = -1 Then
'Riempi_ListBox_Clienti
Svuota_TextBox
Else
Riempi_ListBox_Clienti_Per_Provincie
Svuota_TextBox
End If
End If
End Sub
Private Sub Elimina_nota_Click()
Dim Righe As Integer
Righe = Form1.Note.Row
Inserisci_nota.Caption = "Elimina"
If Righe > -1 Then
Salvatagio = "Elimina"
Form1.Timer1.Interval = 0
Inserisci_nota.Id_Cliente = SplitLista(0)
Inserisci_nota.Data_Telefonata.Text = Note.TextMatrix(Righe, 1)
Inserisci_nota.Inizio_Telefonata.Text = Note.TextMatrix(Righe, 2)
Inserisci_nota.Fine_Telefonata.Text = Note.TextMatrix(Righe, 3)
Inserisci_nota.Nota_Telefonata.Text = Note.TextMatrix(Righe, 4)
Inserisci_nota.Show vbModal
End If
Carica_Note (SplitLista(0))
End Sub
Private Sub Form_Load()
Form1.Caption = Form1.Caption & " " & DateTime.Date
Check1.Enabled = False
Check2.Enabled = False
Check3.Enabled = False
Check4.Enabled = False
Riempi_ComboBox_CategoriaForm
Riempi_ComboBox_Regione
Riempi_ComboBox_Provincia
'Riempi_ListBox_Clienti
End Sub
Private Sub Form_Terminate()
If Salva.Enabled = True Then
MsgBox "Prima di uscire salvare o annllare"
End If
End Sub
Private Sub Ins_Contratto_Click()
On Error GoTo SelezionaUnCliente
InserisciScadenzaProdotto.Id_Cliente.Text = SplitLista(0)
InserisciScadenzaProdotto.Show vbModal
Exit Sub
SelezionaUnCliente: MsgBox "Selezionare un cliente"
End Sub
Private Sub List1_Click()
On Error Resume Next
Form1.Check1.Value = 0
Form1.Check2.Value = 0
Form1.Check3.Value = 0
Form1.Check4.Value = 0
SplitLista = Split(List1.Text, " ")
Elimina.Enabled = True
Trova SplitLista(0)
Note.Clear
Carica_Note (SplitLista(0))
Riempi_ComboBox_AllegatiCliente (SplitLista(0))
Carica_Contratti (SplitLista(0))
Carica_Domanda_Risposta (SplitLista(0))
End Sub
Private Sub Modifica_Click()
Button_click = "Button_Modifica"
Salva.Enabled = True
Annulla.Enabled = True
CProvincia.Enabled = False
CRegione.Enabled = False
Categoria1.Enabled = False
Pulsante = "Modifica"
End Sub
Private Sub Modifica_note_Click()
Dim Righe, Colonne As Integer
Righe = Note.Row
Inserisci_nota.Caption = "Modifica telefonata"
If Righe > -1 Then
Salvatagio = "Modifica"
Form1.Timer1.Interval = 0
Inserisci_nota.Id_Cliente = SplitLista(0)
Inserisci_nota.Data_Telefonata.Text = Note.TextMatrix(Righe, 1)
Inserisci_nota.Inizio_Telefonata.Text = Note.TextMatrix(Righe, 2)
Inserisci_nota.Fine_Telefonata.Text = Note.TextMatrix(Righe, 3)
Inserisci_nota.Nota_Telefonata.Text = Note.TextMatrix(Righe, 4)
Inserisci_nota.Show vbModal
End If
Carica_Note (SplitLista(0))
End Sub
Private Sub NomCogn_Change()
If Tasto_Premuto = 1 Then
'MsgBox ("NomCogn")
Trova_Con_Qualsiasi_Textbox "NomeCogn", Form1.NomCogn.Text
Tasto_Premuto = 0
End If
End Sub
Private Sub NomCogn_KeyPress(KeyAscii As Integer)
Tasto_Premuto = 1
End Sub
Private Sub Note_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim Righe As Integer
Righe = Note.Row
If Righe > -1 Then
If Button = vbLeftButton Then PopupMenu Menu_Nota
End If
End Sub
Private Sub Nuovo_Click()
'Svuota le TexBox
Svuota_TextBox
Salva.Enabled = True
Annulla.Enabled = True
CProvincia.Enabled = False
CRegione.Enabled = False
Categoria1.Enabled = False
Rag_soc.SetFocus
Button_click = "Button_salva"
Check1.Value = 0
Check2.Value = 0
Check3.Value = 0
Check4.Value = 0
Pulsante = "Nuovo"
End Sub
Private Sub Posizione_TextBox_Change()
If Tasto_Premuto = 1 Then
Trova_Con_Qualsiasi_Textbox "Posizione", Form1.Posizione_TextBox.Text
Tasto_Premuto = 0
End If
End Sub
Private Sub Posizione_KeyDown(KeyCode As Integer, Shift As Integer)
Tasto_Premuto = 1
End Sub
Private Sub Rag_soc_Change()
If Tasto_Premuto = 1 Then
Trova_Con_Qualsiasi_Textbox "RegioneSociale", Form1.Rag_soc.Text
Tasto_Premuto = 0
End If
End Sub
Private Sub Rag_soc_KeyDown(KeyCode As Integer, Shift As Integer)
Tasto_Premuto = 1
End Sub
Private Sub Salva_Click()
Select Case Button_click
Case "Button_salva" 'Se si e premuto il pulsante salva
If Controllo_TextBox_Piene = 0 Then
Scrivi
Svuota_TextBox
Salva.Enabled = False
Annulla.Enabled = False
Riempi_ListBox_Clienti_Per_Provincie
End If
Case "Button_Modifica" 'Se si e premuto il pulsante modifica
Modifica_Clienti (SplitLista(0))
If CProvincia.ListIndex = -1 Then
'Riempi_ListBox_Clienti
Svuota_TextBox
Salva.Enabled = False
Annulla.Enabled = False
Else
Riempi_ListBox_Clienti_Per_Provincie
Svuota_TextBox
Salva.Enabled = False
Annulla.Enabled = False
End If
End Select
CProvincia.Enabled = True
CRegione.Enabled = True
Categoria1.Enabled = True
End Sub
Private Sub SSTab1_Click(PreviousTab As Integer)
RegistroFax.ColWidth(0) = 0
RegistroFax.ColWidth(1) = 1000
RegistroFax.ColWidth(2) = 3000
RegistroFax.ColWidth(3) = 1400
RegistroFax.ColWidth(4) = 3200
RegistroFax.TextMatrix(0, 1) = "Data invio"
RegistroFax.TextMatrix(0, 2) = "Destinatario"
RegistroFax.TextMatrix(0, 3) = "Registro invio"
RegistroFax.TextMatrix(0, 4) = "Allegati"
Documenti.ColWidth(0) = 600
Documenti.ColWidth(1) = 3500
Documenti.ColWidth(2) = 1000
Documenti.ColWidth(3) = 1200
Documenti.ColWidth(4) = 1500
Documenti.ColWidth(5) = 1300
Documenti.ColWidth(6) = 1100
Documenti.TextMatrix(0, 0) = "Id"
Documenti.TextMatrix(0, 1) = "Prodotto"
Documenti.TextMatrix(0, 2) = "Data inizio"
Documenti.TextMatrix(0, 3) = "Data scadenza"
Documenti.TextMatrix(0, 4) = "Scadenza contratto"
Documenti.TextMatrix(0, 5) = "Tipo pagamento"
Documenti.TextMatrix(0, 6) = "Tipo contratto"
Form1.Documenti.Rows = 1
On Error Resume Next
If SSTab1.Tab = 1 Then Carica_Note (SplitLista(0))
If SSTab1.Tab = 2 Then Carica_Contratti (SplitLista(0))
If SSTab1.Tab = 4 Then
RisposteQuestionario.TextMatrix(0, 0) = "Domanda"
RisposteQuestionario.TextMatrix(0, 1) = "Risposta"
RisposteQuestionario.TextMatrix(0, 2) = "Altro"
RisposteQuestionario.ColWidth(0) = 3000
RisposteQuestionario.RowHeight(1) = 600
RisposteQuestionario.ColWidth(1) = 900
RisposteQuestionario.ColWidth(2) = 3000
Carica_Domanda_Risposta (SplitLista(0))
End If
End Sub
Private Sub Timer1_Timer()
'Pulsante elimina e modifica
If List1.Text = "" Or Annulla.Enabled = True Then
Elimina.Enabled = False
Modifica.Enabled = False
Else
Elimina.Enabled = True
Modifica.Enabled = True
End If
'Pulsante nuovo
If CRegione.Text = "" Or CProvincia.Text = "" Or Annulla.Enabled = True Then
Nuovo.Enabled = False
Else
Nuovo.Enabled = True
End If
'Controllo della ListBox
If Annulla.Enabled = True Then
List1.Enabled = False
If Pulsante = "Nuovo" Then Check1.Enabled = False
If Pulsante = "Modifica" Then Check1.Enabled = True
Check2.Enabled = True
Check3.Enabled = True
Check4.Enabled = True
If CProvincia.Text <> "" Then Provincia.Text = CProvincia.Text
Reg.Text = CRegione.Text
Else
List1.Enabled = True
Form1.Check1.Enabled = False
Form1.Check2.Enabled = False
Form1.Check3.Enabled = False
Form1.Check4.Enabled = False
Pulsante = ""
End If
If List1.Text = "" Then
Form1.Cmd_Telefonata.Enabled = False
Form1.Note.Enabled = False
Else
Form1.Cmd_Telefonata.Enabled = True
Form1.Note.Enabled = True
End If
End Sub
Private Sub VScroll1_Change()
Picture2.Top = -VScroll1.Value
End Sub
Private Sub Visualizza_nota_Click()
Dim Righe, Colonne As Integer
Righe = Note.Row
If Righe > -1 Then
Form1.Timer1.Interval = 0
'Disabilita la modifica delle note e della telefonata perche e in sola visualizzazione
Inserisci_nota.Nota_Telefonata.Locked = True
Inserisci_nota.Combo1.Enabled = False
'------------------------------------------------------------------------------------
Inserisci_nota.Id_Cliente = SplitLista(0)
Inserisci_nota.Data_Telefonata.Text = Note.TextMatrix(Righe, 1)
Inserisci_nota.Inizio_Telefonata.Text = Note.TextMatrix(Righe, 2)
Inserisci_nota.Fine_Telefonata.Text = Note.TextMatrix(Righe, 3)
Inserisci_nota.Nota_Telefonata.Text = Note.TextMatrix(Righe, 4)
'Carica quando si deve rischiamare il cliente
If Note.TextMatrix(Righe, 7) = "Calendario" Then
Inserisci_nota.Combo1.ListIndex = 3
Inserisci_nota.MonthView1.Visible = False
Inserisci_nota.Chiama_Textbox.Text = Note.TextMatrix(Righe, 5) & " " & Note.TextMatrix(Righe, 6)
Else
If Note.TextMatrix(Righe, 7) = "Minuti" Or Note.TextMatrix(Righe, 7) = "Ore" Then
If Note.TextMatrix(Righe, 7) = "Minuti" Then
Inserisci_nota.Combo1.ListIndex = 1
Else
Inserisci_nota.Combo1.ListIndex = 2
End If
Inserisci_nota.Chiama_Textbox.Text = "Scadenza alle ore " & Note.TextMatrix(Righe, 6)
Inserisci_nota.Cmd_decrementa.Visible = False
Inserisci_nota.Cmd_Incrementa.Visible = False
End If
End If
Salvatagio = ""
Inserisci_nota.Show vbModal
End If
End Sub