This commit is contained in:
2024-09-05 11:55:54 -07:00
22 changed files with 501 additions and 189 deletions

View File

@@ -116,38 +116,94 @@
<ajax:TabPanel ID="TabPedidos" runat="server" HeaderText="Pedidos">
<ContentTemplate>
<div style="min-height: 250px; overflow-x: scroll">
<asp:GridView ID="GvDatos" runat="server" AutoGenerateColumns="False" EmptyDataText="No se encontraron Ventas con los filtros especificados"
CssClass="table table-striped table-advance table-hover Widthall ScrollAD" DataKeyNames="CveCliente,CveVendedor,CveSubProyecto,CvePS,CveUnidadMedida,Cantidad,PU,CveVentaDetalle,GastosEnvio" data-sort="true" GridLines="None" Width="99%">
<Columns>
<asp:TemplateField >
<ItemTemplate>
<asp:Label ID="LblCliente" runat="server" Text='<%#Eval("NombreComercial") %>'></asp:Label><br />
<asp:Label ID="LblDir" Font-Italic="true" runat="server" Text='<%#Eval("DireccionEnvio") %>'></asp:Label>
<div style="min-height: 250px; overflow-x: scroll">
<asp:GridView ID="GvDatos" runat="server" AutoGenerateColumns="False" EmptyDataText="No se encontraron Ventas con los filtros especificados"
CssClass="table table-striped table-advance table-hover Widthall ScrollAD mysmallbtn"
DataKeyNames="CveCliente,CveVendedor,CveSubProyecto,CvePS,CveUnidadMedida,Cantidad,PU,CveVentaDetalle,GastosEnvio,CveVenta,SerieFolio,CodigoPS,CantidadOrg,CvePSOrg,CodigoPSOrg" data-sort="true" GridLines="None" Width="99%">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="LblCliente" runat="server" Text='<%#Eval("NombreComercial") %>'></asp:Label><br />
<asp:Label ID="LblDir" Font-Italic="true" runat="server" Text='<%#Eval("DireccionEnvio") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="SerieFolio" ItemStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:Label ID="LblSerieFolio" runat="server" Text='<%#Eval("SerieFolio") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Fecha" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="LblFecha" runat="server" Text='<%# Eval("Fecha", "{0:dd/MM/yyyy}") %>' ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Right" HeaderText="Cantidad">
<EditItemTemplate>
<asp:TextBox ID="TxtCantidad" runat="server" CausesValidation="true" MaxLength="12" style="text-align:right" Text='<%# Eval("Cantidad", "{0:0.######}") %>' Width="45px" Height="24px"></asp:TextBox>
<ajax:FilteredTextBoxExtender runat="server" TargetControlID="TxtCantidad" FilterType="Custom" ValidChars="1234567890." />
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="LblCantidad" runat="server" Text='<%# Eval("Cantidad", "{0:#,###.####}") %>' ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="SerieFolio" DataField="SerieFolio" />
<asp:BoundField HeaderText="Fecha" DataField="Fecha" DataFormatString="{0:d}" />
<asp:BoundField HeaderText="Cantidad" DataField="Cantidad" DataFormatString="{0:#,###.##}" ItemStyle-HorizontalAlign="Right" />
<asp:BoundField HeaderText="Producto" DataField="CodigoPS" />
<asp:BoundField HeaderText="Vendedor" DataField="Vendedor" />
<asp:TemplateField ItemStyle-Width="2.5%">
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Left" HeaderText="Producto">
<EditItemTemplate>
<asp:DropDownList runat="server" ID="DdlPS" DataTextField="CodigoPS" CssClass="form-control select2me" Width="100%" DataValueField="CvePS" ></asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="LblProducto" runat="server" Text='<%#Eval("CodigoPS") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Vendedor" ItemStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:Label ID="LblVendedor" runat="server" Text='<%#Eval("Vendedor") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="Editar">
<EditItemTemplate >
<div style="width: 85px;">
<asp:LinkButton ID="imgU" runat="server" AlternateText="Actualizar" CausesValidation="True" CommandName="Update" CssClass="btn btn-circle btn-sm green" Text="<i class='fa fa-check'></i>" ValidationGroup="GprGV" />
<asp:LinkButton ID="imgC" runat="server" AlternateText="Cancelar" CausesValidation="False" CommandName="Cancel" CssClass="btn btn-circle btn-sm red" Text="<i class='fa fa-times'></i>" />
</div>
</EditItemTemplate>
<ItemTemplate>
<asp:Checkbox runat="server" ID="chk" ></asp:Checkbox>
<asp:LinkButton ID="imgE" runat="server" AlternateText="Editar" CausesValidation="False" CommandName="Edit"
CssClass="btn btn-circle btn-sm green" Text="<i class='fa fa-pencil'></i>" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle CssClass="Texto" />
<HeaderStyle CssClass="Titulos" />
</asp:GridView>
</div>
<div class="row">
<div class="col-md-12" style="text-align:center;">
<asp:Button ID="BtnEntregar" runat="server" Text="Entregado" class="btn btn-primary" OnClick="BtnEntregar_Click" />
</div>
</div>
</ContentTemplate>
<asp:TemplateField ItemStyle-Width="2.5%">
<ItemTemplate>
<asp:CheckBox runat="server" ID="chk"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle CssClass="Texto" />
<HeaderStyle CssClass="Titulos" />
</asp:GridView>
</div>
<div class="row">
<div class="col-md-12" style="text-align: center;">
<asp:Button ID="BtnEntregar" runat="server" Text="Entregado" class="btn btn-primary" OnClick="BtnEntregar_Click" />
</div>
</div>
</ContentTemplate>
</ajax:TabPanel>
<ajax:TabPanel ID="TabEntregas" runat="server" HeaderText="Entregas">
<ContentTemplate>
@@ -175,5 +231,16 @@
</asp:Content>
<asp:Content ID="Content8" ContentPlaceHolderID="JS" runat="Server">
<script>
function seleccionVenta(chkId, cveVenta) {
// Obtener el estado actual del checkbox que fue clicado
var isChecked = $('#' + chkId).prop('checked');
// Seleccionar o deseleccionar todos los checkboxes que tienen la clase 'cveVenta'
$('.' + cveVenta).each(function () {
$(this).prop('checked', isChecked);
});
}
</script>
</asp:Content>

