Option Explicit On Option Strict On Imports System.Data Imports Extensiones Partial Class PopUpBuscarFolio Inherits ClsPaginas Private ReadOnly Property Ruta As String Get Return AppDomain.CurrentDomain.BaseDirectory & "Empresas\" & UsuarioActual.CveEmpresa & "\" 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 = 800 txtFechaI.Text = Now.AddMonths(-12).ToShortDateString 'RegistraScript("$get('tdContenido').style.height='500px'") CargaSubProyectos() CargaEstatus() CargaUsuarios() CargaNombreClientes() CargaClasificaciones() CargaPS(-1) 'CargaCodigoCliente() 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(CveEmpresa:=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("", 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("Seleccione el Producto", "-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 ObjVentas As New ClsVentas() 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 Serie = Array(0) Folio = Array(1).ToEntero 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 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) 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 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 'If e.Row.RowIndex = 0 Then ' e.Row.Cells(0).Width = Unit.Pixel(38) ' e.Row.Cells(1).Width = Unit.Pixel(65) ' e.Row.Cells(2).Width = Unit.Pixel(70) ' e.Row.Cells(3).Width = Unit.Pixel(250) ' 'e.Row.Cells(4).Width = Unit.Pixel(75) ' e.Row.Cells(4).Width = Unit.Pixel(75) ' e.Row.Cells(5).Width = Unit.Pixel(100) ' e.Row.Cells(6).Width = Unit.Pixel(100) 'End If e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Left 'e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Right e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Right Dim Liga As String = String.Format("", e.Row.DBCampo("CveVenta")) e.Row.FCLiteral("LtlTipo").Text = String.Format("
{0}{1}
", Liga, e.Row.DBCampo("TipoDocto")) e.Row.FCLiteral("LtlFolio").Text = String.Format("
{0}{1}
", Liga, e.Row.DBCampo("Folio")) e.Row.FCLiteral("LtlFecha").Text = String.Format("
{0}{1}
", Liga, e.Row.DBCampo("Fecha").ToDate.ToShortDateString) e.Row.FCLiteral("LtlNombre").Text = String.Format("
{0}{1}
", Liga, e.Row.DBCampo("Nombre")) 'e.Row.FCLiteral("LtlSubTotal").Text = Liga & e.Row.DBCampo("SubTotal").FormatoNumero & " " e.Row.FCLiteral("LtlTotal").Text = String.Format("
{0}{1}
", Liga, e.Row.DBCampo("Total").FormatoNumero) e.Row.FCLiteral("LtlSucursal").Text = String.Format("
{0}{1}
", Liga, e.Row.DBCampo("SubProyecto")) e.Row.FCLiteral("LtlEstatus").Text = String.Format("
{0}{1}
", Liga, e.Row.DBCampo("EstatusFactura")) e.Row.FCLiteral("LtlPedidoContrato").Text = String.Format("
{0}{1}
", Liga, e.Row.DBCampo("PedidoContrato")) If IO.File.Exists($"{Ruta}XML\{e.Row.DBCampo("TipoDocto")}\{e.Row.DBCampo("Folio")}.xml") Then e.Row.FCLiteral("LtlXML").Text = String.Format("
XML
", UsuarioActual.CveEmpresa, e.Row.DBCampo("TipoDocto"), e.Row.DBCampo("Folio")) Else e.Row.FCLiteral("LtlXML").Text = "
" End If If IO.File.Exists($"{Ruta}PDF\{e.Row.DBCampo("TipoDocto")}\{e.Row.DBCampo("Folio")}.pdf") Then e.Row.FCLiteral("LtlPDF").Text = String.Format("
PDF
", UsuarioActual.CveEmpresa, e.Row.DBCampo("TipoDocto"), e.Row.DBCampo("Folio")) Else e.Row.FCLiteral("LtlPDF").Text = "
" 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 End Class