Commit inicial Ventas Productivo

This commit is contained in:
JORGE LUIS CAUDILLO ESPARZA
2019-08-14 16:40:54 -07:00
commit c35cf91883
13328 changed files with 3711549 additions and 0 deletions

180
PV/PVRepCompras.aspx Normal file
View File

@@ -0,0 +1,180 @@
<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="PVRepCompras.aspx.vb" Inherits="PV_PVRepCompras" %>
<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Css" runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HB" runat="Server">
<asp:UpdatePanel runat="server">
<ContentTemplate>
<li>
<asp:LinkButton ID="ImgImprimir" runat="server" Enabled="false"> <i class="fa fa-print"></i> Imprimir</asp:LinkButton>
<%--<asp:ImageButton ID="ImgImprimir" runat="server" ImageUrl="/Imagenes/btnImprimir.gif" Width="17px" Height="17px" Enabled="false" />--%>
</li>
<li>
<asp:LinkButton ID="ImgExcel" runat="server" > <i class="fa fa-ad-excel"></i> Generar</asp:LinkButton>
<%--<asp:ImageButton ID="ImgExcel" runat="server" ImageUrl="/Imagenes/IconoExcel.gif" Width="17px" Height="17px" />--%>
</li>
<li>
<asp:HyperLink NavigateUrl ="#" data-toggle="modal" data-target="#DivPersonalizar" ID="ImgPersonalizar" runat="server" > <i class="fa fa-pencil"></i> Personalizar</asp:HyperLink>
<%--<asp:Image ID="ImgPersonalizar" runat="server" ImageUrl="/Imagenes/Table-icon.png" Width="17px" Height="17px" Style="cursor: pointer;" />--%>
</li>
</ContentTemplate>
</asp:UpdatePanel>
<%--<asp:ImageButton ID="ImgImprimir" runat="server" ImageUrl="/Imagenes/btnImprimir.gif" Width="17px" Height="17px" Enabled="false" />
<asp:ImageButton ID="ImgExcel" runat="server" ImageUrl="/Imagenes/IconoExcel.gif" Width="17px" Height="17px" />
<asp:Image ID="ImgPersonalizar" runat="server" ImageUrl="/Imagenes/Table-icon.png" Width="17px" Height="17px" Style="cursor: pointer;" />--%>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="E" runat="Server">
Reporte de Compras
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="H" runat="Server">
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="C" runat="Server">
<asp:UpdatePanel ID="UPFiltros" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div class="portlet solid grey-cascade portlet-filter" style="">
<div class="portlet-title portlet-filterT" style="">
<div class="titlefiltros caption ">
<ul class="list-inline">
<li>Proveedor:
<asp:DropDownList ID="DdlProveedores" runat="server" AppendDataBoundItems="true" DataTextField="RazonSocial" DataValueField="CveProveedor" Class="table-group-action-input form-control input-inline input-small input-sm" Style="width: 250px !important;">
<asp:ListItem Selected="True" Text="Todos" Value="-1"></asp:ListItem>
</asp:DropDownList>
</li>
<li>Responsable:
<asp:DropDownList ID="DdlUsuario" runat="server" AppendDataBoundItems="true" DataTextField="Usuario" DataValueField="CveUsuario" Class="table-group-action-input form-control input-inline input-small input-sm" Style="width: 100px !important;">
<asp:ListItem Selected="True" Text="Todos" Value="-1"></asp:ListItem>
</asp:DropDownList>
</li>
<li>Moneda:
<asp:DropDownList ID="DdlMonedas" runat="server" AppendDataBoundItems="true" DataTextField="Moneda" DataValueField="CveMoneda" Class="table-group-action-input form-control input-inline input-small input-sm" Style="width: 100px !important;">
<asp:ListItem Selected="True" Text="Todos" Value="-1"></asp:ListItem>
</asp:DropDownList>
</li>
</ul>
</div>
<div class="tools">
<asp:Button ID="BtnConsultar" runat="server" Text="Consultar" class="btn btn-primary" />
<a href="javascript:;" class="expand"></a>
<a onclick="document.getElementById('C_BtnConsultar').click();" class="reload"></a>
</div>
</div>
<div class="portlet-body" style="display: none;">
<ul class="list-inline">
<li>F.I.:
<asp:TextBox ID="txtFechaI" runat="server" Width="70px"></asp:TextBox>
&nbsp;<asp:ImageButton runat="server" ID="imgCalendario" ImageUrl="/Imagenes/calendar.png" ImageAlign="AbsMiddle" Width="16px" Height="16px" AlternateText="Click para ver el Calendario" />
<ajax:MaskedEditExtender ID="MEEFechaI" runat="server" TargetControlID="txtFechaI" Mask="99/99/9999" MaskType="Date" DisplayMoney="Left" AcceptNegative="Left"></ajax:MaskedEditExtender>
<ajax:CalendarExtender runat="server" ID="Calendario" TargetControlID="txtFechaI" PopupButtonID="ImgCalendario" PopupPosition="BottomRight" Enabled="True"></ajax:CalendarExtender>
<asp:RequiredFieldValidator ID="rfvFechaI" runat="server" ControlToValidate="txtFechaI" Display="None" ErrorMessage="El campo <b>''Fecha Inicial''</b> es requerido por la aplicación, por favor ingrese una fecha." ValidationGroup="Valida"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="cvFechaI" runat="server" ControlToValidate="txtFechaI" Display="None" ErrorMessage="El campo <b>''Fecha Inicial''</b> no tienes el formato correcto, por favor intente de nuevo con el siguiente formato: (dd/mm/yyyy)." Operator="DataTypeCheck" Type="Date" ValidationGroup="Valida"></asp:CompareValidator>
<ajax:ValidatorCalloutExtender ID="vcoFfvFI" runat="server" HighlightCssClass="vco" TargetControlID="rfvFechaI" Width="350px"></ajax:ValidatorCalloutExtender>
<ajax:ValidatorCalloutExtender ID="vcoCvFI" runat="server" HighlightCssClass="vco" TargetControlID="cvFechaI" Width="350px"></ajax:ValidatorCalloutExtender>
</li>
<li style="width: 233px;">F.F.:
<asp:TextBox ID="txtFechaF" runat="server" Width="70px"></asp:TextBox>
&nbsp;<asp:ImageButton runat="server" ID="imgCalendarioF" ImageUrl="/Imagenes/calendar.png" ImageAlign="AbsMiddle" Width="16px" Height="16px" AlternateText="Click para ver el Calendario" />
<ajax:MaskedEditExtender ID="MEEFechaF" runat="server" TargetControlID="txtFechaF" Mask="99/99/9999" MaskType="Date" DisplayMoney="Left" AcceptNegative="Left"></ajax:MaskedEditExtender>
<ajax:CalendarExtender runat="server" ID="Calendario2" TargetControlID="txtFechaF" PopupButtonID="imgCalendarioF" PopupPosition="BottomRight" Enabled="True"></ajax:CalendarExtender>
<asp:RequiredFieldValidator ID="rfvFechaF" runat="server" ControlToValidate="txtFechaF" Display="None" ErrorMessage="El campo <b>''Fecha Final''</b> es requerido por la aplicación, por favor ingrese una fecha." ValidationGroup="Valida"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="cvFechaF" runat="server" ControlToValidate="txtFechaF" Display="None" ErrorMessage="El campo <b>''Fecha Final''</b> no tienes el formato correcto, por favor intente de nuevo con el siguiente formato: (dd/mm/yyyy)." Operator="DataTypeCheck" Type="Date" ValidationGroup="Valida"></asp:CompareValidator>
<ajax:ValidatorCalloutExtender ID="vcoRfvFF" runat="server" HighlightCssClass="vco" TargetControlID="rfvFechaF" Width="350px"></ajax:ValidatorCalloutExtender>
<ajax:ValidatorCalloutExtender ID="vcoCvFF" runat="server" HighlightCssClass="vco" TargetControlID="cvFechaF" Width="350px"></ajax:ValidatorCalloutExtender>
</li>
<li>Grupo:
<asp:DropDownList ID="DdlGrupo" runat="server" Class="table-group-action-input form-control input-inline input-small input-sm" Style="width: 140px !important;">
<asp:ListItem Text="Año" Value="1"></asp:ListItem>
<asp:ListItem Text="Mes" Value="2"></asp:ListItem>
<asp:ListItem Selected="True" Text="Año/Mes" Value="3"></asp:ListItem>
<asp:ListItem Text="Fecha" Value="4"></asp:ListItem>
<asp:ListItem Text="Proveedor" Value="5"></asp:ListItem>
<asp:ListItem Text="Tipo Documento" Value="6"></asp:ListItem>
<asp:ListItem Text="Clasificación Prov" Value="7"></asp:ListItem>
<asp:ListItem Text="Responsable" Value="8"></asp:ListItem>
</asp:DropDownList>
</li>
</ul>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<br />
<asp:UpdatePanel ID="UPDatos" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table border="0" cellpadding="0" cellspacing="0" id="tblSucursales" runat="server" visible="false">
<tr>
<td style="width: 150px">&nbsp;</td>
</tr>
</table>
<asp:GridView ID="GvDatos" runat="server" AutoGenerateColumns="False" EmptyDataText="No se encontraron Compras con los filtros especificados" ToolTip="Listado de Compras" CssClass="table table-striped table-advance table-hover" Style="margin-top: -10px; text-align: center;" GridLines="None">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
Grupo
</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="LtlGrupo" runat="server" Text='<%# Eval("GPO") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle CssClass="Texto" />
<HeaderStyle CssClass="Titulos" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel runat="server" ID="UPPersonalizar" UpdateMode="Conditional">
<ContentTemplate>
<div id="DivPersonalizar" style="width: 315px; background-color: White; border: solid 1px black; color: Black; display: none; position: absolute;">
<table class="table table-striped table-advance table-hover" width="315px">
<tr class="Titulos">
<th style="width: 310px">
<asp:Label ID="LblTitulo1" runat="server" ClientIDMode="Static" Text="Personalizar Columnas"></asp:Label>
</th>
<th style="padding-right: 4px; padding-top: 4px" valign="top">
<img alt="" src="/Imagenes/close.gif" style="cursor: pointer;" onclick="$('#DivPersonalizar').hide(1000);" /></th>
</tr>
<tr align="left">
<td colspan="2">
<table class="table table-striped table-advance table-hover">
<thead>
<tr>
<th style="text-align: left;">
<asp:CheckBox ID="ChkRetIVA" runat="server" Text="Ret. IVA" /></th>
<th style="text-align: left;">
<asp:CheckBox ID="ChkMinSub" runat="server" Text="SubTotal Mínimo" /></th>
</tr>
<tr>
<th style="text-align: left;">
<asp:CheckBox ID="ChkRetISR" runat="server" Text="Ret. ISR" /></th>
<th style="text-align: left;">
<asp:CheckBox ID="ChkMaxTot" runat="server" Text="Total Máximo" /></th>
</tr>
<tr>
<th style="text-align: left;">
<asp:CheckBox ID="ChkMaxSub" runat="server" Text="SubTotal Máximo" /></th>
<th style="text-align: left;">
<asp:CheckBox ID="ChkAvgTot" runat="server" Text="Total Promedio" /></th>
</tr>
<tr>
<th style="text-align: left;">
<asp:CheckBox ID="ChkAVGSub" runat="server" Text="SubTotal Promedio" /></th>
<th style="text-align: left;">
<asp:CheckBox ID="ChkMinTot" runat="server" Text="Total Mínimo" /></th>
</tr>
</thead>
</table>
</td>
</tr>
<tr style="height: 25px">
<td style="text-align: center;" colspan="2">
<asp:Button ID="BtnPersonalizar" runat="server" Text="Personalizar" class="btn btn-primary" /><input type="button" value="Cancelar" onclick="$('#DivPersonalizar').hide(1000);" class="btn btn-danger" /></td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="JS" runat="Server">
</asp:Content>

