Indicador Resumen, Comp Productores agrupar por PS, + Abonado en CxP Productores

CAMBIOS EN BD (Ventas):
- PA_Citrus_IndicadoresGet
This commit is contained in:
MLopez
2023-02-18 12:00:19 -07:00
parent 951b02fc9b
commit 32561f3953
2 changed files with 32 additions and 37 deletions

View File

@@ -179,16 +179,20 @@
<div class="portlet-body formnombottom"> <div class="portlet-body formnombottom">
<asp:GridView ID="GvCompProductores" runat="server" GridLines="None" <asp:GridView ID="GvCompProductores" runat="server" GridLines="None"
CssClass="table table-striped table-advance table-hover ScrollAD Widthall " ShowHeader="True" EmptyDataText="No se encontraron resultados." ShowHeaderWhenEmpty="true" CssClass="table table-striped table-advance table-hover ScrollAD Widthall " ShowHeader="True" EmptyDataText="No se encontraron resultados." ShowHeaderWhenEmpty="true"
AutoGenerateColumns="False" AllowPaging="False" ShowFooter="True"> AutoGenerateColumns="False" AllowPaging="False">
<Columns> <Columns>
<asp:BoundField DataField="RazonSocial" HeaderText="Proveedor" /> <asp:BoundField DataField="GPO" HeaderText="Prod/Serv" />
<asp:BoundField DataFormatString="{0:n}" DataField="Cantidad" ItemStyle-CssClass="margenbound" HeaderText="Cantidad(kg)" /> <asp:BoundField DataFormatString="{0:n}" DataField="Cantidad" ItemStyle-CssClass="margenbound" HeaderText="Cantidad(kg)" />
<asp:BoundField DataFormatString="{0:c}" DataField="SubTotal" ItemStyle-CssClass="margenbound" HeaderText="Importe" /> <asp:BoundField DataFormatString="{0:c}" DataField="SubTotal" ItemStyle-CssClass="margenbound" HeaderText="Importe" />
<asp:BoundField DataFormatString="{0:c}" DataField="PUPromedioKG" ItemStyle-CssClass="margenbound" HeaderText="Promedio/kg" /> <%--TODO: Esto se puede meter en el stored procedured, pero me da cosa moverle :S--%>
<asp:BoundField DataFormatString="{0:c}" DataField="Saldo" ItemStyle-CssClass="margenbound" HeaderText="Saldo" /> <asp:TemplateField ItemStyle-CssClass="margenbound" HeaderText="P. Promedio">
<asp:BoundField DataFormatString="{0:c}" DataField="Abonado" ItemStyle-CssClass="margenbound" HeaderText="Abonado" /> <ItemTemplate>
<%--TODO: Esto puede tronar si el valor es DBNull --%>
<%# If(Convert.ToDecimal(Eval("Cantidad")) = 0, 0.ToString("C"), (Convert.ToDecimal(Eval("SubTotal")) / Convert.ToInt32(Eval("Cantidad"))).ToString("C")) %>
</ItemTemplate>
</asp:TemplateField>
<%--<asp:BoundField DataFormatString="{0:c}" DataField="PUPromedioKG" ItemStyle-CssClass="margenbound" HeaderText="Promedio/kg" />--%>
</Columns> </Columns>
<FooterStyle CssClass="Totales"/>
</asp:GridView> </asp:GridView>
</div> </div>
</ContentTemplate> </ContentTemplate>
@@ -343,6 +347,7 @@
<Columns> <Columns>
<asp:BoundField DataField="RazonSocial" HeaderText="Proveedor" /> <asp:BoundField DataField="RazonSocial" HeaderText="Proveedor" />
<asp:BoundField DataFormatString="{0:c}" DataField="Saldo" ItemStyle-CssClass="margenbound" HeaderText="Saldo" /> <asp:BoundField DataFormatString="{0:c}" DataField="Saldo" ItemStyle-CssClass="margenbound" HeaderText="Saldo" />
<asp:BoundField DataFormatString="{0:c}" DataField="Abonado" ItemStyle-CssClass="margenbound" HeaderText="Abonado" />
</Columns> </Columns>
</asp:GridView> </asp:GridView>
</div> </div>

