Files
SIG/Ventas/PopUpBuscarFolio.aspx.vb
rakcsle 5a4e735812 Gdiaz
2025-01-02 11:20:06 -07:00

313 lines
15 KiB
VB.net

Option Explicit On
Option Strict On
Imports System.Data
Imports Extensiones
Partial Class PopUpBuscarFolio
Inherits ClsPaginas
Private ReadOnly Property Ruta As String
Get
Return UsuarioActual.Empresa.Ruta
End Get
End Property
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
If UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario.Contiene(77, 21) Then Response.Redirect("/Inicio.aspx")
CType(Me.Master, BaseMasterPage).EsPopup = True
CType(Me.Master, BaseMasterPage).PopupWidth = 850
txtFechaI.Text = NowADS().AddMonths(-12).ToShortDateString
'RegistraScript("$get('tdContenido').style.height='500px'")
'venta de pv, y gdiaz
If UsuarioActual.Empresa.Funcionalidad(109) = "1" OrElse UsuarioActual.Empresa.Funcionalidad(382) = "1" Then txtFechaI.Text = NowADS.ToShortDateString
CargaSubProyectos()
CargaEstatus()
CargaUsuarios()
CargaNombreClientes()
CargaClasificaciones()
CargaPS(-1)
'CargaCodigoCliente()
DdlVendedor.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa).FiltraParametros("VendedorTipo = 1")
DdlVendedor.DataBind()
RegistraScript($"$('#{TxtFolio.ClientID}').focus();", "A1")
End If
End Sub
Private Sub CargaNombreClientes()
DdlNombre.setEsWebService(True)
DdlNombre.Attributes.Add("data-metodo", "getcliente")
'DdlNombre.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa)
'DdlNombre.DataBind()
'DdlNombre.Items.Insert(0, New ListItem("Todos", "-1"))
End Sub
Private Sub CargaSubProyectos()
DdlSubProyecto.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1)
DdlSubProyecto.DataBind()
End Sub
Private Sub CargaUsuarios()
DdlUsuario.DataSource = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa)
DdlUsuario.DataBind()
End Sub
Private Sub CargaClasificaciones()
If UsuarioActual.Empresa.UsaAC Then
DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros(" Codigo = '' OR Codigo IS NULL ", Orderby:="Clasificacion")
Else
DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros("UsoClasificacion = 1", Orderby:="Clasificacion")
End If
'DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa)
DdlClasificacion.DataBind()
End Sub
Protected Sub DdlClasificacion_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlClasificacion.SelectedIndexChanged
CargaPS(DdlClasificacion.SelectedValue.ToEntero)
UPPS.Update()
End Sub
Private Sub CargaPS(CveClasificacion As Integer)
DdlPS.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1")
If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then
DdlPS.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacion.SelectedValue)
DdlPS.SelectedText = ""
DdlPS.SelectedValue = "-1"
Else
DdlPS.ddl.Items.Clear()
DdlPS.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacion)
DdlPS.ddl.DataBind()
DdlPS.ddl.Items.Insert(0, New ListItem("Todos", "-1"))
End If
End Sub
'Private Sub CargaCodigoCliente()
' DdlCodigoCliente.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltraParametros("Codigo <> ''")
' DdlCodigoCliente.DataBind()
'End Sub
Protected Sub BtnBuscar_Click(sender As Object, e As System.EventArgs) Handles BtnBuscar.Click
Dim Serie As String = "-1"
Dim Folio As Integer = -1
Dim Codigo As String = "-1"
Dim Cliente As String = "-1"
Dim FechaI As String = "-1"
Dim FechaF As String = "-1"
Dim FolioFiscal As String = "-1"
Dim PeidoContrato As String = "-1"
Dim OrdenCompra As String = "-1"
If TxtFolio.Text.Trim.Length = 0 Then
Serie = "-1"
Folio = -1
Else
Dim Array() As String = TxtFolio.Text.Trim.Split(CChar("-"))
If Array.Length >= 2 Then
If Array.Length = 2 Then
Serie = Array(0)
Folio = Array(1).ToEntero
End If
If Array.Length = 3 Then
Serie = Array(0) + "-" + Array(1)
Folio = Array(2).ToEntero
End If
Else
Serie = "-1"
Folio = TxtFolio.Text.Trim.ToEntero
End If
End If
Codigo = "-1" 'If(DdlCodigoCliente.SelectedValue.ToEntero > 0, DdlCodigoCliente.SelectedItem.ToString, "-1")
Cliente = If(DdlNombre.SelectedValue.ToEntero > 0, DdlNombre.SelectedValue, "-1")
FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.Trim(), "-1")
FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.Trim(), "-1")
FolioFiscal = If(TxtFolioFiscal.Text.Trim.Length = 0, "-1", TxtFolioFiscal.Text.Trim)
PeidoContrato = If(TxtPedidoContrato.Text.Length = 0, "-1", TxtPedidoContrato.Text.Trim)
OrdenCompra = If(TxtOrdenCompra.Text.Length = 0, "-1", TxtOrdenCompra.Text.Trim)
If ValidarUnFiltroSeleccionado() Then
Dim ObjVentas As New ClsVentas()
If ObjVentas.GetVentas(UsuarioActual.CveEmpresa, DdlTipoDocto.SelectedValue, Serie, Folio, Codigo, Cliente.ToEntero, DdlSubProyecto.SelectedValue.ToEntero,
DdlEstatusFactura.SelectedValue.ToEntero, DdlUsuario.SelectedValue.ToEntero, FechaI, FechaF, FolioFiscal, If(DdlSucursalCliente.Visible, DdlSucursalCliente.SelectedValue.ToEntero, -1),
DdlPS.SelectedValue.ToEntero, PedidoContrato:=PeidoContrato, OrdenCompra:=OrdenCompra, CveUsuarioConsulta:=UsuarioActual.CveUsuario, TopSelect:=100, CveVendedor:=DdlVendedor.SelectedValue.ToEntero) Then
If ObjVentas.DtResultados.Rows.Count > 0 Then
LtlTotalRegistros.Text = ObjVentas.DtResultados.Rows.Count.ToString.FormatoNumero(0)
GV.DataSource = ObjVentas.DtResultados
Else
LtlTotalRegistros.Text = "0"
GV.DataSource = Nothing
Alert("No se encontraron registros con los parámetros solicitados.", Extensiones.TipoMensaje.MsgAdvertencia)
End If
End If
ObjVentas.Dispose()
GV.DataBind()
UPDatos.Update()
TblBusqueda.Visible = True
Else
Alert("Asigne un valor a cualquiera de los filtros", TipoMensaje.MsgAdvertencia)
End If
End Sub
Protected Sub GV_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GV.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Left
'e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Right
e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Right
Dim Liga As String = String.Format("<a class='Texto' href='javascript:Ir(""{0}"");'>", e.Row.DBCampo("CveVenta"))
If UsuarioActual.CveEmpresa = 140 AndAlso e.Row.DBCampo("TipoDocto").Contiene("Rem") Then
Liga = String.Format("<a class='Texto' href='javascript:IrPV(""{0}"");'>", e.Row.DBCampo("CveVenta"))
End If
e.Row.FCLiteral("LtlTipo").Text = String.Format("<div style='width:22px;'>{0}{1}</a></div>", Liga, e.Row.DBCampo("TipoDocto"))
e.Row.FCLiteral("LtlFolio").Text = String.Format("<div class='truncate' style='width:95px;'>{0}{1}</a></div>", Liga, e.Row.DBCampo("Folio"))
e.Row.FCLiteral("LtlFecha").Text = String.Format("<div class='truncate' style='width:64px;'>{0}{1}</a></div>", Liga, e.Row.DBCampo("Fecha").ToDate.ToShortDateString)
e.Row.FCLiteral("LtlNombre").Text = String.Format("<div class='truncate' style='width:200px;'>{0}{1}</a></div>", Liga, e.Row.DBCampo("NombreComercial"))
'e.Row.FCLiteral("LtlSubTotal").Text = Liga & e.Row.DBCampo("SubTotal").FormatoNumero & "&nbsp;</a>"
e.Row.FCLiteral("LtlTotal").Text = String.Format("<div class='truncate' style='width:56px;'>{0}{1}</a></div>", Liga, e.Row.DBCampo("Total").FormatoNumero)
e.Row.FCLiteral("LtlMon").Text = String.Format("<div class='truncate' style='width:30px;'>{0}{1}</a></div>", Liga, e.Row.DBCampo("Abreviatura"))
e.Row.FCLiteral("LtlSucursal").Text = String.Format("<div class='truncate' style='width:80px;'>{0}{1}</a></div>", Liga, e.Row.DBCampo("SubProyecto"))
e.Row.FCLiteral("LtlEstatus").Text = String.Format("<div class='truncate' style='width:70px;'>{0}{1}</a></div>", Liga, e.Row.DBCampo("EstatusFactura"))
If IO.File.Exists($"{Ruta}XML\{e.Row.DBCampo("TipoDocto")}\{e.Row.DBCampo("Folio")}.xml") Then
e.Row.FCLiteral("LtlXML").Text = String.Format("<div class='truncate' style='width:20px;'><a class=""Texto"" target=""_blank"" href=""/Compras/PopUpVerFactura.aspx?TipoDocto={0}&File={1}.xml&TipoArchivo=XML""><i class='fa fa-code' style='font-weight:bold;'></i></a></div>", e.Row.DBCampo("TipoDocto"), e.Row.DBCampo("Folio"))
Else
e.Row.FCLiteral("LtlXML").Text = "<div class='truncate' style='width:20px;'></div>"
End If
If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then
If e.Row.DBCampo("TipoDocto") <> "Cot" AndAlso IO.File.Exists($"{Ruta}PDF\{e.Row.DBCampo("TipoDocto")}\{e.Row.DBCampo("Folio")}.pdf") Then
e.Row.FCLiteral("LtlPDF").Text = String.Format("<div class='truncate' style='width:20px;'><a class=""Texto"" target=""_blank"" href=""/Compras/PopUpVerFactura.aspx?TipoDocto={0}&File={1}.pdf&TipoArchivo=PDF""><i class='fa fa-file-pdf-o' style='font-weight: bold;'></i></a></div>", e.Row.DBCampo("TipoDocto"), e.Row.DBCampo("Folio"))
Else
e.Row.FCLiteral("LtlPDF").Text = "<div class='truncate' style='width:20px;'></div>"
End If
Else
If IO.File.Exists($"{Ruta}PDF\{e.Row.DBCampo("TipoDocto")}\{e.Row.DBCampo("Folio")}.pdf") Then
e.Row.FCLiteral("LtlPDF").Text = String.Format("<div class='truncate' style='width:20px;'><a class=""Texto"" target=""_blank"" href=""/Compras/PopUpVerFactura.aspx?TipoDocto={0}&File={1}.pdf&TipoArchivo=PDF""><i class='fa fa-file-pdf-o' style='font-weight: bold;'></i></a></div>", e.Row.DBCampo("TipoDocto"), e.Row.DBCampo("Folio"))
Else
e.Row.FCLiteral("LtlPDF").Text = "<div class='truncate' style='width:20px;'></div>"
End If
End If
End If
End Sub
'Private Sub DdlNombre_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlNombre.SelectedIndexChanged
' DdlSucursalCliente.Items.Clear()
' If DdlNombre.SelectedValue.ToEntero > 0 Then
' Dim ObjCliente As New ClsClientes()
' If ObjCliente.GetSucursales(DdlNombre.SelectedValue.ToEntero) Then
' DdlSucursalCliente.DataSource = ObjCliente.DtResultados
' If ObjCliente.DtResultados.Rows.Count > 0 Then
' LitSucursalCliente.Visible = True
' DdlSucursalCliente.Visible = True
' Else
' LitSucursalCliente.Visible = False
' DdlSucursalCliente.Visible = False
' End If
' Else
' DdlSucursalCliente.DataSource = Nothing
' LitSucursalCliente.Visible = False
' DdlSucursalCliente.Visible = False
' End If
' ObjCliente.Dispose()
' DdlSucursalCliente.Items.Insert(0, New ListItem("Todos", "-1"))
' DdlSucursalCliente.DataBind()
' UPFiltros.Update()
' End If
'End Sub
Protected Sub DdlNombre_selectedindexchange(sender As Object, e As EventArgs)
DdlSucursalCliente.Items.Clear()
If DdlNombre.SelectedValue.ToEntero > 0 Then
Dim ObjCliente As New ClsClientes()
If ObjCliente.GetSucursales(DdlNombre.SelectedValue.ToEntero) Then
DdlSucursalCliente.DataSource = ObjCliente.DtResultados
If ObjCliente.DtResultados.Rows.Count > 0 Then
'LitSucursalCliente.Visible = True
DdlSucursalCliente.Visible = True
Else
'LitSucursalCliente.Visible = False
DdlSucursalCliente.Visible = False
End If
Else
DdlSucursalCliente.DataSource = Nothing
'LitSucursalCliente.Visible = False
DdlSucursalCliente.Visible = False
End If
ObjCliente.Dispose()
DdlSucursalCliente.Items.Insert(0, New ListItem("Todos", "-1"))
DdlSucursalCliente.DataBind()
UPFiltros.Update()
End If
End Sub
Protected Sub DdlPS_selectedindexchange(sender As Object, e As EventArgs)
If DdlPS.SelectedValue.ToEntero > 0 Then
Dim PS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlPS.SelectedValue.ToEntero).FiltroPrimero("")
If PS IsNot Nothing Then
If DdlClasificacion.SelectedIndex = 0 Then
If PS("CveClasificacion").ToString IsNot Nothing Then
DdlClasificacion.SelectedValueExist(PS("CveClasificacion").ToString)
Else
Alert("El Productos/Servicio no tiene asignada una Clasificación.")
End If
End If
End If
End If
UPPS.Update()
End Sub
Protected Sub DdlTipoDocto_SelectedIndexChanged(sender As Object, e As EventArgs)
CargaEstatus()
End Sub
Private Sub CargaEstatus()
DdlEstatusFactura.Items.Clear()
If DdlTipoDocto.SelectedValue <> "-1" Then
DdlEstatusFactura.DataSource = GlobalDTEstatusFactura.FiltraParametros($"TipoDocto = '{DdlTipoDocto.SelectedValue}' OR ('Cot' = '{DdlTipoDocto.SelectedValue}' AND CveEstatusFactura = 2)")
Else
DdlEstatusFactura.DataSource = GlobalDTEstatusFactura
End If
DdlEstatusFactura.Items.Add(New ListItem("Todos", "-1"))
DdlEstatusFactura.DataBind()
End Sub
Private Function ValidarUnFiltroSeleccionado() As Boolean
'If DdlClasificacion.SelectedValue.ToEntero > 0 Then Return True
'If DdlTipoDocto.SelectedValue <> "-1" Then Return True
'If DdlSubProyecto.SelectedValue.ToEntero > 0 Then Return True
'If DdlEstatusFactura.SelectedValue.ToEntero > 0 Then Return True
'If DdlUsuario.SelectedValue.ToEntero > 0 Then Return True
'If DdlPS.SelectedValue.ToEntero > 0 Then Return True
'If TxtFolio.Text.Trim.Length > 0 Then Return True
'If DdlNombre.SelectedValue.ToEntero > 0 Then Return True
'If TxtFolioFiscal.Text.Trim.Length > 0 Then Return True
'If TxtPedidoContrato.Text.Length > 0 Then Return True
'If TxtOrdenCompra.Text.Length > 0 Then Return True
Return True
End Function
End Class