client/Seguridad/Perfil.vb

478 lines
20 KiB
VB.net
Raw Permalink Normal View History

'Noviembre 2005
Imports System.Data.SqlClient
Imports System.IO
Imports CLIENTE.clsComplejo
Public Class Perfil
Inherits System.Windows.Forms.Form
#Region " C<>digo generado por el Dise<73>ador de Windows Forms "
Public Sub New()
MyBase.New()
'El Dise<73>ador de Windows Forms requiere esta llamada.
InitializeComponent()
'Agregar cualquier inicializaci<63>n despu<70>s de la llamada a InitializeComponent()
End Sub
'Form reemplaza a Dispose para limpiar la lista de componentes.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Requerido por el Dise<73>ador de Windows Forms
Private components As System.ComponentModel.IContainer
'NOTA: el Dise<73>ador de Windows Forms requiere el siguiente procedimiento
'Puede modificarse utilizando el Dise<73>ador de Windows Forms.
'No lo modifique con el editor de c<>digo.
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
Public WithEvents lblIdPerfil As System.Windows.Forms.Label
Friend WithEvents BntSalie As System.Windows.Forms.Button
Friend WithEvents BtnAlta As System.Windows.Forms.Button
Friend WithEvents BtnLimpiar As System.Windows.Forms.Button
Friend WithEvents grdPerfil As C1.Win.C1TrueDBGrid.C1TrueDBGrid
Friend WithEvents BtnNuevo As System.Windows.Forms.Button
Friend WithEvents BtnImprimir As System.Windows.Forms.Button
Private WithEvents panel2 As Panel
Private WithEvents Img_logoCabecera As PictureBox
Friend WithEvents label4 As Label
Private WithEvents panel3 As Panel
Friend WithEvents Label1 As Label
Friend WithEvents lblFooter As Label
Public WithEvents lblNombrePerfil As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Perfil))
Me.GroupBox1 = New System.Windows.Forms.GroupBox()
Me.grdPerfil = New C1.Win.C1TrueDBGrid.C1TrueDBGrid()
Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
Me.lblIdPerfil = New System.Windows.Forms.Label()
Me.lblNombrePerfil = New System.Windows.Forms.Label()
Me.BntSalie = New System.Windows.Forms.Button()
Me.BtnAlta = New System.Windows.Forms.Button()
Me.BtnLimpiar = New System.Windows.Forms.Button()
Me.BtnNuevo = New System.Windows.Forms.Button()
Me.BtnImprimir = New System.Windows.Forms.Button()
Me.panel2 = New System.Windows.Forms.Panel()
Me.Img_logoCabecera = New System.Windows.Forms.PictureBox()
Me.label4 = New System.Windows.Forms.Label()
Me.panel3 = New System.Windows.Forms.Panel()
Me.Label1 = New System.Windows.Forms.Label()
Me.lblFooter = New System.Windows.Forms.Label()
Me.GroupBox1.SuspendLayout()
CType(Me.grdPerfil, System.ComponentModel.ISupportInitialize).BeginInit()
Me.panel2.SuspendLayout()
CType(Me.Img_logoCabecera, System.ComponentModel.ISupportInitialize).BeginInit()
Me.panel3.SuspendLayout()
Me.SuspendLayout()
'
'GroupBox1
'
Me.GroupBox1.BackColor = System.Drawing.Color.White
Me.GroupBox1.Controls.Add(Me.grdPerfil)
Me.GroupBox1.Location = New System.Drawing.Point(12, 54)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(456, 249)
Me.GroupBox1.TabIndex = 0
Me.GroupBox1.TabStop = False
'
'grdPerfil
'
Me.grdPerfil.AllowArrows = False
Me.grdPerfil.AllowUpdate = False
Me.grdPerfil.AllowUpdateOnBlur = False
Me.grdPerfil.BackColor = System.Drawing.Color.White
Me.grdPerfil.EditDropDown = False
Me.grdPerfil.GroupByCaption = "AGRUPAR"
Me.grdPerfil.Images.Add(CType(resources.GetObject("grdPerfil.Images"), System.Drawing.Image))
Me.grdPerfil.Location = New System.Drawing.Point(12, 15)
Me.grdPerfil.MultiSelect = C1.Win.C1TrueDBGrid.MultiSelectEnum.None
Me.grdPerfil.Name = "grdPerfil"
Me.grdPerfil.PreviewInfo.Location = New System.Drawing.Point(0, 0)
Me.grdPerfil.PreviewInfo.Size = New System.Drawing.Size(0, 0)
Me.grdPerfil.PreviewInfo.ZoomFactor = 75.0R
Me.grdPerfil.PrintInfo.PageSettings = CType(resources.GetObject("grdPerfil.PrintInfo.PageSettings"), System.Drawing.Printing.PageSettings)
Me.grdPerfil.Size = New System.Drawing.Size(434, 225)
Me.grdPerfil.TabIndex = 77
Me.grdPerfil.Text = "C1TrueDBGrid1"
Me.grdPerfil.PropBag = resources.GetString("grdPerfil.PropBag")
'
'ImageList1
'
Me.ImageList1.ImageStream = CType(resources.GetObject("ImageList1.ImageStream"), System.Windows.Forms.ImageListStreamer)
Me.ImageList1.TransparentColor = System.Drawing.Color.Turquoise
Me.ImageList1.Images.SetKeyName(0, "")
Me.ImageList1.Images.SetKeyName(1, "")
Me.ImageList1.Images.SetKeyName(2, "")
Me.ImageList1.Images.SetKeyName(3, "")
Me.ImageList1.Images.SetKeyName(4, "")
Me.ImageList1.Images.SetKeyName(5, "")
Me.ImageList1.Images.SetKeyName(6, "")
Me.ImageList1.Images.SetKeyName(7, "")
'
'lblIdPerfil
'
Me.lblIdPerfil.ForeColor = System.Drawing.SystemColors.Control
Me.lblIdPerfil.Location = New System.Drawing.Point(48, 90)
Me.lblIdPerfil.Name = "lblIdPerfil"
Me.lblIdPerfil.Size = New System.Drawing.Size(32, 16)
Me.lblIdPerfil.TabIndex = 3
'
'lblNombrePerfil
'
Me.lblNombrePerfil.ForeColor = System.Drawing.Color.White
Me.lblNombrePerfil.Location = New System.Drawing.Point(264, 90)
Me.lblNombrePerfil.Name = "lblNombrePerfil"
Me.lblNombrePerfil.Size = New System.Drawing.Size(100, 8)
Me.lblNombrePerfil.TabIndex = 4
Me.lblNombrePerfil.Text = "Label1"
'
'BntSalie
'
Me.BntSalie.BackColor = System.Drawing.Color.Black
Me.BntSalie.Cursor = System.Windows.Forms.Cursors.Hand
Me.BntSalie.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.BntSalie.ForeColor = System.Drawing.Color.White
Me.BntSalie.Location = New System.Drawing.Point(487, 270)
Me.BntSalie.Name = "BntSalie"
Me.BntSalie.Size = New System.Drawing.Size(106, 33)
Me.BntSalie.TabIndex = 100
Me.BntSalie.Text = "Cerrar"
Me.BntSalie.UseVisualStyleBackColor = False
'
'BtnAlta
'
Me.BtnAlta.BackColor = System.Drawing.Color.Black
Me.BtnAlta.Cursor = System.Windows.Forms.Cursors.Hand
Me.BtnAlta.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.BtnAlta.ForeColor = System.Drawing.Color.White
Me.BtnAlta.Location = New System.Drawing.Point(487, 154)
Me.BtnAlta.Name = "BtnAlta"
Me.BtnAlta.Size = New System.Drawing.Size(106, 33)
Me.BtnAlta.TabIndex = 98
Me.BtnAlta.Text = "Editar"
Me.BtnAlta.UseVisualStyleBackColor = False
'
'BtnLimpiar
'
Me.BtnLimpiar.BackColor = System.Drawing.Color.Black
Me.BtnLimpiar.Cursor = System.Windows.Forms.Cursors.Hand
Me.BtnLimpiar.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.BtnLimpiar.ForeColor = System.Drawing.Color.White
Me.BtnLimpiar.Location = New System.Drawing.Point(487, 80)
Me.BtnLimpiar.Name = "BtnLimpiar"
Me.BtnLimpiar.Size = New System.Drawing.Size(106, 33)
Me.BtnLimpiar.TabIndex = 95
Me.BtnLimpiar.Text = "Limpiar"
Me.BtnLimpiar.UseVisualStyleBackColor = False
Me.BtnLimpiar.Visible = False
'
'BtnNuevo
'
Me.BtnNuevo.BackColor = System.Drawing.Color.Black
Me.BtnNuevo.Cursor = System.Windows.Forms.Cursors.Hand
Me.BtnNuevo.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.BtnNuevo.ForeColor = System.Drawing.Color.White
Me.BtnNuevo.Location = New System.Drawing.Point(487, 193)
Me.BtnNuevo.Name = "BtnNuevo"
Me.BtnNuevo.Size = New System.Drawing.Size(106, 33)
Me.BtnNuevo.TabIndex = 102
Me.BtnNuevo.Text = "Nuevo"
Me.BtnNuevo.UseVisualStyleBackColor = False
'
'BtnImprimir
'
Me.BtnImprimir.BackColor = System.Drawing.Color.Black
Me.BtnImprimir.Cursor = System.Windows.Forms.Cursors.Hand
Me.BtnImprimir.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.BtnImprimir.ForeColor = System.Drawing.Color.White
Me.BtnImprimir.Location = New System.Drawing.Point(488, 231)
Me.BtnImprimir.Name = "BtnImprimir"
Me.BtnImprimir.Size = New System.Drawing.Size(106, 33)
Me.BtnImprimir.TabIndex = 108
Me.BtnImprimir.Text = "Exportar"
Me.BtnImprimir.UseVisualStyleBackColor = False
'
'panel2
'
Me.panel2.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.panel2.BackColor = System.Drawing.Color.Black
Me.panel2.Controls.Add(Me.Img_logoCabecera)
Me.panel2.Controls.Add(Me.label4)
Me.panel2.ForeColor = System.Drawing.Color.Navy
Me.panel2.Location = New System.Drawing.Point(0, -3)
Me.panel2.Name = "panel2"
Me.panel2.Size = New System.Drawing.Size(608, 51)
Me.panel2.TabIndex = 160
'
'Img_logoCabecera
'
Me.Img_logoCabecera.Image = Global.CLIENTE.My.Resources.Resources.blackrock_logo
Me.Img_logoCabecera.Location = New System.Drawing.Point(474, 1)
Me.Img_logoCabecera.Name = "Img_logoCabecera"
Me.Img_logoCabecera.Size = New System.Drawing.Size(117, 50)
Me.Img_logoCabecera.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.Img_logoCabecera.TabIndex = 360
Me.Img_logoCabecera.TabStop = False
'
'label4
'
Me.label4.AutoSize = True
Me.label4.BackColor = System.Drawing.Color.Transparent
Me.label4.Font = New System.Drawing.Font("Century Gothic", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.label4.ForeColor = System.Drawing.SystemColors.Window
Me.label4.Location = New System.Drawing.Point(21, 8)
Me.label4.Name = "label4"
Me.label4.Size = New System.Drawing.Size(70, 22)
Me.label4.TabIndex = 2
Me.label4.Text = "Perfiles"
'
'panel3
'
Me.panel3.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.panel3.BackColor = System.Drawing.Color.Black
Me.panel3.Controls.Add(Me.Label1)
Me.panel3.Controls.Add(Me.lblFooter)
Me.panel3.ForeColor = System.Drawing.Color.Navy
Me.panel3.Location = New System.Drawing.Point(0, 319)
Me.panel3.Name = "panel3"
Me.panel3.Size = New System.Drawing.Size(608, 33)
Me.panel3.TabIndex = 361
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.BackColor = System.Drawing.Color.Transparent
Me.Label1.Font = New System.Drawing.Font("Century Gothic", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.ForeColor = System.Drawing.SystemColors.Window
Me.Label1.Location = New System.Drawing.Point(549, 5)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(42, 17)
Me.Label1.TabIndex = 3
Me.Label1.Text = "Minds"
'
'lblFooter
'
Me.lblFooter.AutoSize = True
Me.lblFooter.BackColor = System.Drawing.Color.Transparent
Me.lblFooter.Font = New System.Drawing.Font("Century Gothic", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblFooter.ForeColor = System.Drawing.SystemColors.Window
Me.lblFooter.Location = New System.Drawing.Point(1019, 7)
Me.lblFooter.Name = "lblFooter"
Me.lblFooter.Size = New System.Drawing.Size(42, 17)
Me.lblFooter.TabIndex = 2
Me.lblFooter.Text = "Minds"
'
'Perfil
'
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None
Me.BackColor = System.Drawing.Color.White
Me.ClientSize = New System.Drawing.Size(606, 351)
Me.Controls.Add(Me.panel3)
Me.Controls.Add(Me.panel2)
Me.Controls.Add(Me.BtnImprimir)
Me.Controls.Add(Me.BtnNuevo)
Me.Controls.Add(Me.BntSalie)
Me.Controls.Add(Me.BtnAlta)
Me.Controls.Add(Me.BtnLimpiar)
Me.Controls.Add(Me.GroupBox1)
Me.Controls.Add(Me.lblIdPerfil)
Me.Controls.Add(Me.lblNombrePerfil)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "Perfil"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Perfiles"
Me.GroupBox1.ResumeLayout(False)
CType(Me.grdPerfil, System.ComponentModel.ISupportInitialize).EndInit()
Me.panel2.ResumeLayout(False)
Me.panel2.PerformLayout()
CType(Me.Img_logoCabecera, System.ComponentModel.ISupportInitialize).EndInit()
Me.panel3.ResumeLayout(False)
Me.panel3.PerformLayout()
Me.ResumeLayout(False)
End Sub
#End Region
'Declaracion de variables o instancia de clases
Dim clCmp As New clsComplejo()
Dim desh As New clsDeshabilita()
Dim dap As SqlDataAdapter = New SqlDataAdapter()
Dim cmd As SqlCommand
Dim das As DataSet
Dim cnn As SqlConnection
Dim _Accion As String 'Permite definir que tipo de actualizacion se va a realizar
Dim idPerfil As Integer 'Variable compartida, pasa el valor al form de permiso
Dim NombrePerfil As String
Dim Fila As DataRow 'Para obetner la fila que tiene el valor del total de registros
Dim Idperfilx As Integer
Public Shared NuevoPerfil As Boolean
Private Sub Perfiles_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If clsVaribles.lbDemo = True Then Exit Sub
NuevoPerfil = False
IniciaCargaForm()
LlenarGrid()
enlazar()
End Sub
Private Sub enlazar()
'Permite enlazar los controles del formulario con un campo de una tabla o una vista
If clsVaribles.lbDemo = True Then Exit Sub
End Sub
Private Sub IniciaCargaForm()
'Permite conectar a la base de datos y establecer la el select
'Conecto a la base de datos
Dim Conexion As LeeEditorRegistro = New LeeEditorRegistro()
Dim valor As String
If clsVaribles.lbDemo = True Then Exit Sub
Try
valor = clsVaribles.Conexion.ConnectionString
cnn = New SqlConnection(valor)
cmd = New SqlCommand("spConperfil 1", cnn)
dap.SelectCommand = cmd
das = New DataSet()
dap.Fill(das, "Perfil")
'Cargo otra tabla al mismo Dataset
cmd.CommandText = "spConperfil 2"
dap.Fill(das, "PerfilCount")
Catch ex As Exception
MessageBox.Show("Error en el m<>todo 'IniciaCargaForm' del formulario 'Perfil'" & ex.Message)
End Try
Try
cnn.Open()
'MsgBox("base abierta")
Catch er As SqlException
MsgBox("Error al abrir la conexion, en el m<>todo 'IniciaCargaForm' en el formulario 'Perfil': " & er.Message)
Finally
cnn.Close()
End Try
End Sub
Private Sub LlenarGrid()
'Oculto columnas del datagrid con la ayuda de la clase "clOcultarColumna"
'Los parametros son: Nombre de la tabla o vista, nombre columna a ocultar, nombre del dataset
Dim OcultarCol As clOcultarColumna = New clOcultarColumna()
If clsVaribles.lbDemo = True Then Exit Sub
Dim ClassCatalogos As New ClassCatalogos
Dim SQL As String
Try
'Lleno el grid
SQL = "spConperfil 1"
ClassCatalogos.LlenaGrid(SQL, Me.grdPerfil)
Catch er As Exception
MsgBox("Error en el metodo 'LlenarGrid' del formulario 'Perfil': " & er.Message)
End Try
End Sub
Private Sub BntSalie_Click(sender As System.Object, e As System.EventArgs) Handles BntSalie.Click
Me.Close()
End Sub
Private Sub BtnAlta_Click(sender As System.Object, e As System.EventArgs) Handles BtnAlta.Click
'----------------------------------------------
If idPerfil = 0 Then
MsgBox("Favor de seleccionar un perfil ", MsgBoxStyle.Information, "MInds")
Exit Sub
End If
Dim frmPermiso As Permiso = New Permiso(idPerfil, NombrePerfil)
frmPermiso.ShowDialog()
LlenarGrid()
If clsVaribles.lbDemo = True Then Exit Sub
'---------------------------------------------
'quitar las lineas anteriores
End Sub
Private Sub BtnCambios_Click(sender As System.Object, e As System.EventArgs)
If clsVaribles.lbDemo = True Then Exit Sub
NuevoPerfil = False
idPerfil = lblIdPerfil.Text
NombrePerfil = lblNombrePerfil.Text
Dim frmPermiso As Permiso = New Permiso()
frmPermiso.ShowDialog()
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles BtnNuevo.Click
'If idPerfil = 0 Then
' MsgBox("Favor de seleccionar un perfil ", MsgBoxStyle.Information, "MInds")
' Exit Sub
'End If
idPerfil = 0
NombrePerfil = ""
Dim frmPermiso As Permiso = New Permiso(idPerfil, NombrePerfil)
frmPermiso.ShowDialog()
LlenarGrid()
If clsVaribles.lbDemo = True Then Exit Sub
End Sub
Private Sub grdPerfil_SelChange(sender As System.Object, e As C1.Win.C1TrueDBGrid.CancelEventArgs) Handles grdPerfil.SelChange
Dim MiSel As New C1.Win.C1TrueDBGrid.C1TrueDBGrid
MiSel = sender
Me.grdPerfil.Row = MiSel.DestinationRow
idPerfil = Me.grdPerfil.Columns("idperfil").Value
NombrePerfil = Me.grdPerfil.Columns("perfil").Value
End Sub
Private Sub BtnImprimir_Click(sender As System.Object, e As System.EventArgs) Handles BtnImprimir.Click
Exportar()
End Sub
Private Function Exportar() As Boolean
Try
If grdPerfil.RowCount = 0 Then
MessageBox.Show("Realiza una consulta ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
Dim copyDS As DataSet = grdPerfil.DataSource.Copy()
Dim clsExcel As aExcel = New aExcel
clsExcel.Titulo = Me.Text
clsExcel.ExportDataset(copyDS)
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Function
End Class