วิธีสามารถแสดงการแจ้งให้ทราบต่างๆหลายคนหลังจากอีก

0

คำถาม

ฉันหน่อยสูญเสียฉันไม่รู้ว่าจะทำการแสดงผลหนึ่งการแจ้งให้ทราบหลังจากนั้นอย่างอื่นอีก เอาเป็นว่าเพื่อนตัวอย่างของฉันเวลาปัจจุบันคือ"23/11/202108:00"และฉันต้องการสร้างการเตือนความจำสำหรับ"23/11/202109:30"ครั้งแรกที่การแจ้งให้ทราบก็โผล่ขึ้นแต่ถ้าฉันสร้างอีกเตือนความจำสำหรับ"23/11/202109: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 ในความคิดเห็นดังนั้นฉันไม่สนใจเป็นแบบนี้โหลดทั้งหมด

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

คุณไม่สามารถกำหนดที่มี String จาก FormatDateTime ต้อง CurrentDataTime เพราะมันเป็นเรื่องประกาศตอนเป็น Date. คุณพึ่งจะได้รับมอบหมายงาน Date มันคือเส้นทางด้านบน เหมือนกับ ReminderDateTime. ทำให้คุณเป็นวันที่ Date จนกว่าคุณต้องการที่จะแสดงพวกเขา

ฉันแยกกันอยู่ฐานข้อมูลรหัสจากส่วนติดต่อผู้ใช้ถอดรหัส ในของคุณ While วงนายเก็บ overwriting ค่าของ 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

ขอโทษฉันไม่รู้ว่าในขณะที่วงจะต้องการเขียนทับหรือไม่ดังนั้นฉันถูกเอาออกในขณะที่วงตั้งแต่คุณบอกว่าฉันเก็บ overwriting ค่าของ ReminderDateTime.
Yousaer10

ฉันยังตอบคำถามของคุณภายใต้ของฉันซะหน่อย
Yousaer10

ในภาษาอื่นๆ

หน้านี้อยู่ในภาษาอื่นๆ

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

ดังอยู่ในนี้หมวดหมู่

ดังคำถามอยู่ในนี้หมวดหมู่