307
PV/PVRepCompras.aspx.vb Normal file
View File

@@ -0,0 +1,307 @@
Option Explicit On
Option Strict On
Imports Extensiones
Imports System.Data
Partial Class PV_PVRepCompras
Inherits ClsPaginas
#Region "Propiedades"
'Local
Private Property TmpDT As DataTable
Get
Return CType(ViewState("TmpDT"), DataTable)
End Get
Set(value As DataTable)
ViewState("TmpDT") = value
End Set
End Property
#End Region
Protected Sub Page_Init(sender As Object, e As EventArgs) Handles Me.Init
CreaGrid()
End Sub
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
CargaCombos()
'ImgPersonalizar.Attributes.Add("onclick", "javascript:$('#DivPersonalizar').show(1000); PosicionaObjeto(this.id,'DivPersonalizar');")
End If
End Sub
Private Sub CargaCombos()
'CargaProveedores
'Dim ObjProveedores As New ClsCompProveedores
'If ObjProveedores.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, -1, "-1", "-1", "-1", "-1", "-1", "-1", "-1", UsuarioActual.CveEmpresa) Then
' DdlProveedores.DataSource = ObjProveedores.DtResultados
'Else
' DdlProveedores.DataSource = Nothing
'End If
'ObjProveedores.Dispose()
DdlProveedores.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa)
DdlProveedores.DataBind()
'CargaUsuarios
DdlUsuario.DataSource = GlobalDTUsuarioResponsable.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
DdlUsuario.DataBind()
DdlMonedas.DataSource = GlobalDTMonedas()
DdlMonedas.DataBind()
End Sub
Protected Sub BtnConsultar_Click(sender As Object, e As System.EventArgs) Handles BtnConsultar.Click
CargaDatos()
UPDatos.Update()
End Sub
Private Sub CreaGrid()
Dim TotalAncho As Integer = 150
Dim TotalAnchoSucursal As Integer = 0
Dim SucursalTitulo As String = ""
TmpDT = New DataTable
TmpDT.Columns.Add("GPO", GetType(String))
Dim ObjCompras As New ClsPV()
Dim FechaI, FechaF As String
FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.Trim(), "-1")
FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.Trim(), "-1")
If ObjCompras.GetRepPVCompras(FechaI, FechaF, DdlProveedores.SelectedValue.ToEntero, DdlUsuario.SelectedValue.ToEntero, DdlMonedas.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlGrupo.SelectedValue.ToEntero) Then
Dim gv As New GridView
For Each Col As DataColumn In ObjCompras.DtResultados.Columns
If Col.ColumnName.Split(CChar("_")).Length = 3 AndAlso Col.ColumnName.Substring(0, 2).ToUpper = "T_" Then
Dim Sucursal As String = Col.ColumnName.Split(CChar("_"))(1).ToUpper()
Dim Categoria As String = Col.ColumnName.Split(CChar("_"))(2).ToUpper()
Dim bfield As New TemplateField
' Dim iTemplate As System.Web.UI.ITemplate
bfield.HeaderText = Categoria
'bfield.FooterText = Row("CveEstatus").ToString
bfield.ItemStyle.HorizontalAlign = HorizontalAlign.Right
If Sucursal = "TOTAL" Or Categoria = "TOTAL" Then
bfield.ItemStyle.Width = 97
TotalAnchoSucursal = TotalAnchoSucursal + 100
TotalAncho = TotalAncho + 100
Else
bfield.ItemStyle.Width = 87
TotalAnchoSucursal = TotalAnchoSucursal + 90
TotalAncho = TotalAncho + 90
End If
bfield.ItemTemplate = New GridViewTemplate(ListItemType.Item, Col.ColumnName)
gv.Columns.Add(bfield)
TmpDT.Columns.Add(Col.ColumnName, GetType(Integer))
If SucursalTitulo <> Sucursal And Categoria.ToUpper = "TOTAL" Then
SucursalTitulo = Sucursal
Dim Celda As New HtmlTableCell()
Celda.InnerText = SucursalTitulo
Celda.Attributes.Add("class", "Titulos")
Celda.Attributes.Add("style", "border-width: 1px;border-right-style: solid;")
Celda.Width = TotalAnchoSucursal.ToString
tblSucursales.Rows(0).Cells.Add(Celda)
TotalAnchoSucursal = 0
End If
End If
Next
For Each Columna In gv.Columns
GvDatos.Columns.Add(CType(Columna, DataControlField))
Next
GvDatos.Width = TotalAncho
Else
GvDatos.DataSource = Nothing
End If
ObjCompras.Dispose()
UPDatos.Update()
End Sub
Private Sub CargaDatos()
Dim ObjCompras As New ClsPV()
Dim FechaI, FechaF As String
FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.Trim(), "-1")
FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.Trim(), "-1")
'FechaI, FechaF, -1, UsuarioActual.CveEmpresa, DdlGrupo.SelectedValue.ToEntero
If ObjCompras.GetRepPVCompras(FechaI, FechaF, DdlProveedores.SelectedValue.ToEntero, DdlUsuario.SelectedValue.ToEntero, DdlMonedas.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlGrupo.SelectedValue.ToEntero) Then
GvDatos.DataSource = ObjCompras.DtResultados
tblSucursales.Visible = True
Else
GvDatos.DataSource = Nothing
End If
ObjCompras.Dispose()
GvDatos.DataBind()
End Sub
Public Class GridViewTemplate
Implements ITemplate
'A variable to hold the type of ListItemType.
Private _templateType As ListItemType
'A variable to hold the column name.
Private _columnName As String
'Constructor where we define the template type and column name.
Public Sub New(type As ListItemType, colname As String)
'Stores the template type.
_templateType = type
'Stores the column name.
_columnName = colname
End Sub
Private Sub ITemplate_InstantiateIn(container As System.Web.UI.Control) Implements ITemplate.InstantiateIn
Select Case _templateType
Case ListItemType.Header
'Creates a new label control and add it to the container.
Dim lbl As New Label()
'Allocates the new label object.
lbl.Text = _columnName
'Assigns the name of the column in the lable.
container.Controls.Add(lbl)
'Adds the newly created label control to the container.
Exit Select
Case ListItemType.Item
'Creates a new text box control and add it to the container.
Dim ltl1 As New Literal
ltl1.ID = String.Format("ltl{0}", _columnName)
AddHandler ltl1.DataBinding, AddressOf ltl_DataBinding
'Creates a column with size 4.
container.Controls.Add(ltl1)
'Adds the newly created textbox to the container.
Exit Select
Case ListItemType.EditItem
'As, I am not using any EditItem, I didnot added any code here.
Exit Select
Case ListItemType.Footer
Dim chkColumn As New CheckBox()
chkColumn.ID = Convert.ToString("Chk") & _columnName
container.Controls.Add(chkColumn)
Exit Select
End Select
End Sub
Private Sub hdn_DataBinding(sender As Object, e As EventArgs)
Dim hidden As HiddenField = DirectCast(sender, HiddenField)
Dim row As GridViewRow = DirectCast(hidden.NamingContainer, GridViewRow)
Dim value As String = DataBinder.Eval(row.DataItem, _columnName).ToString()
hidden.Value = If(value Is Nothing OrElse value = String.Empty, "-1", value)
End Sub
Private Sub ltl_DataBinding(sender As Object, e As EventArgs)
Dim ltl As Literal = DirectCast(sender, Literal)
Dim row As GridViewRow = DirectCast(ltl.NamingContainer, GridViewRow)
Dim celda As DataControlFieldCell = DirectCast(ltl.Parent, DataControlFieldCell)
Dim value As String = DataBinder.Eval(row.DataItem, _columnName).ToString()
ltl.Text = value.FormatoNumero
End Sub
''' <summary>
''' This is the event, which will be raised when the binding happens.
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
Private Sub tb1_DataBinding(sender As Object, e As EventArgs)
Dim txtdata As TextBox = DirectCast(sender, TextBox)
Dim container As GridViewRow = DirectCast(txtdata.NamingContainer, GridViewRow)
Dim dataValue As Object = DataBinder.Eval(container.DataItem, _columnName)
If dataValue Is DBNull.Value Then
txtdata.Text = dataValue.ToString()
End If
End Sub
End Class
Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim Css As String = "Texto"
If e.Row.RowIndex = 0 Then
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Center
e.Row.CssClass = "Totales"
Css = "Totales"
End If
'If e.Row.DBCampo("Orden") = "" Then
' e.Row.BackColor = Drawing.Color.LightGray
'End If
Dim FechaI, FechaF As String
FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.Trim(), "-1")
FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.Trim(), "-1")
Dim Liga As String = String.Format("/Compras/RepComprasDetalle.aspx?GPO={0}&Anio={1}&Mes={2}&AnioMes={3}&Fecha={4}&CveProveedor={5}&CveUsuario={6}&FechaI={7}&FechaF={8}&CveMoneda={9}",
DdlGrupo.SelectedValue, e.Row.DBCampo("Anio"), e.Row.DBCampo("Mes"), e.Row.DBCampo("AnioMes"), e.Row.DBCampo("Fecha"), e.Row.DBCampo("CveProveedor"), e.Row.DBCampo("CveUsuario"), FechaI, FechaF, e.Row.DBCampo("CveMoneda"))
e.Row.FCLiteral("LtlGrupo").Text = String.Format("<a class='{0}' href='{1}'>{2}</a>", Css, Liga, e.Row.FCLiteral("LtlGrupo").Text)
End If
End Sub
Protected Sub BtnPersonalizar_Click(sender As Object, e As System.EventArgs) Handles BtnPersonalizar.Click
If ChkRetIVA.Checked Then
GvDatos.Columns(6).Visible = True
Else
GvDatos.Columns(6).Visible = False
End If
If ChkRetISR.Checked Then
GvDatos.Columns(7).Visible = True
Else
GvDatos.Columns(7).Visible = False
End If
If ChkMinSub.Checked Then
GvDatos.Columns(9).Visible = True
Else
GvDatos.Columns(9).Visible = False
End If
If ChkAVGSub.Checked Then
GvDatos.Columns(10).Visible = True
Else
GvDatos.Columns(10).Visible = False
End If
If ChkMaxSub.Checked Then
GvDatos.Columns(11).Visible = True
Else
GvDatos.Columns(11).Visible = False
End If
If ChkMinTot.Checked Then
GvDatos.Columns(12).Visible = True
Else
GvDatos.Columns(12).Visible = False
End If
If ChkAvgTot.Checked Then
GvDatos.Columns(13).Visible = True
Else
GvDatos.Columns(13).Visible = False
End If
If ChkMaxTot.Checked Then
GvDatos.Columns(14).Visible = True
Else
GvDatos.Columns(14).Visible = False
End If
UPDatos.Update()
End Sub
Protected Sub ImgExcel_Click(sender As Object, e As System.EventArgs) Handles ImgExcel.Click
GvDatos.ExportToExcel("ReporteCompras" & Now.ToShortDateString)
End Sub
End Class

