Commit inicial Ventas Productivo
This commit is contained in:
283
Inventarios/RepNotasSinAlmacen.aspx.vb
Normal file
283
Inventarios/RepNotasSinAlmacen.aspx.vb
Normal file
@@ -0,0 +1,283 @@
|
||||
Imports System.Data
|
||||
Imports Extensiones
|
||||
Imports Microsoft.Reporting.WebForms
|
||||
|
||||
Partial Class RepNotasSinAlmacen
|
||||
Inherits ClsPaginas
|
||||
#Region "propiedades"
|
||||
|
||||
Private Property dt As DataTable
|
||||
Get
|
||||
Try
|
||||
dt = DirectCast(ViewState("dt"), DataTable)
|
||||
Return DirectCast(ViewState("dt"), DataTable)
|
||||
Catch ex As Exception
|
||||
Return Nothing
|
||||
End Try
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("dt") = value
|
||||
End Set
|
||||
End Property
|
||||
Public Property DtEquivalencias() As DataTable
|
||||
Get
|
||||
Return CType(ViewState("dtReporte"), DataTable)
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("dtReporte") = value
|
||||
End Set
|
||||
End Property
|
||||
Public Property FechaInicial As String
|
||||
Get
|
||||
Return ViewState("FechaInicial").ToString
|
||||
End Get
|
||||
Set(value As String)
|
||||
ViewState("FechaInicial") = value
|
||||
End Set
|
||||
End Property
|
||||
Public Property FechaFinal As String
|
||||
Get
|
||||
Return ViewState("FechaFinal").ToString
|
||||
End Get
|
||||
Set(value As String)
|
||||
ViewState("FechaFinal") = value
|
||||
End Set
|
||||
End Property
|
||||
Private Property DtNotasSinAlmacenVentas As DataTable
|
||||
Get
|
||||
Return DirectCast(ViewState("DtNotasSinAlmacenVentas"), DataTable)
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("DtNotasSinAlmacenVentas") = value
|
||||
End Set
|
||||
End Property
|
||||
Private Property DtNotasSinAlmacenCompras As DataTable
|
||||
Get
|
||||
Return DirectCast(ViewState("DtNotasSinAlmacenCompras"), DataTable)
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("DtNotasSinAlmacenCompras") = value
|
||||
End Set
|
||||
End Property
|
||||
#End Region
|
||||
|
||||
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
If Not IsPostBack Then
|
||||
|
||||
CargaCombos()
|
||||
'CargaDatos()
|
||||
CargaPermisos()
|
||||
End If
|
||||
End Sub
|
||||
Private Sub CargaPermisos()
|
||||
Dim TienePermisoImportes As Boolean = UsuarioActual.TienePermisoProceso(201)
|
||||
GvVentas.Columns(4).Visible = TienePermisoImportes
|
||||
GvCompras.Columns(3).Visible = TienePermisoImportes
|
||||
End Sub
|
||||
Private Sub CargaCombos()
|
||||
TxtFechaF.Text = Date.Now.ToShortDateString
|
||||
TxtFechaI.Text = Now.FirstDayOfMonth.ToShortDateString
|
||||
|
||||
DdlCliente.setEsWebService(True)
|
||||
DdlCliente.Attributes.Add("data-metodo", "getcliente")
|
||||
DdlCliente.SelectedText = "Todos"
|
||||
DdlCliente.SelectedValue = "-1"
|
||||
|
||||
DdlProveedor.setEsWebService(True)
|
||||
DdlProveedor.Attributes.Add("data-metodo", "getproveedores")
|
||||
DdlProveedor.SelectedText = "Todos"
|
||||
DdlProveedor.SelectedValue = "-1"
|
||||
|
||||
'DdlSucursal.DataSource = GlobalDTSucursales(UsuarioActual.CveEmpresa)
|
||||
'DdlSucursal.DataBind()
|
||||
|
||||
DdlSubProyecto.Items.Clear()
|
||||
DdlSubProyecto.SelectedValue = Nothing
|
||||
DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa, Estatus:=1)
|
||||
DdlSubProyecto.DataBind()
|
||||
|
||||
DdlSubProyecto.Items.Insert(0, New ListItem("Sin SubProyecto Asignado", "-1"))
|
||||
End Sub
|
||||
|
||||
Protected Sub btConsultar_Click(sender As Object, e As EventArgs) Handles btConsultar.Click
|
||||
CargaDatos()
|
||||
End Sub
|
||||
|
||||
Private Sub CargaDatos()
|
||||
Dim Reporte As New ClsInventarios
|
||||
Dim CveClienteProveedor As Integer = -1
|
||||
|
||||
Dim TipoDocumento As String = DdlTipoDocto1.SelectedValue
|
||||
Dim Opcion As Integer = 1
|
||||
|
||||
FechaInicial = If(TxtFechaI.Text.Trim <> "" AndAlso TxtFechaI.Text <> "__/__/____", TxtFechaI.Text.ToDate, MinFecha)
|
||||
FechaFinal = If(TxtFechaF.Text.Trim <> "" AndAlso TxtFechaF.Text <> "__/__/____", TxtFechaF.Text.ToDate.AddDays(1), MaxFecha)
|
||||
|
||||
If Tab.ActiveTabIndex = 0 Then
|
||||
'Ventas
|
||||
If Not DdlCliente.SelectedValue.ToEntero > 0 Then
|
||||
CveClienteProveedor = -1
|
||||
Else
|
||||
CveClienteProveedor = DdlCliente.SelectedValue.ToEntero
|
||||
End If
|
||||
|
||||
If Reporte.RepNotasSinAlmacen(Opcion, CveClienteProveedor, FechaInicial, FechaFinal, TipoDocumento, DdlSubProyecto.SelectedValue.ToEntero, UsuarioActual.Empresa.CveEmpresa) Then
|
||||
GvVentas.DataSource = Reporte.DtResultados
|
||||
DtNotasSinAlmacenVentas = Reporte.DtResultados
|
||||
Else
|
||||
GvVentas.DataSource = Nothing
|
||||
End If
|
||||
|
||||
GvVentas.DataBind()
|
||||
|
||||
'If (GvVentas.Rows.Count > 0) Then
|
||||
' GvVentas.UseAccessibleHeader = True
|
||||
' GvVentas.HeaderRow.TableSection = TableRowSection.TableHeader
|
||||
' RegistraScript("OrdenarGvVentas();")
|
||||
'End If
|
||||
Else
|
||||
'Compras
|
||||
If Not DdlProveedor.SelectedValue.ToEntero > 0 Then
|
||||
CveClienteProveedor = -1
|
||||
Else
|
||||
CveClienteProveedor = DdlProveedor.SelectedValue.ToEntero
|
||||
End If
|
||||
|
||||
If Reporte.RepNotasSinAlmacen(2, CveClienteProveedor, FechaInicial, FechaFinal, DdlTipoDocto2.SelectedValue.ToEntero, -1, UsuarioActual.Empresa.CveEmpresa) Then
|
||||
GvCompras.DataSource = Reporte.DtResultados
|
||||
DtNotasSinAlmacenCompras = Reporte.DtResultados
|
||||
Else
|
||||
GvCompras.DataSource = Nothing
|
||||
End If
|
||||
|
||||
GvCompras.DataBind()
|
||||
|
||||
'If (GvCompras.Rows.Count > 0) Then
|
||||
' GvCompras.UseAccessibleHeader = True
|
||||
' GvCompras.HeaderRow.TableSection = TableRowSection.TableHeader
|
||||
' RegistraScript("OrdenarGvCompras();")
|
||||
'End If
|
||||
End If
|
||||
|
||||
UpDatosGvVentas.Update()
|
||||
UpDatosGvCompras.Update()
|
||||
Reporte.Dispose()
|
||||
End Sub
|
||||
|
||||
|
||||
Protected Sub Tab_ActiveTabChanged(sender As Object, e As EventArgs)
|
||||
DivCliente1.Visible = False
|
||||
DivCliente2.Visible = False
|
||||
DivProveedor1.Visible = False
|
||||
DivProveedor2.Visible = False
|
||||
DivTipoDoctoVenta.Visible = False
|
||||
DivTipoDocto1.Visible = False
|
||||
DivTipoDoctoCompra.Visible = False
|
||||
DivTipoDoctoCompra2.Visible = False
|
||||
DivSubProyecto.Visible = True
|
||||
DivSubProyecto2.Visible = True
|
||||
|
||||
|
||||
If Tab.ActiveTabIndex = 0 Then
|
||||
DivCliente1.Visible = True
|
||||
DivCliente2.Visible = True
|
||||
DivTipoDoctoVenta.Visible = True
|
||||
DivTipoDocto1.Visible = True
|
||||
DivSubProyecto.Visible = True
|
||||
DivSubProyecto2.Visible = True
|
||||
Else
|
||||
DivProveedor1.Visible = True
|
||||
DivProveedor2.Visible = True
|
||||
DivTipoDoctoCompra.Visible = True
|
||||
DivTipoDoctoCompra2.Visible = True
|
||||
|
||||
End If
|
||||
|
||||
UpFiltros.Update()
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
#Region " EXPORTAR - PDF - EXCEL "
|
||||
Private Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click
|
||||
ImprimirPDFExcel("Excel")
|
||||
End Sub
|
||||
|
||||
#Region "P D F"
|
||||
Private Sub LinkPDF_Click(sender As Object, e As EventArgs) Handles LinkPDF.Click
|
||||
ImprimirPDFExcel()
|
||||
End Sub
|
||||
|
||||
Private Sub ImprimirPDFExcel(Optional Formato As String = "PDF")
|
||||
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
|
||||
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
|
||||
|
||||
'OBTENEMOS LOS DATOS
|
||||
'Dim CveCliente As Integer = -1
|
||||
|
||||
'If DdlCliente.SelectedIndex = 0 Then
|
||||
' CveCliente = -1
|
||||
'Else
|
||||
' CveCliente = DdlCliente.SelectedValue.ToEntero
|
||||
|
||||
'End If
|
||||
|
||||
|
||||
FechaInicial = If(TxtFechaI.Text.Trim <> "" AndAlso TxtFechaI.Text <> "__/__/____", TxtFechaI.Text.ToDate, MinFecha)
|
||||
FechaFinal = If(TxtFechaF.Text.Trim <> "" AndAlso TxtFechaF.Text <> "__/__/____", TxtFechaF.Text.ToDate.AddDays(1), MaxFecha)
|
||||
Dim Filtros As String = ""
|
||||
|
||||
If Tab.ActiveTabIndex = 0 Then
|
||||
Filtros = "<b>Filtros:</b> " & " cliente: " & DdlCliente.SelectedText & ", Tipo: " & DdlTipoDocto1.SelectedItem.Text & ", Fecha I: " & TxtFechaI.Text & " Fecha F: " & TxtFechaF.Text
|
||||
Else
|
||||
Filtros = "<b>Filtros:</b> " & " cliente: " & DdlCliente.SelectedText & ", Tipo: " & DdlTipoDocto2.SelectedItem.Text & ", Fecha I: " & TxtFechaI.Text & " Fecha F: " & TxtFechaF.Text
|
||||
End If
|
||||
'If Reporte.RepNotasSinAlmacen(1, CveCliente, FechaInicial, FechaFinal, 1, 1, UsuarioActual.Empresa.CveEmpresa) Then
|
||||
' rpt = Reporte.DtResultados
|
||||
'Else
|
||||
' rpt = Nothing
|
||||
'End If
|
||||
|
||||
|
||||
Dim params As New List(Of ReportParameter)
|
||||
|
||||
params.Add(New ReportParameter("AgrupadoPor", Filtros))
|
||||
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
||||
params.Add(New ReportParameter("RFC", UsuarioActual.Empresa.RFC))
|
||||
params.Add(New ReportParameter("DireccionEmpresa", UsuarioActual.Empresa.Direccion))
|
||||
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
||||
params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToString()))
|
||||
params.Add(New ReportParameter("FechaInicio", FechaInicial))
|
||||
params.Add(New ReportParameter("FechaFin", FechaFinal))
|
||||
|
||||
If Imagen.Exists Then
|
||||
params.Add(New ReportParameter("LogoPath", logouri))
|
||||
Else
|
||||
params.Add(New ReportParameter("LogoPath", ""))
|
||||
End If
|
||||
If Tab.ActiveTabIndex = 0 Then
|
||||
ImprimirPDF("Empresas/Grales/Formatos/RepNotasSinAlmacenVentas.rdlc", DtNotasSinAlmacenVentas, params, "RepNotasSinAlmacenVentas", Formato:=Formato)
|
||||
Else
|
||||
ImprimirPDF("Empresas/Grales/Formatos/RepNotasSinAlmacenCompras.rdlc", DtNotasSinAlmacenCompras, params, "RepNotasSinAlmacenCompras", Formato:=Formato)
|
||||
End If
|
||||
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
Protected Sub GvCompras_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
If Not e.Row.DBCampo("CveCompraDetalle").ToEntero > 0 Then
|
||||
e.Row.CssClass = "Totales"
|
||||
e.Row.Cells(0).Text = "<a class=""Texto"" href=""/Compras/Compras.aspx?CveCompra=" & e.Row.DBCampo("CveCompra") & """>" & e.Row.DBCampo("SerieFolio") & "</a>"
|
||||
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
|
||||
e.Row.Cells(1).Text = e.Row.DBCampo("Fecha").ToDate.ToShortDateString
|
||||
e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Center
|
||||
e.Row.Cells(2).Text = "<a class=""Texto"" href=""/Compras/Proveedores.aspx?CveProveedor=" & e.Row.DBCampo("CveProveedor") & """>" & e.Row.DBCampo("RazonSocial") & "</a>"
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user