View File

@@ -32,7 +32,6 @@ Partial Class General_RepIndicadorResumen
Dim ObjVentas As New ClsVentas Dim ObjVentas As New ClsVentas
Dim ObjCompras As New ClsCompras Dim ObjCompras As New ClsCompras
Dim ObjMovtos As New ClsMovimientos
Dim ObjCitrus As New ClsCGame Dim ObjCitrus As New ClsCGame
Dim Grupo As Integer = 28 'Clasificación - PS Dim Grupo As Integer = 28 'Clasificación - PS
@@ -41,9 +40,14 @@ Partial Class General_RepIndicadorResumen
GvVxP.DataSource = ObjVentas.DtResultados GvVxP.DataSource = ObjVentas.DtResultados
End If End If
If ObjCompras.GetRepProductosServicios(-1, DdlSubProyecto.SelectedValue.ToEntero, -1, -1, -1, TxtFechaI.Text.Trim(), TxtFechaF.Text.Trim(), -1, -1, -1,
UsuarioActual.CveEmpresa, 5, -1, -1, "-1", "-1", -1, TipoCambio:=1, CveUsuarioConsulta:=UsuarioActual.CveUsuario, CveProveedorClasificacion:=192) Then
GvCompProductores.DataSource = ObjCompras.DtResultados.FiltraParametros("", "Cantidad DESC")
End If
If ObjCitrus.GetIndicadores(UsuarioActual.CveEmpresa, TxtFechaI.Text, TxtFechaF.Text, UsuarioActual.CveUsuario, DdlSubProyecto.SelectedValue.ToEntero) Then If ObjCitrus.GetIndicadores(UsuarioActual.CveEmpresa, TxtFechaI.Text, TxtFechaF.Text, UsuarioActual.CveUsuario, DdlSubProyecto.SelectedValue.ToEntero) Then
'Compras Productores 'Compras Productores
GvCompProductores.DataSource = ObjCitrus.DTSetResultados.Tables(0).FiltraParametros("", "RazonSocial ASC") 'GvCompProductores.DataSource = ObjCitrus.DTSetResultados.Tables(0).FiltraParametros("", "RazonSocial ASC")
'CxP Productores 'CxP Productores
GvCxP192.DataSource = ObjCitrus.DTSetResultados.Tables(1).FiltraParametros("", "CveMoneda,Saldo DESC") GvCxP192.DataSource = ObjCitrus.DTSetResultados.Tables(1).FiltraParametros("", "CveMoneda,Saldo DESC")
'CxP NO productores 'CxP NO productores
@@ -55,6 +59,7 @@ Partial Class General_RepIndicadorResumen
End If End If
ObjVentas.Dispose() ObjVentas.Dispose()
ObjCompras.Dispose()
ObjCitrus.Dispose() ObjCitrus.Dispose()
GvVxP.DataBind() GvVxP.DataBind()
@@ -167,28 +172,11 @@ Partial Class General_RepIndicadorResumen
End Sub End Sub
Dim CompProductoresTotales As Decimal() = New Decimal(5 - 1) {} Dim CompProductoresTotales As Decimal() = New Decimal(5 - 1) {}
Protected Sub GvCompProductores_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCompProductores.RowDataBound Protected Sub GvCompProductores_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCompProductores.RowDataBound
'Esto tambien se podría meter en el Stored Procedure
If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.RowType = DataControlRowType.DataRow Then
CompProductoresTotales(0) += Convert.ToDecimal(IfNull(DataBinder.Eval(e.Row.DataItem, "Cantidad"), 0)) If e.Row.DBCampo("Orden") = "00ND" Then
CompProductoresTotales(1) += Convert.ToDecimal(IfNull(DataBinder.Eval(e.Row.DataItem, "SubTotal"), 0)) e.Row.CssClass = "Totales"
CompProductoresTotales(2) += Convert.ToDecimal(IfNull(DataBinder.Eval(e.Row.DataItem, "PUPromedioKG"), 0)) e.Row.Cells(0).Text = "Total " + e.Row.DBCampo("Moneda")
CompProductoresTotales(3) += Convert.ToDecimal(IfNull(DataBinder.Eval(e.Row.DataItem, "Saldo"), 0)) End If
CompProductoresTotales(4) += Convert.ToDecimal(IfNull(DataBinder.Eval(e.Row.DataItem, "Abonado"), 0))
ElseIf e.Row.RowType = DataControlRowType.Footer Then
'Movemos el pie a la primera fila de la tabla
Dim footerRow As GridViewRow = e.Row
GvCompProductores.Controls(0).Controls.Remove(footerRow)
GvCompProductores.Controls(0).Controls.AddAt(1, footerRow)
'Ahora se registran los datos
e.Row.Cells(0).Text = "Totales"
e.Row.Cells(1).Text = CompProductoresTotales(0).ToString("N")
e.Row.Cells(2).Text = CompProductoresTotales(1).ToString("C")
e.Row.Cells(3).Text = (CompProductoresTotales(2) / GvCompProductores.Rows.Count).ToString("C") 'Promedio
e.Row.Cells(4).Text = CompProductoresTotales(3).ToString("C")
e.Row.Cells(5).Text = CompProductoresTotales(4).ToString("C")
For i As Integer = 1 To e.Row.Cells.Count - 1
e.Row.Cells(i).CssClass = "margenbound"
Next
End If End If
End Sub End Sub
Protected Sub GvComprasAcreed_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCompAcreed.RowDataBound Protected Sub GvComprasAcreed_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCompAcreed.RowDataBound
@@ -257,13 +245,15 @@ Partial Class General_RepIndicadorResumen
DtCompProductores.Columns.Add("UnidadC") DtCompProductores.Columns.Add("UnidadC")
DtCompProductores.Columns.Add("UnidadI") DtCompProductores.Columns.Add("UnidadI")
For Each Dr As DataRow In GvCompProductores.DataSource.Rows For Each Dr As DataRow In GvCompProductores.DataSource.Rows
Dim Row = DtCompProductores.NewRow() If Not Dr("Orden").ToString = "00ND" Then
Row("Texto") = Dr("RazonSocial").ToString Dim Row = DtCompProductores.NewRow()
Row("Cantidad") = Dr("Cantidad").ToString.FormatoNumero Row("Texto") = Dr("GPO").ToString
Row("Importe") = Dr("SubTotal").ToString.FormatoNumero Row("Cantidad") = Dr("Cantidad").ToString.FormatoNumero
Row("UnidadC") = "Kg" Row("Importe") = Dr("SubTotal").ToString.FormatoNumero
Row("UnidadI") = "MXN" Row("UnidadC") = "Kg"
DtCompProductores.Rows.Add(Row) Row("UnidadI") = "MXN"
DtCompProductores.Rows.Add(Row)
End If
Next Next
Dim comp_productores = From s In DtCompProductores.AsEnumerable() Select New With {.Texto = s("Texto").ToString(), .Cantidad = s("Cantidad").ToString().ToDouble(), .Importe = s("Importe").ToString().ToDouble(), .UnidadC = s("UnidadC").ToString(), .UnidadI = s("UnidadI").ToString()} Dim comp_productores = From s In DtCompProductores.AsEnumerable() Select New With {.Texto = s("Texto").ToString(), .Cantidad = s("Cantidad").ToString().ToDouble(), .Importe = s("Importe").ToString().ToDouble(), .UnidadC = s("UnidadC").ToString(), .UnidadI = s("UnidadI").ToString()}
Dim group_comp_productores = comp_productores.GroupBy(Function(x) x.Texto).[Select](Function(g) New With { Dim group_comp_productores = comp_productores.GroupBy(Function(x) x.Texto).[Select](Function(g) New With {