2014-10-06 85 views
-4

如何在显示表单之前获取所有消息,并逐个显示此表单?使用字符串显示表格

首先,我有一个程序获取条目,如果“客户端”已经签出或者客户端的预订已经过期。通过这种方法,我将得到他们的交易号码和客户号码,将他们的信息放在一个表格中并显示出来。请注意,我对于过期预订和退房有不同的表单

有人可以检查我的程序吗?这是我的代码,如果他/她的登记已过期,可以获得客户端。

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 
+0

请在您的问题中发布代码而不是链接到图像 – 2014-10-06 13:04:59

+0

我为我的代码创建了一个链接。 – Ellis 2014-10-06 13:06:27

+0

否 - 在此网站上发布您的代码;如果PasteBin删除你的代码,那么将来人们怎么可以引用它? – Paul 2014-10-06 15:19:06

回答

1

也许这是不是这样做的最佳方式在客户端显示。为每个过期的预订打开新表单/弹出窗口/可能会吸收所有资源。

我建议你显示一个GridViewDataGridListView或类似的(我们还在凿石碑出在VS2008,所以我不知道什么极端的技术有较新版本!)。可以编写背后的代码来突出显示不同颜色的问题记录,以便它们更加明显。

要做到这一点,你只需要在窗体上创建一个DataSource与相关的查询,然后将结果显示在适当的数据启用网格中。