This commit is contained in:
2021-03-19 09:49:05 -07:00
5 changed files with 562 additions and 22 deletions

View File

@@ -1405,6 +1405,7 @@ Partial Class Clientes
Dim RetSC As Boolean = CargaSucursalesCliente()
Dim RetCC As Boolean = CargaCotizaciones()
CargaHistorial()
CargaResumenHistorial()
Dim RetCxC As Boolean = CargaCxC()
CargaAnticipos()
CargaPersonalAsignado()
@@ -1799,14 +1800,9 @@ Partial Class Clientes
Private Sub CargaHistorial(Optional SelectTop As Integer = 21, Optional CveClienteSucursal As Integer = -1)
Dim ObjClientes As New ClsClientes()
If ObjClientes.GetHistorialVentas(CveCliente, SelectTop, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero()) Then
If ObjClientes.DtResultados.Rows.Count > 0 Then
'Carga Generales
LtlCantidad.Text = ObjClientes.DtResultados.Rows(0)("CountTotal").ToString().FormatoNumero()(0)
LtlTotalVendido.Text = ObjClientes.DtResultados.Rows(0)("Total").ToString().FormatoNumero()(2)
LtlMinima.Text = ObjClientes.DtResultados.Rows(0)("MIN_Total").ToString().FormatoNumero()(2)
LtlPromedio.Text = ObjClientes.DtResultados.Rows(0)("AVG_Total").ToString().FormatoNumero()(2)
LtlMaxima.Text = ObjClientes.DtResultados.Rows(0)("MAX_Total").ToString().FormatoNumero()(2)
'Carga Grid
If ObjClientes.DtResultados.Rows.Count > 0 Then
'Carga Grid
DTHistorialVentas = ObjClientes.DtResultados
GVHistorial.DataSource = ObjClientes.DtResultados
Else
@@ -10313,5 +10309,44 @@ Partial Class Clientes
UpDatos.Update()
End Sub
Private Sub CargaResumenHistorial()
Dim ObjClientes As New ClsClientes()
If ObjClientes.GetHistorialVentas(CveCliente, -1, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero()) Then
If ObjClientes.DtResultados.Rows.Count > 0 Then
Dim Cantidad As Double
Dim Max As Double
Dim Min As Double = 1000000000000
Dim Total As Double
Dim Promedio As Double
For Each row As DataRow In ObjClientes.DtResultados.Rows
If row.Item("Folio").ToString <> "" Then
If row.Item("Total").ToString.ToDouble > Max Then
Max = row.Item("Total").ToString.ToDouble
End If
If row.Item("Total").ToString.ToDouble < Min And row.Item("Total").ToString.ToDouble > 0 Then
Min = row.Item("Total").ToString.ToDouble
End If
Total += row.Item("Total").ToString.ToDouble
Cantidad += 1
End If
Next
Promedio = Total / Cantidad
'Carga Generales
LtlCantidad.Text = Cantidad.ToString.FormatoNumero(0)
LtlTotalVendido.Text = Total.ToString.FormatoNumero()
LtlMinima.Text = Min.ToString.FormatoNumero()
LtlPromedio.Text = Promedio.ToString.FormatoNumero()
LtlMaxima.Text = Max.ToString.FormatoNumero()
End If
End If
ObjClientes.Dispose()
End Sub
End Class