client/conexion/Catalogos/PlazaCat.vb

402 lines
18 KiB
VB.net
Raw Blame History

Public Class PlazaCat
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
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
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents cmbEstado As System.Windows.Forms.ComboBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents txtNombre As System.Windows.Forms.TextBox
Friend WithEvents chkActivo As System.Windows.Forms.CheckBox
Friend WithEvents btnSalir As System.Windows.Forms.ToolBarButton
Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents C1TrueDBGrid1 As C1.Win.C1TrueDBGrid.C1TrueDBGrid
Friend WithEvents ToolBar As System.Windows.Forms.ToolBar
Friend WithEvents btnNuevo As System.Windows.Forms.ToolBarButton
Friend WithEvents btnGuardar As System.Windows.Forms.ToolBarButton
Friend WithEvents txtClave As System.Windows.Forms.TextBox
Friend WithEvents linkAlias As System.Windows.Forms.LinkLabel
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(PlazaCat))
Me.Label4 = New System.Windows.Forms.Label
Me.cmbEstado = New System.Windows.Forms.ComboBox
Me.Label2 = New System.Windows.Forms.Label
Me.txtNombre = New System.Windows.Forms.TextBox
Me.chkActivo = New System.Windows.Forms.CheckBox
Me.ToolBar = New System.Windows.Forms.ToolBar
Me.btnGuardar = New System.Windows.Forms.ToolBarButton
Me.btnNuevo = New System.Windows.Forms.ToolBarButton
Me.btnSalir = New System.Windows.Forms.ToolBarButton
Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.C1TrueDBGrid1 = New C1.Win.C1TrueDBGrid.C1TrueDBGrid
Me.linkAlias = New System.Windows.Forms.LinkLabel
Me.txtClave = New System.Windows.Forms.TextBox
Me.GroupBox1.SuspendLayout()
CType(Me.C1TrueDBGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'Label4
'
Me.Label4.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label4.Location = New System.Drawing.Point(94, 313)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(48, 16)
Me.Label4.TabIndex = 57
Me.Label4.Text = "Estado:"
'
'cmbEstado
'
Me.cmbEstado.Location = New System.Drawing.Point(144, 311)
Me.cmbEstado.Name = "cmbEstado"
Me.cmbEstado.Size = New System.Drawing.Size(208, 21)
Me.cmbEstado.TabIndex = 55
'
'Label2
'
Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label2.Location = New System.Drawing.Point(90, 287)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(54, 16)
Me.Label2.TabIndex = 56
Me.Label2.Text = "Nombre:"
'
'txtNombre
'
Me.txtNombre.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
Me.txtNombre.Location = New System.Drawing.Point(144, 287)
Me.txtNombre.Name = "txtNombre"
Me.txtNombre.Size = New System.Drawing.Size(207, 20)
Me.txtNombre.TabIndex = 54
Me.txtNombre.Text = ""
'
'chkActivo
'
Me.chkActivo.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.chkActivo.ForeColor = System.Drawing.Color.Red
Me.chkActivo.Location = New System.Drawing.Point(208, 268)
Me.chkActivo.Name = "chkActivo"
Me.chkActivo.Size = New System.Drawing.Size(56, 16)
Me.chkActivo.TabIndex = 58
Me.chkActivo.Text = "Activo:"
'
'ToolBar
'
Me.ToolBar.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.ToolBar.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.btnGuardar, Me.btnNuevo, Me.btnSalir})
Me.ToolBar.ButtonSize = New System.Drawing.Size(75, 40)
Me.ToolBar.DropDownArrows = True
Me.ToolBar.ImageList = Me.ImageList1
Me.ToolBar.Location = New System.Drawing.Point(0, 0)
Me.ToolBar.Name = "ToolBar"
Me.ToolBar.ShowToolTips = True
Me.ToolBar.Size = New System.Drawing.Size(468, 47)
Me.ToolBar.TabIndex = 59
'
'btnGuardar
'
Me.btnGuardar.ImageIndex = 7
Me.btnGuardar.Text = "Guardar"
'
'btnNuevo
'
Me.btnNuevo.ImageIndex = 6
Me.btnNuevo.Text = "Nuevo"
'
'btnSalir
'
Me.btnSalir.ImageIndex = 4
Me.btnSalir.Text = "Salir"
'
'ImageList1
'
Me.ImageList1.ImageSize = New System.Drawing.Size(16, 16)
Me.ImageList1.ImageStream = CType(resources.GetObject("ImageList1.ImageStream"), System.Windows.Forms.ImageListStreamer)
Me.ImageList1.TransparentColor = System.Drawing.Color.Turquoise
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.C1TrueDBGrid1)
Me.GroupBox1.Location = New System.Drawing.Point(8, 56)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(456, 196)
Me.GroupBox1.TabIndex = 60
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "Plazas"
'
'C1TrueDBGrid1
'
Me.C1TrueDBGrid1.AllowUpdate = False
Me.C1TrueDBGrid1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.C1TrueDBGrid1.Dock = System.Windows.Forms.DockStyle.Fill
Me.C1TrueDBGrid1.GroupByCaption = "Drag a column header here to group by that column"
Me.C1TrueDBGrid1.Images.Add(CType(resources.GetObject("resource"), System.Drawing.Image))
Me.C1TrueDBGrid1.Location = New System.Drawing.Point(3, 16)
Me.C1TrueDBGrid1.MarqueeStyle = C1.Win.C1TrueDBGrid.MarqueeEnum.HighlightRow
Me.C1TrueDBGrid1.Name = "C1TrueDBGrid1"
Me.C1TrueDBGrid1.PreviewInfo.Location = New System.Drawing.Point(0, 0)
Me.C1TrueDBGrid1.PreviewInfo.Size = New System.Drawing.Size(0, 0)
Me.C1TrueDBGrid1.PreviewInfo.ZoomFactor = 75
Me.C1TrueDBGrid1.Size = New System.Drawing.Size(450, 177)
Me.C1TrueDBGrid1.TabIndex = 0
Me.C1TrueDBGrid1.Text = "C1TrueDBGrid1"
Me.C1TrueDBGrid1.PropBag = "<?xml version=""1.0""?><Blob><Styles type=""C1.Win.C1TrueDBGrid.Design.ContextWrappe" & _
"r""><Data>Group{BackColor:ControlDark;Border:None,,0, 0, 0, 0;AlignVert:Center;}E" & _
"ditor{}Style2{}Style5{}Style4{}Style7{}Style6{}EvenRow{BackColor:Aqua;}Selected{" & _
"ForeColor:Aqua;BackColor:Highlight;}Style3{}Inactive{ForeColor:InactiveCaptionTe" & _
"xt;BackColor:InactiveCaption;}FilterBar{}Footer{}Caption{AlignHorz:Center;}Style" & _
"9{}Normal{}HighlightRow{ForeColor:Aqua;BackColor:Highlight;}Style14{}OddRow{}Rec" & _
"ordSelector{AlignImage:Center;}Style15{}Heading{Wrap:True;AlignVert:Center;Borde" & _
"r:Raised,,1, 1, 1, 1;ForeColor:ControlText;BackColor:Control;}Style8{}Style10{Al" & _
"ignHorz:Near;}Style11{}Style12{}Style13{}Style1{}</Data></Styles><Splits><C1.Win" & _
".C1TrueDBGrid.MergeView Name="""" CaptionHeight=""17"" ColumnCaptionHeight=""17"" Colu" & _
"mnFooterHeight=""17"" MarqueeStyle=""HighlightRow"" RecordSelectorWidth=""16"" DefRecS" & _
"elWidth=""16"" VerticalScrollGroup=""1"" HorizontalScrollGroup=""1""><Height>173</Heig" & _
"ht><CaptionStyle parent=""Style2"" me=""Style10"" /><EditorStyle parent=""Editor"" me=" & _
"""Style5"" /><EvenRowStyle parent=""EvenRow"" me=""Style8"" /><FilterBarStyle parent=""" & _
"FilterBar"" me=""Style13"" /><FooterStyle parent=""Footer"" me=""Style3"" /><GroupStyle" & _
" parent=""Group"" me=""Style12"" /><HeadingStyle parent=""Heading"" me=""Style2"" /><Hig" & _
"hLightRowStyle parent=""HighlightRow"" me=""Style7"" /><InactiveStyle parent=""Inacti" & _
"ve"" me=""Style4"" /><OddRowStyle parent=""OddRow"" me=""Style9"" /><RecordSelectorStyl" & _
"e parent=""RecordSelector"" me=""Style11"" /><SelectedStyle parent=""Selected"" me=""St" & _
"yle6"" /><Style parent=""Normal"" me=""Style1"" /><ClientRect>0, 0, 446, 173</ClientR" & _
"ect><BorderSide>0</BorderSide><BorderStyle>Sunken</BorderStyle></C1.Win.C1TrueDB" & _
"Grid.MergeView></Splits><NamedStyles><Style parent="""" me=""Normal"" /><Style paren" & _
"t=""Normal"" me=""Heading"" /><Style parent=""Heading"" me=""Footer"" /><Style parent=""H" & _
"eading"" me=""Caption"" /><Style parent=""Heading"" me=""Inactive"" /><Style parent=""No" & _
"rmal"" me=""Selected"" /><Style parent=""Normal"" me=""Editor"" /><Style parent=""Normal" & _
""" me=""HighlightRow"" /><Style parent=""Normal"" me=""EvenRow"" /><Style parent=""Norma" & _
"l"" me=""OddRow"" /><Style parent=""Heading"" me=""RecordSelector"" /><Style parent=""No" & _
"rmal"" me=""FilterBar"" /><Style parent=""Caption"" me=""Group"" /></NamedStyles><vertS" & _
"plits>1</vertSplits><horzSplits>1</horzSplits><Layout>None</Layout><DefaultRecSe" & _
"lWidth>16</DefaultRecSelWidth><ClientArea>0, 0, 446, 173</ClientArea><PrintPageH" & _
"eaderStyle parent="""" me=""Style14"" /><PrintPageFooterStyle parent="""" me=""Style15""" & _
" /></Blob>"
'
'linkAlias
'
Me.linkAlias.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.linkAlias.Location = New System.Drawing.Point(396, 296)
Me.linkAlias.Name = "linkAlias"
Me.linkAlias.Size = New System.Drawing.Size(32, 16)
Me.linkAlias.TabIndex = 61
Me.linkAlias.TabStop = True
Me.linkAlias.Text = "Alias"
Me.linkAlias.VisitedLinkColor = System.Drawing.Color.Blue
'
'txtClave
'
Me.txtClave.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
Me.txtClave.Enabled = False
Me.txtClave.Location = New System.Drawing.Point(10, 256)
Me.txtClave.Name = "txtClave"
Me.txtClave.Size = New System.Drawing.Size(20, 20)
Me.txtClave.TabIndex = 62
Me.txtClave.Text = ""
Me.txtClave.Visible = False
'
'PlazaCat
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.Color.White
Me.ClientSize = New System.Drawing.Size(468, 337)
Me.Controls.Add(Me.txtClave)
Me.Controls.Add(Me.linkAlias)
Me.Controls.Add(Me.GroupBox1)
Me.Controls.Add(Me.ToolBar)
Me.Controls.Add(Me.chkActivo)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.cmbEstado)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.txtNombre)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D
Me.MaximizeBox = False
Me.Name = "PlazaCat"
Me.Text = "Plazas"
Me.GroupBox1.ResumeLayout(False)
CType(Me.C1TrueDBGrid1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Dim clCmp As New clsComplejo
Dim bandera As Boolean 'Para q el combo solo cambie cuadno
Private Sub PlazaCat_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
sbIniciaForma()
bandera = False
Me.btnGuardar.Enabled = False
End Sub
Private Sub sbIniciaForma()
Try
clCmp.sbLlenaCombo("spListaEstado", Me.cmbEstado) 'Llena combo
clCmp.fdtDataSetTabla("spGridPlazas " & cmbEstado.SelectedValue) 'Llena un dataset
Me.C1TrueDBGrid1.SetDataBinding(clCmp.ds, "Tabla") 'Llena el grid
Me.C1TrueDBGrid1.Splits(0, 0).DisplayColumns("Activo").Visible = False
Catch ex As Exception
MessageBox.Show("Error PlazaCat; sbIniciaForma: " & ex.Message, "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub LlenaGrid()
'Se llena el grid cada vz que se selecciona un estado diferente
Try
Dim clCmpEdo As New clsComplejo
clCmpEdo.fdtDataSetTabla("spGridPlazas " & cmbEstado.SelectedValue)
Me.C1TrueDBGrid1.SetDataBinding(clCmpEdo.ds, "Tabla") 'Llena el grid
Me.C1TrueDBGrid1.Splits(0, 0).DisplayColumns("Activo").Visible = False
Catch ex As Exception
MessageBox.Show("Error PlazaCat; LlenaGrid: " & ex.Message, "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub cmbEstado_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbEstado.SelectedIndexChanged
If bandera = True Then
LlenaGrid()
End If
End Sub
Private Sub cmbEstado_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbEstado.DropDown
bandera = True
End Sub
Private Sub ToolBar_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar.ButtonClick
Select Case e.Button.Text
Case "Guardar"
sbGuardar()
limpia()
Me.C1TrueDBGrid1.Focus()
Me.btnGuardar.Enabled = False
Case "Nuevo"
Me.btnGuardar.Enabled = True ' habilita el botn de guardar
limpia()
Case "Salir"
Me.Close()
End Select
End Sub
Private Sub limpia()
Me.txtNombre.Text = ""
Me.chkActivo.Checked = True
Me.txtClave.Text = ""
Me.txtNombre.Focus()
End Sub
Private Sub C1TrueDBGrid1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles C1TrueDBGrid1.DoubleClick
'Recupera datos
Try
Me.txtNombre.Text = Me.C1TrueDBGrid1.Columns("Nombre").Value
Me.chkActivo.Checked = Me.C1TrueDBGrid1.Columns("Activo").Value
Me.txtClave.Text = Me.C1TrueDBGrid1.Columns("Clave").Value
Me.btnGuardar.Enabled = True ' habilita el botn de guardar
Catch ex As Exception
MessageBox.Show("Error PlazaCat; C1TrueDBGrid1_DoubleClick: " & ex.Message, "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub sbGuardar()
Dim lsMensaje As String
If MsgBox("<EFBFBD>Desea guardar los cambios?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "MINDS Cliente") = MsgBoxResult.No Then Exit Sub
If fbValidaGrabar() Then
lsMensaje = "Datos guardados correctamente"
'sbIniciaForma()
LlenaGrid()
Else
lsMensaje = "Los datos no fueron guardados"
End If
MsgBox(lsMensaje, MsgBoxStyle.Information + MsgBoxStyle.OKOnly, "Cliente")
End Sub
Private Function fbValidaGrabar() As Boolean
Dim liClave As Integer
Dim liClaveEstado As Integer
Dim liActivo As Integer
Dim lsNombre As String
Dim lsSQL As String
On Error GoTo eh
fbValidaGrabar = False
If cmbEstado.SelectedIndex = -1 Then
MsgBox("Estado no v<>lido", MsgBoxStyle.Information + MsgBoxStyle.OKOnly, "Cliente")
Exit Function
End If
If Len(txtClave.Text) = 0 Then
liClave = -1
Else
liClave = Val(txtClave.Text)
End If
liClaveEstado = cmbEstado.SelectedValue
liActivo = IIf(chkActivo.Checked, 1, 0)
lsNombre = txtNombre.Text.Trim
If Len(lsNombre.Trim) = 0 Then
MsgBox("Nombre no v<>lido", MsgBoxStyle.Information + MsgBoxStyle.OKOnly, "Cliente")
Exit Function
End If
lsSQL = ""
lsSQL = lsSQL & "spGrabaCatPlaza "
lsSQL = lsSQL & liClave & ", "
lsSQL = lsSQL & liClaveEstado & ", 17, '"
lsSQL = lsSQL & lsNombre & "', "
lsSQL = lsSQL & liActivo
clCmp.sbGuardaModifica(lsSQL)
Return True
Exit Function
eh:
Return False
End Function
Private Sub linkAlias_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles linkAlias.LinkClicked
If txtClave.Text <> "" Then
sbAlias()
Else
MessageBox.Show("Debe Selecionar un elemento", "Minds", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
End Sub
Private Sub sbAlias()
Dim miAlias As New ActAlias
miAlias.Entra(17, txtClave.Text.Trim) 'Se pasa el numero de catalogo y el Registro
miAlias.Text = "Alias Plaza"
miAlias.piCatalogo = 17
miAlias.Show()
End Sub
End Class