English 中文(简体)
如何处理以前删除的顺序交易编号,以便它们能够继续按顺序在维也纳国际中心的MSESS数据库中。 NET
原标题:How to handle sequential transaction numbers that were previously deleted so they can remain sequential in MS ACCESS database in Dapper with VB.NET

如何在使用VB的Dapper的MSACESS数据库中删除以往的顺序交易编号。 NET?

Below is the transaction number that I deleted previously:

Invno
DEPT-ITI-1023-00002

如果我从 com箱中选择转让项目“DEPT-ITU-”的价值,交易编号如下:

Invno
DEPT-ITI-1023-00004

因此,如果我从 com箱中选择转让项目“DEPT-ITU-”的价值,那么交易号预期结果如下:

Invno
DEPT-ITI-1023-00002

请 指南

增 编

Public Class Form1
    Private HeaderInvno As Integer
    Dim sis As New Stocksinservice()
    Private CurrentMonthYear As String
    Private ItemTransferIn As String   Define ItemTransferIn as a string
    Private Sub CreateInvno()
         Dim myDate As DateTime = DateTime.Now
        Dim myDate As DateTime = DateTimePicker1.Value
        Dim strTime As String = myDate.ToString("MMyy-")
        Dim newMonthYear As String = myDate.ToString("yyMM")

          Set ItemTransferIn based on ComboBox1.Text
        If ComboBox1.Text = "ITEM TRANSFER IN" Then
            ItemTransferIn = "DEPT-ITI-"
        ElseIf ComboBox1.Text = "PURCHASE INVOICE" Then
            ItemTransferIn = "DEPT-PI-"
        ElseIf ComboBox1.Text = "RECEIVE ITEM" Then
            ItemTransferIn = "DEPT-RI-"
        End If
          Retrieve the HeaderInvno and MonthYear from the database
        Dim stockin = sis.SelectTop(ItemTransferIn)
        If stockin IsNot Nothing Then
            HeaderInvno = stockin.HeaderInvno
            CurrentMonthYear = stockin.MonthYear
        Else
            HeaderInvno = 0
            CurrentMonthYear = ""
        End If
           Check if the month and year have changed
        If stockin Is Nothing OrElse myDate.Year > stockin.InvnoDate.Year OrElse myDate.Month > stockin.InvnoDate.Month Then
                     If Not newMonthYear.Equals(CurrentMonthYear) Then
            HeaderInvno = 1
            CurrentMonthYear = newMonthYear
        Else
            HeaderInvno = stockin.HeaderInvno + 1
        End If
          Concatenate ItemTransferIn with other parts of the invoice number
        BtxtInvoNo.Text = ItemTransferIn & strTime & HeaderInvno.ToString("00000")
    End Sub
    Private Sub ComboBox1_SelectedValueChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedValueChanged
        CreateInvno()
    End Sub

Public Class Stocksinservice
    Private connectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|DEMO.accdb;Persist Security Info=False;"
    Public Function SelectTop(itemTransferIn As String) As Stocksin
        Dim sql = $"SELECT TOP 1 HeaderInvno,InvnoDate FROM Stocksin WHERE ItemTransferIn =  {itemTransferIn}  ORDER BY HeaderInvno DESC "
        Using _conn = New OleDbConnection(connectionString)
            Return _conn.Query(Of Stocksin)(sql).FirstOrDefault()
        End Using
    End Function
End Class
Public Class Stocksin
    Public Property Invno() As String
    Public Property HeaderInvno() As Integer
    Public Property Transaction() As String
    Public Property InvnoDate As DateTime
    Public Property ItemTransferIn() As String
    Public Property MonthYear() As String
End Class

表 <代码>Stockin

Invno HeaderInvno Transaction InvnoDate ItemTransferIn MonthYear
DEPT-ITI-1023-00001 1 ITEM TRANSFER IN 19/10/2023 DEPT-ITI- 2310
DEPT-ITI-1023-00003 3 ITEM TRANSFER IN 19/10/2023 DEPT-ITI- 2310
问题回答

暂无回答




相关问题
Is Shared ReadOnly lazyloaded?

I was wondering when I write Shared ReadOnly Variable As DataType = New DataType() Or alternatively Shared ReadOnly Variable As New DataType() Is it lazy loaded or as the instance initializes? ...

Entertaining a baby with VB.NET

I would like to write a little application in VB.NET that will detect a baby s cry. How would I get started with such an application?

Choose Enter Rather than Pressing Ok button

I have many fields in the page and the last field is a dropdown with list of values. When I select an item in a dropdown and press Enter, it doesn t do the "Ok". Instead I have to manually click on Ok ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

Set Select command in code

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...

Hover tooltip on specific words in rich text box?

I m trying to create something like a tooltip suddenly hoovering over the mouse pointer when specific words in the richt text box is hovered over. How can this be done?

热门标签