어떻게 표시할 수 있는 여러 다른 후 하나 알림

0

질문

내가 조금 손실지 모르겠를 표시하는 방법 하나 알림니다. 예를 들자면 현재 시간이"23/11/2021 08:00"내가 만들에 대한 알림"23/11/2021 09:30"처음 알림이 나타납 하지만 만약 내가 만들의 또 다른 신호에 대한"23/11/2021 09:35"알림이 표시되지 않습니다하지 않는 한 나는 프로그램을 종료한 후 처음 알림 통지가 표시되고 예를 들어 사용자 설정 1 개 이상의 알림 같은 날짜와 시간 다만 1 개의 알림이 표시되어야 합니다.

감사합니다.

이것은 무엇을 나와 같이 보

Imports System.Data.OleDb

Public Class frmReminder

    Private CurrentReminderID As Integer = -1

    Private Sub frmReminder_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        BtnClear.PerformClick()
        Timer1.Enabled = True
        Timer2.Enabled = True
    End Sub

    Dim CurrentDateTime As Date
    Dim ReminderDateTime As Date

    Public Sub ShowNotification()
        Notification.ShowBalloonTip(1000, "Reminder", "Customer Order Due!", ToolTipIcon.None)
    End Sub

    Private Sub DateTimeVariable()
        CurrentDateTime = Date.Now
        CurrentDateTime = FormatDateTime(DateTime.Now, DateFormat.GeneralDate)
        ReminderDateTime = FormatDateTime(ReminderDateTime, DateFormat.GeneralDate)
        If CurrentDateTime = ReminderDateTime Then
            ShowNotification()

        Else
            If DbConnect() Then
                Dim SQLCmd As New OleDbCommand
                With SQLCmd
                    .Connection = cn
                    .CommandText = "SELECT ReminderDate FROM TblReminder"
                    Dim rs As OleDbDataReader = .ExecuteReader()
                        ReminderDateTime = (rs(0))
                End With
            End If
            cn.Close()
        End If
    End Sub

    Private Sub BtnClear_Click(sender As Object, e As EventArgs) Handles BtnClear.Click
        Label6.Text = ""
        TxtCustName.Text = ""
        TxtDeviceInfo.Text = ""
        TxtPrice.Text = ""
        TxtReminderDateTime.ResetText()
        CurrentReminderID = -1
    End Sub

    Private Sub BtnSetReminder_Click(sender As Object, e As EventArgs) Handles BtnSetReminder.Click

        If TxtCustName.Text.Length < 1 Then
            MessageBox.Show("Customer name is empty!" & vbCrLf, "Reminder", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            TxtCustName.Focus()

        ElseIf TxtDeviceInfo.Text.Length < 1 Then
            MessageBox.Show("Device Information is empty!" & vbCrLf, "Reminder", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            TxtDeviceInfo.Focus()

        ElseIf TxtPrice.Text.Length < 1 Then
            MessageBox.Show("No price entered!" & vbCrLf, "Reminder", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            TxtPrice.Focus()

        ElseIf DbConnect() Then
            Dim SQLCmd As New OleDbCommand
            If CurrentReminderID = -1 Then
                With SQLCmd
                    .Connection = cn
                    .CommandText = "Insert into TblReminder (CustomerName, DeviceInfo, RepairPrice, ReminderDate)"
                    .CommandText &= "Values (@CustomerName, @DeviceInfo, @RepairPrice, @ReminderDate)"
                    .Parameters.AddWithValue("@CustomerName", TxtCustName.Text)
                    .Parameters.AddWithValue("@DeviceInfo", TxtDeviceInfo.Text)
                    .Parameters.AddWithValue("@RepairPrice", TxtPrice.Text)
                    .Parameters.AddWithValue(" @ReminderDate", TxtReminderDateTime.Text)
                    .ExecuteNonQuery()

                    .CommandText = "Select @@Identity"
                    CurrentReminderID = .ExecuteScalar
                    Label6.Text = CurrentReminderID
                    'ShowNotification()
                End With
            End If
        End If
    End Sub

    Private Sub TxtCustName_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TxtCustName.KeyPress
        If Not Char.IsLetter(e.KeyChar) Then 'Checks if key pressed isn't a digit
            If Asc(e.KeyChar) <> Keys.Back Then 'Checks the key pressed wasn't Backspace
                e.Handled = True 'It doesn't take any further action
            End If
        End If
    End Sub

    Private Sub TxtPrice_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TxtPrice.KeyPress
        If Not Char.IsDigit(e.KeyChar) Then 'Checks if key pressed isn't a digit
            If Asc(e.KeyChar) <> Keys.Back Then 'Checks the key pressed wasn't Backspace
                e.Handled = True 'It doesn't take any further action
            End If
        End If
    End Sub

    Private Sub Notification_Click(sender As Object, e As EventArgs) Handles Notification.Click
        frmReminderInfo.Show()
    End Sub

    Private Sub Notification_BalloonTipClicked(sender As Object, e As EventArgs) Handles Notification.BalloonTipClicked
        frmReminderInfo.Show()
    End Sub

    Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
        DateTimeVariable()
    End Sub

    Private Sub BtnOpenReminders_Click(sender As Object, e As EventArgs) Handles BtnOpenReminders.Click
        frmReminderInfo.Show()
    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        TxtCurrentDateTime.Text = Date.Now.ToString("dd/MM/yyyy      HH:mm")
    End Sub
End Class
ms-access notifications timer vb.net
2021-11-23 23:32:41
1

최고의 응답

0

나는 생각할 수 있는 설정을 사용 속성 타이머입니다. 나는 분께서 BtnClear 에서 의견을 나는 무시 Form.로드니다.

CurrentDateTime = FormatDateTime(DateTime.Now, DateFormat.GeneralDate)
ReminderDateTime = FormatDateTime(ReminderDateTime, DateFormat.GeneralDate)

에 할당할 수 없습 a StringFormatDateTime 하기 CurrentDataTime 기 때문에 그것으로 선언 Date. 당신은 할당 Date 그것은 선이다. 동 ReminderDateTime. 당신을 유지합니다. Date 할 때까지 필요를 표시합니다.

나는 분리된 데이터베이스에서 코드의 사용자 인터페이스 코드입니다. 에 While 루프 유지 덮어 쓰기의 값 ReminderDateTime 그래서 그만 마지막 값은 변수가 있습니다. 이러한 관점에서 단순히 선택 Last() 고 사용 ExecuteScalar. 왜 당신이 원하는 것이 다만 마지막 날짜를 하지만 그 무엇이 당신의 코드입니다.

Private CurrentReminderID As Integer = -1
Private CurrentDateTime As Date
Private ReminderDateTime As Date

Public Sub ShowNotification()
    Notification.ShowBalloonTip(1000, "Reminder", "Customer Order Due!", ToolTipIcon.None)
End Sub

Private Sub DateTimeVariable()
    CurrentDateTime = Date.Now
    If CurrentDateTime = ReminderDateTime Then
        ShowNotification()
    Else
        ReminderDateTime = RetrieveReminderDate()
    End If
End Sub

Private Function RetrieveReminderDate() As Date
    Dim RemindDate As New Date
    Using cn As New OleDbConnection(OPConStr),
            cmd As New OleDbCommand("SELECT Last(ReminderDate) FROM TblReminder", cn)
        cn.Open()
        RemindDate = CDate(cmd.ExecuteScalar)
    End Using
    Return RemindDate
End Function

Private Sub BtnClear_Click(sender As Object, e As EventArgs) Handles BtnClear.Click
    Label6.Text = ""
    TxtCustName.Text = ""
    TxtDeviceInfo.Text = ""
    TxtPrice.Text = ""
    DtpReminderDateTime.ResetText()
    CurrentReminderID = -1
End Sub

Private Sub BtnSetReminder_Click(sender As Object, e As EventArgs) Handles BtnSetReminder.Click
    Dim price As Decimal
    If TxtCustName.Text.Length < 1 Then
        MessageBox.Show("Customer name is empty!" & vbCrLf, "Reminder", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        TxtCustName.Focus()
        Exit Sub
    ElseIf TxtDeviceInfo.Text.Length < 1 Then
        MessageBox.Show("Device Information is empty!" & vbCrLf, "Reminder", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        TxtDeviceInfo.Focus()
        Exit Sub
    ElseIf Not Decimal.TryParse(TxtPrice.Text, price) Then
        MessageBox.Show("No price entered!" & vbCrLf, "Reminder", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        TxtPrice.Focus()
        Exit Sub
    Else
        If CurrentReminderID = -1 Then
            CurrentReminderID = SaveReminder(TxtCustName.Text, TxtDeviceInfo.Text, price, DtpReminderDateTime.Value)
        End If
    End If
End Sub

Private Function SaveReminder(Name As String, Device As String, Price As Decimal, RemindDate As Date) As Integer
    Dim Id As Integer
    Using cn As New OleDbConnection(OPConStr),
            cmd As New OleDbCommand("Insert into TblReminder (CustomerName, DeviceInfo, RepairPrice, ReminderDate)
                                    Values (@CustomerName, @DeviceInfo, @RepairPrice, @ReminderDate)")
        With cmd.Parameters
            .Add("@CustomerName", OleDbType.VarChar).Value = Name
            .Add("@DeviceInfo", OleDbType.VarChar).Value = Device
            .Add("@RepairPrice", OleDbType.Decimal).Value = Price
            .Add(" @ReminderDate", OleDbType.Date).Value = RemindDate
        End With
        cn.Open()
        cmd.ExecuteNonQuery()
        cmd.CommandText = "Select @@Identity"
        Id = CInt(cmd.ExecuteScalar)
    End Using
    Return Id
End Function

Private Sub Notification_Click(sender As Object, e As EventArgs) Handles Notification.Click
    frmReminderInfo.Show()
End Sub

Private Sub Notification_BalloonTipClicked(sender As Object, e As EventArgs) Handles Notification.BalloonTipClicked
    frmReminderInfo.Show()
End Sub

Private Sub BtnOpenReminders_Click(sender As Object, e As EventArgs) Handles BtnOpenReminders.Click
    frmReminderInfo.Show()
End Sub

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
    TxtCurrentDateTime.Text = Date.Now.ToString("dd/MM/yyyy      HH:mm")
End Sub

Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
    DateTimeVariable()
End Sub
2021-11-24 17:12:59

감사에 대한 응답,나는 원하지 않는 마지막 날짜와 시간을 확인하고 싶어 모두의 저장된 날짜와 시간에서 데이터베이스 분야(ReminderDate)과 비교하는 날짜와 시간에 저장된 데이터베이스는 현재 날짜와 시간,면 비교가"="다 알림이 표시되어야에 관계 없이 있는 경우 다른 다가오는 알림서 예를 들면 다음과 같은 5 분의 시간입니다.
Yousaer10

@Yousaer10 에 대답하십시오 내에서 질문에 대한 의견의 질문에 대한 알림입니다.
Mary

@Yousaer10 에 관한 ReminderDate,편집할 수는 코드에서는 당신의 질문을 보여 당신이 무엇을 원하는가?
Mary

죄송하지 않았다는 것을 알고 동안 루프는 것을 덮어 그래서 내가 제거하는 동안 반복 이후 당신은 내가 말하기를 덮어쓰지의 값 ReminderDateTime.
Yousaer10

또한 질문에 대한 대답을 얻에 게시합니다.
Yousaer10

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................