Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Virtual Helper - frmDiary.vb

frmDiary.vb

Caricato da: Totem
Scarica il programma completo

  1. Public Class frmDiary
  2.     Public Modified As Boolean = False
  3.     Private Sub dtpDay_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dtpDay.ValueChanged
  4.         If Modified Then
  5.             If MsgBox("Aggiornare gli impegni di " + dtpDay.Value.Date.ToLongDateString + "?", MsgBoxStyle.Question + vbYesNo) Then
  6.                 Dim W As New IO.StreamWriter(Application.StartupPath + "\Imps\" + dtpDay.Value.Date.ToLongDateString + ".app")
  7.                 W.Write(txtImp.Text)
  8.                 W.Close()
  9.                 Modified = False
  10.             End If
  11.         End If
  12.  
  13.         Try
  14.             Dim R As New IO.StreamReader(Application.StartupPath + "\Imps\" + dtpDay.Value.Date.ToLongDateString + ".app")
  15.             txtImp.Text = R.ReadToEnd
  16.             R.Close()
  17.         Catch FNFE As IO.FileNotFoundException
  18.             txtImp.Text = "[Nessun impegno per questo giorno]"
  19.         Catch DNFE As IO.DirectoryNotFoundException
  20.             IO.Directory.CreateDirectory(Application.StartupPath + "\Imps")
  21.             txtImp.Text = "[Nessun impegno per questo giorno]"
  22.         End Try
  23.         Modified = False
  24.     End Sub
  25.     Private Sub cmdRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRefresh.Click
  26.         Dim W As New IO.StreamWriter(Application.StartupPath + "\Imps\" + dtpDay.Value.Date.ToLongDateString + ".app")
  27.         W.Write(txtImp.Text)
  28.         W.Close()
  29.         Modified = False
  30.     End Sub
  31.     Private Sub txtImp_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtImp.TextChanged
  32.         Modified = True
  33.     End Sub
  34.     Private Sub cmdDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDelete.Click
  35.         If MsgBox("L'eliminazione dei file associati a " + dtpDay.Value.Date.ToLongDateString + " sarà permanente. Procedere?", MsgBoxStyle.Question + vbYesNo) = MsgBoxResult.No Then
  36.             Exit Sub
  37.         End If
  38.         Kill(Application.StartupPath + "\Imps\" + dtpDay.Value.Date.ToLongDateString + ".app")
  39.         txtImp.Text = "[Nessun impegno per questo giorno]"
  40.     End Sub
  41. End Class