314 lines
12 KiB
VB.net
314 lines
12 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
|
|
|
|
Partial Class CatProyectos
|
|
Inherits ClsPaginas
|
|
|
|
'Private Property DTSucursales As DataTable
|
|
' Get
|
|
' Return CType(ViewState("DTSucursales"), DataTable)
|
|
' End Get
|
|
' Set(value As DataTable)
|
|
' ViewState("DTSucursales") = value
|
|
' End Set
|
|
'End Property
|
|
'Private Property CveSucursal As Integer
|
|
' Get
|
|
' If ViewState("CveSucursal") Is Nothing Then
|
|
' Return -1
|
|
' Else
|
|
' Return ViewState("CveSucursal").ToString.ToEntero
|
|
' End If
|
|
' End Get
|
|
' Set(value As Integer)
|
|
' ViewState("CveSucursal") = value
|
|
' End Set
|
|
'End Property
|
|
|
|
Private Property CveProyecto As Integer
|
|
Get
|
|
If ViewState("CveProyecto") Is Nothing Then
|
|
Return -1
|
|
Else
|
|
Return ViewState("CveProyecto").ToString.ToEntero
|
|
End If
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveProyecto") = value
|
|
End Set
|
|
End Property
|
|
|
|
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
|
|
|
|
If Not Page.IsPostBack Then
|
|
'ViewState("Orden") = ""
|
|
CargaDatos()
|
|
'CargaDDL()
|
|
|
|
'Permisos
|
|
'If UsuarioActual.TienePermisoProceso(39) Then LbAgregar.Enabled = True Else LbAgregar.Enabled = False
|
|
|
|
'Permiso Modificar
|
|
'If UsuarioActual.TienePermisoProceso(40) Then GvDatos.Columns(5).Visible = True Else GvDatos.Columns(5).Visible = False
|
|
|
|
'Permiso Eliminar
|
|
'If UsuarioActual.TienePermisoProceso(41) Then GvDatos.Columns(6).Visible = True Else GvDatos.Columns(6).Visible = False
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub CargaDatos()
|
|
Dim ObjProyectos As New ClsProyectos
|
|
If ObjProyectos.GetProyectos(1) Then
|
|
Application("GlobalDTProyectos") = ObjProyectos.DtResultados
|
|
GvDatos.DataSource = ObjProyectos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
GvDatos.DataBind()
|
|
End If
|
|
ObjProyectos.Dispose()
|
|
UpDatos.Update()
|
|
'se regeneran los subproyectos
|
|
'If UsuarioActual.Empresa.GralSoloProyecto Then CargaSuproyectos()
|
|
|
|
|
|
'If ViewState("Orden").ToString() <> String.Empty Then
|
|
' CargaGrid(ViewState("Orden").ToString(), 0)
|
|
'Else
|
|
' CargaGrid("", 0)
|
|
'End If
|
|
End Sub
|
|
|
|
Private Sub RecargaGlobal()
|
|
Dim ObjProyectos As New ClsProyectos
|
|
If ObjProyectos.GetProyectos(1) Then
|
|
GlobalDTProyectos(-1) = ObjProyectos.DtResultados
|
|
End If
|
|
ObjProyectos.Dispose()
|
|
End Sub
|
|
|
|
Private Sub CargaSuproyectos()
|
|
Dim ObjSubProyectos As New ClsSubProyectos
|
|
If ObjSubProyectos.GetSubProyectos() Then
|
|
GlobalDTSubProyectos(-1) = ObjSubProyectos.DtResultados
|
|
End If
|
|
|
|
ObjSubProyectos.Dispose()
|
|
End Sub
|
|
|
|
Protected Sub LbAgregar_Click(ByVal sender As Object, ByVal e As EventArgs) Handles LbAgregar.Click
|
|
Dim ObjProyectos As New ClsProyectos
|
|
'Dim ObjSubproyectos As New ClsSubProyectos(ObjProyectos.IniciaTransacSQL())
|
|
Dim TieneError = False
|
|
|
|
If HdnModalidadProyecto.Value = "A" Then
|
|
|
|
'Agregamos Proyecto
|
|
If Not ObjProyectos.AddProyecto(TxtProyecto.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1) Then
|
|
TieneError = True
|
|
End If
|
|
|
|
|
|
'If CveProyecto > 0 Then
|
|
' ViewState("DTProyectos") = ObjProyectos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
' GlobalDTProyectos(-1) = ObjProyectos.DtResultados
|
|
|
|
' 'Centro de Costos
|
|
' 'If UsuarioActual.Empresa.Tipo_CentroCosto = 1 Then
|
|
|
|
' ' Obtenemos Sucursal Matriz
|
|
' ' Dim CveSucursalMatriz = -1
|
|
' ' If GlobalDTSucursales().FiltraParametros(String.Format("CveEmpresa = {0} AND Sucursal = 'MATRIZ'")).Rows.Count = 1 Then
|
|
' ' CveSucursalMatriz = GlobalDTSucursales().FiltraParametros(String.Format("CveEmpresa = {0} AND Sucursal = 'MATRIZ'")).Rows(0)("CveSucursal").ToString.ToEntero
|
|
' ' Else
|
|
' ' TieneError = True
|
|
' ' End If
|
|
|
|
' ' Agregamos SubProyecto
|
|
' ' If Not TieneError Then
|
|
' ' If Not ObjSubproyectos.AddSubProyecto(CveProyecto, TxtProyecto.Text.Trim, 0, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveSucursalMatriz) Then
|
|
' ' TieneError = True
|
|
|
|
' ' End If
|
|
' ' End If
|
|
' 'End If
|
|
|
|
'Else
|
|
' TieneError = True
|
|
'End If
|
|
'se regeneran los subproyectos
|
|
'If Not TieneError Then
|
|
' If UsuarioActual.Empresa.GralSoloProyecto Then
|
|
' If ObjSubproyectos.GetSubProyectos() Then
|
|
' GlobalDTSubProyectos(-1) = ObjSubproyectos.DtResultados
|
|
' Else
|
|
' TieneError = True
|
|
' End If
|
|
' End If
|
|
'End If
|
|
If TieneError = False Then
|
|
'ObjProyectos.Commit()
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "ModalProyectos"))
|
|
Alert("El nuevo Proyecto se guardó correctamente.", TipoMensaje.MsgInformacion)
|
|
TxtProyecto.Text = ""
|
|
'TxtProyecto.Focus()
|
|
'DDLSucursal.SelectedValue = "-1"
|
|
CargaDatos()
|
|
'Else
|
|
' ObjProyectos.RollBack()
|
|
'If (ObjProyectos.GetProyectos()) Then
|
|
' Application("GlobalDTProyectos") = ObjProyectos.DtResultados.AsEnumerable
|
|
'End If
|
|
|
|
End If
|
|
ElseIf HdnModalidadProyecto.Value = "U" Then
|
|
'CveSucursal = DDLSucursal.SelectedValue.ToEntero
|
|
If ObjProyectos.UpdateProyecto(TxtProyecto.Text, True, UsuarioActual.CveUsuario, CveProyecto, -1) Then
|
|
'ViewState("DTProyectos") = ObjProyectos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
'GlobalDTProyectos(-1) = ObjProyectos.DtResultados
|
|
''se regeneran los subproyectos
|
|
'If UsuarioActual.Empresa.GralSoloProyecto Then CargaSuproyectos()
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "ModalProyectos"))
|
|
Alert("El Proyecto se actualizo correctamente.", TipoMensaje.MsgInformacion)
|
|
TxtProyecto.Text = ""
|
|
'TxtProyecto.Focus()
|
|
'DDLSucursal.SelectedValue = "-1"
|
|
CargaDatos()
|
|
'If (ObjProyectos.GetProyectos()) Then
|
|
' Application("GlobalDTProyectos") = ObjProyectos.DtResultados
|
|
'End If
|
|
End If
|
|
End If
|
|
|
|
|
|
|
|
ObjProyectos.Dispose()
|
|
|
|
If Not TieneError Then
|
|
RecargaGlobal()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
|
|
#Region "G V D A T O S"
|
|
Protected Sub GvDatos_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GvDatos.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.RowIndex <= 1 Then
|
|
e.Row.Cells(0).Width = Unit.Pixel(240)
|
|
e.Row.Cells(1).Width = Unit.Pixel(75)
|
|
e.Row.Cells(2).Width = Unit.Pixel(75)
|
|
e.Row.Cells(3).Width = Unit.Pixel(100)
|
|
e.Row.Cells(4).Width = Unit.Pixel(60)
|
|
e.Row.Cells(5).Width = Unit.Pixel(60)
|
|
|
|
End If
|
|
If e.Row.RowState = DataControlRowState.Alternate OrElse e.Row.RowState = DataControlRowState.Normal Then
|
|
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
|
|
End If
|
|
|
|
e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Center
|
|
e.Row.Cells(2).HorizontalAlign = HorizontalAlign.Center
|
|
e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Center
|
|
e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Center
|
|
e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Center
|
|
|
|
End If
|
|
|
|
'If e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then
|
|
' e.Row.FCDropDownList("DDLSucursalEdit").DataSource = DTSucursales
|
|
' e.Row.FCDropDownList("DDLSucursalEdit").DataBind()
|
|
' e.Row.FCDropDownList("DDLSucursalEdit").SelectedValue = e.Row.DataKey("CveSucursal")
|
|
|
|
'End If
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowEditing(ByVal sender As Object, ByVal e As GridViewEditEventArgs) Handles GvDatos.RowEditing
|
|
GvDatos.EditIndex = e.NewEditIndex
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs) Handles GvDatos.RowUpdating
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowDeleting(ByVal sender As Object, ByVal e As GridViewDeleteEventArgs) Handles GvDatos.RowDeleting
|
|
Dim TieneError = False
|
|
|
|
Dim ObjProyectos As New ClsProyectos
|
|
If ObjProyectos.RemoveProyecto(GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then
|
|
GvDatos.EditIndex = -1
|
|
ViewState("DTProyectos") = ObjProyectos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
Alert("El Proyecto se elimino correctamente.", TipoMensaje.MsgInformacion)
|
|
CargaDatos()
|
|
If UsuarioActual.Empresa.GralSoloProyecto Then CargaSuproyectos()
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
ObjProyectos.Dispose()
|
|
|
|
If Not TieneError Then
|
|
RecargaGlobal()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowCancelingEdit(ByVal sender As Object, ByVal e As GridViewCancelEditEventArgs) Handles GvDatos.RowCancelingEdit
|
|
GvDatos.EditIndex = -1
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "Ordenamiento"
|
|
Private Sub CargaGrid(ByVal Orden As String, gvi As Integer)
|
|
If Orden <> String.Empty Then
|
|
Dim DV As New DataView(CType(ViewState("DTProyectos"), DataTable), "", Orden, DataViewRowState.CurrentRows)
|
|
GvDatos.DataSource = DV.ToTable()
|
|
DV.Dispose()
|
|
Else
|
|
GvDatos.DataSource = CType(ViewState("DTProyectos"), DataTable)
|
|
End If
|
|
|
|
GvDatos.DataBind()
|
|
UpDatos.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
'Public Sub CargaDDL()
|
|
' Dim Objeto As New ClsSucursales
|
|
' If Objeto.GetSucursales(UsuarioActual.CveEmpresa) Then
|
|
' DTSucursales = Objeto.DtResultados
|
|
' DDLSucursal.DataSource = DTSucursales
|
|
' DDLSucursal.DataBind()
|
|
' DDLSucursal.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
' End If
|
|
' Objeto.Dispose()
|
|
'End Sub
|
|
|
|
Private Sub HlAgregarProyecto_Click(sender As Object, e As EventArgs) Handles HlAgregarProyecto.Click
|
|
TxtProyecto.Text = ""
|
|
'DDLSucursal.SelectedIndex = 0
|
|
LtlTituloModal.Text = "Agregar Proyecto"
|
|
LbAgregar.Text = "Agregar"
|
|
HdnModalidadProyecto.Value = "A"
|
|
UpModal.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "ModalProyectos"))
|
|
End Sub
|
|
|
|
Public Sub ActualizaProyecto(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
CveProyecto = GvRow.DataKey("CveProyecto").ToString.ToString.ToEntero
|
|
'CveSucursal = GvRow.DataKey("CveSucursal").ToString.ToEntero
|
|
TxtProyecto.Text = GvRow.DataKey("Proyecto").ToString
|
|
'DDLSucursal.SelectedValue = CveSucursal
|
|
HdnModalidadProyecto.Value = "U"
|
|
LtlTituloModal.Text = "Actualizar Proyecto"
|
|
LbAgregar.Text = "Actualizar"
|
|
UpModal.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "ModalProyectos"))
|
|
End Sub
|
|
|
|
End Class
|