Complemento Prepoliza

This commit is contained in:
rakcsle
2024-09-04 12:18:50 -07:00
parent d61b7b7189
commit b82039f0ee
8 changed files with 237 additions and 42 deletions

View File

@@ -116,38 +116,77 @@
<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"
DataKeyNames="CveCliente,CveVendedor,CveSubProyecto,CvePS,CveUnidadMedida,Cantidad,PU,CveVentaDetalle,GastosEnvio,CveVenta,SerieFolio" 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: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:TemplateField ItemStyle-HorizontalAlign="Left" HeaderText="Cantidad">
<EditItemTemplate>
<asp:DropDownList runat="server" ID="DdlPS" DataTextField="CodigoPS" CssClass="form-control select2me" Width="100%" DataValueField="CvePS" ></asp:DropDownList>
</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" Font-Italic="true" runat="server" Text='<%#Eval("CodigoPS") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Vendedor" DataField="Vendedor" />
<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 +214,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

@@ -7,10 +7,42 @@ 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 +66,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,8 +77,10 @@ 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()
@@ -53,7 +89,9 @@ Partial Class Ventas_RepPedidosSTF
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
GvDatos.DataSource = DatosGV
End If
ObjVentas.Dispose()
GvDatos.DataBind()
@@ -61,19 +99,94 @@ 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
DatosGV.Rows(GvDatos.EditIndex)("Cantidad") = Cantidad
DatosGV.Rows(GvDatos.EditIndex)("CvePS") = CvePSNuevo
DatosGV.Rows(GvDatos.EditIndex)("CodigoPS") = PSNuevo
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
@@ -86,9 +199,12 @@ 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))
'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
@@ -99,6 +215,8 @@ 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")
TmpDTRemis.Rows.Add(drp)
End If
Next
@@ -120,7 +238,7 @@ 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
If Not ObjFactura.AgregarPS(dr("CvePS").ToString.ToEntero, dr("Cantidad").ToString.ToDecimal, dr("PU").ToString.ToDecimal, 0, dr("Observacion").ToString, CveSubProyecto:=dr("CveSubProyecto").ToString.ToEntero, CveVentaDetallePadre:=dr("CveVentaDetalle").ToString.ToEntero) Then
Alert("Error al agregar producto", TipoMensaje.MsgAdvertencia)
TieneError = True
Exit For
@@ -133,8 +251,8 @@ 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
If Not ObjFactura.AgregarPS(tCvePSEnvio, 1, drt("GastosEnvio").ToString.ToDecimal, 0, drt("Observacion").ToString, CveSubProyecto:=drt("CveSubProyecto").ToString.ToEntero) Then
TieneError = True
End If
End If