Correcciones Cancelación OP
This commit is contained in:
@@ -7,7 +7,7 @@ Public Class BundleConfig
|
||||
bundles.Add(New ScriptBundle("~/bundles/jquery").Include(
|
||||
"~/Metronic/assets/global/plugins/jquery.min.js"
|
||||
))
|
||||
ScriptManager.ScriptResourceMapping.AddDefinition("jquery", Nothing, New ScriptResourceDefinition with {.Path = "~/bundles/jquery"})
|
||||
ScriptManager.ScriptResourceMapping.AddDefinition("jquery", Nothing, New ScriptResourceDefinition With {.Path = "~/bundles/jquery"})
|
||||
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ Public Class BundleConfig
|
||||
"~/Scripts/WebForms/TreeView.js",
|
||||
"~/Scripts/WebForms/WebParts.js"))
|
||||
|
||||
ScriptManager.ScriptResourceMapping.AddDefinition("WebFormsBundle", new ScriptResourceDefinition With {.Path = "~/bundles/WebFormsJs"})
|
||||
ScriptManager.ScriptResourceMapping.AddDefinition("WebFormsBundle", New ScriptResourceDefinition With {.Path = "~/bundles/WebFormsJs"})
|
||||
|
||||
' Order is very important for these files to work, they have explicit dependencies
|
||||
bundles.Add(New ScriptBundle("~/bundles/MsAjaxJs").Include(
|
||||
|
||||
@@ -813,6 +813,16 @@
|
||||
/*----------------------------------------
|
||||
ANCHO DE COLUMNAS DE IMPORTES (AÑO, MES, ETC)
|
||||
-----------------------------------------*/
|
||||
|
||||
/* Ancho libre para primeras columnas (Sucursal, Vendedor, etc.) */
|
||||
.custom-grid td:first-child,
|
||||
.custom-grid th:first-child {
|
||||
width: auto !important;
|
||||
min-width: auto !important;
|
||||
max-width: none !important;
|
||||
|
||||
}
|
||||
|
||||
.custom-grid td:nth-child(2),
|
||||
.custom-grid td:nth-child(3),
|
||||
.custom-grid td:nth-child(4),
|
||||
@@ -830,7 +840,6 @@
|
||||
.custom-grid th:nth-child(4),
|
||||
.custom-grid th:nth-child(5) {
|
||||
text-align: center !important;
|
||||
|
||||
}
|
||||
|
||||
/* Asegurar ancho libre para primera columna */
|
||||
|
||||
254
OP/OP.aspx
254
OP/OP.aspx
@@ -309,6 +309,19 @@
|
||||
background: #f8f9fa;
|
||||
cursor: pointer;
|
||||
}
|
||||
/* Alinear celda y contenido a la derecha */
|
||||
.celda-derecha {
|
||||
text-align: right !important;
|
||||
|
||||
}
|
||||
|
||||
.txt-merma {
|
||||
/* Ancho reducido al 50% */
|
||||
margin-left: 30px !important; /* Mueve el TextBox a la derecha dentro de la celda */
|
||||
display: block !important; /* Permite que margin-left:auto funcione */
|
||||
/* Alinea el texto interno a la derecha */
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
</asp:Content>
|
||||
@@ -338,7 +351,7 @@
|
||||
<div class="labeltruncate labeltext labelbold">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group form-md-line-input input-iconright">
|
||||
<div class="form-group">
|
||||
<label for="<%= DdlClientes.ClientID.ToString()%>">Cliente</label>
|
||||
<ADS:Dropdownlost ID="DdlClientes" runat="server"
|
||||
CssClassDdl="form-control" DataTextField="NombreComercial"
|
||||
@@ -346,88 +359,85 @@
|
||||
DataValueField="CveCliente" Enabled="false" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Centro de Costo -->
|
||||
<div class="portlet-body form">
|
||||
<div class="labeltruncate labeltext labelbold">
|
||||
<div class="row">
|
||||
<div class="col-md-16">
|
||||
<div class="form-group form-md-line-input input-iconright">
|
||||
<asp:Label ID="LblProyecto" runat="server">
|
||||
<label>Proyecto:</label>
|
||||
</asp:Label>
|
||||
<div runat="server" id="DivProyecto">
|
||||
<asp:DropDownList ID="DdlProyecto" runat="server" AutoPostBack="true" AppendDataBoundItems="true" DataTextField="Proyecto" DataValueField="CveProyecto" Class="form-control select2me" Style="width: 100%;"></asp:DropDownList>
|
||||
</div>
|
||||
<asp:Label ID="LblSubProyecto" runat="server" class="col-md-2">
|
||||
<label>Subproyecto:</label>
|
||||
</asp:Label>
|
||||
<div runat="server" id="DivSubProyecto" class="col-md-4">
|
||||
<asp:DropDownList ID="DdlSubProyecto" runat="server" AppendDataBoundItems="true" DataTextField="SubProyecto" DataValueField="CveSubProyecto" Class="form-control select2me" Style="width: 100%;"></asp:DropDownList>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Descripción -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-10">
|
||||
<div class="form-group form-md-line-input input-iconright">
|
||||
<asp:TextBox ID="TxtDescripcion" runat="server"
|
||||
CssClass="form-control"
|
||||
Style="width: 95%; height: 40px;"
|
||||
ValidationGroup="GrpGuardar"
|
||||
TextMode="MultiLine"
|
||||
Rows="2"
|
||||
MaxLength="1000" />
|
||||
<asp:RequiredFieldValidator ID="RFVDescripcion" runat="server"
|
||||
ControlToValidate="TxtDescripcion"
|
||||
ErrorMessage="Descripción requerida"
|
||||
Display="None"
|
||||
CssClass="text-danger"
|
||||
ValidationGroup="GrpGuardar" />
|
||||
<label for="<%= TxtDescripcion.ClientID.ToString()%>">Descripcion</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Fecha -->
|
||||
<div class="form-section">
|
||||
<div class="row">
|
||||
<!-- Columna Fecha-->
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<div class="col-md-1">
|
||||
<label class="mb-0">Fecha</label>
|
||||
<label>Fecha</label>
|
||||
|
||||
<div class="input-group input-sm input-small date date-picker" style="height: 30px;" data-date-format="dd/mm/yyyy">
|
||||
<asp:TextBox ID="Txtfecha" runat="server"
|
||||
CssClass="form-control"
|
||||
style="margin-top: -6px;"
|
||||
Width="100%"
|
||||
CausesValidation="true"
|
||||
MaxLength="10"></asp:TextBox>
|
||||
<span class="input-group-btn">
|
||||
<asp:LinkButton ID="imgCalendarioF" class="btn default " style="margin-top: -11px; height: 29px;" Text="<i class='fa fa-calendar'></i>" runat="server"></asp:LinkButton>
|
||||
</span>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="input-group input-sm input-small date date-picker " data-date-format="dd/mm/yyyy" style="width: 100px !important; padding: 0px;">
|
||||
<asp:TextBox Width="80px" ID="Txtfecha" runat="server" CssClass="form-control" CausesValidation="true" MaxLength="10"></asp:TextBox>
|
||||
<span class="input-group-btn ">
|
||||
<asp:LinkButton ID="imgCalendarioF" class="btn default " Text="<i class='fa fa-calendar'></i>" runat="server"></asp:LinkButton>
|
||||
</span>
|
||||
<ajax:MaskedEditExtender ID="MEEFechaF" runat="server" TargetControlID="Txtfecha" Mask="99/99/9999" MaskType="Date" DisplayMoney="Left" AcceptNegative="Left"></ajax:MaskedEditExtender>
|
||||
<ajax:CalendarExtender runat="server" ID="Calendario2" TargetControlID="Txtfecha" PopupButtonID="imgCalendarioF" PopupPosition="BottomRight" Enabled="True"></ajax:CalendarExtender>
|
||||
<asp:RequiredFieldValidator ID="rfvFechaF" runat="server" ControlToValidate="Txtfecha" Display="None" ErrorMessage="El campo <b>''Fecha Final''</b> es requerido por la aplicación, por favor ingrese una fecha." ValidationGroup="Valida"></asp:RequiredFieldValidator>
|
||||
<asp:CompareValidator ID="cvFechaF" runat="server" ControlToValidate="Txtfecha" Display="None" ErrorMessage="El campo <b>''Fecha Final''</b> no tienes el formato correcto, por favor intente de nuevo con el siguiente formato: (dd/mm/yyyy)." Operator="DataTypeCheck" Type="Date" ValidationGroup="Valida"></asp:CompareValidator>
|
||||
<ajax:ValidatorCalloutExtender ID="vcoRfvFF" runat="server" HighlightCssClass="vco" TargetControlID="rfvFechaF" Width="350px"></ajax:ValidatorCalloutExtender>
|
||||
<ajax:ValidatorCalloutExtender ID="vcoCvFF" runat="server" HighlightCssClass="vco" TargetControlID="cvFechaF" Width="350px"></ajax:ValidatorCalloutExtender>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Centro de Costo -->
|
||||
<div class="portlet-body form" style="margin-top: -15px;">
|
||||
<div class="labeltruncate labeltext labelbold">
|
||||
<div class="row">
|
||||
<div class="col-md-16">
|
||||
<div class="form-group">
|
||||
<asp:Label ID="LblProyecto" runat="server">
|
||||
<label>Proyecto:</label>
|
||||
</asp:Label>
|
||||
<div runat="server" id="DivProyecto">
|
||||
<asp:DropDownList ID="DdlProyecto" runat="server" AutoPostBack="true" AppendDataBoundItems="true" DataTextField="Proyecto" DataValueField="CveProyecto" Class="form-control select2me" Style="width: 100%;"></asp:DropDownList>
|
||||
</div>
|
||||
<asp:Label ID="LblSubProyecto" runat="server" class="col-md-2">
|
||||
<label>Subproyecto:</label>
|
||||
</asp:Label>
|
||||
<div runat="server" id="DivSubProyecto" class="col-md-4">
|
||||
<asp:DropDownList ID="DdlSubProyecto" runat="server" AppendDataBoundItems="true" DataTextField="SubProyecto" DataValueField="CveSubProyecto" Class="form-control select2me" Style="width: 100%;"></asp:DropDownList>
|
||||
</div>
|
||||
<ajax:MaskedEditExtender ID="MEEFechaF" runat="server" TargetControlID="Txtfecha" Mask="99/99/9999" MaskType="Date" DisplayMoney="Left" AcceptNegative="Left"></ajax:MaskedEditExtender>
|
||||
<ajax:CalendarExtender runat="server" ID="Calendario2" TargetControlID="Txtfecha" PopupButtonID="imgCalendarioF" PopupPosition="BottomRight" Enabled="True"></ajax:CalendarExtender>
|
||||
<asp:RequiredFieldValidator ID="rfvFechaF" runat="server" ControlToValidate="Txtfecha" Display="None" ErrorMessage="El campo <b>''Fecha Final''</b> es requerido por la aplicación, por favor ingrese una fecha." ValidationGroup="Valida"></asp:RequiredFieldValidator>
|
||||
<asp:CompareValidator ID="cvFechaF" runat="server" ControlToValidate="Txtfecha" Display="None" ErrorMessage="El campo <b>''Fecha Final''</b> no tienes el formato correcto, por favor intente de nuevo con el siguiente formato: (dd/mm/yyyy)." Operator="DataTypeCheck" Type="Date" ValidationGroup="Valida"></asp:CompareValidator>
|
||||
<ajax:ValidatorCalloutExtender ID="vcoRfvFF" runat="server" HighlightCssClass="vco" TargetControlID="rfvFechaF" Width="350px"></ajax:ValidatorCalloutExtender>
|
||||
<ajax:ValidatorCalloutExtender ID="vcoCvFF" runat="server" HighlightCssClass="vco" TargetControlID="cvFechaF" Width="350px"></ajax:ValidatorCalloutExtender>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Descripción -->
|
||||
<div class="row">
|
||||
<div class="col-md-10">
|
||||
<div class="form-group form-md-line-input input-iconright">
|
||||
<asp:TextBox ID="TxtDescripcion" runat="server"
|
||||
CssClass="form-control"
|
||||
Style="width: 95%; height: 40px;"
|
||||
ValidationGroup="GrpGuardar"
|
||||
TextMode="MultiLine"
|
||||
Rows="2"
|
||||
MaxLength="1000" />
|
||||
<asp:RequiredFieldValidator ID="RFVDescripcion" runat="server"
|
||||
ControlToValidate="TxtDescripcion"
|
||||
ErrorMessage="Descripción requerida"
|
||||
Display="None"
|
||||
CssClass="text-danger"
|
||||
ValidationGroup="GrpGuardar" />
|
||||
<label for="<%= TxtDescripcion.ClientID.ToString()%>">Descripcion</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="portlet light xspadding bordered">
|
||||
<div class="portlet-title">
|
||||
@@ -437,23 +447,17 @@
|
||||
|
||||
</div>
|
||||
<div class="portlet-body form">
|
||||
<asp:TextBox ID="TxtEstatus" runat="server" CssClass="form-control" Width="150px"></asp:TextBox>
|
||||
<asp:RequiredFieldValidator ID="RFVEstatus" runat="server"
|
||||
ControlToValidate="TxtEstatus"
|
||||
Display="Dynamic"
|
||||
ErrorMessage="Estatus requerido"
|
||||
CssClass="text-danger"
|
||||
ValidationGroup="GrpGuardar" />
|
||||
<asp:Label ID="TxtEstatus" runat="server" CssClass="form-control" Width="150px"></asp:Label>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</ContentTemplate>
|
||||
</asp:UpdatePanel>
|
||||
</div>
|
||||
|
||||
<!-- GridViews -->
|
||||
<asp:UpdatePanel ID="UpGvDatosOP" runat="server" UpdateMode="Conditional">
|
||||
<asp:UpdatePanel ID="UpGvDatosOP" runat="server" UpdateMode="Conditional" style="margin-top: -170px;">
|
||||
<ContentTemplate>
|
||||
|
||||
<div class="row">
|
||||
@@ -466,13 +470,15 @@
|
||||
</div>
|
||||
<div class="portlet-body">
|
||||
<div class="row">
|
||||
<label class="col-md-1" style="max-width: 70px;">Producto</label>
|
||||
<div id="PanelProducto" runat="server">
|
||||
<asp:label ID="LblProducto" class="col-md-1" runat="server" style="max-width: 70px;" Text="Producto"></asp:label>
|
||||
<div class="col-md-3">
|
||||
<ADS:Dropdownlost ID="DdlPS" runat="server" Width="100%" CssStyle="width: 100%;"
|
||||
CssClass="select2me"
|
||||
CssClassDdl="form-control" DataTextField="PSCodigo"
|
||||
DataValueField="CvePS" Enabled="false" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 d-flex align-items-center" style="gap: 10px;">
|
||||
<asp:LinkButton ID="BtnAgregarProducto" runat="server"
|
||||
CssClass="btn btn-primary"
|
||||
@@ -760,31 +766,39 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Área de acción: Guardar, Terminar y Cancelar -->
|
||||
<asp:UpdatePanel runat="server" ID="UpBtns" UpdateMode="Conditional">
|
||||
<ContentTemplate>
|
||||
<div class="row mt-4">
|
||||
<div class="col-md-12 d-flex justify-content-end align-items-center">
|
||||
<!-- Botón Guardar -->
|
||||
<asp:Button
|
||||
ID="BtnGuardarOP" runat="server"
|
||||
Text="Guardar Orden de Producción"
|
||||
CssClass="btn btn-success me-2"
|
||||
OnClick="BtnGuardarOP_Click"
|
||||
ValidationGroup="GrpGuardar" />
|
||||
|
||||
<!-- Botón para Guardar la OP -->
|
||||
<div class="form-group" style="margin-top: 20px;">
|
||||
<asp:Button ID="BtnGuardarOP" runat="server" Text="Guardar Orden de Producción"
|
||||
CssClass="btn btn-success" OnClick="BtnGuardarOP_Click"
|
||||
ValidationGroup="GrpGuardar" />
|
||||
</div>
|
||||
<!-- Botones Derecha: Terminar y Cancelar -->
|
||||
|
||||
<div class="row mt-4">
|
||||
<div class="col-md-12 d-flex justify-content-end">
|
||||
<asp:Button ID="BtnFinalizarOP" runat="server" Text="Terminar"
|
||||
CssClass="btn btn-success mr-2" OnClick="BtnFinalizarOP_Click"
|
||||
Visible="false" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mt-4">
|
||||
<div class="col-md-12 d-flex justify-content-end">
|
||||
<asp:Button ID="BtnCancelarOP" runat="server" Text="Cancelar OP"
|
||||
CssClass="btn btn-danger" Visible="false"
|
||||
OnClick="BtnCancelarOP_Click" />
|
||||
</div>
|
||||
</div>
|
||||
<asp:Button
|
||||
ID="BtnFinalizarOP" runat="server"
|
||||
Text="Terminar"
|
||||
CssClass="btn btn-success mr-2"
|
||||
OnClick="BtnFinalizarOP_Click"
|
||||
Visible="false" />
|
||||
|
||||
<asp:Button
|
||||
ID="BtnCancelarOP" runat="server"
|
||||
Text="Cancelar OP"
|
||||
CssClass="btn btn-danger"
|
||||
OnClick="BtnCancelarOP_Click"
|
||||
Visible="false" />
|
||||
</div>
|
||||
</div>
|
||||
</ContentTemplate>
|
||||
|
||||
</asp:UpdatePanel>
|
||||
|
||||
<div id="DVModalFinalizarOP" class="modal ADS fade" role="dialog" data-backdrop="static">
|
||||
<div class="modal-dialog" style="width: 750px;">
|
||||
@@ -838,11 +852,13 @@
|
||||
<asp:TextBox ID="TxtCantidadPT" runat="server"
|
||||
Text='<%# Bind("Cantidad") %>'
|
||||
CssClass="form-control"
|
||||
style="text-align: right;"
|
||||
TextMode="Number"
|
||||
min="0"
|
||||
step="1"
|
||||
data-original='<%# Eval("Cantidad") %>'
|
||||
onchange="validarCantidad(this)" />
|
||||
onchange="validarCantidad(this)"
|
||||
ItemStyle-HorizontalAlign="Right"/>
|
||||
</ItemTemplate>
|
||||
</asp:TemplateField>
|
||||
</Columns>
|
||||
@@ -856,17 +872,18 @@
|
||||
CssClass="table table-striped table-hover" GridLines="None" Width="100%">
|
||||
<Columns>
|
||||
<asp:BoundField DataField="PSCodigo" HeaderText="Producto" />
|
||||
<asp:BoundField DataField="Cantidad" HeaderText="Cantidad" DataFormatString="{0:N2}" />
|
||||
<asp:BoundField DataField="Cantidad" HeaderText="Cantidad" DataFormatString="{0:N2}" ItemStyle-HorizontalAlign="Right"/>
|
||||
<asp:TemplateField HeaderText="Devolución">
|
||||
<ItemTemplate>
|
||||
<asp:TextBox ID="TxtDevolucionMP" runat="server"
|
||||
Text="0"
|
||||
CssClass="form-control"
|
||||
style="width: 50%; text-align: right; margin-left: 38px; display: block;"
|
||||
TextMode="Number"
|
||||
min="0"
|
||||
step="1"
|
||||
data-original='<%# Eval("Cantidad") %>'
|
||||
onchange="validarCantidad(this)" />
|
||||
onchange="validarCantidad(this)"
|
||||
/>
|
||||
</ItemTemplate>
|
||||
|
||||
</asp:TemplateField>
|
||||
@@ -929,13 +946,17 @@
|
||||
<asp:TemplateField HeaderText="Merma">
|
||||
<ItemTemplate>
|
||||
<asp:TextBox ID="TxtMerma" runat="server" Text="0"
|
||||
CssClass="form-control" TextMode="Number" step="0.01" min="0" />
|
||||
CssClass="txt-merma" TextMode="Number" step="0.01" min="0"
|
||||
style="width: 50%; text-align: right;"
|
||||
onchange="calcularDevolucion(this);"
|
||||
data-original='<%# Eval("Cantidad")%>'
|
||||
/>
|
||||
</ItemTemplate>
|
||||
</asp:TemplateField>
|
||||
<asp:TemplateField HeaderText="Devolución">
|
||||
<asp:TemplateField HeaderText="Devolución" ItemStyle-CssClass="celda-derecha">
|
||||
<ItemTemplate>
|
||||
<asp:TextBox ID="TxtDevolucionCancel" runat="server" Text="0"
|
||||
CssClass="form-control" TextMode="Number" step="0.01" min="0" />
|
||||
<asp:Label ID="LblDevolucion" runat="server" Text='<%# Eval("Cantidad", "{0:N2}") %>' CssClass="devolucion-label" style="text-align: right;"/>
|
||||
<asp:HiddenField ID="HfDevolucion" runat="server" Value='<%# Eval("Cantidad", "{0:N2}") %>' />
|
||||
</ItemTemplate>
|
||||
</asp:TemplateField>
|
||||
</Columns>
|
||||
@@ -969,7 +990,20 @@
|
||||
}
|
||||
}
|
||||
|
||||
function calcularDevolucion(input) {
|
||||
var cantidadOriginal = parseFloat(input.dataset.original) || 0; // Usar dataset.original
|
||||
var merma = parseFloat(input.value) || 0;
|
||||
|
||||
if (merma > cantidadOriginal) {
|
||||
input.value = cantidadOriginal.toFixed(2);
|
||||
merma = cantidadOriginal;
|
||||
}
|
||||
|
||||
var devolucion = cantidadOriginal - merma;
|
||||
var row = input.closest('tr');
|
||||
row.querySelector('.devolucion-label').innerText = devolucion.toFixed(2);
|
||||
row.querySelector('[id$="HfDevolucion"]').value = devolucion.toFixed(2);
|
||||
}
|
||||
|
||||
</script>
|
||||
</asp:Content>
|
||||
|
||||
301
OP/OP.aspx.vb
301
OP/OP.aspx.vb
@@ -21,6 +21,15 @@ Partial Class OP_OP
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property CveEstatusInicial As Integer
|
||||
Get
|
||||
Return ViewState("CveEstatusInicial").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("CveEstatusInicial") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property DtPS As DataTable
|
||||
Get
|
||||
Return DirectCast(ViewState("DtPS"), DataTable)
|
||||
@@ -103,6 +112,11 @@ Partial Class OP_OP
|
||||
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
||||
If Not IsPostBack Then
|
||||
CveOP = If(Request("CveOP") <> "", Request("CveOP").ToString.ToEntero, "-1".ToEntero)
|
||||
|
||||
If Not CveOP > 0 Then
|
||||
TxtEstatus.Text = GlobalDTOPEstatus(UsuarioActual.CveEmpresa).FiltroPrimeroValor("EstatusOP", "TipoEstatus=1")
|
||||
End If
|
||||
CveEstatusInicial = GlobalDTOPEstatus(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveEstatusOP", "TipoEstatus=1").ToEntero()
|
||||
TipoEstatus = -1
|
||||
CreaPS()
|
||||
SetValues()
|
||||
@@ -132,8 +146,6 @@ Partial Class OP_OP
|
||||
DtMP.Columns.Add("UnidadMedida", GetType(String))
|
||||
DtMP.Columns.Add("Cantidad", GetType(Decimal))
|
||||
DtMP.Columns.Add("Surtido", GetType(Decimal))
|
||||
'DtMP.Columns.Add("CvePSProducto", GetType(Integer))
|
||||
'DtMP.Columns.Add("CveAlmacenDestino", GetType(Integer))
|
||||
|
||||
DtMO = New DataTable()
|
||||
DtMO.Columns.Add("Tipo", GetType(String)) ' Producto, MP, MO, CI
|
||||
@@ -152,7 +164,6 @@ Partial Class OP_OP
|
||||
DtCI.Columns.Add("productoMateriaPrima", GetType(String))
|
||||
DtCI.Columns.Add("CvePSProducto", GetType(Integer))
|
||||
DtCI.Columns.Add("Cantidad", GetType(Decimal))
|
||||
'DtCI.Columns.Add("Costo", GetType(Decimal))
|
||||
DtCI.Columns.Add("ImporteCostoIndirecto", GetType(Decimal))
|
||||
DtCI.Columns.Add("Total", GetType(Decimal))
|
||||
|
||||
@@ -166,7 +177,7 @@ Partial Class OP_OP
|
||||
CargarProductos()
|
||||
CargaDatos()
|
||||
|
||||
If TipoEstatus = 3 Then
|
||||
If TipoEstatus = 3 Or TipoEstatus = 4 Then
|
||||
DeshabilitarControles() ' Deshabilita todos los controles relevantes
|
||||
Else
|
||||
If CveOP = -1 Then ' Nueva OP
|
||||
@@ -199,14 +210,20 @@ Partial Class OP_OP
|
||||
|
||||
UpOP.Update()
|
||||
UpGvDatosOP.Update()
|
||||
UpBtns.Update()
|
||||
End Sub
|
||||
|
||||
Private Sub DeshabilitarControles()
|
||||
' Deshabilitar DropDownLists
|
||||
DdlClientes.Enabled = False
|
||||
|
||||
DdlProyecto.Enabled = False
|
||||
DdlSubProyecto.Enabled = False
|
||||
DdlPS.Enabled = False
|
||||
DdlClientes.ddl.Enabled = False
|
||||
DdlClientes.ddlWS.Disabled = True
|
||||
DdlPS.ddl.Visible = False
|
||||
DdlPS.ddlWS.Visible = False
|
||||
LblProducto.Visible = False
|
||||
|
||||
|
||||
' Deshabilitar TextBox y Date
|
||||
TxtDescripcion.Enabled = False
|
||||
@@ -219,10 +236,16 @@ Partial Class OP_OP
|
||||
BtnSimularMP.Visible = False
|
||||
BtnGuardarOP.Visible = False
|
||||
BtnFinalizarOP.Visible = False
|
||||
BtnCancelarOP.Visible = False
|
||||
LnkSolicitarMP.Visible = False
|
||||
GvProductos.Columns(3).Visible = False
|
||||
|
||||
|
||||
|
||||
UpOP.Update()
|
||||
UpGvDatosOP.Update()
|
||||
UpBtns.Update()
|
||||
UpModalCancelar.Update()
|
||||
End Sub
|
||||
|
||||
Private Sub CargaDatos()
|
||||
@@ -298,7 +321,6 @@ Partial Class OP_OP
|
||||
newRow("Tipo") = "CI"
|
||||
newRow("CvePS") = rowCI("CvePS").ToString().ToEntero()
|
||||
newRow("CvePSProducto") = rowCI("CvePSProducto").ToString().ToEntero()
|
||||
'newRow("CvePSMateriaPrima") = rowCI("CvePSMateriaPrima").ToString().ToEntero()
|
||||
newRow("productoMateriaPrima") = rowCI("producto").ToString
|
||||
newRow("ImporteCostoIndirecto") = rowCI("ImporteCostoIndirecto").ToString.ToDecimal()
|
||||
newRow("Total") = rowCI("ImporteCostoIndirecto")
|
||||
@@ -306,11 +328,18 @@ Partial Class OP_OP
|
||||
|
||||
Next
|
||||
End If
|
||||
|
||||
|
||||
End If
|
||||
End If
|
||||
ObjOP.Dispose()
|
||||
ActualizarGrids()
|
||||
End If
|
||||
|
||||
' Validar si la OP está Terminada (3) o Cancelada (4)
|
||||
If TipoEstatus = 3 Or TipoEstatus = 4 Then
|
||||
DeshabilitarControles()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub CargarClientes()
|
||||
@@ -402,7 +431,6 @@ Partial Class OP_OP
|
||||
rowCI("Tipo") = "CI"
|
||||
rowCI("CvePS") = CvePS
|
||||
rowCI("CvePSProducto") = drCI("CvePSProducto").ToString()
|
||||
'rowCI("CvePSMateriaPrima") = drCI("CvePSMateriaPrima").ToString().ToEntero()
|
||||
rowCI("productoMateriaPrima") = drCI("productoMateriaPrima").ToString()
|
||||
rowCI("ImporteCostoIndirecto") = drCI("ImporteCostoIndirecto").ToString().ToDecimal()
|
||||
rowCI("Total") = rowCI("ImporteCostoIndirecto")
|
||||
@@ -912,9 +940,26 @@ Partial Class OP_OP
|
||||
DdlAlmacenMermas.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 1")
|
||||
DdlAlmacenMermas.DataBind()
|
||||
|
||||
' Cargar MP
|
||||
GvMPCancelacion.DataSource = DtMP.FiltraParametros("Tipo = 'MP'")
|
||||
' 1. Crear copia del DataTable
|
||||
Dim dtMPCopy As DataTable = DtMP.FiltraParametros("Tipo = 'MP'").Copy()
|
||||
|
||||
' 2. Agregar columna "Devolucion" como NO READONLY
|
||||
If Not dtMPCopy.Columns.Contains("Devolucion") Then
|
||||
Dim colDevolucion As New DataColumn("Devolucion", GetType(Decimal))
|
||||
colDevolucion.ReadOnly = False
|
||||
dtMPCopy.Columns.Add(colDevolucion)
|
||||
End If
|
||||
|
||||
' 3. Asignar valores manualmente
|
||||
For Each row As DataRow In dtMPCopy.Rows
|
||||
row("Devolucion") = row("Cantidad")
|
||||
Next
|
||||
|
||||
' 4. Configurar GridView
|
||||
GvMPCancelacion.DataSource = dtMPCopy
|
||||
GvMPCancelacion.DataBind()
|
||||
ViewState("DtMPCancelacion") = dtMPCopy
|
||||
|
||||
|
||||
RegistraScript("$('#DVModalCancelarOP').modal('show');")
|
||||
UpModalCancelar.Update()
|
||||
@@ -931,9 +976,9 @@ Partial Class OP_OP
|
||||
Dim ObjInventario As New ClsInventarios()
|
||||
Dim CveMovimientoSalida As Integer = 1
|
||||
Dim CveMovEntradaDev As Integer = 0
|
||||
Dim CveMovMerma As Integer = 1
|
||||
Dim TieneError As Boolean = False
|
||||
Dim MensajeError As String = ""
|
||||
Dim CveMovMerma As Integer = 0
|
||||
Dim ErrorMovInv As Boolean = False
|
||||
Dim TextoError As String = ""
|
||||
ObjInventario.IniciaTransacSQL()
|
||||
Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL())
|
||||
Dim ObjOP As New ClsOP(ObjInventario.IniciaTransacSQL())
|
||||
@@ -942,12 +987,14 @@ Partial Class OP_OP
|
||||
Dim TotalMP As Decimal = 0
|
||||
Dim TotalDevoluciones As Decimal = 0
|
||||
Dim TotalMermas As Decimal = 0
|
||||
' Obtener folios de movimientos
|
||||
Dim folioDevolucion = 0
|
||||
Dim folioMerma = 0
|
||||
|
||||
|
||||
Dim Fecha As DateTime = NowADS()
|
||||
|
||||
Try
|
||||
|
||||
|
||||
' Validaciones
|
||||
If DdlAlmacenSalidaMP.SelectedValue = "-1" OrElse
|
||||
DdlAlmacenDevolucionCancel.SelectedValue = "-1" Then
|
||||
@@ -957,81 +1004,162 @@ Partial Class OP_OP
|
||||
' 1. Movimiento de Salida MP
|
||||
CveMovimientoSalida = ObjInventario.AddMovimiento(DdlAlmacenSalidaMP.SelectedValue.ToEntero(), TipoMovimientoSalida, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:="Cancelación OP #" & LblFolio.Text, Modulo:="OP/CancelanciónSalida")
|
||||
|
||||
' 2. Registrar detalles y obtener PU (Igual que en Finalizar)
|
||||
Dim DtMPCancelacion As DataTable = Nothing
|
||||
If CveMovimientoSalida > 0 Then
|
||||
For Each row As GridViewRow In GvMPCancelacion.Rows
|
||||
Dim CvePS As Integer = row.DataKey("CvePSMateriaPrima").ToEntero
|
||||
Dim CveUM As Integer = row.DataKey("CveUMMateriaPrima").ToEntero
|
||||
Dim Cantidad As Decimal = CDec(row.Cells(2).Text)
|
||||
|
||||
|
||||
' Registrar con PU=0 temporalmente
|
||||
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Cantidad, CveUM, CvePS, 0) Then
|
||||
ErrorMovInv = True
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
|
||||
End If
|
||||
|
||||
' Obtener PU reales del movimiento
|
||||
If Not ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
|
||||
ErrorMovInv = True
|
||||
End If
|
||||
|
||||
DtMPCancelacion = ObjInventario.DtResultados.Copy()
|
||||
|
||||
' 3. Recalcular totales con PU reales (Clave)
|
||||
TotalMP = DtMPCancelacion.SUMD("Total")
|
||||
|
||||
' 2. Movimiento de Entrada Devoluciones
|
||||
CveMovEntradaDev = ObjInventario.AddMovimiento(DdlAlmacenDevolucionCancel.SelectedValue.ToEntero(), TipoMovimientoEntrada, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Modulo:="OP/CancelaciónEntrada", CveMovimientoRelacionado:=CveMovimientoSalida)
|
||||
|
||||
folioDevolucion = ObjInventario.Folio
|
||||
' 3. Procesar cada material
|
||||
For Each row As GridViewRow In GvMPCancelacion.Rows
|
||||
Dim Cantidad As Decimal = CDec(row.Cells(2).Text)
|
||||
Dim Merma As Decimal = row.FCTextBox("TxtMerma").Text.ToDecimal()
|
||||
Dim Devolucion As Decimal = row.FCTextBox("TxtDevolucionCancel").Text.ToDecimal()
|
||||
|
||||
If (Merma + Devolucion) > Cantidad Then
|
||||
Throw New Exception("La suma de merma y devolución no puede exceder la cantidad")
|
||||
End If
|
||||
|
||||
TotalMP += Cantidad
|
||||
TotalDevoluciones += Devolucion
|
||||
TotalMermas += Merma
|
||||
|
||||
Dim CvePS As Integer = row.DataKey("CvePSMateriaPrima").ToEntero
|
||||
Dim CveUM As Integer = row.DataKey("CveUMMateriaPrima").ToEntero
|
||||
|
||||
|
||||
' Registrar salida
|
||||
ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Cantidad, CveUM, CvePS, 0)
|
||||
|
||||
' Registrar devolución
|
||||
If Devolucion > 0 Then
|
||||
ObjInventario.AddMovimientoDetalle(CveMovEntradaDev, Devolucion, CveUM, CvePS, 0)
|
||||
End If
|
||||
Next
|
||||
|
||||
' 4. Registrar mermas si existen
|
||||
|
||||
If DdlAlmacenMermas.SelectedValue <> "-1" Then
|
||||
CveMovMerma = ObjInventario.AddMovimiento(DdlAlmacenMermas.SelectedValue.ToEntero(), TipoMovimientoSalida, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Modulo:="OP/CancelaciónMerma", CveMovimientoRelacionado:=CveMovimientoSalida)
|
||||
|
||||
If Not ErrorMovInv Then
|
||||
For Each row As GridViewRow In GvMPCancelacion.Rows
|
||||
|
||||
Dim CvePS As Integer = row.DataKey("CvePSMateriaPrima").ToEntero
|
||||
Dim CveUM As Integer = row.DataKey("CveUMMateriaPrima").ToEntero
|
||||
Dim Merma As Decimal = row.FCTextBox("TxtMerma").Text.ToDecimal()
|
||||
If Merma > 0 Then
|
||||
Dim CvePS As Integer = row.DataKey("CvePSMateriaPrima").ToEntero
|
||||
Dim CveUM As Integer = row.DataKey("CveUMMateriaPrima").ToEntero
|
||||
ObjInventario.AddMovimientoDetalle(CveMovMerma, Merma, CveUM, CvePS, 0)
|
||||
TotalMermas += Merma
|
||||
Dim Cantidad As Decimal = CDec(row.Cells(2).Text)
|
||||
Dim Devolucion As Decimal = Cantidad - Merma ' Cálculo automático
|
||||
|
||||
Dim PU As Decimal = DtMPCancelacion.FiltroPrimeroValor("PU", $"CvePS = {CvePS} AND CveUM = {CveUM}").ToDecimal()
|
||||
|
||||
' Actualizar devoluciones con PU correcto
|
||||
If Devolucion > 0 Then
|
||||
ObjInventario.AddMovimientoDetalle(CveMovEntradaDev, Devolucion, CveUM, CvePS, PU)
|
||||
TotalDevoluciones += Devolucion * PU
|
||||
End If
|
||||
|
||||
If Devolucion < 0 Then
|
||||
Throw New Exception($"Devolución negativa en {row.Cells(0).Text}")
|
||||
End If
|
||||
|
||||
Next
|
||||
End If
|
||||
|
||||
Dim TieneMerma As Boolean = False
|
||||
For Each row As GridViewRow In GvMPCancelacion.Rows
|
||||
If row.FCTextBox("TxtMerma").Text.ToDecimal() > 0 Then
|
||||
TieneMerma = True
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
|
||||
' 4. Registrar mermas si existen
|
||||
If TieneMerma Then
|
||||
If DdlAlmacenMermas.SelectedValue = "-1" Then
|
||||
Alert("Seleccione almacén para mermas", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
Dim GeneraSalidaMerma As Boolean = False
|
||||
If GeneraSalidaMerma = True Then
|
||||
CveMovMerma = ObjInventario.AddMovimiento(DdlAlmacenMermas.SelectedValue.ToEntero(), TipoMovimientoSalida, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Modulo:="OP/CancelaciónMerma", CveMovimientoRelacionado:=CveMovimientoSalida)
|
||||
folioMerma = ObjInventario.Folio
|
||||
If CveMovMerma > 0 Then
|
||||
For Each row As GridViewRow In GvMPCancelacion.Rows
|
||||
Dim CvePS As Integer = row.DataKey("CvePSMateriaPrima").ToEntero
|
||||
Dim CveUM As Integer = row.DataKey("CveUMMateriaPrima").ToEntero
|
||||
Dim PU As Decimal = DtMPCancelacion.FiltroPrimeroValor("PU", $"CvePS = {CvePS} AND CveUM = {CveUM}").ToDecimal()
|
||||
Dim Merma As Decimal = row.FCTextBox("TxtMerma").Text.ToDecimal()
|
||||
Dim Cantidad As Decimal = CDec(row.Cells(2).Text)
|
||||
|
||||
If Merma > 0 Then
|
||||
ObjInventario.AddMovimientoDetalle(CveMovMerma, Merma, CveUM, CvePS, PU)
|
||||
End If
|
||||
|
||||
' Validaciones
|
||||
If Merma > Cantidad Then
|
||||
ErrorMovInv = True
|
||||
End If
|
||||
|
||||
|
||||
Next
|
||||
If Not ObjInventario.GetMovimientosDetalle(CveMovMerma, UsuarioActual.CveEmpresa) Then
|
||||
ErrorMovInv = True
|
||||
End If
|
||||
TotalMermas = DtMPCancelacion.SUMD("Total")
|
||||
|
||||
End If
|
||||
Else
|
||||
TotalMermas = TotalMP - TotalDevoluciones
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
' 5. Generar pólizas contables
|
||||
Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("OP/Cancelacion", 53, 0, 0, 1, Fecha,
|
||||
If Not ErrorMovInv Then
|
||||
Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("OP/Cancelacion", 53, 0, 0, 1, Fecha,
|
||||
"Cancelación OP #" & LblFolio.Text,
|
||||
UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
||||
|
||||
' Salida MP (Abono 68)
|
||||
ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TotalMP, TotalMP, 68, "Cancelación MP OP #" & LblFolio.Text, "Cancelación MP OP #" & LblFolio.Text, CveMovimientoAlmacen:=CveMovimientoSalida)
|
||||
' Salida MP (Abono 68)
|
||||
If CvePrePoliza > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TotalMP, TotalMP, 68, "Cancelación MP OP #" & LblFolio.Text, "Cancelación MP OP #" & LblFolio.Text, CveMovimientoAlmacen:=CveMovimientoSalida) Then
|
||||
ErrorMovInv = True
|
||||
End If
|
||||
' Entrada Devoluciones (Cargo 68)
|
||||
If Not ErrorMovInv AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TotalDevoluciones, TotalDevoluciones, 68, "Devoluciones Cancelación OP #" & LblFolio.Text, "Devoluciones Cancelación OP #" & LblFolio.Text, CveMovimientoAlmacen:=CveMovEntradaDev) Then
|
||||
ErrorMovInv = True
|
||||
End If
|
||||
|
||||
' Entrada Devoluciones (Cargo 68)
|
||||
ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TotalDevoluciones, TotalDevoluciones, 68, "Devoluciones Cancelación OP #" & LblFolio.Text, "Devoluciones Cancelación OP #" & LblFolio.Text, CveMovimientoAlmacen:=CveMovEntradaDev)
|
||||
|
||||
If TotalMermas > 0 Then
|
||||
' Salida Mermas (Abono 68)
|
||||
ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TotalMermas, TotalMermas, 68, "Mermas Cancelación OP #" & LblFolio.Text, "Mermas Cancelación OP #" & LblFolio.Text, CveMovimientoAlmacen:=CveMovMerma)
|
||||
' Cargo Mermas (95)
|
||||
ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TotalMermas, TotalMermas, 95, "Ajuste Mermas Cancelación OP #" & LblFolio.Text, "Ajuste Mermas Cancelación OP #" & LblFolio.Text)
|
||||
If TotalMermas > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TotalMermas, TotalMermas, 95, "Mermas Cancelación OP #" & LblFolio.Text, "Mermas Cancelación OP #" & LblFolio.Text, CveMovimientoAlmacen:=CveMovMerma) Then
|
||||
ErrorMovInv = True
|
||||
End If
|
||||
End If
|
||||
|
||||
' 6. Actualizar estatus OP
|
||||
' 6. Actualizar estatus OP
|
||||
If Not ErrorMovInv Then
|
||||
If ObjOP.UpdateEstatusOP(CveOP, CveEstatusCancelacion, UsuarioActual.CveEmpresa) Then
|
||||
ObjInventario.Commit()
|
||||
TxtEstatus.Text = EstatusCancelacion
|
||||
PanelProducto.Visible = False
|
||||
DeshabilitarControles()
|
||||
|
||||
If ObjOP.UpdateEstatusOP(CveOP, CveEstatusCancelacion, UsuarioActual.CveEmpresa) Then
|
||||
ObjInventario.Commit()
|
||||
TxtEstatus.Text = "Cancelado"
|
||||
BtnCancelarOP.Visible = False
|
||||
UpOP.Update()
|
||||
RegistraScript("$('#DVModalCancelarOP').modal('hide');")
|
||||
Alert("OP cancelada correctamente", TipoMensaje.MsgInformacion)
|
||||
|
||||
Dim linkDevolucion = $"<a class='Texto' href='/Inventarios/EntradasSalidas.aspx?CveMovimiento={CveMovEntradaDev}'>{folioDevolucion}</a>"
|
||||
|
||||
Dim mensaje = $"OP cancelada correctamente.<br/>Devolución: {linkDevolucion}"
|
||||
|
||||
' Validar si existe movimiento de merma
|
||||
If CveMovMerma > 0 Then
|
||||
Dim linkMerma = $"<a class='Texto' href='/Inventarios/EntradasSalidas.aspx?CveMovimiento={CveMovMerma}'>{folioMerma}</a>"
|
||||
mensaje &= $"<br/>Merma: {linkMerma}"
|
||||
End If
|
||||
|
||||
RegistraScript("$('#DVModalCancelarOP').modal('hide');")
|
||||
Alert(mensaje, TipoMensaje.MsgInformacion)
|
||||
Else
|
||||
ObjInventario.RollBack()
|
||||
Alert("Error al actualizar el estatus.", TipoMensaje.MsgError)
|
||||
|
||||
End If
|
||||
Else
|
||||
Throw New Exception("Error al actualizar el estatus de la OP")
|
||||
ObjInventario.RollBack()
|
||||
Alert($"Error contable: {TextoError}", TipoMensaje.MsgError)
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
@@ -1112,10 +1240,6 @@ Partial Class OP_OP
|
||||
Dim CveMovimientoEntrada As Integer = 0
|
||||
Dim IDPoliza As Integer = 0
|
||||
Dim FolioSalida As Integer = 0
|
||||
'Dim CveMovimientoVirtualEntrada As Integer = 0
|
||||
'Dim CveMovimientoVirtualSalida As Integer = 0
|
||||
'Dim FolioVirtualEntrada As Integer = 0
|
||||
'Dim FolioVirtualSalida As Integer = 0
|
||||
Dim FolioEntrada As Integer = 0
|
||||
Dim Fecha As DateTime = NowADS()
|
||||
Dim ErrorMovInv As Boolean = False
|
||||
@@ -1124,7 +1248,6 @@ Partial Class OP_OP
|
||||
Dim TipoMovimientoDev As Integer = 33
|
||||
Dim CveConceptoEntrada As Integer = 9
|
||||
Dim TotalCostoMP As Decimal = 0
|
||||
'Dim TotalDevoluciones As Decimal = 0
|
||||
Dim CveMovimientoDev As Integer = 0
|
||||
Dim CostoDevoluciones As Decimal = 0
|
||||
|
||||
@@ -1222,8 +1345,8 @@ Partial Class OP_OP
|
||||
For Each row As GridViewRow In GvMPUtilizada.Rows
|
||||
Dim Devolucion As Decimal = row.FCTextBox("TxtDevolucionMP").Text.ToDecimal()
|
||||
If Devolucion > 0 Then
|
||||
Dim CvePS As Integer = row.DataKey("CvePSMateriaPrima").ToEntero 'GvMPUtilizada.DataKeys(row.RowIndex)("CvePSMateriaPrima").ToString.ToEntero()
|
||||
Dim CveUM As Integer = row.DataKey("CveUMMateriaPrima").ToEntero 'GvMPUtilizada.DataKeys(row.RowIndex)("CveUMMateriaPrima").ToString.ToEntero()
|
||||
Dim CvePS As Integer = row.DataKey("CvePSMateriaPrima").ToEntero
|
||||
Dim CveUM As Integer = row.DataKey("CveUMMateriaPrima").ToEntero
|
||||
|
||||
|
||||
Dim PU As Decimal = DtMPAlmacen.FiltroPrimeroValor("PU", $"CvePS = {CvePS} AND CveUM = {CveUM}").ToDecimal()
|
||||
@@ -1253,8 +1376,7 @@ Partial Class OP_OP
|
||||
If CveMovimientoEntrada > 0 AndAlso Not ErrorMovInv Then
|
||||
Dim CostoTotalProduccion As Decimal = TotalMPProducto + TotalMOProducto + TotalCIProducto
|
||||
Dim CostoPTAjustado As Decimal = CostoTotalProduccion - CostoDevoluciones
|
||||
'Dim CantidadPT As Decimal = DtPS.AsEnumerable().Sum(Function(r) r.Field(Of Decimal)("Cantidad"))
|
||||
'Dim PU_PT As Decimal = If(CantidadPT > 0, CostoPTAjustado / CantidadPT, 0)
|
||||
|
||||
|
||||
For Each rowPT As DataRow In DtPS.Select("Tipo = 'Producto'")
|
||||
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, rowPT("Cantidad").ToString.ToDecimal(), rowPT("CveUM").ToString.ToEntero(), rowPT("CvePS").ToString.ToEntero(), rowPT("Costo").ToString.ToDecimal()) Then
|
||||
@@ -1288,14 +1410,6 @@ Partial Class OP_OP
|
||||
ErrorMovInv = True
|
||||
End If
|
||||
End If
|
||||
|
||||
'If Not ErrorMovInv Then
|
||||
'If Not ObjConta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual) Then
|
||||
'ErrorMovInv = True : TextoError = "Error en validación de póliza"
|
||||
'ElseIf ObjConta.ValorPolizaDescuadre > 0 Then
|
||||
' ErrorMovInv = True : TextoError = "Descuadre en póliza contable"
|
||||
'End If
|
||||
'End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
@@ -1306,16 +1420,12 @@ Partial Class OP_OP
|
||||
ObjInventario.Commit()
|
||||
TxtEstatus.Text = EstatusFinalizar
|
||||
DeshabilitarControles()
|
||||
UpOP.Update()
|
||||
UpGvDatosOP.Update()
|
||||
|
||||
Alert("Orden de producción finalizada.<br/>" & "<a class='Texto' href='/Inventarios/EntradasSalidas.aspx?CveMovimiento=" & CveMovimientoEntrada & "'>" & FolioEntrada & "</a>",
|
||||
TipoMensaje.MsgInformacion)
|
||||
|
||||
|
||||
|
||||
RegistraScript("$('#DVModalFinalizarOP').modal('hide');")
|
||||
|
||||
|
||||
Else
|
||||
ObjInventario.RollBack()
|
||||
Alert("Error al actualizar el estatus.", TipoMensaje.MsgError)
|
||||
@@ -1326,9 +1436,6 @@ Partial Class OP_OP
|
||||
Alert($"Error contable: {TextoError}", TipoMensaje.MsgError)
|
||||
End If
|
||||
|
||||
|
||||
|
||||
|
||||
Catch ex As Exception
|
||||
ObjInventario.RollBack()
|
||||
Alert($"Error crítico: {ex.Message}", TipoMensaje.MsgError)
|
||||
|
||||
Reference in New Issue
Block a user