1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
'ajoute sur le form
'-un datagridview
'-un picbox
'-un textbox
'-un button
Public Class Form2
'Un class exemple
Private myIntevention As Intervention
'un list d'exemple binde au datagridview (mais ca peut etre un datatable)
Private ListInteventions As List(Of Intervention)
Dim dateSaisie As Date = Nothing
Dim dateAlert As Date = Nothing
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'setup format data in datetimepicker
Me.DateTimePickerUser.Format = DateTimePickerFormat.Short
'populate liste exemple
ListInteventions = New List(Of Intervention)()
Dim startDate As DateTime = DateTime.Now.ToShortDateString
myIntevention = New Intervention
myIntevention.DelaisDesire = startDate
ListInteventions.Add(myIntevention)
For i = 1 To 4
startDate = startDate.AddMonths(i)
myIntevention = New Intervention
myIntevention.IDName = "Item" & i.ToString
myIntevention.DelaisDesire = startDate.ToShortDateString
ListInteventions.Add(myIntevention)
Next
Me.DataGridView1.DataSource = ListInteventions
End Sub
Private Sub buttonCheckDates_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buttonCheckDates.Click
CheckDates()
End Sub
'check colonne date saise
Private Sub CheckDates()
If dateAlert = Nothing Then Return
'verification du delai
Dim dateSaisie As Date
'idname concerne
Dim currentID As String
'intervalle de temps systeme(jpurs,mois,secondes ou ce que tu veux)
Dim diff As TimeSpan = New TimeSpan
'ton delai exprime mettons en jours
Dim DelaiEnJour As Integer = 20
'recherche des colonnes à probleme
For Each dgvRow As DataGridViewRow In Me.DataGridView1.Rows
currentID = dgvRow.Cells(0).Value
dateSaisie = CType(dgvRow.Cells(1).Value, DateTime).ToShortDateString
If dateSaisie > dateAlert Then
diff = dateSaisie - dateAlert
'diff.Days convertit diff dans tes unites:les jours
If (diff.Days > DelaiEnJour) Then
Me.PictureBox1.BackColor = Color.FromArgb(34, 177, 76)
MsgBox(diff.Days.ToString & " jours" & " ID : " & currentID, vbOKOnly + vbExclamation, " Délai dépassé ....")
Me.PictureBox1.BackColor = Color.FromArgb(255, 0, 0)
Me.PictureBox1.Focus()
End If
End If
Next
End Sub
'DateTimePickerChooseAlert :permet de choisir une date alerte
Private Sub DateTimePickerChooseAlert_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePickerChooseAlert.ValueChanged
'affiche date alert
Me.TextBoxDateAlarm.ForeColor = Color.Red
Me.TextBoxDateAlarm.Text = Me.DateTimePickerChooseAlert.Value.ToShortDateString
'choisit une date alerte
dateAlert = Me.DateTimePickerChooseAlert.Value.ToShortDateString
End Sub
End Class |
Partager