OCDetalleAlmacen

This commit is contained in:
Rakcsle Supertramp
2019-09-14 17:02:37 -07:00
parent 073ce57982
commit 67f7a5e8c2
4 changed files with 269 additions and 25 deletions

View File

@@ -5809,6 +5809,27 @@ Public Class ClsContabilidad
#End Region
#Region "OCDETALLE ALMACEN"
Public Function GetOCDetalleAlmacen(MaxDiferencia As Decimal, CveEmpresa As Integer) As Boolean
Dim Retorno As Boolean = False
DataAdapter("PA_Conta_OCDetalleAlmacen")
With SqlAdapter.SelectCommand.Parameters
.Add("@MaxDiferencia", SqlDbType.Money).Value = MaxDiferencia
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
End With
Try
SqlAdapter.Fill(Data)
Retorno = True
Catch ex As Exception
OnError("Ocurrió un error al obtener los datos de oc detalle almacen", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
End Try
Return Retorno
End Function
#End Region
#Region "IDisposable Support"
' IDisposable
Protected Overridable Sub Dispose(disposing As Boolean)

View File

@@ -4531,31 +4531,38 @@ Public Class ClsPaginas
'Pyme 2017
PaginaDict.Add("/PyME/Sistemas/RegistroEmpresa.aspx".ToUpper(), -1)
PaginaDict.Add("/PyME/Sistemas/WizardRegistro.aspx".ToUpper(), -1)
'PaginaDict.Add("/Compras/Efacturas.aspx".ToUpper(), 2007)
'PaginaDict.Add("/Compras/Compras.aspx".ToUpper(), 2008)
'PaginaDict.Add("/Compras/Proveedores.aspx".ToUpper(), 2009)
'PaginaDict.Add("/OC/OC.aspx".ToUpper(), 2011)
'PaginaDict.Add("/OC/RepOC.aspx".ToUpper(), 2012)
'PaginaDict.Add("/Ventas/CatPS.aspx".ToUpper(), 2033)
'PaginaDict.Add("/Ventas/CatPS.aspx".ToUpper(), 2034)
''PaginaDict.Add("/Sistemas/WizardRegistro.aspx".ToUpper(), 2035)
'PaginaDict.Add("/Planeacion/CatSucursales.aspx".ToUpper(), 2036)
'PaginaDict.Add("/Planeacion/CatFolios.aspx".ToUpper(), 2037)
'PaginaDict.Add("/Sistemas/CatRoles.aspx".ToUpper(), 2038)
'PaginaDict.Add("/Sistemas/Usuarios.aspx".ToUpper(), 2039)
'PaginaDict.Add("/Sistemas/CatProcesos.aspx".ToUpper(), 2040)
'CONTSIG (CONTabilidad al SIGuiente nivel)
PaginaDict.Add("/PyME/Sistemas/WizardRegistro.aspx".ToUpper(), -1)
PaginaDict.Add("/Contabilidad/OCDetalleAlmacen.aspx".ToUpper(), -1)
'PaginaDict.Add("/Compras/Efacturas.aspx".ToUpper(), 2007)
'PaginaDict.Add("/Compras/Compras.aspx".ToUpper(), 2008)
'PaginaDict.Add("/Compras/Proveedores.aspx".ToUpper(), 2009)
'PaginaDict.Add("/OC/OC.aspx".ToUpper(), 2011)
'PaginaDict.Add("/OC/RepOC.aspx".ToUpper(), 2012)
'PaginaDict.Add("/Ventas/CatPS.aspx".ToUpper(), 2033)
'PaginaDict.Add("/Ventas/CatPS.aspx".ToUpper(), 2034)
''PaginaDict.Add("/Sistemas/WizardRegistro.aspx".ToUpper(), 2035)
'PaginaDict.Add("/Planeacion/CatSucursales.aspx".ToUpper(), 2036)
'PaginaDict.Add("/Planeacion/CatFolios.aspx".ToUpper(), 2037)
'PaginaDict.Add("/Sistemas/CatRoles.aspx".ToUpper(), 2038)
'PaginaDict.Add("/Sistemas/Usuarios.aspx".ToUpper(), 2039)
'PaginaDict.Add("/Sistemas/CatProcesos.aspx".ToUpper(), 2040)
'CONTSIG (CONTabilidad al SIGuiente nivel)
PaginaDict.Add("/Compras/RepCxPCaudillo.aspx".ToUpper(), -1)

View File

@@ -0,0 +1,53 @@
<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="OCDetalleAlmacen.aspx.vb" Inherits="Contabilidad_OCDetalleAlmacen" %>
<asp:Content ID="Content1" ContentPlaceHolderID="CP" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Css" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="E" Runat="Server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="HB" Runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="H" Runat="Server">
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="HA" Runat="Server">
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="C" Runat="Server">
<asp:UpdatePanel ID="UPCuerpo" runat="server">
<ContentTemplate>
<asp:Button id ="BtnProcesarRegistros" runat="server" Text="Procesar" CssClass="btn btn-primary" OnClick="BtnProcesarRegistros_Click" />
<br />
<br />
<asp:GridView ID="GvDAtos" runat="server" AutoGenerateColumns="false"
DataKeyNames="Cargo,Abono,dif,CveMoneda,Fecha,Referencia,CveOrdenCompraDetalle,CveOrdenCompra,CveProveedor,CveCompra,Folio" CssClass="table table-hover table-advance " >
<Columns>
<asp:TemplateField ItemStyle-HorizontalAlign="center" ItemStyle-Width="60px" HeaderText="">
<ItemTemplate>
<asp:CheckBox ID="Chk" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="CvePrePoliza" HeaderText="CvePrePoliza"></asp:BoundField>
<asp:BoundField DataField="Folio" HeaderText="Folio OC"></asp:BoundField>
<asp:BoundField DataField="CveOCDetalle" HeaderText="CveOCDetalle"></asp:BoundField>
<asp:BoundField DataField="Cargo" HeaderText="Cargo" DataFormatString="{0:C2}" ></asp:BoundField>
<asp:BoundField DataField="Abono" HeaderText="Abono" DataFormatString="{0:C2}"></asp:BoundField>
<asp:BoundField DataField="Dif" HeaderText="Dif" DataFormatString="{0:C2}" ></asp:BoundField>
<asp:BoundField DataField="CveCompra" HeaderText="CveCompra"></asp:BoundField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
<asp:Content ID="Content8" ContentPlaceHolderID="JS" Runat="Server">
</asp:Content>

View File

@@ -0,0 +1,163 @@

Imports System.Data
Imports Extensiones
Partial Class Contabilidad_OCDetalleAlmacen
Inherits ClsPaginas
Property DTDatos As DataTable
Get
If ViewState("DTDatos") Is Nothing Then
Return New DataTable
Else
Return DirectCast(ViewState("DTDatos"), DataTable)
End If
End Get
Set(value As DataTable)
ViewState("DTDatos") = value
End Set
End Property
Private Sub Contabilidad_OCDetalleAlmacen_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
CargaDatos()
End If
End Sub
Private Sub CargaDatos()
Dim ObjConta As New ClsContabilidad
If ObjConta.GetOCDetalleAlmacen(1000D, UsuarioActual.CveEmpresa) Then
If ObjConta.DtResultados.Rows.Count > 0 Then
DTDatos = ObjConta.DtResultados
GvDAtos.DataSource = DTDatos
Alert($"Se encontraron {ObjConta.DtResultados.Rows.Count} registros.")
Else
DTDatos = Nothing
Alert("Nos se encontraron registros por proocesar ")
GvDAtos.DataSource = Nothing
End If
Else
DTDatos = Nothing
GvDAtos.DataSource = Nothing
End If
GvDAtos.DataBind()
ObjConta.Dispose()
End Sub
Protected Sub BtnProcesarRegistros_Click(sender As Object, e As EventArgs)
Dim ObjConta As New ClsContabilidad
ObjConta.IniciaTransacSQL()
Dim modulo As String = "OC Ajuste Manual"
Dim ErrorProcesamiento As Boolean = False
Dim mensaje As String = ""
Dim ContadorProcesados As Integer = 0
For Each GvDrow As GridViewRow In GvDAtos.Rows
Dim CvePrePoliza As Integer = 0
Dim Cargo As Decimal = GvDrow.DataKey("Cargo").ToString.ToDecimal
Dim Abono As Decimal = GvDrow.DataKey("Abono").ToString.ToDecimal
Dim Diferencia As Decimal = Math.Abs(GvDrow.DataKey("dif").ToString.ToDecimal)
Dim CveMoneda As Integer = GvDrow.DataKey("CveMoneda").ToString.ToEntero
Dim Fecha As Date = GvDrow.DataKey("Fecha").ToString.ToDate
Dim Referencia As String = GvDrow.DataKey("Referencia").ToString
Dim CveOCDetalle As Integer = GvDrow.DataKey("CveOrdenCompraDetalle").ToString.ToEntero
Dim CveOC As Integer = GvDrow.DataKey("CveOrdenCompra").ToString.ToEntero
Dim CveProveedor As Integer = GvDrow.DataKey("CveProveedor").ToString.ToEntero
Dim CveCompra As Integer = GvDrow.DataKey("CveCompra").ToString.ToEntero
Dim Folio As String = GvDrow.DataKey("Folio").ToString
Dim CveCuenta176 As Integer = 55169
Dim IdCtaCuenta176 As Integer = 1245
Dim CveCuenta177 As Integer = 55294
Dim IdCtaCuenta177 As Integer = 1148
Dim Chk As CheckBox = GvDrow.FCCheckBox("Chk")
If Chk IsNot Nothing AndAlso Chk.Checked Then
CvePrePoliza = ObjConta.AddPrePolizas(modulo, 3, Diferencia, Diferencia, CveMoneda, Fecha, modulo, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
GvDrow.Cells(1).Text = CvePrePoliza.ToString
mensaje = mensaje & $"CvePrePoliza {CvePrePoliza } OC: {Folio} Importe :{Diferencia} <br>"
If CvePrePoliza > 0 Then
If Cargo > Abono Then
If (ObjConta.AddPrePolizasDetalle(CvePrePoliza, 1, Diferencia, Referencia, 176, Referencia, Fecha, IdCtaCuenta176, -1, ImporteME:=0, ImporteMX:=Diferencia, CveCompra:=CveCompra, Contabilizable:=1, CveOC:=CveOC, CveOCDetalle:=CveOCDetalle, CveProveedor:=CveProveedor)) Then
If (ObjConta.AddPrePolizasDetalle(CvePrePoliza, 1, -Diferencia, Referencia, 177, Referencia, Fecha, IdCtaCuenta177, -1, ImporteME:=-0, ImporteMX:=-Diferencia, CveCompra:=CveCompra, Contabilizable:=1, CveOC:=CveOC, CveOCDetalle:=CveOCDetalle, CveProveedor:=CveProveedor)) Then
ContadorProcesados = ContadorProcesados + 1
Else
ErrorProcesamiento = True
Exit For
End If
Else
ErrorProcesamiento = True
Exit For
End If
Else
If (ObjConta.AddPrePolizasDetalle(CvePrePoliza, 1, -Diferencia, Referencia, 176, Referencia, Fecha, IdCtaCuenta176, -1, ImporteME:=-0, ImporteMX:=-Diferencia, CveCompra:=CveCompra, Contabilizable:=1, CveOC:=CveOC, CveOCDetalle:=CveOCDetalle, CveProveedor:=CveProveedor)) Then
If (ObjConta.AddPrePolizasDetalle(CvePrePoliza, 1, Diferencia, Referencia, 177, Referencia, Fecha, IdCtaCuenta177, -1, ImporteME:=0, ImporteMX:=Diferencia, CveCompra:=CveCompra, Contabilizable:=1, CveOC:=CveOC, CveOCDetalle:=CveOCDetalle, CveProveedor:=CveProveedor)) Then
ContadorProcesados = ContadorProcesados + 1
Else
ErrorProcesamiento = True
Exit For
End If
Else
ErrorProcesamiento = True
Exit For
End If
End If
End If
End If
Next
DTDatos.AcceptChanges()
If Not ErrorProcesamiento Then
ObjConta.Commit()
'ObjConta.RollBack() '
'BtnProcesarRegistros.Enabled = False
Alert($"PrePolizas agregadas correctamente <br> registros procesados: {ContadorProcesados} <br> {mensaje}")
Else
ObjConta.RollBack()
End If
ObjConta.Dispose()
CargaDatos()
End Sub
End Class