View File

@@ -1,16 +1,49 @@
Option Explicit On
Option Strict On
Imports System.Activities.Expressions
Imports System.Data
Imports DocumentFormat.OpenXml.Office.CustomUI
Imports Extensiones
Partial Class Ventas_RepPedidosSTF
Inherits ClsPaginas
Public Property DTProductosEdicion As DataTable
Get
If ViewState("DTProductosEdicion") Is Nothing Then
ViewState("DTProductosEdicion") = New DataTable
End If
Return DirectCast(ViewState("DTProductosEdicion"), DataTable)
End Get
Set(value As DataTable)
ViewState("DTProductosEdicion") = value
End Set
End Property
Public Property DatosGV As DataTable
Get
If ViewState("DatosGV") Is Nothing Then
ViewState("DatosGV") = New DataTable
End If
Return DirectCast(ViewState("DatosGV"), DataTable)
End Get
Set(value As DataTable)
ViewState("DatosGV") = value
End Set
End Property
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
CargaCombos()
CargaProductosEdicion()
End If
End Sub
Private Sub CargaCombos()
@@ -34,6 +67,8 @@ Partial Class Ventas_RepPedidosSTF
Protected Sub CargaDatos()
DatosGV = New DataTable
Dim Opcion As Integer = 1
Dim FechaInicio As Date = MinFecha
Dim FechaFin As Date = MaxFecha
@@ -43,15 +78,26 @@ Partial Class Ventas_RepPedidosSTF
FechaInicio = txtFechaI.Text.ToDate
FechaFin = txtFechaF.Text.ToDate
Dim ObjVentas As New ClsVentas
If ObjVentas.GetRepPedidosSTF(DdlSubProyecto.SelectedValue.ToEntero, DdlVendedor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, Opcion, FechaInicio, FechaFin) Then
GvE.DataSource = ObjVentas.DtResultados
End If
ObjVentas.Dispose()
GvE.DataBind()
Else
FechaInicio = txtFechaI.Text.ToDate
FechaFin = txtFechaF.Text.ToDate
Dim ObjVentas As New ClsVentas
If ObjVentas.GetRepPedidosSTF(DdlSubProyecto.SelectedValue.ToEntero, DdlVendedor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, Opcion, FechaInicio, FechaFin) Then
GvDatos.DataSource = ObjVentas.DtResultados
DatosGV = ObjVentas.DtResultados
DatosGV.Columns.Add("CantidadOrg", GetType(Decimal))
DatosGV.Columns.Add("CvePSOrg", GetType(Integer))
DatosGV.Columns.Add("CodigoPSOrg", GetType(String))
GvDatos.DataSource = DatosGV
End If
ObjVentas.Dispose()
GvDatos.DataBind()
@@ -59,19 +105,119 @@ Partial Class Ventas_RepPedidosSTF
End Sub
Private Sub CargaProductosEdicion()
DTProductosEdicion = New DataTable
Dim ObjVentas As ClsVentas = New ClsVentas()
If ObjVentas.GetPSSubProyectosVendedores(UsuarioActual.CveEmpresa) Then
DTProductosEdicion = ObjVentas.DtResultados.FiltraParametros($" CveVendedor = {UsuarioActual.CveVendedor}")
End If
ObjVentas.Dispose()
End Sub
Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DBCampo("CveVendedor") = "" OrElse e.Row.DBCampo("CvePS") = "" Then e.Row.FCCheckBox("Chk").Visible = False
If e.Row.DBCampo("CveVendedor") = "" OrElse e.Row.DBCampo("CvePS") = "" Then
e.Row.FCCheckBox("Chk").InputAttributes.Add("onclick", $"seleccionVenta('{e.Row.FCCheckBox("Chk").ClientID}','{e.Row.DataKey("CveVenta")}')")
e.Row.FCLinkButton("imgE").Visible = False
Else
e.Row.FCCheckBox("Chk").InputAttributes.Add("class", e.Row.DataKey("CveVenta"))
End If
If e.Row.DBCampo("TipoRenglon") = "1" Then e.Row.CssClass = "SubTotales"
End If
If e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then
If e.Row.DBCampo("CveVendedor") = "" OrElse e.Row.DBCampo("CvePS") = "" Then
Else
e.Row.FCDropDownList("DdlPS").DataSource = DTProductosEdicion
e.Row.FCDropDownList("DdlPS").DataBind()
e.Row.FCDropDownList("DdlPS").SelectedValueExist(e.Row.DBCampo("CvePS"))
End If
End If
End Sub
Protected Sub GvDatos_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GvDatos.RowEditing
GvDatos.EditIndex = e.NewEditIndex
CargaGvDatos()
End Sub
Protected Sub GvDatos_RowCancelingEdit(sender As Object, e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GvDatos.RowCancelingEdit
GvDatos.EditIndex = -1
CargaGvDatos()
End Sub
Protected Sub GvDatos_RowUpdating(sender As Object, e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GvDatos.RowUpdating
Dim Cantidad As Decimal = GvDatos.Rows(e.RowIndex).FCTextBox("TxtCantidad").Text.ToDecimal
Dim CvePSNuevo As Integer = GvDatos.Rows(e.RowIndex).FCDropDownList("DdlPS").SelectedValue.ToEntero
Dim PSNuevo As String = GvDatos.Rows(e.RowIndex).FCDropDownList("DdlPS").SelectedItem.Text
Dim PU As Decimal = DTProductosEdicion.FiltroPrimeroValor("Precio", $"CvePS = {CvePSNuevo}").ToDecimal
If Not CvePSNuevo > 0 Then
Alert("Producto no encontrado.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If Not Cantidad > 0 Then
Alert("Debe especificar la cantidad.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If Not PU > 0 Then
Alert("El precio del producto no puede ser 0.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
Dim CvPSOrg As Integer = DatosGV.Rows(GvDatos.EditIndex)("CvePSOrg").ToString.ToEntero
Dim CantidadOrg As Decimal = DatosGV.Rows(GvDatos.EditIndex)("CantidadOrg").ToString.ToDecimal
If Not (CvPSOrg > 0 Or CantidadOrg > 0) Then
DatosGV.Rows(GvDatos.EditIndex)("CantidadOrg") = GvDatos.Rows(GvDatos.EditIndex).DataKey("Cantidad")
DatosGV.Rows(GvDatos.EditIndex)("CvePSOrg") = GvDatos.Rows(GvDatos.EditIndex).DataKey("CvePS")
DatosGV.Rows(GvDatos.EditIndex)("CodigoPSOrg") = GvDatos.Rows(GvDatos.EditIndex).DataKey("CodigoPS")
End If
DatosGV.Rows(GvDatos.EditIndex)("Cantidad") = Cantidad
DatosGV.Rows(GvDatos.EditIndex)("CvePS") = CvePSNuevo
DatosGV.Rows(GvDatos.EditIndex)("CodigoPS") = PSNuevo
DatosGV.Rows(GvDatos.EditIndex)("PU") = PU
DatosGV.AcceptChanges()
GvDatos.EditIndex = -1
GvDatos.DataSource = DatosGV
GvDatos.DataBind()
UPDatos.Update()
End Sub
Private Sub CargaGvDatos()
GvDatos.DataSource = DatosGV
GvDatos.DataBind()
UPDatos.Update()
End Sub
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
CargaDatos()
UPDatos.Update()
End Sub
Protected Sub BtnEntregar_Click(sender As Object, e As EventArgs)
'validar que están seleccionados
Dim TmpDTRemis As New DataTable
@@ -84,9 +230,16 @@ Partial Class Ventas_RepPedidosSTF
TmpDTRemis.Columns.Add("PU", GetType(Decimal))
TmpDTRemis.Columns.Add("CveVendedor", GetType(Decimal))
TmpDTRemis.Columns.Add("GastosEnvio", GetType(Decimal))
TmpDTRemis.Columns.Add("Observacion", GetType(String))
TmpDTRemis.Columns.Add("CantidadOrg", GetType(Decimal))
TmpDTRemis.Columns.Add("CvePSOrg", GetType(Integer))
TmpDTRemis.Columns.Add("CodigoPSOrg", GetType(String))
'agruparo por cliente
For Each gvr As GridViewRow In GvDatos.Rows
If gvr.FCCheckBox("chk").Checked Then
If gvr.DataKey("CveVendedor").ToEntero > 0 AndAlso gvr.DataKey("CvePS").ToEntero > 0 AndAlso gvr.FCCheckBox("chk").Checked Then
Dim drp As DataRow = TmpDTRemis.NewRow
drp("CvePS") = gvr.DataKey("CvePS").ToEntero
drp("Cantidad") = gvr.DataKey("Cantidad").ToDecimal
@@ -97,10 +250,18 @@ Partial Class Ventas_RepPedidosSTF
drp("CveVendedor") = gvr.DataKey("CveVendedor").ToEntero
drp("CveVentaDetalle") = gvr.DataKey("CveVentaDetalle").ToEntero
drp("GastosEnvio") = gvr.DataKey("GastosEnvio").ToDecimal
drp("Observacion") = gvr.DataKey("SerieFolio")
drp("CantidadOrg") = gvr.DataKey("CantidadOrg").ToDecimal
drp("CvePSOrg") = gvr.DataKey("CvePSOrg").ToEntero
drp("CodigoPSOrg") = gvr.DataKey("CodigoPSOrg")
TmpDTRemis.Rows.Add(drp)
End If
Next
If TmpDTRemis IsNot Nothing AndAlso TmpDTRemis.Rows.Count = 0 Then
Alert("No se ha seleccionado ninguna partida, favor de seleccionar", TipoMensaje.MsgAdvertencia)
Exit Sub
@@ -118,7 +279,19 @@ Partial Class Ventas_RepPedidosSTF
For Each dr As DataRow In TmpDTRemis.FiltraParametros($"CveCliente ={drt("CveCliente")} AND CveVendedor = {drt("CveVendedor")} AND CveSubProyecto = {drt("CveSubProyecto")}").Rows
If ObjFactura IsNot Nothing Then
If Not ObjFactura.AgregarPS(dr("CvePS").ToString.ToEntero, dr("Cantidad").ToString.ToDecimal, dr("PU").ToString.ToDecimal, 0, "", CveSubProyecto:=dr("CveSubProyecto").ToString.ToEntero, CveVentaDetallePadre:=dr("CveVentaDetalle").ToString.ToEntero) Then
Dim Obs As String = dr("Observacion").ToString
If (dr("CantidadOrg").ToString.ToEntero > 0) AndAlso (dr("Cantidad").ToString.ToDecimal <> dr("CantidadOrg").ToString.ToDecimal) Then
Obs = $"{Obs}, Cantidad Original: {dr("CantidadOrg").ToString.ToDecimal.ToString("###,###,###.00")}"
End If
If (dr("CvePSOrg").ToString.ToEntero > 0) AndAlso (dr("CvePS").ToString.ToEntero <> dr("CvePSOrg").ToString.ToEntero) Then
Obs = $"{Obs}, Producto Original: {dr("CodigoPSOrg").ToString}"
End If
If Not ObjFactura.AgregarPS(dr("CvePS").ToString.ToEntero, dr("Cantidad").ToString.ToDecimal, dr("PU").ToString.ToDecimal, 0, Obs, CveSubProyecto:=dr("CveSubProyecto").ToString.ToEntero, CveVentaDetallePadre:=dr("CveVentaDetalle").ToString.ToEntero) Then
Alert("Error al agregar producto", TipoMensaje.MsgAdvertencia)
TieneError = True
Exit For
@@ -131,8 +304,15 @@ Partial Class Ventas_RepPedidosSTF
Next
If drt("GastosEnvio").ToString.ToDecimal > 0 Then
Dim tCvePSEnvio As Integer = usuarioactual.empresa.Funcionalidad(160).toentero
If Not ObjFactura.AgregarPS(tCvePSEnvio, 1, drt("GastosEnvio").ToString.ToDecimal, 0, "", CveSubProyecto:=drt("CveSubProyecto").ToString.ToEntero) Then
Dim tCvePSEnvio As Integer = UsuarioActual.Empresa.Funcionalidad(160).ToEntero
Dim Obs As String = drt("Observacion").ToString
If (drt("CantidadOrg").ToString.ToEntero > 0 Or drt("CvePSOrg").ToString.ToEntero > 0) AndAlso (drt("CvePS").ToString.ToEntero <> drt("CvePSOrg").ToString.ToEntero Or drt("Cantidad").ToString.ToDecimal <> drt("CantidadOrg").ToString.ToDecimal) Then
Obs = $"{Obs} - Cantidad Original: {drt("CantidadOrg").ToString.ToDecimal.ToString("###,###,###.00")}, Producto Original: {drt("CodigoPSOrg").ToString}"
End If
If Not ObjFactura.AgregarPS(tCvePSEnvio, 1, drt("GastosEnvio").ToString.ToDecimal, 0, Obs, CveSubProyecto:=drt("CveSubProyecto").ToString.ToEntero) Then
TieneError = True
End If
End If