字符串格式使用增量

时间:2014-01-16 08:10:54

标签: vb.net

我有一个ticket_no字段,格式为“storecode - datetoday - n”我想要的是什么时候只要日期是今天“n”只会增加但是如果日期改变了“n” “将重置为1。

    TMP_SQL = "select max(ticket_no) from tbl_main where store_id = '" + frm_store.store_code + "'"
    Dim OBJCMD As New SqlCommand(TMP_SQL, OBJCON)
    OBJREADER = OBJCMD.ExecuteReader()
    Dim ydate As String
    ydate = Now.ToString("MMddyy")
    With OBJREADER
        .Read()
        Dim x As string
        Dim str As String

        If IsDBNull(OBJREADER(0)) = False Then
            str = OBJREADER(0)
            x = Int32.Parse(OBJREADER(0).ToString().Split("-")(1))
            If x <> ydate Then
                tmp = 0
                tmp = Int32.Parse(OBJREADER(0).ToString().Split("-")(2)) + 1
            Else
                tmp = Int32.Parse(OBJREADER(0).ToString().Split("-")(2)) + 1
            End If
        End If

    End With

    txtTicketno.Text = frm_store.store_code & "-" & Now.ToString("MMddyy") & "-" & tmp

0 个答案:

没有答案