none
Permissions when logged in correctly then some treeview is blocked

    Question

  • Good Night  brother dan sister, help me.

    How to create permissions when logged correctly then treeview will be in some treeview block and how treeviews can be moved
    Sample design below

    Thank you

    Sunday, April 23, 2017 4:22 PM

All replies

  • Hi FahmiZR,

    According to your description, I don't know what's permissions, and what is the screenshot. If the permissions is the TreeView, you can load this in your project.

    If the permissions is not TreeView, You want to compare the permission and screenshot, and delete some data that the permission doesn't have.

    If my guess is wrong, please correct me.

    Best Regards,

    Cherry Bu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, April 24, 2017 7:34 AM
    Moderator
  • For example: I want to enter as Headmaster, then Master menu can not be clicked by headmaster. Only the Report / menu ("Laporan"), the principal can click and view it in the treeview.

    Coding in Main Menu

     Private Sub TreeView1_AfterSelect(sender As Object, e As TreeViewEventArgs) Handles TreeView1.AfterSelect
    
            Dim tn As TreeNode = Me.TreeView1.SelectedNode
            ' Dim tn1 As TreeNode = Me.TreeView1.SelectedNode
            Select Case tn.Text
       Case "Lap. Alumni"
                    buku.hide()
                    LaporanTunggakanSiswa.Close()
                    Laporan_Perlengkapan.Close()
                    Laporan_Buku.Close()
                    Laporan_Pembayaran_Buku.Close()
                    Laporan_Pembayaran_Perlengkapan.Close()
                    Laporan_Pembayaran_SPP.Close()
                    Laporan_Mata_Pelajaran.Close()
                    Laporan_Absensi_Guru.Close()
                    Laporan_Absensi_Siswa.Close()
                    Laporan_Nilai_Siswa.Close()
                    Laporan_Siswa_Pindah.Close()
                    Laporan_Siswa_Pindahan.Close()
                    Laporan_Kelas.Close()
                    Laporan_Guru.Close()
                    Laporan_Data_Siswa.Close()
                    Laporan_Pendaftaran_Ulang.Close()
                    Laporan_Pendaftaran.Close()
                    Raport.Close()
                    Data_Siswa_Pindah.Close()
                    Tunggakan_Siswa.Close()
                    Kartu_Tanda_Siswa.Close()
                    Dgv_Perlengkapan__dan_Pendaftaran.Close()
                    Dgv_Pembayaran_Buku.Close()
                    Dgv_Pembayaran_SPP.Close()
                    Dgv_Perlengkapan__dan_Pendaftaran.Close()
                    Dgv_Data_Jadwal_Mengajar.Close()
                    Dgv_Data_Mata_Pelajaran.Close()
                    dgv_Informasi_Jadwal_Mengajar.Close()
                    absensi_Guru.Close()
                    Dgv_Data_Absensi_Siswa.Close()
                    Dgv_Nilai_Siswa.Close()
                    Pendaftaran.hide()
                    Dgv_Alumni.Close()
                    pembagianbuku.hide()
                    administrasi.hide()
                    perlengkapan1.hide()
                    buku.hide()
                    spp.hide()
                    kelas.hide()
                    guru1.hide()
                    Dgv_Data_Siswa.Close()
                    PictureBox2.Hide()
    
                    Laporan_Alumni.MdiParent = Me
                    '    dgv_Pendaftaran.WindowState = FormWindowState.Maximized
                    Laporan_Alumni.Show()
            End Select
            '  Dim n As String
    
    
        End Sub

    coding Login

      Try
                sqlcmd = New SqlCommand("select * from Login where username='" & txtUsername.Text & "' and Password= '" & txtpassword.Text & "'", sqlcon)
                sqlreader = sqlcmd.ExecuteReader
                sqlreader.Read()
                If Not sqlreader.HasRows Then
                    MessageBox.Show("Silahkan masukkan Username dan Password dengan benar", "Informasi", MessageBoxButtons.OK)
                    txtUsername.Clear()
                    txtpassword.Clear()
                    txtUsername.Focus()
                Else
                    Me.Visible = False
                    Menu_Utama.Show()

    Monday, April 24, 2017 6:08 PM
  • Hi FahmiZR,

    Can you tell me what is the headmaster, and where the Master menu is stored. In you code, there are many LaporanTunggakanSiswa.Close(), Laporan_Perlengkapan.Close()...., what are these.

    Thanks for your support.

    Best Regards,

    Cherry Bu 


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, April 26, 2017 1:47 AM
    Moderator
  • Headmasters are leaders in a school. The master menu is stored in each table, for example the equipment is saved to the table and others. "LaporanTunggakanSiswa.close" and others is a report later for Headmaster.
    Wednesday, April 26, 2017 6:32 PM
  • Here is an example of denying access to a node and its subnodes, just put the code shown below in a form with no controls or anything else

    Public Class Form1
        WithEvents TreeView1 As New TreeView
        Dim RNG As New Random
        Dim Forbidden As New List(Of String)
        Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            Me.Width = 350
            Me.Height = 400
            TreeView1.Location = New Point(10, 10)
            TreeView1.Size = New Size(250, 300)
            TreeView1.Font = New Font("Lucida Console", 10, FontStyle.Bold)
            Me.Controls.Add(TreeView1)
            TreeView1.Nodes.Clear()
    
            Dim root = New TreeNode("Test Applications")
            TreeView1.Nodes.Add(root)
    
            For NodeIndex = 0 To RNG.Next(6, 8)
                TreeView1.Nodes(0).Nodes.Add(New TreeNode("Project " & NodeIndex.ToString))
                For loopindex As Integer = 1 To RNG.Next(2, 5)
                    TreeView1.Nodes(0).Nodes(NodeIndex).Nodes.Add(New TreeNode("Sub Project #" & loopindex.ToString))
                Next loopindex
                If RNG.Next(0, 100) > 50 And NodeIndex > 0 Then
                    Forbidden.Add("Project " & NodeIndex.ToString)
                    TreeView1.Nodes(0).Nodes(NodeIndex).ForeColor = Color.Red
                Else
                    TreeView1.Nodes(0).Nodes(NodeIndex).ForeColor = Color.Green
                End If
            Next
        End Sub
    
        Private Sub TreeView1_BeforeExpand(sender As Object, e As System.Windows.Forms.TreeViewCancelEventArgs) Handles TreeView1.BeforeExpand
            If Forbidden.IndexOf(e.Node.Text) > -1 Then
                MessageBox.Show("Access Denied")
                e.Cancel = True
            End If
        End Sub
    End Class
    
    

    Hope that helps.

    • Proposed as answer by Frank L. Smith Wednesday, April 26, 2017 8:56 PM
    Wednesday, April 26, 2017 8:23 PM
  • Can be simple coding, some nodes that will be hidden during login. Would be read in advance in the database in accordance with access rights
    Thursday, May 11, 2017 6:37 AM