尝试加载子表格

时间:2019-04-05 07:38:39

标签: vb.net

我正在制作一个按钮,以在单击时显示数据,然后更改按钮的文本以隐藏数据,但我找不到解决方法。我需要帮助。

如何使其重新加载Form1_Load或重新启动程序以解决该问题。

试图执行show()函数,但showdiaglog对我也不起作用。了解我在这里缺少的东西

Imports System.Data
Imports System.Data.SqlClient
Public Class Form1

    Dim con As New SqlConnection
    Dim cmd As New SqlCommand
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'AccountsC20DataSet.ProductMast' table. You can move, or remove it, as needed.


    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Try

            con.ConnectionString = "Data Source = OMAR;Initial Catalog=AccountsC20;Persist Security Info=True;User ID=ofamo;Password="
            con.Open()
            cmd.Connection = con



            Dim Selected = ListBox1.SelectedValue.ToString()

            cmd.CommandText = "Insert into SInvoice  Values('SIV-1',0,1," & Selected & ",5.000000,0.000000,'04/04/2019 13:39:44',4.000000,20.000000,'',0,1,1,1,1,'04/04/2019 13:39:44','',1.000000,1,0,'','b',0.000000,5,0.000000,20.000000,'Nos',1.000000,'','','','','','','','','','','','','','','','','','','','','',0,3,'SIV-',1,1,1,1,1,1,0.000000)"
            cmd.ExecuteNonQuery()

            cmd.CommandText = "Insert into SInvoice  Values('SIV-1',1,2," & Selected & ",4.000000,0.000000,'04/04/2019 13:39:44',8.000000,32.000000,'',0,1,1,1,1,'04/04/2019 13:39:44','',1.000000,1,1,'','b',0.000000,5,0.000000,32.000000,'Nos',1.000000,'','','','','','','','','','','','','','','','','','','','','',0,3,'SIV-',1,1,1,1,1,1,0.000000)"
            cmd.ExecuteNonQuery()


            cmd.CommandText = "Insert into IDetails Values ('SIV-1',5,'','',1)"
            cmd.ExecuteNonQuery()

            cmd.CommandText = " Insert into Modified (VoucherNo,VoucherDate,CustomerNo,LoginName,ExtraFieldIndex,ActualVoucherPrefix,ModificationType,ModificationDate,ModificationTime,code,name,mastertype) Values ('SIV-1','04/04/2019 13:39:44',5,'su',3,'SIV-','Add','04/04/2019','04/04/2019 13:40:54','','','')"
            cmd.ExecuteNonQuery()

            cmd.CommandText = "Insert into HFields Values('SIV-1',0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,'','','','','','','','','','',1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,-155,-155,-155,-155,-155,-155,-155,-155,-155,-155,-155,-155,-155,-155,-155,-155,-155,-155,-155,-155)"
            cmd.ExecuteNonQuery()

            cmd.CommandText = "Insert into ExtraFields Values('SIV-1',1,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,'','','','','','','','','','','','','','','','','','','','',1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000)"
            cmd.ExecuteNonQuery()

            cmd.CommandText = "Insert into ExtraFields Values('SIV-1',2,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,'','','','','','','','','','','','','','','','','','','','',1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000,1.000000)"
            cmd.ExecuteNonQuery()

            cmd.CommandText = "Insert into PurchaseData Values('SIV-1','04/04/2019 13:39:44',5,'',1,20.000000,0.000000,0,'',1.000000,'N','Y','04/04/2019 13:39:44',1,1,1,1," & Selected & ",1,'',0,1,1,1,1,1,1,0)"
            cmd.ExecuteNonQuery()

            cmd.CommandText = "Insert into PurchaseData Values('SIV-1','04/04/2019 13:39:44'," & Selected & ",'',5,0.000000,20.000000,0,'',1.000000,'N','Y','04/04/2019 13:39:44',1,1,1,1," & Selected & ",1,'',0,1,1,1,1,1,1,0)"
            cmd.ExecuteNonQuery()

            cmd.CommandText = "Insert into PurchaseData Values('SIV-1','04/04/2019 13:39:44',5,'',1,32.000000,0.000000,0,'',1.000000,'N','Y','04/04/2019 13:39:44',1,1,1,1," & Selected & ",1,'',0,1,1,1,1,1,1,0)"
            cmd.ExecuteNonQuery()

            cmd.CommandText = "Insert into PurchaseData Values('SIV-1','04/04/2019 13:39:44'," & Selected & ",'',5,0.000000,32.000000,0,'',1.000000,'N','Y','04/04/2019 13:39:44',1,1,1,1," & Selected & ",1,'',0,1,1,1,1,1,1,0)"
            cmd.ExecuteNonQuery()
            MessageBox.Show("Data Saved Successfully")


        Catch ex As Exception
            MessageBox.Show("Error while inserting record on table..." & ex.Message, "Insert Records")
        Finally

            con.Close()
        End Try
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

        If Me.Button2.Text = "Show Products" Then
            Me.ProductMastTableAdapter.Fill(Me.AccountsC20DataSet.ProductMast)
            Me.Button2.Text = "Hide"

        ElseIf Me.Button2.Text = "Hide" Then


        End If

    End Sub
End Class


0 个答案:

没有答案