【问题标题】:Displaying Forms With Strings用字符串显示表单
【发布时间】:2014-11-30 17:54:27
【问题描述】:

如何在显示表单之前获取所有消息,并将此表单一一显示?

首先,如果“客户”已经签出或者客户的预订已经过期,我有一个程序会获取一个条目。使用这种方法,我将获取他们的交易编号和客户编号,并将他们的信息放在一个表格中并显示出来。请注意,我有一个不同的 EXPIRED RESERVATION 和 CHECK OUT 表格

有人可以检查我的程序吗?如果客户的签到已过期,这是我获取客户的代码。

Public Sub computeRemainingDaysForCheckedIns()

    Dim computedDays As Integer
    Dim dateNow As Date = Date.Now.ToString("yyyy-MM-dd")

    Try
        mysqlconn = New MySqlConnection(con)
        mysqlconn.Open()
        query = "select TransactionNumber, ClientNumber, DATEDIFF(dateout,curdate()) as 'ComputedDays' from dbo_transactions where ClientStatus = 'Checked In'"
        cmd = New MySqlCommand(query, mysqlconn)
        rd = cmd.ExecuteReader
        If rd.HasRows Then
            'hasRows ibig sabhin mayLAMAN ung table
            While rd.Read
                computedDays = rd.GetString("ComputedDays")
                'Console.WriteLine(computedDays)
                If computedDays > 0 Then
                    getTransactionNumber = ""
                    getClientNumber = ""
                ElseIf computedDays < 0 Then

                    getTransactionNumber = rd.GetString("TransactionNumber")
                    getClientNumber = rd.GetString("ClientNumber")

                    iTitle = "CHECK OUT CLIENT."
                    iMessage.AppendLine("* Client: " & getClientNumber & ", Transaction: " & getTransactionNumber & " *")
                    isCNotifShowed = True
                End If

            End While
            'notificationFormC.Show()
        Else
            'no data
        End If
        mysqlconn.Close()
    Catch ex As Exception
        isCNotifShowed = False
        MsgBox("Something Went Wrong!" & vbNewLine &
               ex.Message, MsgBoxStyle.Exclamation)
    Finally
        mysqlconn.Dispose()
    End Try
End Sub

Public Sub computeRemainingDaysForReservations()

    Dim computedDays As Integer

    Try
        mysqlconn = New MySqlConnection(con)
        mysqlconn.Open()
        query = "Select TransactionNumber, ClientNumber, DATEDIFF(DateIn, CURDATE()) as 'ComputedDays' from dbo_transactions where ClientStatus = 'Reserved'"
        cmd = New MySqlCommand(query, mysqlconn)
        rd = cmd.ExecuteReader
        If rd.HasRows Then
            'hasRows ibig sabhin mayLAMAN ung table
            While rd.Read
                computedDays = rd.GetString("ComputedDays")
                'Console.WriteLine(computedDays)
                If computedDays > 0 Then
                    getTransactionNumber = ""
                    getClientNumber = ""
                ElseIf computedDays <= 0 Then
                    getTransactionNumber = rd.GetString("TransactionNumber")
                    getClientNumber = rd.GetString("ClientNumber")

                    iiTitle = "RESERVATION IS ALREADY EXPIRED."
                    iiMessage.AppendLine("* " & getClientNumber & ", Transaction: " & getTransactionNumber & " *")
                    isRNotifShowed = True
                End If

            End While
        Else
            'no data
        End If
        rd.Close()
        mysqlconn.Close()
    Catch ex As Exception
        isRNotifShowed = False
        MsgBox("Something Went Wrong!" & vbNewLine &
               ex.Message, MsgBoxStyle.Exclamation)
    Finally
        mysqlconn.Dispose()
    End Try
End Sub

然后用于使用表单显示客户端

Private Sub RepeatProcess()
    computeRemainingDaysForReservations()
    computeRemainingDaysForCheckedIns()

    If iMessage.Length <> 0 Then

    ElseIf iiMessage.Length <> 0 Then

    End If

    'If isCNotifShowed = True Then
    'notificationFormC.Show()
    'ElseIf isRNotifShowed = True Then
    ' notificationFormR.Show()
    'Else
    'End If

End Sub

Private Sub timerTask_Tick_1(sender As Object, e As EventArgs) Handles timerTask.Tick
    tCount += 1
    If tCount = tSecs Then
        Call RepeatProcess()
        tCount = 0                     'reset
    End If
End Sub

【问题讨论】:

  • 请在您的问题中发布代码,而不是链接到图片
  • 我为我的代码创建了一个链接。
  • 否 - 在此站点上发布您的代码;如果 PasteBin 删除了你的代码,那么以后怎么会有人引用它?
  • @paul 我已经发布了我的代码。你能帮帮我吗?

标签: mysql sql vb.net forms boolean


【解决方案1】:

也许这不是最好的方法。为每个过期的预订打开一个新的表单/弹出窗口/其他任何内容都可能会占用您的所有资源。

我建议你显示GridViewDataGridListView 或类似的(我们仍在 VS2008 中凿出石碑,所以我不确定最近有哪些极端技术版本!)。后面的代码可以写成用不同颜色突出问题记录,让问题更明显。

为此,您只需在表单上创建一个带有相关查询的数据源,然后在相应的启用数据的网格中显示结果。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-13
    • 1970-01-01
    • 2010-11-30
    • 1970-01-01
    相关资源
    最近更新 更多