Commit inicial Ventas Productivo
This commit is contained in:
807
Planeacion/CatSubProyectos.aspx.vb
Normal file
807
Planeacion/CatSubProyectos.aspx.vb
Normal file
@@ -0,0 +1,807 @@
|
||||
Option Explicit On
|
||||
Option Strict On
|
||||
|
||||
Imports System.Data
|
||||
Imports Extensiones
|
||||
Imports System.IO
|
||||
Imports System.Data.OleDb
|
||||
|
||||
Partial Class CatSubProyectos
|
||||
Inherits ClsPaginas
|
||||
|
||||
#Region "P R O P I E D A D E S"
|
||||
Public Property DtSegmentosNegocio As Data.DataTable
|
||||
Get
|
||||
Return CType((ViewState("DtSegmentosNegocio")), Data.DataTable)
|
||||
End Get
|
||||
Set(value As Data.DataTable)
|
||||
ViewState("DtSegmentosNegocio") = value
|
||||
End Set
|
||||
End Property
|
||||
Public Property DTSubProyectos As Data.DataTable
|
||||
Get
|
||||
Return CType((ViewState("DTSubProyectos")), Data.DataTable)
|
||||
End Get
|
||||
Set(value As Data.DataTable)
|
||||
ViewState("DTSubProyectos") = value
|
||||
End Set
|
||||
End Property
|
||||
Private Property CveCentroCosto As Integer
|
||||
Get
|
||||
Return ViewState("CveCentroCosto").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("CveCentroCosto") = value
|
||||
End Set
|
||||
End Property
|
||||
#End Region
|
||||
|
||||
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
||||
If Not Page.IsPostBack Then
|
||||
ViewState("Orden") = ""
|
||||
|
||||
If Not UsuarioActual.Empresa.UsaRH Then
|
||||
GvDatos.Columns(2).Visible = False
|
||||
End If
|
||||
|
||||
|
||||
|
||||
Dim objsubproyecto As New ClsSubProyectos
|
||||
'If objsubproyecto.GetSubProyectosexcel(9, UsuarioActual.CveEmpresa) Then
|
||||
' 'DatatableToExcel(objsubproyecto.DtResultados)
|
||||
' objsubproyecto.DtResultados.ExportToExcel("subproyecto")
|
||||
'End If
|
||||
objsubproyecto.Dispose()
|
||||
|
||||
If Not UsuarioActual.Empresa.Tipo_CentroCosto = 3 Then
|
||||
'GvDatos.Columns(0).Visible = False
|
||||
'TdTituloProyecto.Visible = False
|
||||
'TdProyecto.Visible = False
|
||||
'LbSubProyecto.Text = "Proyecto"
|
||||
|
||||
GvDatos.Columns(2).Visible = False
|
||||
End If
|
||||
CargaProyecto()
|
||||
CargaSegmentosNegocio()
|
||||
|
||||
'COMERCIO EXTERIOR
|
||||
CargaPais()
|
||||
CargaEstado()
|
||||
CargaMunicipio()
|
||||
CargaColonia()
|
||||
|
||||
CargaPrecioLista()
|
||||
|
||||
CargaDatos()
|
||||
If UsuarioActual.Empresa.UsaContabilidad Then
|
||||
GvDatos.Columns(1).Visible = True
|
||||
DivSegmentoNegocio.Visible = True
|
||||
End If
|
||||
BtnGuardar.OnClientClick = $"ValidaGuardar();"
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub RecargaGlobal()
|
||||
Dim ObjSubProyectos As New ClsSubProyectos
|
||||
If ObjSubProyectos.GetSubProyectos() Then
|
||||
GlobalDTSubProyectos(-1) = ObjSubProyectos.DtResultados
|
||||
End If
|
||||
ObjSubProyectos.Dispose()
|
||||
End Sub
|
||||
|
||||
#Region "O R D E N A M I E N T O"
|
||||
Protected Sub LbOrden_Click(ByVal sender As Object, ByVal e As EventArgs)
|
||||
Dim Orden As String = ""
|
||||
Dim Campo As String = ""
|
||||
Dim Literal As Literal = Nothing
|
||||
Const OrdenInicial As String = ""
|
||||
Dim Arg(2) As String
|
||||
|
||||
Arg = CType(sender, LinkButton).CommandArgument().ToString.Split(";"c)
|
||||
Campo = Arg(0)
|
||||
Literal = CType(CType(sender, LinkButton).NamingContainer.FindControl("Img" & Campo.Replace(",", "_")), Literal)
|
||||
|
||||
If ViewState(String.Format("O{0}", Campo)) IsNot Nothing AndAlso ViewState(String.Format("O{0}", Campo)).ToString = String.Format("{0} DESC", Campo) Then
|
||||
ViewState(String.Format("O{0}", Campo)) = String.Format("{0} ASC", Campo)
|
||||
Literal.Text = String.Format("<i class='fa fa-sort-asc' style='color:#999' ></i>")
|
||||
Else
|
||||
ViewState(String.Format("O{0}", Campo)) = String.Format("{0} DESC", Campo)
|
||||
Literal.Text = String.Format("<i class='fa fa-sort-desc' style='color:#999' ></i>")
|
||||
End If
|
||||
Orden = OrdenInicial & ViewState(String.Format("O{0}", Campo)).ToString
|
||||
ViewState("Orden") = Orden
|
||||
CargaDatos()
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "C A R G A S"
|
||||
Public Sub CargaDatos()
|
||||
|
||||
Dim ObjSub As New ClsSubProyectos
|
||||
If ObjSub.GetSubProyectos() Then
|
||||
GvDatos.DataSource = ObjSub.DtResultados.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa}")
|
||||
GvDatos.DataBind()
|
||||
End If
|
||||
ObjSub.Dispose()
|
||||
UpDatos.Update()
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub CargaProyecto()
|
||||
DdlProyecto.DataSource = GlobalDTProyectos(UsuarioActual.CveEmpresa).FiltraParametros("", "", {"CveProyecto", "Proyecto"})
|
||||
DdlProyecto.DataBind()
|
||||
End Sub
|
||||
Private Sub CargaPrecioLista()
|
||||
DdlPrecioLista.DataSource = GlobalDTPrecioListas(UsuarioActual.CveEmpresa)
|
||||
DdlPrecioLista.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
||||
DdlPrecioLista.DataBind()
|
||||
End Sub
|
||||
|
||||
Private Sub CargaSegmentosNegocio()
|
||||
DdlSegmentoNegocio.Items.Clear()
|
||||
Dim Cuenta As New ClsContPAQi(UsuarioActual.Empresa)
|
||||
|
||||
If Cuenta.GetSegmentosNegocio(-1, "-1") Then
|
||||
|
||||
DtSegmentosNegocio = Cuenta.DtResultados.FiltraParametros("Id > 0")
|
||||
DtSegmentosNegocio.Rows.Add(New Object() {0, 0, " - ", "", ""})
|
||||
|
||||
Dim dataView As New DataView(DtSegmentosNegocio)
|
||||
dataView.Sort = "Id ASC"
|
||||
|
||||
DtSegmentosNegocio = dataView.ToTable
|
||||
|
||||
End If
|
||||
Cuenta.Dispose()
|
||||
DdlSegmentoNegocio.DataSource = DtSegmentosNegocio : DdlSegmentoNegocio.DataBind()
|
||||
DdlSegmentoNegocio.Items.Insert(0, New ListItem("-", "-1"))
|
||||
|
||||
For Each Gvr As GridViewRow In GvDatos.Rows
|
||||
'If Gvr.DataKey("IdSegNeg").ToEntero > 0 Then
|
||||
|
||||
' 'COMENTADO PORQUE TRUENA | IPP - 17 AGOSTO 2017
|
||||
' 'Dim Cuenta2 As New ClsContPAQi(UsuarioActual.Empresa)
|
||||
' 'If Cuenta2.GetSegmentosNegocio(Gvr.DataKey("IdSegNeg").ToEntero, "-1") Then
|
||||
' ' Dim DRES2 As DataRow
|
||||
' ' DRES2 = Cuenta2.DtResultados(0)
|
||||
' ' Gvr.Cells(1).Text = DRES2("Nombre").ToString
|
||||
' 'Else
|
||||
' ' Gvr.Cells(1).Text = "-"
|
||||
' 'End If
|
||||
' 'Cuenta2.Dispose()
|
||||
|
||||
' 'If DtSegmentosNegocio IsNot Nothing AndAlso DtSegmentosNegocio.Rows.Count > 0 Then
|
||||
' ' Dim dr As DataRow
|
||||
' ' dr = DtSegmentosNegocio.FiltroPrimero(String.Format("Id ={0}", Gvr.DataKey("IdSegNeg")))
|
||||
' ' Gvr.Cells(1).Text = dr("Nombre").ToString
|
||||
' 'End If
|
||||
|
||||
'Else
|
||||
' Gvr.Cells(1).Text = "0"
|
||||
'End If
|
||||
Next
|
||||
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
#Region "GV"
|
||||
Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
|
||||
ScriptManager.GetCurrent(Me).RegisterPostBackControl(e.Row.FCLinkButton("downExcel"))
|
||||
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
|
||||
e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Left
|
||||
|
||||
If e.Row.RowIndex > 0 AndAlso e.Row.Cells(1).Visible Then
|
||||
e.Row.Cells(1).Text = DtSegmentosNegocio.FiltroPrimeroValor("Nombre", $"Id = {e.Row.DataKey("IdSegNeg")}")
|
||||
End If
|
||||
|
||||
End If
|
||||
End Sub
|
||||
Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting
|
||||
Dim ObjSubProyectos As New ClsSubProyectos
|
||||
If ObjSubProyectos.RemoveSubProyecto(GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then
|
||||
GvDatos.EditIndex = -1
|
||||
ViewState("DTSubProyectos") = ObjSubProyectos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
||||
GlobalDTSubProyectos(-1) = ObjSubProyectos.DtResultados
|
||||
Alert("El SubProyecto se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
||||
End If
|
||||
|
||||
ObjSubProyectos.Dispose()
|
||||
|
||||
CargaDatos()
|
||||
End Sub
|
||||
Protected Sub GvDatos_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs)
|
||||
|
||||
If (e.CommandName = "AgregarSubProyecto") Then
|
||||
|
||||
Dim ObjContpaQ As New ClsContPAQi(UsuarioActual.Empresa)
|
||||
ObjContpaQ.IniciaTransacSQL()
|
||||
Dim ObjSubProyectos As New ClsSubProyectos
|
||||
ObjSubProyectos.IniciaTransacSQL()
|
||||
|
||||
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
|
||||
Dim row As GridViewRow = GvDatos.Rows(index)
|
||||
|
||||
Dim SubProyecto = GvDatos.Rows(index).DataKey("SubProyecto").ToString
|
||||
Dim CveSegmento As Integer = ObjContpaQ.AddSegmentosNegocio(SubProyecto)
|
||||
Dim CveSubProyecto As Integer = GvDatos.DataKeys(index).Value.ToString.ToEntero
|
||||
Dim ErrorSubProyecto As Boolean = False
|
||||
|
||||
If ObjSubProyectos.UpdateSubProyectoSegNeg(CveSubProyecto, CveSegmento, UsuarioActual.CveEmpresa) Then
|
||||
GvDatos.EditIndex = -1
|
||||
ViewState("DTSubProyectos") = ObjSubProyectos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
||||
GlobalDTSubProyectos(-1) = ObjSubProyectos.DtResultados
|
||||
Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion)
|
||||
Else
|
||||
ErrorSubProyecto = True
|
||||
End If
|
||||
|
||||
If CveSegmento > 0 AndAlso Not ErrorSubProyecto Then
|
||||
ObjContpaQ.Commit()
|
||||
ObjSubProyectos.Commit()
|
||||
|
||||
If ObjContpaQ.GetSegmentosNegocio(-1, "-1") Then
|
||||
DtSegmentosNegocio = ObjContpaQ.DtResultados.FiltraParametros("Id > 1")
|
||||
End If
|
||||
|
||||
CargaDatos()
|
||||
Else
|
||||
ObjContpaQ.RollBack()
|
||||
ObjSubProyectos.RollBack()
|
||||
End If
|
||||
|
||||
ObjSubProyectos.Dispose()
|
||||
ObjContpaQ.Dispose()
|
||||
|
||||
|
||||
End If
|
||||
|
||||
End Sub
|
||||
Public Sub Edit_Click(sender As Object, e As EventArgs)
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
CveCentroCosto = (GvRow.DataKey("CveSubProyecto")).ToEntero
|
||||
HdnModalidad.Value = "U"
|
||||
TxtCentroCosto.Text = (GvRow.DataKey("SubProyecto"))
|
||||
DdlSegmentoNegocio.SelectedValueExist(GvRow.DataKey("IdSegNeg"))
|
||||
ChkEstatus.Checked = If(GvRow.DataKey("Estatus").ToString = "Activo", True, False)
|
||||
DdlProyecto.SelectedValueExist(GvRow.DataKey("CveProyecto"))
|
||||
TxtSerie.Text = (GvRow.DataKey("Serie"))
|
||||
TxtIVA.Text = (GvRow.DataKey("IVA"))
|
||||
TxtCalle.Text = (GvRow.DataKey("Calle"))
|
||||
TxtNoExt.Text = (GvRow.DataKey("NoExt"))
|
||||
TxtNoInt.Text = (GvRow.DataKey("NoInt"))
|
||||
TxtColonia.Text = (GvRow.DataKey("Colonia"))
|
||||
TxtLocalidad.Text = (GvRow.DataKey("Localidad"))
|
||||
TxtMunicipio.Text = (GvRow.DataKey("Municipio"))
|
||||
TxtEstado.Text = (GvRow.DataKey("Estado"))
|
||||
TxtPais.Text = (GvRow.DataKey("Pais"))
|
||||
TxtCP.Text = (GvRow.DataKey("CP"))
|
||||
ChkEsMatriz.Checked = If(GvRow.DataKey("TipoSucursal").ToString.ToEntero = 1, True, False)
|
||||
ChkEsSucursal.Checked = If(GvRow.DataKey("EsSucursal").ToString.ToEntero = 1, True, False)
|
||||
DdlPrecioLista.SelectedIndex = 0
|
||||
DdlPrecioLista.SelectedValueExist(GvRow.DataKey("CvePrecioLista"))
|
||||
TxtCorreo.Text = (GvRow.DataKey("Correo"))
|
||||
TxtTelefono.Text = (GvRow.DataKey("Telefono"))
|
||||
|
||||
'COMERCIO EXTERIOR
|
||||
ChkAplicaComercioExterior.Checked = If(GvRow.DataKey("AplicaComercioExterior").ToString = "True", True, False)
|
||||
DdlPais.SelectedValueExist(GvRow.DataKey("CvePais"))
|
||||
CargaEstado()
|
||||
DdlEstado.SelectedValueExist(GvRow.DataKey("CveEstado"))
|
||||
CargaMunicipio()
|
||||
DdlMunicipio.SelectedValueExist(GvRow.DataKey("CveMunicipio"))
|
||||
CargaColonia()
|
||||
DdlColonia.SelectedValueExist(GvRow.DataKey("CveColonia"))
|
||||
AplicaComercio()
|
||||
|
||||
BtnGuardar.Text = "Actualizar"
|
||||
CargaRequired()
|
||||
UpAddCentroEstatus.Update()
|
||||
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarCentroCosto"))
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
#Region "G U A R D A R"
|
||||
|
||||
Private Function ValidaComercioExterior() As Boolean
|
||||
If ChkAplicaComercioExterior.Checked Then
|
||||
If Not DdlPais.SelectedValue.ToEntero > 0 Then
|
||||
Alert("Tiene que seleccionar un pais para comercio exterior.", TipoMensaje.MsgAdvertencia)
|
||||
Return False
|
||||
End If
|
||||
|
||||
If Not DdlPais.SelectedValue.ToEntero > 0 Then
|
||||
Alert("Tiene que seleccionar un pais para comercio exterior.", TipoMensaje.MsgAdvertencia)
|
||||
Return False
|
||||
End If
|
||||
|
||||
If Not DdlEstado.SelectedValue.ToEntero > 0 Then
|
||||
Alert("Tiene que seleccionar un estado para comercio exterior.", TipoMensaje.MsgAdvertencia)
|
||||
Return False
|
||||
End If
|
||||
|
||||
If DdlPais.SelectedValue.ToEntero = 151 Then
|
||||
If Not DdlMunicipio.SelectedValue.ToEntero > 0 Then
|
||||
Alert("Tiene que seleccionar un municipio para comercio exterior si el pais es mexico.", TipoMensaje.MsgAdvertencia)
|
||||
Return False
|
||||
End If
|
||||
|
||||
If Not DdlColonia.SelectedValue.ToEntero > 0 Then
|
||||
Alert("Tiene que seleccionar una colonia para comercio exterior si el pais es mexico.", TipoMensaje.MsgAdvertencia)
|
||||
Return False
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click
|
||||
If Not ValidaComercioExterior() Then
|
||||
Exit Sub
|
||||
End If
|
||||
CreaProyectoSubProyectoSucursal()
|
||||
End Sub
|
||||
Private Sub CreaProyectoSubProyectoSucursal()
|
||||
Dim ObjSubproyectos As New ClsSubProyectos
|
||||
Dim CveUsuarioNomina As Integer = Nothing
|
||||
Dim CveSubProyecto = -1
|
||||
Dim TieneError = False
|
||||
Dim TipoSucursal As Integer
|
||||
Dim EsSucursal As Integer
|
||||
If ChkEsMatriz.Checked = True Then TipoSucursal = 1 Else TipoSucursal = 0
|
||||
If ChkEsSucursal.Checked = True Then EsSucursal = 1 Else EsSucursal = 0
|
||||
'GlobalDTProyectos(-1) = ObjSubproyectos.DtResultados
|
||||
ObjSubproyectos.IniciaTransacSQL()
|
||||
Dim IdSeg As Integer
|
||||
If DdlSegmentoNegocio.Visible = True Then IdSeg = DdlSegmentoNegocio.SelectedValue.ToEntero Else IdSeg = 0
|
||||
|
||||
'CREA SUBPROYECTO
|
||||
If HdnModalidad.Value = "I" Then
|
||||
If Not ObjSubproyectos.AddCentroCosto(TxtCentroCosto.Text.Trim, IdSeg, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, DdlProyecto.SelectedValue.ToEntero, Serie:=TxtSerie.Text.Trim, IVA:=TxtIVA.Text.ToDecimal, Calle:=TxtCalle.Text.Trim, NoExt:=TxtNoExt.Text.Trim,
|
||||
NoInt:=TxtNoInt.Text.Trim, Colonia:=TxtColonia.Text.Trim, Localidad:=TxtLocalidad.Text.Trim, Municipio:=TxtMunicipio.Text.Trim, Estado:=TxtEstado.Text.Trim, Pais:=TxtPais.Text.Trim, CP:=TxtCP.Text.Trim, TipoSucursal:=TipoSucursal, EsSucursal:=EsSucursal,
|
||||
CvePais:=DdlPais.SelectedValue.ToEntero, CveEstado:=DdlEstado.SelectedValue.ToEntero, CveMunicipio:=DdlMunicipio.SelectedValue.ToEntero, CveColonia:=DdlColonia.SelectedValue.ToEntero, AplicaComercioExterior:=ChkAplicaComercioExterior.Checked, Correo:=TxtCorreo.Text, CvePrecioLista:=DdlPrecioLista.SelectedValue.ToEntero,
|
||||
Telefono:=TxtTelefono.Text) Then
|
||||
TieneError = True
|
||||
Else
|
||||
CveSubProyecto = ObjSubproyectos.CveSubProyecto
|
||||
End If
|
||||
Else
|
||||
If Not ObjSubproyectos.UpdateCentroCosto(CveCentroCosto, TxtCentroCosto.Text.Trim, IdSeg, If(ChkEstatus.Checked = True, 1, 0), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, DdlProyecto.SelectedValue.ToEntero, Serie:=TxtSerie.Text.Trim, IVA:=TxtIVA.Text.ToDecimal, Calle:=TxtCalle.Text.Trim, NoExt:=TxtNoExt.Text.Trim,
|
||||
NoInt:=TxtNoInt.Text.Trim, Colonia:=TxtColonia.Text.Trim, Localidad:=TxtLocalidad.Text.Trim, Municipio:=TxtMunicipio.Text.Trim, Estado:=TxtEstado.Text.Trim, Pais:=TxtPais.Text.Trim, CP:=TxtCP.Text.Trim, TipoSucursal:=TipoSucursal, EsSucursal:=EsSucursal,
|
||||
CvePais:=DdlPais.SelectedValue.ToEntero, CveEstado:=DdlEstado.SelectedValue.ToEntero, CveMunicipio:=DdlMunicipio.SelectedValue.ToEntero, CveColonia:=DdlColonia.SelectedValue.ToEntero, AplicaComercioExterior:=ChkAplicaComercioExterior.Checked, Correo:=TxtCorreo.Text, CvePrecioLista:=DdlPrecioLista.SelectedValue.ToEntero,
|
||||
Telefono:=TxtTelefono.Text) Then
|
||||
TieneError = True
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
|
||||
If Not TieneError Then
|
||||
ObjSubproyectos.Commit()
|
||||
If HdnModalidad.Value = "I" Then
|
||||
Alert("La nueva Sucursal se guardó correctamente.", TipoMensaje.MsgInformacion)
|
||||
Else
|
||||
Alert("La Sucursal se actualizo correctamente.", TipoMensaje.MsgInformacion)
|
||||
End If
|
||||
|
||||
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarCentroCosto"))
|
||||
CargaDatos()
|
||||
RecargaGlobal()
|
||||
Else
|
||||
ObjSubproyectos.RollBack()
|
||||
End If
|
||||
|
||||
'se regeneran los subproyectos
|
||||
'If Not TieneError Then
|
||||
' If UsuarioActual.Empresa.GralSoloProyecto Then
|
||||
' If ObjSubproyectos.GetSubProyectos() Then
|
||||
' GlobalDTSubProyectos(-1) = ObjSubproyectos.DtResultados
|
||||
' UpDatos.Update()
|
||||
' Else
|
||||
' TieneError = True
|
||||
' End If
|
||||
' End If
|
||||
'End If
|
||||
If DdlSegmentoNegocio.Visible = True Then
|
||||
CargaSegmentosNegocio()
|
||||
End If
|
||||
ObjSubproyectos.Dispose()
|
||||
|
||||
If HdnModalidad.Value = "I" Then
|
||||
If UsuarioActual.Empresa.Funcionalidad(523) <> "" Then
|
||||
Dim ObjOC As New ClsOC
|
||||
ObjOC.IniciaTransacSQL()
|
||||
Dim CveUsuario As Integer
|
||||
Dim CveEstatus As Integer
|
||||
Dim ArregloUsuarios As String() = UsuarioActual.Empresa.Funcionalidad(523).ToString.Split(","c)
|
||||
Dim YaExiste As Boolean = False
|
||||
Dim DTEstatus As DataTable = GlobalDTOCEstatus(UsuarioActual.CveEmpresa).FiltraParametros("TipoTermino IN (1, 2)")
|
||||
|
||||
For Each item In ArregloUsuarios
|
||||
CveUsuario = item.ToString.ToEntero
|
||||
For Each row As DataRow In DTEstatus.Rows
|
||||
CveEstatus = row("CveEstatus").ToString.ToEntero
|
||||
If Not ObjOC.AddEstatusUsuarios(CveEstatus, CveSubProyecto, CveUsuario, True, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
||||
YaExiste = True
|
||||
End If
|
||||
Next
|
||||
Next
|
||||
|
||||
If YaExiste Then
|
||||
ObjOC.RollBack()
|
||||
Else
|
||||
ObjOC.Commit()
|
||||
End If
|
||||
|
||||
|
||||
ObjOC.Dispose()
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
#Region "E X C E L"
|
||||
Protected Sub downExcel_Click(sender As Object, e As EventArgs)
|
||||
Dim Gvr As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
'TxtApellidoPaterno.Text = Gvr.DataKey("APaterno")
|
||||
Dim subproyecto As Integer
|
||||
Try
|
||||
subproyecto = Gvr.DataKey("CveSubProyecto").ToEntero
|
||||
Catch ex As Exception
|
||||
subproyecto = 0
|
||||
End Try
|
||||
If subproyecto > 0 Then
|
||||
Dim objsubproyecto As New ClsSubProyectos
|
||||
If objsubproyecto.GetSubProyectosexcel(subproyecto, UsuarioActual.CveEmpresa) Then
|
||||
'DatatableToExcel(objsubproyecto.DtResultados)
|
||||
objsubproyecto.DtResultados.ExportToExcel("subproyecto")
|
||||
End If
|
||||
objsubproyecto.Dispose()
|
||||
End If
|
||||
End Sub
|
||||
Protected Sub UpExcel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles UpExcel.Click
|
||||
If (FileUpload1.HasFile AndAlso IO.Path.GetExtension(FileUpload1.FileName) = ".xlsx") Then
|
||||
Dim FileName As String = Path.GetFileName(FileUpload1.PostedFile.FileName)
|
||||
Dim Extension As String = Path.GetExtension(FileUpload1.PostedFile.FileName)
|
||||
Dim FolderPath As String = Request.ApplicationPath + "Temp\"
|
||||
Dim FilePath As String = Server.MapPath(FolderPath + FileName)
|
||||
FileUpload1.SaveAs(FilePath)
|
||||
|
||||
Dim DTExcel As New Data.DataTable
|
||||
Dim conn As Odbc.OdbcConnection = Nothing
|
||||
Dim ErrorExcel = False
|
||||
Try
|
||||
|
||||
conn = New Odbc.OdbcConnection("Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" & FilePath & ";")
|
||||
conn.Open()
|
||||
Dim cmd = conn.CreateCommand()
|
||||
cmd.CommandType = CommandType.Text
|
||||
cmd.CommandText = "SELECT * FROM [subproyecto$]"
|
||||
|
||||
Dim da = New Odbc.OdbcDataAdapter(cmd)
|
||||
da.Fill(DTExcel)
|
||||
Dim objsubproyectos As New ClsSubProyectos
|
||||
Dim objcontpaqi As New ClsContPAQi(UsuarioActual.Empresa)
|
||||
Dim resultado As Boolean = False
|
||||
|
||||
Dim DTError As New DataTable
|
||||
|
||||
'COLUMNAS DEL REPORTE (GRID)
|
||||
DTError.Columns.Add("Fila", GetType(String))
|
||||
DTError.Columns.Add("Clasificacion", GetType(String))
|
||||
DTError.Columns.Add("SubProyecto", GetType(String))
|
||||
DTError.Columns.Add("CuentaGasto", GetType(String))
|
||||
DTError.Columns.Add("CuentaAnticipo", GetType(String))
|
||||
DTError.Columns.Add("CuentaInventario", GetType(String))
|
||||
Dim hayerrorcol As Boolean = False
|
||||
Dim errores As String = "<table> <tr style=""color:#FFFFCC;background-color:orange;font-weight:bold;""><td style='width:250px'>Clasificación</td><td style='width:250px'>SubProyecto</td><td>CuentaGasto</td><td>CuentaAnticipo</td><td>CuentaInventario</td></tr>"
|
||||
Dim mensajea As String = "el Archivo se cargado Correctamente"
|
||||
For index As Integer = 0 To DTExcel.Rows.Count - 1
|
||||
Dim CveClasificacion As Integer = DTExcel.Rows(index)("CveClasificacion").ToString.ToEntero
|
||||
Dim CveSubProyecto As Integer = DTExcel.Rows(index)("CveSubProyecto").ToString.ToEntero
|
||||
Dim idcuentagasto As Integer = -1
|
||||
Dim idcuentaanticipo As Integer = -1
|
||||
Dim idcuentaInventario As Integer = -1
|
||||
Dim namecuentagasto As String = ""
|
||||
Dim namecuentaanticipo As String = ""
|
||||
Dim namecuentaInventario As String = ""
|
||||
Dim cuentagasto As String = DTExcel.Rows(index)("CuentaGasto").ToString
|
||||
cuentagasto = (cuentagasto.ToString.Trim.Replace("-", ""))
|
||||
Dim cuentaanticipo As String = DTExcel.Rows(index)("CuentaAnticipo").ToString
|
||||
cuentaanticipo = (cuentaanticipo.ToString.Trim.Replace("-", ""))
|
||||
Dim cuentaInventario As String = DTExcel.Rows(index)("CuentaInventario").ToString
|
||||
cuentaInventario = (cuentaInventario.ToString.Trim.Replace("-", ""))
|
||||
Dim NEcuentagasto As Boolean = False
|
||||
Dim NEcuentaanticipo As Boolean = False
|
||||
Dim NEcuentaInventario As Boolean = False
|
||||
If (Not (cuentagasto Is Nothing)) AndAlso cuentagasto.Length > 4 Then
|
||||
If objcontpaqi.GetCuentas(-1, cuentagasto, -1, 1) Then
|
||||
If objcontpaqi.DtResultados.Rows.Count > 0 Then
|
||||
idcuentagasto = objcontpaqi.DtResultados.Rows(0)("Id").ToString.ToEntero
|
||||
namecuentagasto = cuentagasto & " - " & objcontpaqi.DtResultados.Rows(0)("Nombre").ToString
|
||||
Else
|
||||
NEcuentagasto = True
|
||||
End If
|
||||
Else
|
||||
NEcuentagasto = True
|
||||
End If
|
||||
End If
|
||||
|
||||
If (Not (cuentaanticipo Is Nothing)) AndAlso cuentaanticipo.Length > 4 Then
|
||||
If objcontpaqi.GetCuentas(-1, cuentaanticipo, -1, 1) Then
|
||||
If objcontpaqi.DtResultados.Rows.Count > 0 Then
|
||||
idcuentaanticipo = objcontpaqi.DtResultados.Rows(0)("Id").ToString.ToEntero
|
||||
namecuentaanticipo = cuentaanticipo & " - " & objcontpaqi.DtResultados.Rows(0)("Nombre").ToString
|
||||
Else
|
||||
NEcuentaanticipo = True
|
||||
End If
|
||||
Else
|
||||
NEcuentaanticipo = True
|
||||
End If
|
||||
End If
|
||||
|
||||
If (Not (cuentaInventario Is Nothing)) AndAlso cuentaInventario.Length > 4 Then
|
||||
If objcontpaqi.GetCuentas(-1, cuentaInventario, -1, 1) Then
|
||||
If objcontpaqi.DtResultados.Rows.Count > 0 Then
|
||||
idcuentaInventario = objcontpaqi.DtResultados.Rows(0)("Id").ToString.ToEntero
|
||||
namecuentaInventario = cuentaInventario.ToString & " - " & objcontpaqi.DtResultados.Rows(0)("Nombre").ToString
|
||||
Else
|
||||
NEcuentaInventario = True
|
||||
End If
|
||||
Else
|
||||
NEcuentaInventario = True
|
||||
End If
|
||||
End If
|
||||
If (idcuentagasto > 0 Or idcuentaanticipo > 0 Or idcuentaInventario > 0) Then
|
||||
If objsubproyectos.UpdateSubProyectoExcel(UsuarioActual.CveEmpresa, CveClasificacion, CveSubProyecto, idcuentagasto, idcuentaanticipo, idcuentaInventario, namecuentagasto, namecuentaanticipo, namecuentaInventario) Then
|
||||
Else
|
||||
resultado = True
|
||||
End If
|
||||
End If
|
||||
If NEcuentagasto Or NEcuentaanticipo Or NEcuentaInventario Then
|
||||
hayerrorcol = True
|
||||
Dim Row As DataRow = Nothing
|
||||
Row = DTError.NewRow
|
||||
Row("Fila") = (index + 1).ToString
|
||||
Row("Clasificacion") = DTExcel.Rows(index)("Clasificacion").ToString
|
||||
Row("SubProyecto") = DTExcel.Rows(index)("SubProyecto").ToString
|
||||
Row("CuentaGasto") = If(NEcuentagasto, cuentagasto, "")
|
||||
Row("CuentaAnticipo") = If(NEcuentaanticipo, cuentaanticipo, "")
|
||||
Row("CuentaInventario") = If(NEcuentaInventario, cuentaInventario, "")
|
||||
DTError.Rows.Add(Row)
|
||||
mensajea = "<br/><br/> El Archivo ha sido Cargado Correctamente <br/><br/> se han omitido los Siguientes Registros"
|
||||
errores = String.Format("{0}<tr><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td></tr>", errores, Row("Clasificacion").ToString, Row("SubProyecto").ToString, Row("CuentaGasto").ToString, Row("CuentaAnticipo").ToString, Row("CuentaInventario").ToString)
|
||||
End If
|
||||
Next
|
||||
objcontpaqi.Dispose()
|
||||
objsubproyectos.Dispose()
|
||||
If resultado Then
|
||||
Alert("ocurrio un error al guardar los datos")
|
||||
Else
|
||||
Alert(mensajea & " <div style=""width:350px;height:200px;overflow:scroll"">" & errores & " </div>")
|
||||
End If
|
||||
'GridView1.Caption = Path.GetFileName("Lista de errores en carga")
|
||||
'GridView1.DataSource = DTError
|
||||
'GridView1.DataBind()
|
||||
Catch ex As Exception
|
||||
ErrorExcel = True
|
||||
Alert("Ocurrio un error al leer el Excel: " + ex.ToString, TipoMensaje.MsgError)
|
||||
End Try
|
||||
conn.Close()
|
||||
|
||||
Else
|
||||
Alert("No es un archivo de excel valido")
|
||||
End If
|
||||
End Sub
|
||||
Private Sub Import_To_Grid(ByVal FilePath As String, ByVal Extension As String, ByVal isHDR As String)
|
||||
Dim conStr As String = ""
|
||||
Select Case Extension
|
||||
Case ".xls"
|
||||
'Excel 97-03
|
||||
conStr = ConfigurationManager.ConnectionStrings("Excel03ConString") _
|
||||
.ConnectionString
|
||||
Exit Select
|
||||
Case ".xlsx"
|
||||
'Excel 07
|
||||
conStr = ConfigurationManager.ConnectionStrings("Excel07ConString") _
|
||||
.ConnectionString
|
||||
Exit Select
|
||||
End Select
|
||||
conStr = String.Format(conStr, FilePath, isHDR)
|
||||
|
||||
Dim connExcel As New OleDbConnection(conStr)
|
||||
Dim cmdExcel As New OleDbCommand()
|
||||
Dim oda As New OleDbDataAdapter()
|
||||
Dim dt As New DataTable()
|
||||
|
||||
cmdExcel.Connection = connExcel
|
||||
|
||||
'Get the name of First Sheet
|
||||
connExcel.Open()
|
||||
Dim dtExcelSchema As DataTable
|
||||
dtExcelSchema = connExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, Nothing)
|
||||
Dim SheetName As String = dtExcelSchema.Rows(0)("TABLE_NAME").ToString()
|
||||
connExcel.Close()
|
||||
|
||||
'Read Data from First Sheet
|
||||
connExcel.Open()
|
||||
cmdExcel.CommandText = "SELECT * From [" & SheetName & "]"
|
||||
oda.SelectCommand = cmdExcel
|
||||
oda.Fill(dt)
|
||||
connExcel.Close()
|
||||
|
||||
''Bind Data to GridView
|
||||
'GridView1.Caption = Path.GetFileName(FilePath)
|
||||
'GridView1.DataSource = dt
|
||||
'GridView1.DataBind()
|
||||
End Sub
|
||||
|
||||
Public Sub BtnAgregarCentroCosto_Click(sender As Object, e As EventArgs)
|
||||
CveCentroCosto = -1
|
||||
HdnModalidad.Value = "I"
|
||||
TxtCentroCosto.Text = ""
|
||||
ChkEstatus.Checked = True
|
||||
ChkEsMatriz.Checked = False
|
||||
ChkEsSucursal.Checked = False
|
||||
ChkAplicaComercioExterior.Checked = False
|
||||
TabComercioExterior.Visible = False
|
||||
|
||||
TxtSerie.Text = ""
|
||||
TxtIVA.Text = "0.16"
|
||||
TxtCalle.Text = ""
|
||||
TxtNoExt.Text = ""
|
||||
TxtNoInt.Text = ""
|
||||
TxtColonia.Text = ""
|
||||
TxtLocalidad.Text = ""
|
||||
TxtMunicipio.Text = ""
|
||||
TxtEstado.Text = ""
|
||||
TxtPais.Text = ""
|
||||
TxtCP.Text = ""
|
||||
TxtCorreo.Text = ""
|
||||
TxtTelefono.Text = ""
|
||||
|
||||
DdlPais.SelectedValueExist("-1")
|
||||
DdlPrecioLista.SelectedValueExist("-1")
|
||||
CargaEstado()
|
||||
CargaMunicipio()
|
||||
CargaColonia()
|
||||
|
||||
If UsuarioActual.Empresa.UsaContabilidad Then
|
||||
CargaSegmentosNegocio()
|
||||
End If
|
||||
|
||||
BtnGuardar.Text = "Agregar"
|
||||
UpAddCentroEstatus.Update()
|
||||
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarCentroCosto"))
|
||||
End Sub
|
||||
|
||||
Private Sub CargaRequired()
|
||||
If ChkEsSucursal.Checked = True Then
|
||||
RFVSerie.Enabled = True
|
||||
RFVIVA.Enabled = True
|
||||
RFVCalle.Enabled = True
|
||||
RFVNoExt.Enabled = True
|
||||
RFVColonia.Enabled = True
|
||||
RFVLocalidad.Enabled = True
|
||||
RFVMunicipio.Enabled = True
|
||||
RFVEstado.Enabled = True
|
||||
RFVPais.Enabled = True
|
||||
RFVCP.Enabled = True
|
||||
|
||||
RFVSerie.Visible = True
|
||||
RFVIVA.Visible = True
|
||||
RFVCalle.Visible = True
|
||||
RFVNoExt.Visible = True
|
||||
RFVColonia.Visible = True
|
||||
RFVLocalidad.Visible = True
|
||||
RFVMunicipio.Visible = True
|
||||
RFVEstado.Visible = True
|
||||
RFVPais.Visible = True
|
||||
RFVCP.Visible = True
|
||||
|
||||
Else
|
||||
RFVSerie.Enabled = False
|
||||
RFVIVA.Enabled = False
|
||||
RFVCalle.Enabled = False
|
||||
RFVNoExt.Enabled = False
|
||||
RFVColonia.Enabled = False
|
||||
RFVLocalidad.Enabled = False
|
||||
RFVMunicipio.Enabled = False
|
||||
RFVEstado.Enabled = False
|
||||
RFVPais.Enabled = False
|
||||
RFVCP.Enabled = False
|
||||
|
||||
RFVSerie.Visible = False
|
||||
RFVIVA.Visible = False
|
||||
RFVCalle.Visible = False
|
||||
RFVNoExt.Visible = False
|
||||
RFVColonia.Visible = False
|
||||
RFVLocalidad.Visible = False
|
||||
RFVMunicipio.Visible = False
|
||||
RFVEstado.Visible = False
|
||||
RFVPais.Visible = False
|
||||
RFVCP.Visible = False
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub ChkEsSucursal_CheckedChanged(sender As Object, e As EventArgs) Handles ChkEsSucursal.CheckedChanged
|
||||
CargaRequired()
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "COMERCIO EXTERIOR"
|
||||
|
||||
Private Sub CargaPais()
|
||||
DdlPais.DataSource = GlobalDTPais()
|
||||
DdlPais.DataBind()
|
||||
DdlPais.SelectedValueExist("151")
|
||||
End Sub
|
||||
|
||||
Private Sub CargaEstado()
|
||||
DdlEstado.Items.Clear()
|
||||
If DdlPais.SelectedValue.ToEntero > 0 Then
|
||||
DdlEstado.DataSource = GlobalDTEstado(GlobalDTPais.FiltraParametros($"CvePais = {DdlPais.SelectedValue.ToEntero}")(0)("ClaveSATPais").ToString)
|
||||
End If
|
||||
DdlEstado.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
||||
DdlEstado.DataBind()
|
||||
End Sub
|
||||
|
||||
Private Sub CargaMunicipio()
|
||||
DdlMunicipio.Items.Clear()
|
||||
If DdlEstado.SelectedValue.ToEntero > 0 Then
|
||||
DdlMunicipio.DataSource = GlobalDTMunicipio(GlobalDTEstado(GlobalDTPais.FiltraParametros($"CvePais = {DdlPais.SelectedValue.ToEntero}")(0)("ClaveSATPais").ToString).FiltraParametros($"CveEstado = {DdlEstado.SelectedValue.ToEntero}")(0)("ClaveSATEstado").ToString)
|
||||
End If
|
||||
DdlMunicipio.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
||||
DdlMunicipio.DataBind()
|
||||
End Sub
|
||||
|
||||
Private Sub CargaColonia()
|
||||
DdlColonia.Items.Clear()
|
||||
If DdlMunicipio.SelectedValue.ToEntero > 0 Then
|
||||
DdlColonia.DataSource = GlobalDTColonia(GlobalDTMunicipio(GlobalDTEstado(GlobalDTPais.FiltraParametros($"CvePais = {DdlPais.SelectedValue.ToEntero}")(0)("ClaveSATPais").ToString).FiltraParametros($"CveEstado = {DdlEstado.SelectedValue.ToEntero}")(0)("ClaveSATEstado").ToString).FiltraParametros($"CveMunicipio = {DdlMunicipio.SelectedValue.ToEntero}")(0)("ClaveSATMunicipio").ToString)
|
||||
End If
|
||||
DdlColonia.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
||||
DdlColonia.DataBind()
|
||||
End Sub
|
||||
|
||||
Protected Sub DdlPais_SelectedIndexChanged(sender As Object, e As EventArgs)
|
||||
CargaEstado()
|
||||
CargaMunicipio()
|
||||
CargaColonia()
|
||||
End Sub
|
||||
Protected Sub DdlEstado_SelectedIndexChanged(sender As Object, e As EventArgs)
|
||||
CargaMunicipio()
|
||||
CargaColonia()
|
||||
End Sub
|
||||
Protected Sub DdlMunicipio_SelectedIndexChanged(sender As Object, e As EventArgs)
|
||||
CargaColonia()
|
||||
End Sub
|
||||
|
||||
Protected Sub ChkAplicaComercioExterior_CheckedChanged(sender As Object, e As EventArgs)
|
||||
AplicaComercio()
|
||||
End Sub
|
||||
|
||||
Private Sub AplicaComercio()
|
||||
If ChkAplicaComercioExterior.Checked Then
|
||||
TabComercioExterior.Visible = True
|
||||
Else
|
||||
TabComercioExterior.Visible = False
|
||||
End If
|
||||
UpBodyCentroCosto.Update()
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user