229
PV/PVRepVentas.aspx Normal file
View File

@@ -0,0 +1,229 @@
<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="PVRepVentas.aspx.vb" Inherits="PV_PVRepVentas" %>
<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Css" runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HB" runat="Server">
<asp:UpdatePanel runat="server">
<ContentTemplate>
<li>
<asp:LinkButton ID="ImgImprimir" runat="server" Enabled="false"> <i class="fa fa-print"></i> Imprimir</asp:LinkButton>
<%--<asp:ImageButton ID="ImgImprimir" runat="server" ImageUrl="/Imagenes/btnImprimir.gif" Width="17px" Height="17px" Enabled="false" />--%>
</li>
<li>
<asp:LinkButton ID="ImgExcel" runat="server" > <i class="fa fa-ad-excel"></i> Generar</asp:LinkButton>
<%--<asp:ImageButton ID="ImgExcel" runat="server" ImageUrl="/Imagenes/IconoExcel.gif" Width="17px" Height="17px" />--%>
</li>
<li>
<asp:HyperLink NavigateUrl ="#" data-toggle="modal" data-target="#DivPersonalizar" ID="ImgPersonalizar" runat="server" > <i class="fa fa-pencil"></i> Personalizar</asp:HyperLink>
<%--<asp:Image ID="ImgPersonalizar" runat="server" ImageUrl="/Imagenes/Table-icon.png" Width="17px" Height="17px" Style="cursor: pointer;" />--%>
</li>
</ContentTemplate>
</asp:UpdatePanel>
<%-- <asp:ImageButton ID="ImgImprimir" runat="server" ImageUrl="/Imagenes/btnImprimir.gif" Width="17px" Height="17px" Enabled="false" />
<asp:ImageButton ID="ImgExcel" runat="server" ImageUrl="/Imagenes/IconoExcel.gif" Width="17px" Height="17px" />
<asp:Image ID="ImgPersonalizar" runat="server" ImageUrl="/Imagenes/Table-icon.png" Width="17px" Height="17px" Style="cursor: pointer;" />--%>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="E" runat="Server">
Reporte de Ventas
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="H" runat="Server">
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="C" runat="Server">
<asp:UpdatePanel ID="UPFiltros" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div class="portlet solid grey-cascade portlet-filter" style="">
<div class="portlet-title portlet-filterT" style="">
<div class="titlefiltros caption ">
<ul class="list-inline">
<li>Cliente:
<asp:DropDownList ID="DdlClientes" runat="server" AppendDataBoundItems="true" DataTextField="Nombre" DataValueField="CveCliente" Class="table-group-action-input form-control input-inline input-small input-sm" Style="width: 200px !important;">
<asp:ListItem Selected="True" Text="Todos" Value="-1"></asp:ListItem>
</asp:DropDownList>
</li>
<li>Sucursal:
<asp:DropDownList ID="DdlSubProyecto" runat="server" AppendDataBoundItems="true" DataTextField="SubProyecto" DataValueField="CveSubProyecto" Class="table-group-action-input form-control input-inline input-small input-sm" Style="width: 150px !important;">
<asp:ListItem Selected="True" Text="Todas" Value="-1"></asp:ListItem>
</asp:DropDownList>
</li>
<li>Vendedor:
<asp:DropDownList ID="DdlVendedor" runat="server" AppendDataBoundItems="true" DataTextField="Vendedor" DataValueField="Vendedor" Class="table-group-action-input form-control input-inline input-small input-sm" Style="width: 150px !important;">
<asp:ListItem Selected="True" Text="Todos" Value="-1"></asp:ListItem>
</asp:DropDownList>
</li>
<li>Usuario:
<asp:DropDownList ID="DdlUsuario" runat="server" AppendDataBoundItems="true" DataTextField="Usuario" DataValueField="CveUsuario" Class="table-group-action-input form-control input-inline input-small input-sm" Style="width: 110px !important;">
<asp:ListItem Selected="True" Text="Todos" Value="-1"></asp:ListItem>
</asp:DropDownList>
</li>
</ul>
</div>
<div class="tools">
<asp:Button ID="BtnConsultar" runat="server" Text="Consultar" class="btn btn-primary" />
<a href="javascript:;" class="expand"></a>
<a onclick="document.getElementById('C_BtnConsultar').click();" class="reload"></a>
</div>
</div>
<div class="portlet-body" style="display: none;">
<ul class="list-inline">
<li style="width: 384px;">Estatus:
<asp:DropDownList ID="DdlEstatus" runat="server" AppendDataBoundItems="true" DataTextField="EstatusFactura" DataValueField="CveEstatusFactura" Class="table-group-action-input form-control input-inline input-small input-sm" Style="width: 120px !important;">
<asp:ListItem Selected="True" Text="Todos" Value="-1"></asp:ListItem>
</asp:DropDownList>
</li>
<li>F.I.:
<asp:TextBox ID="txtFechaI" runat="server" Width="70px"></asp:TextBox>
&nbsp;<asp:ImageButton runat="server" ID="imgCalendario" ImageUrl="/Imagenes/calendar.png" ImageAlign="AbsMiddle" Width="16px" Height="16px" AlternateText="Click para ver el Calendario" />
<ajax:MaskedEditExtender ID="MEEFechaI" runat="server" TargetControlID="txtFechaI" Mask="99/99/9999" MaskType="Date" DisplayMoney="Left" AcceptNegative="Left"></ajax:MaskedEditExtender>
<ajax:CalendarExtender runat="server" ID="Calendario" TargetControlID="txtFechaI" PopupButtonID="ImgCalendario" PopupPosition="BottomRight" Enabled="True"></ajax:CalendarExtender>
<asp:RequiredFieldValidator ID="rfvFechaI" runat="server" ControlToValidate="txtFechaI" Display="None" ErrorMessage="El campo <b>''Fecha Inicial''</b> es requerido por la aplicación, por favor ingrese una fecha." ValidationGroup="Valida"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="cvFechaI" runat="server" ControlToValidate="txtFechaI" Display="None" ErrorMessage="El campo <b>''Fecha Inicial''</b> no tienes el formato correcto, por favor intente de nuevo con el siguiente formato: (dd/mm/yyyy)." Operator="DataTypeCheck" Type="Date" ValidationGroup="Valida"></asp:CompareValidator>
<ajax:ValidatorCalloutExtender ID="vcoFfvFI" runat="server" HighlightCssClass="vco" TargetControlID="rfvFechaI" Width="350px"></ajax:ValidatorCalloutExtender>
<ajax:ValidatorCalloutExtender ID="vcoCvFI" runat="server" HighlightCssClass="vco" TargetControlID="cvFechaI" Width="350px"></ajax:ValidatorCalloutExtender>
</li>
<li style="width: 191px;">&nbsp;&nbsp;&nbsp;&nbsp;F.F.:
<asp:TextBox ID="txtFechaF" runat="server" Width="70px"></asp:TextBox>
&nbsp;<asp:ImageButton runat="server" ID="imgCalendarioF" ImageUrl="/Imagenes/calendar.png" ImageAlign="AbsMiddle" Width="16px" Height="16px" AlternateText="Click para ver el Calendario" />
<ajax:MaskedEditExtender ID="MEEFechaF" runat="server" TargetControlID="txtFechaF" Mask="99/99/9999" MaskType="Date" DisplayMoney="Left" AcceptNegative="Left"></ajax:MaskedEditExtender>
<ajax:CalendarExtender runat="server" ID="Calendario2" TargetControlID="txtFechaF" PopupButtonID="imgCalendarioF" PopupPosition="BottomRight" Enabled="True"></ajax:CalendarExtender>
<asp:RequiredFieldValidator ID="rfvFechaF" runat="server" ControlToValidate="txtFechaF" Display="None" ErrorMessage="El campo <b>''Fecha Final''</b> es requerido por la aplicación, por favor ingrese una fecha." ValidationGroup="Valida"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="cvFechaF" runat="server" ControlToValidate="txtFechaF" Display="None" ErrorMessage="El campo <b>''Fecha Final''</b> no tienes el formato correcto, por favor intente de nuevo con el siguiente formato: (dd/mm/yyyy)." Operator="DataTypeCheck" Type="Date" ValidationGroup="Valida"></asp:CompareValidator>
<ajax:ValidatorCalloutExtender ID="vcoRfvFF" runat="server" HighlightCssClass="vco" TargetControlID="rfvFechaF" Width="350px"></ajax:ValidatorCalloutExtender>
<ajax:ValidatorCalloutExtender ID="vcoCvFF" runat="server" HighlightCssClass="vco" TargetControlID="cvFechaF" Width="350px"></ajax:ValidatorCalloutExtender>
</li>
<li>Grupo:
<asp:DropDownList ID="DdlGrupo" runat="server" Class="table-group-action-input form-control input-inline input-small input-sm" Style="width: 120px !important;">
<asp:ListItem Text="Año" Value="1"></asp:ListItem>
<asp:ListItem Text="Mes" Value="2"></asp:ListItem>
<asp:ListItem Selected="True" Text="Año/Mes" Value="3"></asp:ListItem>
<asp:ListItem Text="Fecha" Value="4"></asp:ListItem>
<asp:ListItem Text="Cliente" Value="5"></asp:ListItem>
<asp:ListItem Text="Sucursal" Value="6"></asp:ListItem>
<asp:ListItem Text="Corte" Value="16"></asp:ListItem>
<asp:ListItem Text="Vendedor" Value="7"></asp:ListItem>
<asp:ListItem Text="Usuario" Value="8"></asp:ListItem>
<asp:ListItem Text="Estatus Fact." Value="9"></asp:ListItem>
<asp:ListItem Text="% IVA" Value="10"></asp:ListItem>
<asp:ListItem Text="Año Ejec" Value="11"></asp:ListItem>
<asp:ListItem Text="Mes Ejec" Value="12"></asp:ListItem>
<asp:ListItem Text="Año/Mes Ejec" Value="13"></asp:ListItem>
<asp:ListItem Text="Fecha Ejec" Value="14"></asp:ListItem>
<asp:ListItem Text="Sucursal Ejec" Value="15"></asp:ListItem>
</asp:DropDownList>
</li>
</ul>
<ul class="list-inline">
<li>Sucursal Ejecución:
<asp:DropDownList ID="DdlSubProyectoEjecucion" runat="server" AppendDataBoundItems="true" DataTextField="SubProyecto" DataValueField="CveSubProyecto" Class="table-group-action-input form-control input-inline input-small input-sm" Style="width: 250px !important;">
<asp:ListItem Selected="True" Text="Todas" Value="-1"></asp:ListItem>
</asp:DropDownList>
</li>
<li>F.I. E.:
<asp:TextBox ID="TxtFechaIEjec" runat="server" Width="70px"></asp:TextBox>
&nbsp;<asp:ImageButton ID="ImgCalFechaIEjec" runat="server" ImageUrl="/Imagenes/calendar.png" ImageAlign="AbsMiddle" Width="16px" Height="16px" AlternateText="Click para ver el Calendario" />
<ajax:MaskedEditExtender ID="MEEFechaIEjec" runat="server" TargetControlID="TxtFechaIEjec" Mask="99/99/9999" MaskType="Date" DisplayMoney="Left" AcceptNegative="Left"></ajax:MaskedEditExtender>
<ajax:CalendarExtender ID="CalFechaIEjec" runat="server" TargetControlID="TxtFechaIEjec" PopupButtonID="ImgCalFechaIEjec" PopupPosition="BottomRight" Enabled="True"></ajax:CalendarExtender>
<asp:RequiredFieldValidator ID="RFVFechaIEjec" runat="server" ControlToValidate="TxtFechaIEjec" Display="None" ErrorMessage="El campo <b>''Fecha Inicial Ejecución''</b> es requerido por la aplicación, por favor ingrese una fecha." ValidationGroup="Valida"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="CVFechaIEjec" runat="server" ControlToValidate="TxtFechaIEjec" Display="None" ErrorMessage="El campo <b>''Fecha Inicial Ejecución''</b> no tienes el formato correcto, por favor intente de nuevo con el siguiente formato: (dd/mm/yyyy)." Operator="DataTypeCheck" Type="Date" ValidationGroup="Valida"></asp:CompareValidator>
<ajax:ValidatorCalloutExtender ID="VCOFechaIEjec1" runat="server" HighlightCssClass="vco" TargetControlID="RFVFechaIEjec" Width="350px"></ajax:ValidatorCalloutExtender>
<ajax:ValidatorCalloutExtender ID="VCOFechaIEjec2" runat="server" HighlightCssClass="vco" TargetControlID="CVFechaIEjec" Width="350px"></ajax:ValidatorCalloutExtender>
</li>
<li>F.F. E.:
<asp:TextBox ID="TxtFechaFEjec" runat="server" Width="70px"></asp:TextBox>
&nbsp;<asp:ImageButton ID="ImgCalFechaFEjec" runat="server" ImageUrl="/Imagenes/calendar.png" ImageAlign="AbsMiddle" Width="16px" Height="16px" AlternateText="Click para ver el Calendario" />
<ajax:MaskedEditExtender ID="MEEFechaFEjec" runat="server" TargetControlID="TxtFechaFEjec" Mask="99/99/9999" MaskType="Date" DisplayMoney="Left" AcceptNegative="Left"></ajax:MaskedEditExtender>
<ajax:CalendarExtender ID="CalFechaFEjec" runat="server" TargetControlID="TxtFechaFEjec" PopupButtonID="ImgCalFechaFEjec" PopupPosition="BottomRight" Enabled="True"></ajax:CalendarExtender>
<asp:RequiredFieldValidator ID="RFVFechaFEjec" runat="server" ControlToValidate="TxtFechaFEjec" Display="None" ErrorMessage="El campo <b>''Fecha Final Ejecución''</b> es requerido por la aplicación, por favor ingrese una fecha." ValidationGroup="Valida"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="CVFechaFEjec" runat="server" ControlToValidate="TxtFechaFEjec" Display="None" ErrorMessage="El campo <b>''Fecha Final Ejecución''</b> no tienes el formato correcto, por favor intente de nuevo con el siguiente formato: (dd/mm/yyyy)." Operator="DataTypeCheck" Type="Date" ValidationGroup="Valida"></asp:CompareValidator>
<ajax:ValidatorCalloutExtender ID="VCOFechaFEjec1" runat="server" HighlightCssClass="vco" TargetControlID="RFVFechaFEjec" Width="350px"></ajax:ValidatorCalloutExtender>
<ajax:ValidatorCalloutExtender ID="VCOFechaFEjec2" runat="server" HighlightCssClass="vco" TargetControlID="CVFechaFEjec" Width="350px"></ajax:ValidatorCalloutExtender>
</li>
</ul>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<br />
<div class="row">
<div class="col-md-12">
<asp:UpdatePanel ID="UPDatos" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table border="0" cellpadding="0" cellspacing="0" id="tblSucursales" runat="server" visible="false">
<tr>
<td style="width: 150px">&nbsp;</td>
</tr>
</table>
<asp:GridView ID="GvDatos" runat="server" AutoGenerateColumns="False" EmptyDataText="No se encontraron Ventas con los filtros especificados" ToolTip="Listado de Ventas" CssClass="table table-striped table-advance table-hover" Style=" text-align: center;" GridLines="None">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
Grupo
</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="LtlGrupo" runat="server" Text='<%# Eval("GPO") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle CssClass="Texto" />
<HeaderStyle CssClass="Titulos" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel runat="server" ID="UPPersonalizar" UpdateMode="Conditional">
<ContentTemplate>
<div id="DivPersonalizar" style="width: 330px; background-color: White; border: solid 1px black; color: Black; display: none; position: absolute;">
<table class="table table-striped table-advance table-hover" width="330px">
<tr class="Titulos">
<th style="width: 325px">
<asp:Label ID="LblTitulo1" runat="server" ClientIDMode="Static" Text="Personalizar Columnas"></asp:Label>
</th>
<th style="padding-right: 4px; padding-top: 4px" valign="top">
<img alt="" src="/Imagenes/close.gif" style="cursor: pointer;" onclick="$('#DivPersonalizar').hide(1000);" /></th>
</tr>
<tr align="left">
<td colspan="2">
<table class="table table-striped table-advance table-hover">
<thead>
<tr>
<th style="text-align: left;">
<asp:CheckBox ID="ChkRetIVA" runat="server" Text="Ret. IVA" /></th>
<th style="text-align: left;">
<asp:CheckBox ID="ChkMinSub" runat="server" Text="SubTotal Mínimo" /></th>
</tr>
<tr>
<th style="text-align: left;">
<asp:CheckBox ID="ChkRetISR" runat="server" Text="Ret. ISR" /></th>
<th style="text-align: left;">
<asp:CheckBox ID="ChkMaxTot" runat="server" Text="Total Máximo" /></th>
</tr>
<tr>
<th style="text-align: left;">
<asp:CheckBox ID="ChkMaxSub" runat="server" Text="SubTotal Máximo" /></th>
<th style="text-align: left;">
<asp:CheckBox ID="ChkAvgTot" runat="server" Text="Total Promedio" /></th>
</tr>
<tr>
<th style="text-align: left;">
<asp:CheckBox ID="ChkAVGSub" runat="server" Text="SubTotal Promedio" /></th>
<th style="text-align: left;">
<asp:CheckBox ID="ChkMinTot" runat="server" Text="Total Mínimo" /></th>
</tr>
</thead>
</table>
</td>
</tr>
<tr style="height: 25px">
<td style="text-align: center;" colspan="2">
<asp:Button ID="BtnPersonalizar" runat="server" Text="Personalizar" class="btn btn-primary" /><input type="button" value="Cancelar" onclick="$('#DivPersonalizar').hide(1000);" class="btn btn-danger" /></td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="JS" runat="Server">
</asp:Content>

