Disable button click after first click

97 views Asked by At

I am developing a point of sale system using vb.net and SQL Server Compact 4.0. I have a new transaction button that generates a new invoice number using id once clicked. But the problem is its generates a new invoice even when an existing transaction isn't completed. I want to disable this until a transaction is completed, that is once payment is saved where its proceeds to the next invoice number automatically. Kindly help.

    Private Sub btnNewTrns_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewTrns.Click
    If cmbCustomer.SelectedValue Is Nothing Or cmbCustomer.SelectedIndex = -1 Then
        MsgBox("Required: Customer name", MsgBoxStyle.Information, "Information")
    Else
        ExecuteSQLQuery(" INSERT INTO tbl_sale (Sales_Date, Sales_Time, User_ID, customer_id, grand_disc, collection_full, POS, term_of_payment, consin1, consin2, narration, Payment, Change) VALUES  " &
                         " ('" & Format(Now, "MM/dd/yyyy") & "', '" + TimeOfDay + "', '" & xUser_ID & "', " & cmbCustomer.SelectedValue & ", 0, 'N', 'Y', 'DUE', '-', '-', '-',0 , 0) ")
        ExecuteSQLQuery("SELECT        SALES_ID  FROM            tbl_sale  ORDER BY SALES_ID DESC")
        txtInvoiceID.Text = sqlDT.Rows(0)("SALES_ID")
        loadSalesItem()
        txtBarcode.Select()
    End If
End Sub

Until this happens

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
    If cmbType.Text = "" Then
        MsgBox("Required: TERM OF PAYMENT", MsgBoxStyle.Information, "Information")
    ElseIf Not IsNumeric(txtPayment.Text) Then
        MsgBox("Required: Payment", MsgBoxStyle.Information, "Information")
    ElseIf Val(txtPayment.Text) <= 0 Then
        MsgBox("Required: Payment", MsgBoxStyle.Information, "Information")
    Else
        If Val(txtGtotal.Text) <= Val(txtPayment.Text) Then
            ExecuteSQLQuery(" UPDATE  tbl_sale SET  grand_disc=" & str_repl(txtDiscount.Text) & ", collection_full='Y', term_of_payment='" + cmbType.Text + "', Change='" & txtChange.Text & "', Payment='" & txtPayment.Text & "'  WHERE        (SALES_ID = " & txtInvoiceID.Text & ")")
            MsgBox("Payment Completed.", MsgBoxStyle.Information, "Information")
            If MsgBox("Are you sure to print preview INV. NO#  " & txtInvoiceID.Text, MsgBoxStyle.YesNo + MsgBoxStyle.Exclamation, "Confirm..") = MsgBoxResult.Yes Then
                LoadCompanyDetails()
                LoadPOSRecipt(txtInvoiceID.Text)
            End If
            Me.Close()
            frmPOS.btnNewTrns.PerformClick()
            frmPOS.LoadItem()
            frmPOS.txtBarcode.Select()
        Else
            MsgBox("Sorry! Payment not acceptable.", MsgBoxStyle.Critical, "Sorry!")
        End If
    End If
End Sub
0

There are 0 answers