-- mejoras para unificar los productos iguales en material utilizado
This commit is contained in:
@@ -16,6 +16,9 @@
|
|||||||
<li>
|
<li>
|
||||||
<asp:LinkButton ID="LnkAccionesMaterialUtilizado" runat="server" OnClick="LnkAccionesMaterialUtilizado_Click" Visible="false"> <i class="fa fa-plus"></i> Material Utilizado</asp:LinkButton>
|
<asp:LinkButton ID="LnkAccionesMaterialUtilizado" runat="server" OnClick="LnkAccionesMaterialUtilizado_Click" Visible="false"> <i class="fa fa-plus"></i> Material Utilizado</asp:LinkButton>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<asp:LinkButton ID="BtnCancelarRemision" runat="server" Text="Cancelar Material" Visible="false" OnClick="BtnCancelarRemision_Click"/>
|
||||||
|
</li>
|
||||||
</ContentTemplate>
|
</ContentTemplate>
|
||||||
<Triggers>
|
<Triggers>
|
||||||
<asp:PostBackTrigger ControlID="ImgImprimir" />
|
<asp:PostBackTrigger ControlID="ImgImprimir" />
|
||||||
@@ -348,7 +351,7 @@
|
|||||||
<asp:LinkButton runat="server" ID="LnkFinalizar" Text="Finalizar" CssClass="btn btn-primary" OnClick="LnkFinalizar_Click"></asp:LinkButton>
|
<asp:LinkButton runat="server" ID="LnkFinalizar" Text="Finalizar" CssClass="btn btn-primary" OnClick="LnkFinalizar_Click"></asp:LinkButton>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ContentTemplate>
|
</ContentTemplate>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ Imports System.IO
|
|||||||
Imports System.Data
|
Imports System.Data
|
||||||
Imports System.Data.SqlClient
|
Imports System.Data.SqlClient
|
||||||
Imports APP_Code_CSharp
|
Imports APP_Code_CSharp
|
||||||
|
Imports MoreLinq.Extensions
|
||||||
|
|
||||||
Partial Class OS_OrdenesServicios
|
Partial Class OS_OrdenesServicios
|
||||||
Inherits ClsPaginas
|
Inherits ClsPaginas
|
||||||
@@ -578,8 +579,6 @@ Partial Class OS_OrdenesServicios
|
|||||||
'GvPS.DataSource = TmpDT
|
'GvPS.DataSource = TmpDT
|
||||||
'GvPS.DataBind()
|
'GvPS.DataBind()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Dim tmpTipoEstatus As Integer = GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("TipoEstatus", $" CveEstatusOrdenServicio = {DdlEstatusOS.SelectedValue}").ToEntero
|
Dim tmpTipoEstatus As Integer = GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("TipoEstatus", $" CveEstatusOrdenServicio = {DdlEstatusOS.SelectedValue}").ToEntero
|
||||||
Select Case tmpTipoEstatus
|
Select Case tmpTipoEstatus
|
||||||
Case 1, 2, 3
|
Case 1, 2, 3
|
||||||
@@ -732,6 +731,10 @@ Partial Class OS_OrdenesServicios
|
|||||||
If TipoEstatus.Contiene(1, 2, 3) Then
|
If TipoEstatus.Contiene(1, 2, 3) Then
|
||||||
LnkAccionesMaterialUtilizado.Visible = True
|
LnkAccionesMaterialUtilizado.Visible = True
|
||||||
End If
|
End If
|
||||||
|
If TipoEstatus.Contiene(4) Then 'finalizada
|
||||||
|
BtnCancelarRemision.Visible = True
|
||||||
|
End If
|
||||||
|
|
||||||
Else
|
Else
|
||||||
Alert("La Orden de Servicio Solicitado no existe, por favor revise su búsqueda.", TipoMensaje.MsgAdvertencia)
|
Alert("La Orden de Servicio Solicitado no existe, por favor revise su búsqueda.", TipoMensaje.MsgAdvertencia)
|
||||||
BtnGuardar.Enabled = False
|
BtnGuardar.Enabled = False
|
||||||
@@ -3530,7 +3533,7 @@ Partial Class OS_OrdenesServicios
|
|||||||
If PU > 0 Then
|
If PU > 0 Then
|
||||||
CountDetalles = CountDetalles + 1
|
CountDetalles = CountDetalles + 1
|
||||||
Else
|
Else
|
||||||
Alert($"Prodcuto {CodigoPS} con precio unitario en cero.", TipoMensaje.MsgAdvertencia)
|
Alert($"Producto {CodigoPS} con precio unitario en cero.", TipoMensaje.MsgAdvertencia)
|
||||||
PuEnCero = True
|
PuEnCero = True
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
@@ -3552,7 +3555,7 @@ Partial Class OS_OrdenesServicios
|
|||||||
Return Respuesta
|
Return Respuesta
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If ObjVentas.GetVenta(CvePedido, UsuarioActual.CveEmpresa, VerificaAlmacen:=False) Then
|
If ObjVentas.GetVenta(CvePedido, UsuarioActual.CveEmpresa) Then
|
||||||
Dim DbRowVenta As DataRow = ObjVentas.DtResultados.Copy().Rows(0)
|
Dim DbRowVenta As DataRow = ObjVentas.DtResultados.Copy().Rows(0)
|
||||||
CveMoneda = DbRowVenta("CveMoneda").ToString.ToEntero
|
CveMoneda = DbRowVenta("CveMoneda").ToString.ToEntero
|
||||||
CveSubProyectoPedido = DbRowVenta("CveSubProyecto").ToString().ToEntero()
|
CveSubProyectoPedido = DbRowVenta("CveSubProyecto").ToString().ToEntero()
|
||||||
@@ -3585,6 +3588,14 @@ Partial Class OS_OrdenesServicios
|
|||||||
TmpDTMat.Columns.Add("Lote", GetType(String))
|
TmpDTMat.Columns.Add("Lote", GetType(String))
|
||||||
TmpDTMat.Columns.Add("FechaCaducidad", GetType(Date))
|
TmpDTMat.Columns.Add("FechaCaducidad", GetType(Date))
|
||||||
TmpDTMat.Columns.Add("CveVentaDetalle", GetType(Integer))
|
TmpDTMat.Columns.Add("CveVentaDetalle", GetType(Integer))
|
||||||
|
'unificar en un solo producto, y generar las salidas a esa relación
|
||||||
|
|
||||||
|
|
||||||
|
Respuesta.CveVenta = -1
|
||||||
|
Respuesta.SerieFolio = ""
|
||||||
|
Respuesta.dtdetalle = New DataTable
|
||||||
|
Alert("Remision sin detalles.", TipoMensaje.MsgAdvertencia)
|
||||||
|
Return Respuesta
|
||||||
|
|
||||||
For Each GvRow As GridViewRow In GvMU.Rows
|
For Each GvRow As GridViewRow In GvMU.Rows
|
||||||
|
|
||||||
@@ -3594,7 +3605,6 @@ Partial Class OS_OrdenesServicios
|
|||||||
Dim Descuento As Decimal = GvRow.DataKey("Descuento").ToDecimal
|
Dim Descuento As Decimal = GvRow.DataKey("Descuento").ToDecimal
|
||||||
Dim Obs As String = GvRow.DataKey("Observaciones")
|
Dim Obs As String = GvRow.DataKey("Observaciones")
|
||||||
|
|
||||||
|
|
||||||
If CantidadRegistro > 0 Then
|
If CantidadRegistro > 0 Then
|
||||||
If ObjFactura.AgregarPS(CvePS, CantidadRegistro, PU, Descuento, Obs, CveSubProyecto:=CveSubProyectoPedido, CveVentaDetallePadre:=GvRow.DataKey("CveVentaDetalle").ToEntero) Then
|
If ObjFactura.AgregarPS(CvePS, CantidadRegistro, PU, Descuento, Obs, CveSubProyecto:=CveSubProyectoPedido, CveVentaDetallePadre:=GvRow.DataKey("CveVentaDetalle").ToEntero) Then
|
||||||
Dim drp As DataRow = TmpDTMat.NewRow
|
Dim drp As DataRow = TmpDTMat.NewRow
|
||||||
@@ -3635,6 +3645,38 @@ Partial Class OS_OrdenesServicios
|
|||||||
|
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Private Function AgrupadoProductos(gridView As GridView) As DataTable
|
||||||
|
' Filtrar y agrupar las filas por clave3 y clave5
|
||||||
|
Dim groupedData = From row As GridViewRow In gridView.Rows.Cast(Of GridViewRow)()
|
||||||
|
Where row.RowType = DataControlRowType.DataRow
|
||||||
|
Group row By
|
||||||
|
CvePS = gridView.DataKeys(row.RowIndex)("CvePS").ToString(),
|
||||||
|
CveUM = gridView.DataKeys(row.RowIndex)("CveUM").ToString()
|
||||||
|
Into Group
|
||||||
|
Select New With {
|
||||||
|
.CvePS = CvePS,
|
||||||
|
.CveUM = CveUM,
|
||||||
|
.ValorAcumulado = Group.Sum(Function(r) Convert.ToDecimal(r.Cells(5).Text))
|
||||||
|
}
|
||||||
|
|
||||||
|
' Crear un nuevo DataTable para almacenar los resultados agrupados
|
||||||
|
Dim resultTable As New DataTable()
|
||||||
|
resultTable.Columns.Add("CvePS")
|
||||||
|
resultTable.Columns.Add("CveUM")
|
||||||
|
resultTable.Columns.Add("Cantidad", GetType(Decimal))
|
||||||
|
|
||||||
|
For Each item In groupedData
|
||||||
|
Dim newRow As DataRow = resultTable.NewRow()
|
||||||
|
newRow("CvePS") = item.CvePS
|
||||||
|
newRow("CveUM") = item.CveUM
|
||||||
|
newRow("Cantidad") = item.ValorAcumulado
|
||||||
|
resultTable.Rows.Add(newRow)
|
||||||
|
Next
|
||||||
|
|
||||||
|
Return resultTable
|
||||||
|
End Function
|
||||||
|
|
||||||
|
|
||||||
Friend Class RespuestaFacturacion
|
Friend Class RespuestaFacturacion
|
||||||
Public Property CveVenta As Integer = -1
|
Public Property CveVenta As Integer = -1
|
||||||
Public Property SerieFolio As String = "-1"
|
Public Property SerieFolio As String = "-1"
|
||||||
@@ -3786,4 +3828,77 @@ Partial Class OS_OrdenesServicios
|
|||||||
End Try
|
End Try
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Private Sub CancelarRemision(CveVenta As Integer, CveAlmacenDevolucion As Integer, CvePedido As Integer)
|
||||||
|
|
||||||
|
Dim LigaRedirigir As String = ""
|
||||||
|
|
||||||
|
Dim ObjFacturaCancelacion As New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa, EsCancelacion:=True, VerificaAlmacen:=True)
|
||||||
|
Try
|
||||||
|
Dim resp As Modelos.Factura.MCancelacionVentaMensaje = Nothing
|
||||||
|
Dim strMensaje As New StringBuilder()
|
||||||
|
If ObjFacturaCancelacion IsNot Nothing AndAlso ObjFacturaCancelacion.CveVenta > 0 Then
|
||||||
|
|
||||||
|
Dim ListaRemisionesCancelar As New List(Of Integer)
|
||||||
|
ObjFacturaCancelacion.CveAlmacenDevolucion = CveAlmacenDevolucion
|
||||||
|
Dim CancelacionPagos = Modelos.OpcionesCancelacionPagos.SinPagos
|
||||||
|
|
||||||
|
'PARA GENERAR LA DEVOLUCION DE ALMACEN SIN ESPERAR LA ACEPTACION DEL SAT
|
||||||
|
Dim GenerarDevolucionAnticipada As Boolean = True
|
||||||
|
Dim CveEstadoCancelacion As Integer = 1
|
||||||
|
Dim objos As New ClsOS
|
||||||
|
Dim ObjVenta As New ClsVentas(objos.IniciaTransacSQL)
|
||||||
|
|
||||||
|
resp = ObjFacturaCancelacion.CancelarFactura(1, ListaRemisionesCancelar, CveMotivoCancelacion:=1, Motivo:="Corrección de material utilizado", CveEstadoCancelacion:=CveEstadoCancelacion, ForzarDevolucion:=GenerarDevolucionAnticipada, CancelacionPagos:=CancelacionPagos, TransaccionCompartida:=objos.IniciaTransacSQL)
|
||||||
|
|
||||||
|
Dim HuboError As Boolean = False
|
||||||
|
If Not resp.HuboError Then
|
||||||
|
|
||||||
|
If resp.CveEstatus = 12 Then
|
||||||
|
Dim cveoo As Integer = GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveEstatusOrdenServicio", $" TipoEstatus = 3").ToEntero
|
||||||
|
If objos.UpdateOrdenesServiciosEstatus(cveoo, UsuarioActual.CveUsuario, CveOS) Then
|
||||||
|
'retornar el estatus de la OS,
|
||||||
|
If Not ObjVenta.UpdateVentasDevolucionAlmacen(0, CvePedido) Then
|
||||||
|
HuboError = True
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
HuboError = True
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
'si tiene pagos
|
||||||
|
HuboError = True
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
HuboError = True
|
||||||
|
End If
|
||||||
|
strMensaje.Append(resp.Mensaje)
|
||||||
|
If Not HuboError Then
|
||||||
|
objos.Commit()
|
||||||
|
Alert(strMensaje.ToString(), resp.TipoMensaje)
|
||||||
|
Else
|
||||||
|
objos.RollBack()
|
||||||
|
Alert(strMensaje.ToString(), resp.TipoMensaje)
|
||||||
|
End If
|
||||||
|
|
||||||
|
objos.Dispose()
|
||||||
|
ObjVenta.Dispose()
|
||||||
|
Else
|
||||||
|
Alert("Ocurrió un error al generar la cancelación", TipoMensaje.MsgError)
|
||||||
|
End If
|
||||||
|
|
||||||
|
Catch ex As Exception
|
||||||
|
OnError("Ocurrió un error al cancelar", ex)
|
||||||
|
End Try
|
||||||
|
ObjFacturaCancelacion.Dispose()
|
||||||
|
UpEstatus.Update()
|
||||||
|
|
||||||
|
If Not String.IsNullOrEmpty(LigaRedirigir) Then
|
||||||
|
Response.Redirect(LigaRedirigir)
|
||||||
|
End If
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Protected Sub BtnCancelarRemision_Click(sender As Object, e As EventArgs)
|
||||||
|
CancelarRemision(CveVenta, 1, CvePedido)
|
||||||
|
End Sub
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
Reference in New Issue
Block a user