365
PV/PVRepVentas.aspx.vb Normal file
View File

@@ -0,0 +1,365 @@
Option Explicit On
Option Strict On
Imports System.Data
Imports Extensiones
Partial Class PV_PVRepVentas
Inherits ClsPaginas
#Region "Propiedades"
'Local
Private Property TmpDT As DataTable
Get
Return CType(ViewState("TmpDT"), DataTable)
End Get
Set(value As DataTable)
ViewState("TmpDT") = value
End Set
End Property
#End Region
Protected Sub Page_Init(sender As Object, e As EventArgs) Handles Me.Init
CreaGrid()
End Sub
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")
CargaCombos()
'ImgPersonalizar.Attributes.Add("onclick", "javascript:$('#DivPersonalizar').show(1000); PosicionaObjeto(this.id,'DivPersonalizar');")
End If
End Sub
Private Sub CargaCombos()
'CargaClientes
Dim ObjClientes As New ClsClientes
If ObjClientes.GetClientes(-1, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa) Then
DdlClientes.DataSource = ObjClientes.DtResultados
Else
DdlClientes.DataSource = Nothing
End If
ObjClientes.Dispose()
DdlClientes.DataBind()
'CargaSucursales
DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1).FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
DdlSubProyecto.DataBind()
DdlSubProyectoEjecucion.DataSource = GlobalDTSubProyectos(-1).FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
DdlSubProyectoEjecucion.DataBind()
'Vendedor
'CargaUsuarios
DdlUsuario.DataSource = GlobalDTUsuarios.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
DdlUsuario.DataBind()
'CargaEstatus
DdlEstatus.DataSource = GlobalDTEstatusFactura.FiltraParametros(" CveEstatusFactura NOT IN (1, 4, 5) ")
DdlEstatus.DataBind()
DdlEstatus.Items.Add(New ListItem("Canceladas", "4"))
'If UsuarioActual.Empresa.TipoFacturacion = "CFDi" Then
' DdlEstatus.SelectedIndex = 2
'Else
DdlEstatus.SelectedIndex = 1
'End If
End Sub
Protected Sub BtnConsultar_Click(sender As Object, e As System.EventArgs) Handles BtnConsultar.Click
CargaDatos()
ConfiguraEmpresa()
UPDatos.Update()
End Sub
Private Sub CreaGrid()
Dim TotalAncho As Integer = 150
Dim TotalAnchoSucursal As Integer = 0
Dim SucursalTitulo As String = ""
TmpDT = New DataTable
TmpDT.Columns.Add("GPO", GetType(String))
Dim ObjVentas As New ClsPV()
Dim FechaI, FechaF, FechaIEjec, FechaFEjec As String
FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.Trim(), "-1")
FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.Trim(), "-1")
FechaIEjec = If(IsDate(TxtFechaIEjec.Text.Trim()), TxtFechaIEjec.Text.Trim(), "-1")
FechaFEjec = If(IsDate(TxtFechaFEjec.Text.Trim()), TxtFechaFEjec.Text.Trim(), "-1")
If ObjVentas.GetRepPVVentas(FechaI, FechaF, FechaIEjec, FechaFEjec, DdlClientes.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, DdlSubProyectoEjecucion.SelectedValue.ToEntero, DdlVendedor.SelectedValue,
DdlUsuario.SelectedValue.ToEntero, DdlEstatus.SelectedValue.ToEntero, "-1", UsuarioActual.CveEmpresa, DdlGrupo.SelectedValue.ToEntero) Then
Dim gv As New GridView
For Each Col As DataColumn In ObjVentas.DtResultados.Columns
If Col.ColumnName.Split(CChar("_")).Length >= 3 AndAlso Col.ColumnName.Substring(0, 2).ToUpper = "T_" Then
Dim Sucursal As String = Col.ColumnName.Split(CChar("_"))(1).ToUpper()
Dim Categoria As String = Col.ColumnName.Split(CChar("_"))(2).ToUpper()
' Dim CveSucursal As Integer = Col.ColumnName.Split(CChar("_"))(3).ToEntero
Dim bfield As New TemplateField
' Dim iTemplate As System.Web.UI.ITemplate
bfield.HeaderText = Categoria
'bfield.FooterText = Row("CveEstatus").ToString
bfield.ItemStyle.HorizontalAlign = HorizontalAlign.Right
If Sucursal = "TOTAL" Or Categoria = "TOTAL" Then
bfield.ItemStyle.Width = 97
TotalAnchoSucursal = TotalAnchoSucursal + 100
TotalAncho = TotalAncho + 100
Else
bfield.ItemStyle.Width = 87
TotalAnchoSucursal = TotalAnchoSucursal + 90
TotalAncho = TotalAncho + 90
End If
bfield.ItemTemplate = New GridViewTemplate(ListItemType.Item, Col.ColumnName)
' bfield.ItemTemplate
gv.Columns.Add(bfield)
TmpDT.Columns.Add(Col.ColumnName, GetType(Integer))
If SucursalTitulo <> Sucursal And Categoria.ToUpper = "TOTAL" Then
SucursalTitulo = Sucursal
Dim Celda As New HtmlTableCell()
'Celda.InnerHtml = String.Format("<font color='White'>{0}</font>", SucursalTitulo)
Celda.InnerText = SucursalTitulo
'Celda.BorderColor = "White"
'Celda.BgColor = "Gray"
Celda.Attributes.Add("class", "Titulos")
Celda.Attributes.Add("style", "border-width: 1px;border-right-style: solid;")
Celda.Width = TotalAnchoSucursal.ToString
tblSucursales.Rows(0).Cells.Add(Celda)
TotalAnchoSucursal = 0
End If
End If
Next
For Each Columna In gv.Columns
GvDatos.Columns.Add(CType(Columna, DataControlField))
Next
GvDatos.Width = TotalAncho
Else
GvDatos.DataSource = Nothing
End If
ObjVentas.Dispose()
UPDatos.Update()
End Sub
Private Sub CargaDatos()
Dim ObjVentas As New ClsPV()
Dim FechaI, FechaF, FechaIEjec, FechaFEjec As String
FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.Trim(), "-1")
FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.Trim(), "-1")
FechaIEjec = If(IsDate(TxtFechaIEjec.Text.Trim()), TxtFechaIEjec.Text.Trim(), "-1")
FechaFEjec = If(IsDate(TxtFechaFEjec.Text.Trim()), TxtFechaFEjec.Text.Trim(), "-1")
If ObjVentas.GetRepPVVentas(FechaI, FechaF, FechaIEjec, FechaFEjec, DdlClientes.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, DdlSubProyectoEjecucion.SelectedValue.ToEntero, DdlVendedor.SelectedValue,
DdlUsuario.SelectedValue.ToEntero, DdlEstatus.SelectedValue.ToEntero, "-1", UsuarioActual.CveEmpresa, DdlGrupo.SelectedValue.ToEntero) Then
GvDatos.DataSource = ObjVentas.DtResultados
tblSucursales.Visible = True
Else
GvDatos.DataSource = Nothing
End If
ObjVentas.Dispose()
GvDatos.DataBind()
End Sub
Private Sub ConfiguraEmpresa()
'If Not UsuarioActual.Empresa.MostrarRetIVA Then GvDatos.Columns(6).Visible = False
'If Not UsuarioActual.Empresa.MostrarRetISR Then GvDatos.Columns(7).Visible = False
End Sub
Protected Sub BtnPersonalizar_Click(sender As Object, e As System.EventArgs) Handles BtnPersonalizar.Click
If ChkRetIVA.Checked Then
GvDatos.Columns(6).Visible = True
Else
GvDatos.Columns(6).Visible = False
End If
If ChkRetISR.Checked Then
GvDatos.Columns(7).Visible = True
Else
GvDatos.Columns(7).Visible = False
End If
If ChkMinSub.Checked Then
GvDatos.Columns(9).Visible = True
Else
GvDatos.Columns(9).Visible = False
End If
If ChkAVGSub.Checked Then
GvDatos.Columns(10).Visible = True
Else
GvDatos.Columns(10).Visible = False
End If
If ChkMaxSub.Checked Then
GvDatos.Columns(11).Visible = True
Else
GvDatos.Columns(11).Visible = False
End If
If ChkMinTot.Checked Then
GvDatos.Columns(12).Visible = True
Else
GvDatos.Columns(12).Visible = False
End If
If ChkAvgTot.Checked Then
GvDatos.Columns(13).Visible = True
Else
GvDatos.Columns(13).Visible = False
End If
If ChkMaxTot.Checked Then
GvDatos.Columns(14).Visible = True
Else
GvDatos.Columns(14).Visible = False
End If
UPDatos.Update()
End Sub
Protected Sub ImgExcel_Click(sender As Object, e As System.EventArgs) Handles ImgExcel.Click
GvDatos.ExportToExcel("ReporteVentas" & Now.ToShortDateString)
End Sub
'Region "TEMPLATE"
Public Class GridViewTemplate
Implements ITemplate
'A variable to hold the type of ListItemType.
Private _templateType As ListItemType
'A variable to hold the column name.
Private _columnName As String
'Constructor where we define the template type and column name.
Public Sub New(type As ListItemType, colname As String)
'Stores the template type.
_templateType = type
'Stores the column name.
_columnName = colname
End Sub
Private Sub ITemplate_InstantiateIn(container As System.Web.UI.Control) Implements ITemplate.InstantiateIn
Select Case _templateType
Case ListItemType.Header
'Creates a new label control and add it to the container.
Dim lbl As New Label()
'Allocates the new label object.
lbl.Text = _columnName
'Assigns the name of the column in the lable.
container.Controls.Add(lbl)
'Adds the newly created label control to the container.
Exit Select
Case ListItemType.Item
'Creates a new text box control and add it to the container.
Dim ltl1 As New Literal
ltl1.ID = String.Format("ltl{0}", _columnName)
AddHandler ltl1.DataBinding, AddressOf ltl_DataBinding
'AddHandler hdn1.DataBinding, AddressOf hdn_DataBinding
'Creates a column with size 4.
container.Controls.Add(ltl1)
'Adds the newly created textbox to the container.
Exit Select
Case ListItemType.EditItem
'As, I am not using any EditItem, I didnot added any code here.
Exit Select
Case ListItemType.Footer
Dim chkColumn As New CheckBox()
chkColumn.ID = Convert.ToString("Chk") & _columnName
container.Controls.Add(chkColumn)
Exit Select
End Select
End Sub
Private Sub hdn_DataBinding(sender As Object, e As EventArgs)
Dim hidden As HiddenField = DirectCast(sender, HiddenField)
Dim row As GridViewRow = DirectCast(hidden.NamingContainer, GridViewRow)
Dim value As String = DataBinder.Eval(row.DataItem, _columnName).ToString()
hidden.Value = If(value Is Nothing OrElse value = String.Empty, "-1", value)
End Sub
Private Sub ltl_DataBinding(sender As Object, e As EventArgs)
Dim ltl As Literal = DirectCast(sender, Literal)
Dim row As GridViewRow = DirectCast(ltl.NamingContainer, GridViewRow)
Dim celda As DataControlFieldCell = DirectCast(ltl.Parent, DataControlFieldCell)
Dim value As String = DataBinder.Eval(row.DataItem, _columnName).ToString()
ltl.Text = value.FormatoNumero
End Sub
''' <summary>
''' This is the event, which will be raised when the binding happens.
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
Private Sub tb1_DataBinding(sender As Object, e As EventArgs)
Dim txtdata As TextBox = DirectCast(sender, TextBox)
Dim container As GridViewRow = DirectCast(txtdata.NamingContainer, GridViewRow)
Dim dataValue As Object = DataBinder.Eval(container.DataItem, _columnName)
If dataValue Is DBNull.Value Then
txtdata.Text = dataValue.ToString()
End If
End Sub
End Class
Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim Css As String = "Texto"
If e.Row.RowIndex = 0 Then
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Center
' e.Row.Cells(0).Width = Unit.Pixel(150)
e.Row.CssClass = "Totales"
Css = "Totales"
End If
Dim FechaI, FechaF As String
FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.Trim(), "-1")
FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.Trim(), "-1")
Dim Liga As String = String.Format("/Ventas/RepVentaDetalle.aspx?GPO={0}&Anio={1}&Mes={2}&AnioMes={3}&Fecha={4}&CveCliente={5}&CveSucursal={6}&Vendedor={7}&CveUsuario={8}&CveEstatusFactura={9}&FechaI={10}&FechaF={11}&IVA={12}&CveCorte={13}",
DdlGrupo.SelectedValue, e.Row.DBCampo("Anio"), e.Row.DBCampo("Mes"), e.Row.DBCampo("AnioMes"), e.Row.DBCampo("Fecha"), e.Row.DBCampo("CveCliente"), e.Row.DBCampo("CveSubProyecto"),
e.Row.DBCampo("Vendedor"), e.Row.DBCampo("CveUsuario"), e.Row.DBCampo("CveEstatusFactura"), FechaI, FechaF, e.Row.DBCampo("GPO_IVA"), e.Row.DBCampo("CveCorte"))
e.Row.FCLiteral("LtlGrupo").Text = "<a class=""" & Css & """ href=""" & Liga & """>" & e.Row.FCLiteral("LtlGrupo").Text & "</a>"
'e.Row.FCLiteral("LtlCantidad").Text = "<a class=""" & Css & """ href=""" & Liga & """>" & e.Row.FCLiteral("LtlCantidad").Text & "</a>"
For Each Col As DataColumn In DirectCast(e.Row.DataItem, System.Data.DataRowView).Row.Table.Columns
If Col.ColumnName.Split(CChar("_")).Count = 4 Then
Dim CveSubProyecto As Integer = Col.ColumnName.Split(CChar("_"))(3).ToEntero
Liga = String.Format("/Ventas/RepVentaDetalle.aspx?GPO={0}&Anio={1}&Mes={2}&AnioMes={3}&Fecha={4}&CveCliente={5}&CveSucursal={6}&Vendedor={7}&CveUsuario={8}&CveEstatusFactura={9}&FechaI={10}&FechaF={11}&IVA={12}&CveCorte={13}",
DdlGrupo.SelectedValue, e.Row.DBCampo("Anio"), e.Row.DBCampo("Mes"), e.Row.DBCampo("AnioMes"), e.Row.DBCampo("Fecha"), e.Row.DBCampo("CveCliente"), CveSubProyecto,
e.Row.DBCampo("Vendedor"), e.Row.DBCampo("CveUsuario"), e.Row.DBCampo("CveEstatusFactura"), FechaI, FechaF, e.Row.DBCampo("GPO_IVA"), e.Row.DBCampo("CveCorte"))
e.Row.FCLiteral(String.Format("ltl{0}", Col.ColumnName)).Text = "<a class=""" & Css & """ href=""" & Liga & """>" & e.Row.FCLiteral(String.Format("ltl{0}", Col.ColumnName)).Text & "</a>"
End If
Next
'If e.Row.DBCampo("SubTotal").ToDouble = 0 Then e.Row.FCLiteral("LtlSubTotal").Text = ""
'If e.Row.DBCampo("Descuento").ToDouble = 0 Then e.Row.FCLiteral("LtlDescuento").Text = ""
'If e.Row.DBCampo("Amortizacion").ToDouble = 0 Then e.Row.FCLiteral("LtlAmortizacion").Text = ""
'If e.Row.DBCampo("IVA").ToDouble = 0 Then e.Row.FCLiteral("LtlIVA").Text = ""
'If e.Row.DBCampo("RetIVA").ToDouble = 0 Then e.Row.FCLiteral("LtlRetIVA").Text = ""
'If e.Row.DBCampo("RetISR").ToDouble = 0 Then e.Row.FCLiteral("LtlRetISR").Text = ""
'If e.Row.DBCampo("Total").ToDouble = 0 Then e.Row.FCLiteral("LtlTotal").Text = ""
'If e.Row.DBCampo("MAX_SubTotal").ToDouble = 0 Then e.Row.FCLiteral("LtlMaxSubTotal").Text = ""
'If e.Row.DBCampo("AVG_SubTotal").ToDouble = 0 Then e.Row.FCLiteral("LtlAVGSubTotal").Text = ""
'If e.Row.DBCampo("MIN_SubTotal").ToDouble = 0 Then e.Row.FCLiteral("LtlMinSubTotal").Text = ""
'If e.Row.DBCampo("MAX_Total").ToDouble = 0 Then e.Row.FCLiteral("LtlMaxTotal").Text = ""
'If e.Row.DBCampo("AVG_Total").ToDouble = 0 Then e.Row.FCLiteral("LtlAVGTotal").Text = ""
'If e.Row.DBCampo("MIN_Total").ToDouble = 0 Then e.Row.FCLiteral("LtlMinTotal").Text = ""
End If
End Sub
End Class

164
PV/PVRepVentasCompras.aspx Normal file
View File

@@ -0,0 +1,164 @@
<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="PVRepVentasCompras.aspx.vb" Inherits="PV_PVRepVentasCompras" %>
<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Css" runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HB" runat="Server">
<asp:ImageButton ID="ImgImprimir" runat="server" ImageUrl="/Imagenes/btnImprimir.gif" Width="17px" Height="17px" Enabled="false" />
<asp:ImageButton ID="ImgExcel" runat="server" ImageUrl="/Imagenes/IconoExcel.gif" Width="17px" Height="17px" />
<asp:Image ID="ImgPersonalizar" runat="server" ImageUrl="/Imagenes/Table-icon.png" Width="17px" Height="17px" Style="cursor: pointer;" />
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="E" runat="Server">
Reporte de Ventas y Compras
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="H" runat="Server">
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="C" runat="Server">
<asp:UpdatePanel ID="UPFiltros" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div class="portlet solid grey-cascade portlet-filter" style="">
<div class="portlet-title portlet-filterT" style="">
<div class="titlefiltros caption ">
<ul class="list-inline">
<li>Sucursal
<asp:DropDownList ID="DdlSubProyecto" runat="server" AppendDataBoundItems="true" DataTextField="SubProyecto" DataValueField="CveSubProyecto" Class="table-group-action-input form-control input-inline input-small input-sm" Style="width: 200px !important;">
<asp:ListItem Selected="True" Text="Todas" Value="-1"></asp:ListItem>
</asp:DropDownList>
</li>
<li>Fecha Inicial:
<asp:TextBox ID="txtFechaI" runat="server" Width="70px"></asp:TextBox>
&nbsp;<asp:ImageButton runat="server" ID="imgCalendario" ImageUrl="/Imagenes/calendar.png" ImageAlign="AbsMiddle" Width="16px" Height="16px" AlternateText="Click para ver el Calendario" />
<ajax:MaskedEditExtender ID="MEEFechaI" runat="server" TargetControlID="txtFechaI" Mask="99/99/9999" MaskType="Date" DisplayMoney="Left" AcceptNegative="Left"></ajax:MaskedEditExtender>
<ajax:CalendarExtender runat="server" ID="Calendario" TargetControlID="txtFechaI" PopupButtonID="ImgCalendario" PopupPosition="BottomRight" Enabled="True"></ajax:CalendarExtender>
<asp:RequiredFieldValidator ID="rfvFechaI" runat="server" ControlToValidate="txtFechaI" Display="None" ErrorMessage="El campo <b>''Fecha Inicial''</b> es requerido por la aplicación, por favor ingrese una fecha." ValidationGroup="Valida"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="cvFechaI" runat="server" ControlToValidate="txtFechaI" Display="None" ErrorMessage="El campo <b>''Fecha Inicial''</b> no tienes el formato correcto, por favor intente de nuevo con el siguiente formato: (dd/mm/yyyy)." Operator="DataTypeCheck" Type="Date" ValidationGroup="Valida"></asp:CompareValidator>
<ajax:ValidatorCalloutExtender ID="vcoFfvFI" runat="server" HighlightCssClass="vco" TargetControlID="rfvFechaI" Width="350px"></ajax:ValidatorCalloutExtender>
<ajax:ValidatorCalloutExtender ID="vcoCvFI" runat="server" HighlightCssClass="vco" TargetControlID="cvFechaI" Width="350px"></ajax:ValidatorCalloutExtender>
</li>
<li>Fecha Final:
<asp:TextBox ID="txtFechaF" runat="server" Width="70px"></asp:TextBox>
&nbsp;<asp:ImageButton runat="server" ID="imgCalendarioF" ImageUrl="/Imagenes/calendar.png" ImageAlign="AbsMiddle" Width="16px" Height="16px" AlternateText="Click para ver el Calendario" />
<ajax:MaskedEditExtender ID="MEEFechaF" runat="server" TargetControlID="txtFechaF" Mask="99/99/9999" MaskType="Date" DisplayMoney="Left" AcceptNegative="Left"></ajax:MaskedEditExtender>
<ajax:CalendarExtender runat="server" ID="Calendario2" TargetControlID="txtFechaF" PopupButtonID="imgCalendarioF" PopupPosition="BottomRight" Enabled="True"></ajax:CalendarExtender>
<asp:RequiredFieldValidator ID="rfvFechaF" runat="server" ControlToValidate="txtFechaF" Display="None" ErrorMessage="El campo <b>''Fecha Final''</b> es requerido por la aplicación, por favor ingrese una fecha." ValidationGroup="Valida"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="cvFechaF" runat="server" ControlToValidate="txtFechaF" Display="None" ErrorMessage="El campo <b>''Fecha Final''</b> no tienes el formato correcto, por favor intente de nuevo con el siguiente formato: (dd/mm/yyyy)." Operator="DataTypeCheck" Type="Date" ValidationGroup="Valida"></asp:CompareValidator>
<ajax:ValidatorCalloutExtender ID="vcoRfvFF" runat="server" HighlightCssClass="vco" TargetControlID="rfvFechaF" Width="350px"></ajax:ValidatorCalloutExtender>
<ajax:ValidatorCalloutExtender ID="vcoCvFF" runat="server" HighlightCssClass="vco" TargetControlID="cvFechaF" Width="350px"></ajax:ValidatorCalloutExtender>
</li>
<li>Grupo:
<asp:DropDownList ID="DdlGrupo" runat="server" Class="table-group-action-input form-control input-inline input-small input-sm" Style="width: 100px !important;">
<asp:ListItem Text="Año" Value="1"></asp:ListItem>
<asp:ListItem Text="Mes" Value="2"></asp:ListItem>
<asp:ListItem Text="Año/Mes" Value="3"></asp:ListItem>
<asp:ListItem Text="Fecha" Value="4"></asp:ListItem>
<asp:ListItem Text="Cliente" Value="5"></asp:ListItem>
<asp:ListItem Selected="True" Text="Sucursal" Value="6"></asp:ListItem>
</asp:DropDownList>
</li>
</ul>
</div>
<div class="tools">
<asp:Button ID="BtnConsultar" runat="server" Text="Consultar" class="btn btn-primary" />
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<br />
<asp:UpdatePanel ID="UPDatos" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table border="0" cellpadding="0" cellspacing="0" id="tblSucursales" runat="server" visible="false">
<tr>
<td style="width: 150px">&nbsp;</td>
</tr>
</table>
<asp:GridView ID="GvDatos" runat="server" AutoGenerateColumns="False" EmptyDataText="No se encontraron Ventas con los filtros especificados" ToolTip="Listado de Ventas" CssClass="table table-striped table-advance table-hover" Style="margin-top: -10px; text-align: center;" GridLines="None">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
Grupo
</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="LtlGrupo" runat="server" Text='<%# Eval("GPO") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
Ventas
</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="LtlVentas" runat="server" Text='<%# Eval("Ventas", "{0:N2}")%>'></asp:Literal>
</ItemTemplate>
<ItemStyle HorizontalAlign="Right" />
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
Compras
</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="LtlCompras" runat="server" Text='<%# Eval("Compras", "{0:N2}")%>'></asp:Literal>
</ItemTemplate>
<ItemStyle HorizontalAlign="Right" />
</asp:TemplateField>
</Columns>
<RowStyle CssClass="Texto" />
<HeaderStyle CssClass="Titulos" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel runat="server" ID="UPPersonalizar" UpdateMode="Conditional">
<ContentTemplate>
<div id="DivPersonalizar" style="width: 315px; background-color: White; border: solid 1px black; color: Black; display: none; position: absolute;">
<table class="table table-striped table-advance table-hover" width="315px">
<tr class="Titulos">
<th style="width: 310px">
<asp:Label ID="LblTitulo1" runat="server" ClientIDMode="Static" Text="Personalizar Columnas"></asp:Label>
</th>
<th style="padding-right: 4px; padding-top: 4px" valign="top">
<img alt="" src="/Imagenes/close.gif" style="cursor: pointer;" onclick="$('#DivPersonalizar').hide(1000);" /></th>
</tr>
<tr align="left">
<td colspan="2">
<table class="table table-striped table-advance table-hover">
<thead>
<tr>
<th style="text-align: left;">
<asp:CheckBox ID="ChkRetIVA" runat="server" Text="Ret. IVA" /></th>
<th style="text-align: left;">
<asp:CheckBox ID="ChkMinSub" runat="server" Text="SubTotal Mínimo" /></th>
</tr>
<tr>
<th style="text-align: left;">
<asp:CheckBox ID="ChkRetISR" runat="server" Text="Ret. ISR" /></th>
<th style="text-align: left;">
<asp:CheckBox ID="ChkMaxTot" runat="server" Text="Total Máximo" /></th>
</tr>
<tr>
<th style="text-align: left;">
<asp:CheckBox ID="ChkMaxSub" runat="server" Text="SubTotal Máximo" /></th>
<th style="text-align: left;">
<asp:CheckBox ID="ChkAvgTot" runat="server" Text="Total Promedio" /></th>
</tr>
<tr>
<th style="text-align: left;">
<asp:CheckBox ID="ChkAVGSub" runat="server" Text="SubTotal Promedio" /></th>
<th style="text-align: left;">
<asp:CheckBox ID="ChkMinTot" runat="server" Text="Total Mínimo" /></th>
</tr>
</thead>
</table>
</td>
</tr>
<tr style="height: 25px">
<td style="text-align: center;" colspan="2">
<asp:Button ID="BtnPersonalizar" runat="server" Text="Personalizar" class="btn btn-primary" /><input type="button" value="Cancelar" onclick="$('#DivPersonalizar').hide(1000);" class="btn btn-danger" /></td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="JS" runat="Server">
</asp:Content>

View File

@@ -0,0 +1,238 @@
Option Explicit On
Option Strict On
Imports System.Data
Imports Extensiones
Partial Class PV_PVRepVentasCompras
Inherits ClsPaginas
#Region "Propiedades"
'Local
Private Property TmpDT As DataTable
Get
Return CType(ViewState("TmpDT"), DataTable)
End Get
Set(value As DataTable)
ViewState("TmpDT") = value
End Set
End Property
#End Region
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")
CargaCombos()
ImgPersonalizar.Attributes.Add("onclick", "javascript:$('#DivPersonalizar').show(1000); PosicionaObjeto(this.id,'DivPersonalizar');")
End If
End Sub
Private Sub CargaCombos()
'CargaSucursales
DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1).FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
DdlSubProyecto.DataBind()
End Sub
Protected Sub BtnConsultar_Click(sender As Object, e As System.EventArgs) Handles BtnConsultar.Click
CargaDatos()
ConfiguraEmpresa()
UPDatos.Update()
End Sub
Private Sub CargaDatos()
Dim ObjVentas As New ClsPV()
Dim FechaI, FechaF As String
FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.Trim(), "-1")
FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.Trim(), "-1")
If ObjVentas.GetRepPVVentasCompras(FechaI, FechaF, DdlSubProyecto.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlGrupo.SelectedValue.ToEntero) Then
GvDatos.DataSource = ObjVentas.DtResultados
tblSucursales.Visible = True
Else
GvDatos.DataSource = Nothing
End If
ObjVentas.Dispose()
GvDatos.DataBind()
End Sub
Private Sub ConfiguraEmpresa()
'If Not UsuarioActual.Empresa.MostrarRetIVA Then GvDatos.Columns(6).Visible = False
'If Not UsuarioActual.Empresa.MostrarRetISR Then GvDatos.Columns(7).Visible = False
End Sub
Protected Sub BtnPersonalizar_Click(sender As Object, e As System.EventArgs) Handles BtnPersonalizar.Click
If ChkRetIVA.Checked Then
GvDatos.Columns(6).Visible = True
Else
GvDatos.Columns(6).Visible = False
End If
If ChkRetISR.Checked Then
GvDatos.Columns(7).Visible = True
Else
GvDatos.Columns(7).Visible = False
End If
If ChkMinSub.Checked Then
GvDatos.Columns(9).Visible = True
Else
GvDatos.Columns(9).Visible = False
End If
If ChkAVGSub.Checked Then
GvDatos.Columns(10).Visible = True
Else
GvDatos.Columns(10).Visible = False
End If
If ChkMaxSub.Checked Then
GvDatos.Columns(11).Visible = True
Else
GvDatos.Columns(11).Visible = False
End If
If ChkMinTot.Checked Then
GvDatos.Columns(12).Visible = True
Else
GvDatos.Columns(12).Visible = False
End If
If ChkAvgTot.Checked Then
GvDatos.Columns(13).Visible = True
Else
GvDatos.Columns(13).Visible = False
End If
If ChkMaxTot.Checked Then
GvDatos.Columns(14).Visible = True
Else
GvDatos.Columns(14).Visible = False
End If
UPDatos.Update()
End Sub
Protected Sub ImgExcel_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles ImgExcel.Click
GvDatos.ExportToExcel("ReporteVentas" & Now.ToShortDateString)
End Sub
'Region "TEMPLATE"
Public Class GridViewTemplate
Implements ITemplate
'A variable to hold the type of ListItemType.
Private _templateType As ListItemType
'A variable to hold the column name.
Private _columnName As String
'Constructor where we define the template type and column name.
Public Sub New(type As ListItemType, colname As String)
'Stores the template type.
_templateType = type
'Stores the column name.
_columnName = colname
End Sub
Private Sub ITemplate_InstantiateIn(container As System.Web.UI.Control) Implements ITemplate.InstantiateIn
Select Case _templateType
Case ListItemType.Header
'Creates a new label control and add it to the container.
Dim lbl As New Label()
'Allocates the new label object.
lbl.Text = _columnName
'Assigns the name of the column in the lable.
container.Controls.Add(lbl)
'Adds the newly created label control to the container.
Exit Select
Case ListItemType.Item
'Creates a new text box control and add it to the container.
Dim ltl1 As New Literal
ltl1.ID = String.Format("ltl{0}", _columnName)
AddHandler ltl1.DataBinding, AddressOf ltl_DataBinding
'AddHandler hdn1.DataBinding, AddressOf hdn_DataBinding
'Creates a column with size 4.
container.Controls.Add(ltl1)
'Adds the newly created textbox to the container.
Exit Select
Case ListItemType.EditItem
'As, I am not using any EditItem, I didnot added any code here.
Exit Select
Case ListItemType.Footer
Dim chkColumn As New CheckBox()
chkColumn.ID = Convert.ToString("Chk") & _columnName
container.Controls.Add(chkColumn)
Exit Select
End Select
End Sub
Private Sub hdn_DataBinding(sender As Object, e As EventArgs)
Dim hidden As HiddenField = DirectCast(sender, HiddenField)
Dim row As GridViewRow = DirectCast(hidden.NamingContainer, GridViewRow)
Dim value As String = DataBinder.Eval(row.DataItem, _columnName).ToString()
hidden.Value = If(value Is Nothing OrElse value = String.Empty, "-1", value)
End Sub
Private Sub ltl_DataBinding(sender As Object, e As EventArgs)
Dim ltl As Literal = DirectCast(sender, Literal)
Dim row As GridViewRow = DirectCast(ltl.NamingContainer, GridViewRow)
Dim celda As DataControlFieldCell = DirectCast(ltl.Parent, DataControlFieldCell)
Dim value As String = DataBinder.Eval(row.DataItem, _columnName).ToString()
ltl.Text = value.FormatoNumero
End Sub
''' <summary>
''' This is the event, which will be raised when the binding happens.
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
Private Sub tb1_DataBinding(sender As Object, e As EventArgs)
Dim txtdata As TextBox = DirectCast(sender, TextBox)
Dim container As GridViewRow = DirectCast(txtdata.NamingContainer, GridViewRow)
Dim dataValue As Object = DataBinder.Eval(container.DataItem, _columnName)
If dataValue Is DBNull.Value Then
txtdata.Text = dataValue.ToString()
End If
End Sub
End Class
Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim Css As String = "Texto"
If e.Row.RowIndex = 0 Then
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Center
e.Row.Cells(0).Width = Unit.Pixel(150)
e.Row.Cells(1).Width = Unit.Pixel(100)
e.Row.Cells(2).Width = Unit.Pixel(100)
e.Row.CssClass = "Totales"
Css = "Totales"
End If
Dim FechaI, FechaF As String
FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.Trim(), "-1")
FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.Trim(), "-1")
Dim LigaV As String = String.Format("/Ventas/RepVentaDetalle.aspx?GPO={0}&Anio={1}&Mes={2}&AnioMes={3}&Fecha={4}&CveCliente=-1&CveSucursal={5}&Vendedor=-1&CveUsuario=-1&CveEstatusFactura=-1&FechaI={6}&FechaF={7}&IVA=-1&CveCorte=-1",
DdlGrupo.SelectedValue, e.Row.DBCampo("Anio"), e.Row.DBCampo("Mes"), e.Row.DBCampo("AnioMes"), e.Row.DBCampo("Fecha"), e.Row.DBCampo("CveSucursal"), FechaI, FechaF)
Dim LigaC As String = String.Format("/Compras/RepComprasDetalle.aspx?GPO={0}&Anio={1}&Mes={2}&AnioMes={3}&Fecha={4}&CveProveedor=-1&CveUsuario=-1&FechaI={5}&FechaF={6}",
DdlGrupo.SelectedValue, e.Row.DBCampo("Anio"), e.Row.DBCampo("Mes"), e.Row.DBCampo("AnioMes"), e.Row.DBCampo("Fecha"), FechaI, FechaF)
e.Row.FCLiteral("LtlVentas").Text = "<a class=""" & Css & """ href=""" & LigaV & """>" & e.Row.FCLiteral("LtlVentas").Text & "</a>"
e.Row.FCLiteral("LtlCompras").Text = String.Format("<a class='{0}' href='{1}'>{2}</a>", Css, LigaC, e.Row.FCLiteral("LtlCompras").Text)
End If
End Sub
End Class