Home Forums Bunifu UI Winforms Using Panel Open Forms

Tagged: 

Viewing 0 reply threads
  • Author
    Posts
    • luckydead
      Participant
      Post count: 1

      Hello,
      I’m currectly studing the bunifu and trying to create test programs for education purpuse only .
      I have a question if someone can help me out. I’m using VB.net 2015 and mysql
      I’m trying to make this:

      Form1(AdminMenu) is my main form.
      Form2(UsersAddCP) is my sub form

      In form1 i had added Panel and i want to open Form2 inside of it.
      Inside the form2 i have 7 textboxes 4 checkboxes and 1 button (Form2 is register user)
      And i have a problem when i fill all fields and press the button from the Form2 , in mysql database is created new record but all fields are empty, it looks like whatever i type is not readed. But if i set in textboxes default value text in mysql create it with this information.

      In form1 button to open form2 in panel is like this:

      
      Dim form2 As UsersAddCP= New UsersAddCP()
              form2.TopLevel = False
              form2.TopMost = True
              Dim form1 As AdminMenu = CType(Application.OpenForms("AdminMenu"), AdminMenu)
              Dim panel1 As Panel = CType(form1.Controls("panel1"), Panel)
              panel1.Controls.Clear()
              panel1.Controls.Add(form2)
              form2.Show()
      

      What is the problem that when i type information in textboxes and click the button in Form2 is not reading anything.
      Please note if i make Form2 to show as normal open new window form and fill the textboxes and checkboxes all records are added correctly. I’m having only the problem with Panels . Please someone can help me out, i cannot find any guide or someone to help me.
      I would be glad if someone make video about this it will help a lot of people like me that are trying this.
      I must note that in form2 button save uses RegisterUser() module to insert all the information
      Here is my code :

      
      Public Sub RegisterUser()
              Try
                  With cmd
                      .Connection = conn
                      .CommandText = "INSERT INTO users (uname,upassword,ucode,ucreate,utools,usearch) VALUES (@user,@pass,@ucd,@crt,@uto,@usrh)"
                      .Parameters.AddWithValue("@user", UsersAddCP.TextBox1.Text)
                      .Parameters.AddWithValue("@pass", UsersAddCP.TextBox2.Text)
                      .Parameters.AddWithValue("@ucd", UsersAddCP.AdminCheck.Checked)
                      .Parameters.AddWithValue("@crt", UsersAddCP.CreateCheck.Checked)
                      .Parameters.AddWithValue("@uto", UsersAddCP.ToolsCheck.Checked)
                      .Parameters.AddWithValue("@usrh", UsersAddCP.SearchCheck.Checked)
                      .ExecuteNonQuery()
                      .Parameters.Clear()
                      .CommandText = "INSERT INTO personal (pacc,pName,pEmail,pYazaki,pPhone,pPosition) VALUES (@user,@name,@email,@yazaki,@phone,@position)"
                      .Parameters.AddWithValue("@user", UsersAddCP.TextBox1.Text)
                      .Parameters.AddWithValue("@name", UsersAddCP.TextBox3.Text)
                      .Parameters.AddWithValue("@email", UsersAddCP.TextBox4.Text)
                      .Parameters.AddWithValue("@yazaki", UsersAddCP.TextBox5.Text)
                      .Parameters.AddWithValue("@phone", UsersAddCP.TextBox7.Text)
                      .Parameters.AddWithValue("@position", UsersAddCP.TextBox6.Text)
                      Result = .ExecuteNonQuery
                  End With
              Catch ex As Exception
                  MsgBox(ex.Message)
              Finally
                  If Result > 0 Then
                      MessageBox.Show("Sign Up Successful", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
                  Else
                      MsgBox("Failed to register user!")
                  End If
                  cmd.Dispose()
                  If conn IsNot Nothing Then
                      conn.Close()
                  End If
              End Try
          End Sub
      
      • This topic was modified 4 years, 11 months ago by luckydead. Reason: update
Viewing 0 reply threads
  • You must be logged in to reply to this topic.