将一个表单打开到另一个表单,在vb.net

时间:2017-05-26 05:22:38

标签: vb.net

我正在尝试从登录表单打开另一个。但是在两个表单都关闭之后它只执行load事件。

按钮点击从下面登录是代码

Con.ConnectionString = ConnectionString

    Try
        Con.Open()
    Catch ex As SqlException
        ' do something with this type of exception
    Catch ex As DataException
        ' do something with this type of exception
    Catch ex As Exception

    End Try


    Dim Sql As String
    Dim Pass As String = Module1.EncryptPassword(TxtPassword.Text)

    Sql = " select * from c_tpr_users where Usr_name='" & TxtUser.Text & "' and Password='" & Pass & "'"

    Dim SC As New SqlCommand
    SC.Connection = Con
    SC.CommandText = Sql

    Dim Sdr As SqlDataReader = SC.ExecuteReader()

    If Sdr.HasRows Then
        MsgBox("Login Sucess", vbOKOnly + vbInformation)


        Sdr.Close()
        SC.Dispose()
        UserNameInCustomERP = TxtUser.Text
        UserNameInERP = TxtUser.Text

        Sql = "select Year from FinYears where CONVERT(date, GETDATE())>=StartDate and  CONVERT(date, GETDATE())<=EndDate"

        SC.Connection = Con
        SC.CommandText = Sql

        Sdr = SC.ExecuteReader()

        If Sdr.HasRows Then
            If Sdr.Read() Then
                FAYear = Sdr.Item("year")
            End If
        End If
        Sdr.Close()
        SC.Dispose()
        'new form want to opend
        FrmSampleDispatch.Show()

        Me.Close()

请帮助我......提前谢谢

0 个答案:

没有答案