Finalizacion de Orden Produccion
This commit is contained in:
841
OP/OP.aspx
841
OP/OP.aspx
@@ -1,9 +1,227 @@
|
||||
<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="OP.aspx.vb" Inherits="OP_OP" %>
|
||||
<%@ Import Namespace="Extensiones" %>
|
||||
|
||||
<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="OP.aspx.vb" Inherits="OP_OP" %>
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="Css" runat="Server">
|
||||
|
||||
<style>
|
||||
.v-center {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.ajax__calendar_container {
|
||||
position: fixed !important;
|
||||
}
|
||||
|
||||
.one {
|
||||
margin: 10px;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.btn-verde {
|
||||
color: #32c5d2;
|
||||
background-color: #fff;
|
||||
border-color: #32c5d2;
|
||||
}
|
||||
|
||||
.btn-verde .fa-plus {
|
||||
color: #32c5d2 !important;
|
||||
}
|
||||
|
||||
.btn-verde:hover {
|
||||
color: #fff;
|
||||
background-color: #32c5d2;
|
||||
border-color: #32c5d2;
|
||||
}
|
||||
|
||||
.btn-verde:hover .fa-plus {
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
|
||||
.table-scrollable {
|
||||
margin-top: 0px !important;
|
||||
margin-bottom: 0px !important;
|
||||
}
|
||||
|
||||
.Widthall {
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
.dataTables_scrollHeadInner {
|
||||
width: 100% !important;
|
||||
background-color: #dddddd;
|
||||
padding-left: 0px !important;
|
||||
}
|
||||
|
||||
.dataTables_scrollFoot {
|
||||
display: none;
|
||||
position: static;
|
||||
}
|
||||
|
||||
.table-scrollable {
|
||||
margin: 0px !important;
|
||||
}
|
||||
|
||||
.dataTables_scroll {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
.table.dataTable {
|
||||
margin-top: 0px !important;
|
||||
}
|
||||
|
||||
.dataTables_scrollBody table th {
|
||||
padding: 0px !important;
|
||||
padding-right: 4px !important;
|
||||
padding-left: 4px !important;
|
||||
}
|
||||
|
||||
.sinlink td a {
|
||||
pointer-events: none;
|
||||
cursor: default;
|
||||
color: black;
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
.white a {
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.Derecha {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.Izquierda {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.SinColor th {
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.Excede {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.truncate {
|
||||
width: 300px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.select2 .select2-selection__rendered {
|
||||
line-height: 1;
|
||||
color: #111;
|
||||
}
|
||||
|
||||
.select2 .select2-selection--multiple {
|
||||
box-sizing: border-box;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
min-height: 20px;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
|
||||
.select2-container--default .select2-selection--multiple .select2-selection__choice {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.select2-selection__rendered {
|
||||
margin-top: 0px;
|
||||
height: 25px;
|
||||
}
|
||||
|
||||
.select2-selection {
|
||||
margin-top: 0px;
|
||||
height: 31px;
|
||||
}
|
||||
|
||||
.select2-container--default.select2-container--focus .select2-selection--multiple {
|
||||
border: none;
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
#chartdiv {
|
||||
width: 100%;
|
||||
height: 250px;
|
||||
}
|
||||
|
||||
#chartdiv2 {
|
||||
width: 100%;
|
||||
height: 250px;
|
||||
}
|
||||
|
||||
#chartdiv3 {
|
||||
width: 100%;
|
||||
height: 250px;
|
||||
}
|
||||
|
||||
#chartdiv4 {
|
||||
width: 100%;
|
||||
height: 250px;
|
||||
}
|
||||
|
||||
|
||||
.orange {
|
||||
color: orange;
|
||||
background-color: orange;
|
||||
}
|
||||
|
||||
.tooltip-inner {
|
||||
max-width: 750px !important;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.arrow {
|
||||
left: 20%;
|
||||
}
|
||||
|
||||
.popover {
|
||||
width: 500px !important;
|
||||
max-width: 500px !important;
|
||||
}
|
||||
|
||||
.modalBackground {
|
||||
background-color: Black;
|
||||
filter: alpha(opacity=90);
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
|
||||
.select2anothertable {
|
||||
position: absolute;
|
||||
left: 100%;
|
||||
background-color: white;
|
||||
/*top: 50px;*/ top: 21px;
|
||||
/*max-height: 200px;*/ max-height: 229px;
|
||||
/*background-color: #dcdcdc;*/
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.select2anothertable > table > tbody > tr > td:nth-of-type(odd) {
|
||||
background-color: rgba(220, 220, 220, 0.45);
|
||||
}
|
||||
|
||||
.select2anothertable > table > tbody > tr > td {
|
||||
line-height: 21px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.select2anothertable > table > tbody > tr.active {
|
||||
background-color: #5897fb;
|
||||
}
|
||||
|
||||
#C_TrDescuentoProntoPago > td:nth-child(3) > span:nth-child(1) > label:nth-child(2) {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.op-container {
|
||||
max-width: 1400px;
|
||||
margin: 20px auto;
|
||||
@@ -61,12 +279,6 @@
|
||||
padding: 5px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.box {
|
||||
background-color: #EEE;
|
||||
margin-bottom: 10px;
|
||||
padding: 10px;
|
||||
}
|
||||
</style>
|
||||
|
||||
</asp:Content>
|
||||
@@ -81,109 +293,177 @@
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content7" ContentPlaceHolderID="C" runat="Server">
|
||||
<!-- Aquí se muestra la información de la OP -->
|
||||
<asp:UpdatePanel ID="UpOP" runat="server" UpdateMode="Conditional">
|
||||
|
||||
<div class="row">
|
||||
<asp:UpdatePanel ID="UpOP" runat="server" UpdateMode="Conditional">
|
||||
<ContentTemplate>
|
||||
<div class="col-md-6">
|
||||
<div class="portlet light xspadding bordered">
|
||||
<div class="portlet-title">
|
||||
<div class="caption font-green">
|
||||
<span class="caption-subject bold uppercase">Orden de producción #<asp:Label ID="LblFolio" runat="server"></asp:Label></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="portlet-body form">
|
||||
<div class="labeltruncate labeltext labelbold">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group form-md-line-input input-iconright">
|
||||
<label for="<%= DdlClientes.ClientID.ToString()%>">Cliente</label>
|
||||
<ADS:Dropdownlost ID="DdlClientes" runat="server"
|
||||
CssClassDdl="form-control" DataTextField="NombreComercial"
|
||||
data-metodo="getcliente"
|
||||
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">
|
||||
<div class="form-group">
|
||||
<div class="col-md-1">
|
||||
<label class="mb-0">Fecha</label>
|
||||
</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>
|
||||
</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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="portlet light xspadding bordered">
|
||||
<div class="portlet-title">
|
||||
<div class="caption font-green">
|
||||
<span class="caption-subject bold uppercase">Estatus</span>
|
||||
</div>
|
||||
|
||||
</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" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</ContentTemplate>
|
||||
</asp:UpdatePanel>
|
||||
</div>
|
||||
|
||||
<!-- GridViews -->
|
||||
<asp:UpdatePanel ID="UpGvDatosOP" runat="server" UpdateMode="Conditional">
|
||||
<ContentTemplate>
|
||||
<div class="op-container">
|
||||
<!-- Encabezado -->
|
||||
<div class="op-header">
|
||||
<h3 class="op-title">Orden de producción #<asp:Label ID="LblCveOP" runat="server"></asp:Label></h3>
|
||||
<div class="op-status">
|
||||
<label>Estatus:</label>
|
||||
<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" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-section">
|
||||
<div class="form-group">
|
||||
<label>Cliente</label>
|
||||
<ADS:Dropdownlost ID="DdlClientes" runat="server"
|
||||
CssClassDdl="form-control" DataTextField="NombreComercial"
|
||||
data-metodo="getcliente"
|
||||
DataValueField="CveCliente" Enabled="false" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Centro de Costo -->
|
||||
<div class="form-section">
|
||||
|
||||
<div class="form-group">
|
||||
<asp:Label ID="LblProyecto" runat="server" class="col-md-1">
|
||||
<span class="filtro-texto">Proyecto:</span>
|
||||
</asp:Label>
|
||||
<div runat="server" id="DivProyecto" class="col-md-2">
|
||||
<asp:DropDownList ID="DdlProyecto" runat="server" AutoPostBack="true" AppendDataBoundItems="true" DataTextField="Proyecto" DataValueField="CveProyecto" Class="table-group-action-input form-control input-inline input-small input-sm select2me" Style="width: 100%;"></asp:DropDownList>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="portlet light xspadding bordered">
|
||||
<div class="portlet-title">
|
||||
<div class="caption font-green">
|
||||
<span class="caption-subject bold uppercase">Productos</span>
|
||||
</div>
|
||||
</div>
|
||||
<asp:Label ID="LblSubProyecto" runat="server" class="col-md-1">
|
||||
<span class="filtro-texto">Subproyecto:</span>
|
||||
</asp:Label>
|
||||
<div runat="server" id="DivSubProyecto" class="col-md-2">
|
||||
<asp:DropDownList ID="DdlSubProyecto" runat="server" AppendDataBoundItems="true" DataTextField="SubProyecto" DataValueField="CveSubProyecto" Class="table-group-action-input form-control input-inline input-small input-sm select2me" Style="width: 100%;"></asp:DropDownList>
|
||||
<div class="portlet-body">
|
||||
<div class="row">
|
||||
<label class="col-md-1" style="max-width: 70px;">Producto</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 class="col-md-4 d-flex align-items-center" style="gap: 10px;">
|
||||
<asp:LinkButton ID="BtnAgregarProducto" runat="server"
|
||||
CssClass="btn btn-primary"
|
||||
Style="padding: 4px 10px; border-radius: 50%;"
|
||||
ValidationGroup="GrpAgregarProducto">
|
||||
<i class="fa fa-plus"></i>
|
||||
</asp:LinkButton>
|
||||
|
||||
<!-- Botón de Simulación -->
|
||||
|
||||
<asp:LinkButton ID="BtnSimularMP" runat="server" Text="Simular MP"
|
||||
CssClass="btn btn-primary" OnClick="BtnSimularMP_Click" Visible="false"
|
||||
Style="padding: 4px 10px; border-radius: 50%;">
|
||||
<i class="fa fa-cogs"></i>
|
||||
</asp:LinkButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Descripción -->
|
||||
<div class="form-group">
|
||||
<label>Descripción</label>
|
||||
<asp:TextBox ID="TxtDescripcion" runat="server"
|
||||
CssClass="form-control"
|
||||
TextMode="MultiLine"
|
||||
Rows="2" />
|
||||
<asp:RequiredFieldValidator ID="RFVDescripcion" runat="server"
|
||||
ControlToValidate="TxtDescripcion"
|
||||
ErrorMessage="Descripción requerida"
|
||||
Display="Dynamic"
|
||||
CssClass="text-danger"
|
||||
ValidationGroup="GrpGuardar" />
|
||||
</div>
|
||||
|
||||
<!-- Fecha -->
|
||||
<div class="row">
|
||||
<div class="col-md-1">
|
||||
<label class="mb-0">Fecha</label>
|
||||
</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>
|
||||
</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>
|
||||
|
||||
<!-- Producto -->
|
||||
<div class="form-group">
|
||||
<label class="col-md-2">Producto:</label>
|
||||
<div class="col-md-4">
|
||||
<ADS:Dropdownlost ID="DdlPS" runat="server"
|
||||
CssClassDdl="form-control" DataTextField="PSCodigo"
|
||||
DataValueField="CvePS" Enabled="false" />
|
||||
</div>
|
||||
<asp:Button ID="BtnAgregarProducto" runat="server" Text="Agregar Producto"
|
||||
CssClass="btn btn-primary" ValidationGroup="GrpAgregarProducto" />
|
||||
<asp:Button ID="BtnEliminarProducto" runat="server" Text="Eliminar Producto"
|
||||
CssClass="btn-eliminar" OnClick="BtnEliminarProducto_Click" />
|
||||
</div>
|
||||
|
||||
<!-- GridViews -->
|
||||
<asp:UpdatePanel ID="UpGvDatosOP" runat="server" UpdateMode="Conditional">
|
||||
<ContentTemplate>
|
||||
<div class="row">
|
||||
<div class="col-md-12 box">
|
||||
<div class="col-md-12">
|
||||
<div class="section-title">Productos</div>
|
||||
<asp:GridView ID="GvProductos" runat="server" AutoGenerateColumns="False"
|
||||
CssClass="table table-striped table-hover" GridLines="None" Width="100%">
|
||||
@@ -191,60 +471,347 @@
|
||||
<asp:BoundField DataField="PSCodigo" HeaderText="Producto" />
|
||||
<asp:BoundField DataField="UnidadMedida" HeaderText="UM" />
|
||||
<asp:BoundField DataField="Cantidad" HeaderText="Cantidad" />
|
||||
<asp:TemplateField>
|
||||
<ItemTemplate>
|
||||
<asp:LinkButton ID="BtnEliminar" runat="server"
|
||||
CommandArgument='<%# Eval("Clave") %>'
|
||||
OnClick="BtnEliminarProducto_Click"
|
||||
CssClass="btn btn-circle btn-xs red"
|
||||
Text="<i class='icon-trash'></i>" />
|
||||
</ItemTemplate>
|
||||
</asp:TemplateField>
|
||||
</Columns>
|
||||
</asp:GridView>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6 box">
|
||||
<div class="section-title">Materia prima</div>
|
||||
<asp:GridView ID="GvMateriaPrima" runat="server" AutoGenerateColumns="False"
|
||||
CssClass="table table-striped table-hover" GridLines="None" Width="100%">
|
||||
<Columns>
|
||||
<asp:BoundField DataField="producto" HeaderText="Producto" />
|
||||
<asp:BoundField DataField="UnidadMedida" HeaderText="UM" />
|
||||
<asp:BoundField DataField="Cantidad" HeaderText="Cantidad" DataFormatString="{0:#,##0.####}" ItemStyle-HorizontalAlign="Right" />
|
||||
<asp:BoundField DataField="Surtido" HeaderText="Surtido" ItemStyle-HorizontalAlign="Right"/>
|
||||
</Columns>
|
||||
</asp:GridView>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="portlet light xspadding bordered">
|
||||
<div class="portlet-title">
|
||||
<div class="caption font-green">
|
||||
<span class="caption-subject bold uppercase">Materia Prima</span>
|
||||
</div>
|
||||
<div class="col-md-4 d-flex align-items-center" style="gap: 10px;">
|
||||
<asp:LinkButton ID="LnkSolicitarMP" runat="server"
|
||||
CssClass="btn btn-success"
|
||||
OnClick="LnkSolicitarMP_Click"
|
||||
Style="padding: 4px 10px; border-radius: 50%;"
|
||||
Visible="false">
|
||||
Solicitar MP
|
||||
</asp:LinkButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6 box">
|
||||
<div class="portlet-body">
|
||||
|
||||
<div class="section-title">Materia prima</div>
|
||||
<asp:GridView ID="GvMateriaPrima" runat="server" AutoGenerateColumns="False"
|
||||
CssClass="table table-striped table-hover" GridLines="None" Width="100%">
|
||||
<Columns>
|
||||
<asp:BoundField DataField="PSCodigo" HeaderText="Producto" />
|
||||
<asp:BoundField DataField="UnidadMedida" HeaderText="UM" />
|
||||
<asp:BoundField DataField="Cantidad" HeaderText="Cantidad" DataFormatString="{0:#,##0.####}" ItemStyle-HorizontalAlign="Right" />
|
||||
<asp:BoundField DataField="Surtido" HeaderText="Surtido" DataFormatString="{0:#,##0.####}" ItemStyle-HorizontalAlign="Right" />
|
||||
</Columns>
|
||||
</asp:GridView>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="portlet light xspadding bordered">
|
||||
<div class="portlet-title">
|
||||
<div class="caption font-green">
|
||||
<span class="caption-subject bold uppercase">Mano de Obra</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="portlet-body">
|
||||
<div class="section-title">Mano de obra</div>
|
||||
<asp:GridView ID="GvManoObra" runat="server" AutoGenerateColumns="False"
|
||||
CssClass="table table-striped table-hover" GridLines="None" Width="100%">
|
||||
<Columns>
|
||||
<asp:BoundField DataField="Puesto" HeaderText="Puesto" />
|
||||
<asp:BoundField DataField="Cantidad" HeaderText="Cantidad" />
|
||||
<asp:BoundField DataField="Cantidad" HeaderText="Cantidad" DataFormatString="{0:#,##0.####}" ItemStyle-HorizontalAlign="Right" />
|
||||
</Columns>
|
||||
</asp:GridView>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6 box">
|
||||
<div class="section-title">Costo indirecto</div>
|
||||
<asp:GridView ID="GvCostosIndirectos" runat="server" AutoGenerateColumns="False"
|
||||
CssClass="table table-striped table-hover" GridLines="None" Width="100%">
|
||||
<Columns>
|
||||
<asp:BoundField DataField="producto" HeaderText="Producto" />
|
||||
<asp:BoundField DataField="Cantidad" HeaderText="Costo" />
|
||||
</Columns>
|
||||
</asp:GridView>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="portlet light xspadding bordered">
|
||||
<div class="portlet-title">
|
||||
<div class="caption font-green">
|
||||
<span class="caption-subject bold uppercase">Costo Indirecto</span>
|
||||
</div>
|
||||
</div>
|
||||
</ContentTemplate>
|
||||
</asp:UpdatePanel>
|
||||
|
||||
<!-- 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 class="portlet-body">
|
||||
<div class="section-title">Costo indirecto</div>
|
||||
<asp:GridView ID="GvCostosIndirectos" runat="server" AutoGenerateColumns="False"
|
||||
CssClass="table table-striped table-hover" GridLines="None" Width="100%">
|
||||
<Columns>
|
||||
<asp:BoundField DataField="productoMateriaPrima" HeaderText="Producto" />
|
||||
<asp:BoundField DataField="Cantidad" HeaderText="Costo" DataFormatString="{0:#,##0.####}" ItemStyle-HorizontalAlign="Right" />
|
||||
</Columns>
|
||||
</asp:GridView>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ContentTemplate>
|
||||
</asp:UpdatePanel>
|
||||
|
||||
<div id="DVModalSolicitarMP" class="modal ADS fade" role="dialog" data-backdrop="static">
|
||||
<div class="modal-dialog" style="width: 750px;">
|
||||
<asp:UpdatePanel runat="server" class="modal-content" ID="UpModalMP" UpdateMode="Conditional">
|
||||
<ContentTemplate>
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
<h4 class="modal-title">Solicitar Materia Prima - OP #<%= LblFolio.Text %></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<!-- Almacenes -->
|
||||
<div class="row">
|
||||
<div class="col-md-6 form-group">
|
||||
<label>Almacén Origen:</label>
|
||||
<asp:DropDownList ID="DdlAlmacenOrigenMP" runat="server"
|
||||
DataTextField="Almacen" DataValueField="CveAlmacen"
|
||||
CssClass="form-control select2me" AutoPostBack="true"
|
||||
OnSelectedIndexChanged="DdlAlmacenOrigenMP_SelectedIndexChanged" />
|
||||
</div>
|
||||
<div class="col-md-6 form-group">
|
||||
<label>Almacén Destino:</label>
|
||||
<asp:DropDownList ID="DdlAlmacenDestinoMP" runat="server"
|
||||
DataTextField="Almacen" DataValueField="CveAlmacen"
|
||||
CssClass="form-control select2me" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row marginRowLeft">
|
||||
<div class="col-md-12 form-group">
|
||||
<label>Observaciones:</label>
|
||||
<asp:TextBox ID="TxtObservacionesMP" runat="server"
|
||||
CssClass="form-control" TextMode="MultiLine" Rows="3"
|
||||
MaxLength="500" placeholder="Ingrese observaciones..." />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Grid de productos agregados -->
|
||||
<asp:GridView ID="GvMPAgregados" runat="server" AutoGenerateColumns="False"
|
||||
CssClass="table table-striped table-hover" GridLines="None" Width="100%"
|
||||
DataKeyNames="CvePSMateriaPrima,CveUMMateriaPrima, Cantidad" EmptyDataText="No se encontraron Productos registrados" ToolTip="Listado de Productos">
|
||||
<Columns>
|
||||
<asp:BoundField DataField="PSCodigo" HeaderText="Producto" />
|
||||
<asp:BoundField DataField="UnidadMedida" HeaderText="UM" />
|
||||
<asp:BoundField DataField="Cantidad" HeaderText="Cantidad" DataFormatString="{0:N2}" ItemStyle-HorizontalAlign="Right" />
|
||||
</Columns>
|
||||
</asp:GridView>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="modal-footer">
|
||||
<asp:Button ID="BtnGuardarSolicitudMP" runat="server"
|
||||
Text="Guardar Solicitud" CssClass="btn btn-primary"
|
||||
OnClick="BtnGuardarSolicitudMP_Click" />
|
||||
</div>
|
||||
</ContentTemplate>
|
||||
</asp:UpdatePanel>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="DVModalSimularMP" class="modal fade" role="dialog" data-backdrop="static">
|
||||
<div class="modal-dialog" style="width: 750px;">
|
||||
<asp:UpdatePanel ID="UpModalSimular" runat="server" UpdateMode="Conditional">
|
||||
<ContentTemplate>
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
|
||||
<h4 class="modal-title">Simulación de Materia Prima -
|
||||
<span id="SpanNombreProducto" runat="server"></span>
|
||||
</h4>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="portlet light xspadding bordered">
|
||||
<div class="portlet-title">
|
||||
<div class="caption font-green">
|
||||
<span class="caption-subject bold uppercase">Simulación</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<asp:RadioButtonList ID="RblModoSimulacion" runat="server" AutoPostBack="true"
|
||||
OnSelectedIndexChanged="RblModoSimulacion_SelectedIndexChanged" RepeatDirection="Horizontal">
|
||||
<asp:ListItem Text="Por Cantidad" Value="1" Selected="True"></asp:ListItem>
|
||||
<asp:ListItem Text="Por Existencias" Value="2"></asp:ListItem>
|
||||
</asp:RadioButtonList>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<label>Almacén:</label>
|
||||
<asp:DropDownList ID="DdlAlmacenSimular" runat="server"
|
||||
DataTextField="Almacen" DataValueField="CveAlmacen"
|
||||
CssClass="form-control" AutoPostBack="true"
|
||||
OnSelectedIndexChanged="DdlAlmacenSimular_SelectedIndexChanged"
|
||||
AppendDataBoundItems="True">
|
||||
<asp:ListItem Text="Selecciona el almacén" Value="-1" Selected="True"></asp:ListItem>
|
||||
</asp:DropDownList>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<asp:Panel ID="PnlCantidad" runat="server" class="col-md-2">
|
||||
<label>Cantidad:</label>
|
||||
<asp:TextBox ID="TxtCantidadSimular" runat="server"
|
||||
CssClass="form-control" TextMode="Number" Min="1" Value="1" AutoPostBack="true" OnTextChanged="TxtCantidadSimular_TextChanged" />
|
||||
</asp:Panel>
|
||||
</div>
|
||||
<div class="row">
|
||||
<asp:Label ID="LblCantidadPosibleGlobal" runat="server" Class="col-md-2"
|
||||
Visible="false">
|
||||
<strong>Cantidad:</strong> <span id="SpanCantidad">0</span>
|
||||
</asp:Label>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="section-title">Materia prima</div>
|
||||
<asp:GridView ID="GvSimulacionMP" runat="server" AutoGenerateColumns="False"
|
||||
CssClass="table table-striped table-hover"
|
||||
GridLines="None" Width="100%" DataKeyNames="CvePS,CveUM">
|
||||
<Columns>
|
||||
|
||||
<asp:BoundField DataField="productoMateriaPrima" HeaderText="Producto" />
|
||||
<asp:BoundField DataField="CantidadUnitaria" HeaderText="Cantidad Unitaria"
|
||||
DataFormatString="{0:#,##0.####}" ItemStyle-HorizontalAlign="Right" />
|
||||
|
||||
<asp:BoundField DataField="Disponible" HeaderText="Disponible"
|
||||
DataFormatString="{0:#,##0.####}" ItemStyle-HorizontalAlign="Right" />
|
||||
|
||||
<asp:BoundField DataField="TotalRequerido" HeaderText="Total Requerido"
|
||||
DataFormatString="{0:#,##0.####}" ItemStyle-HorizontalAlign="Right"
|
||||
Visible="false" />
|
||||
<asp:BoundField DataField="Faltante" HeaderText="Faltante"
|
||||
DataFormatString="{0:#,##0.####}" ItemStyle-HorizontalAlign="Right"
|
||||
Visible="false" />
|
||||
<asp:BoundField DataField="CantidadPosible" HeaderText="Cantidad Producible"
|
||||
DataFormatString="{0:#,##0.####}" ItemStyle-HorizontalAlign="Right"
|
||||
Visible="false" />
|
||||
</Columns>
|
||||
</asp:GridView>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ContentTemplate>
|
||||
</asp:UpdatePanel>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- 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>
|
||||
|
||||
<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 id="DVModalFinalizarOP" class="modal ADS fade" role="dialog" data-backdrop="static">
|
||||
<div class="modal-dialog" style="width: 750px;">
|
||||
<asp:UpdatePanel runat="server" class="modal-content" ID="UpModalFinalizar" UpdateMode="Conditional">
|
||||
<ContentTemplate>
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
<h4 class="modal-title">Finalizar Orden de Producción #<%= LblFolio.Text %></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<!-- Almacén de Materia Prima (Fijo) -->
|
||||
<div class="row">
|
||||
<div class="col-md-6 form-group">
|
||||
<label>Almacén de Salida (Materia Prima):</label>
|
||||
<asp:DropDownList ID="DdlAlmacenOrigenSalidaMP" runat="server"
|
||||
DataTextField="Almacen" DataValueField="CveAlmacen"
|
||||
CssClass="form-control select2me" />
|
||||
</div>
|
||||
<!-- Almacén de Producto Terminado (Dropdown) -->
|
||||
<div class="col-md-6 form-group">
|
||||
<label>Almacén de Entrada (Producto Terminado):</label>
|
||||
<asp:DropDownList ID="DdlAlmacenTerminado" runat="server"
|
||||
DataTextField="Almacen" DataValueField="CveAlmacen"
|
||||
CssClass="form-control select2me" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- GridViews -->
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="section-title">Producto Terminado</div>
|
||||
<asp:GridView ID="GvProductoTerminado" runat="server" AutoGenerateColumns="False"
|
||||
CssClass="table table-striped table-hover" GridLines="None" Width="100%">
|
||||
<Columns>
|
||||
<asp:BoundField DataField="PSCodigo" HeaderText="Producto" />
|
||||
<asp:BoundField DataField="UnidadMedida" HeaderText="UM" />
|
||||
<asp:BoundField DataField="Cantidad" HeaderText="Cantidad" DataFormatString="{0:N2}" />
|
||||
</Columns>
|
||||
</asp:GridView>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="section-title">Materia Prima</div>
|
||||
<asp:GridView ID="GvMPUtilizada" runat="server" AutoGenerateColumns="False"
|
||||
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}" />
|
||||
</Columns>
|
||||
</asp:GridView>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<%-- Botón Guardar --%>
|
||||
<asp:Button ID="BtnGuardarFinalizarOP" runat="server" Text="Guardar"
|
||||
CssClass="btn btn-primary" OnClick="BtnGuardarFinalizarOP_Click" />
|
||||
<%-- Botón Cerrar --%>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
|
||||
</div>
|
||||
</ContentTemplate>
|
||||
</asp:UpdatePanel>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</asp:Content>
|
||||
|
||||
|
||||
|
||||
779
OP/OP.aspx.vb
779
OP/OP.aspx.vb
@@ -5,6 +5,9 @@ Imports System.IO
|
||||
Imports Extensiones
|
||||
Imports Microsoft.Reporting.WebForms
|
||||
Imports Org.BouncyCastle.Asn1.Utilities
|
||||
Imports Profact.TimbraCFDI.Complementos.Ecc.Ecc11
|
||||
Imports System.Xml
|
||||
Imports System.Data.SqlClient
|
||||
Partial Class OP_OP
|
||||
Inherits ClsPaginas
|
||||
|
||||
@@ -54,6 +57,23 @@ Partial Class OP_OP
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property DtMPAgregados As DataTable
|
||||
Get
|
||||
If ViewState("DtMPAgregados") Is Nothing Then
|
||||
DtMPAgregados = New DataTable()
|
||||
DtMPAgregados.Columns.Add("Clave", GetType(Integer))
|
||||
DtMPAgregados.Columns.Add("PSCodigo", GetType(String))
|
||||
DtMPAgregados.Columns.Add("CveUM", GetType(Integer))
|
||||
DtMPAgregados.Columns.Add("UnidadMedida", GetType(String))
|
||||
DtMPAgregados.Columns.Add("Cantidad", GetType(Decimal))
|
||||
End If
|
||||
Return CType(ViewState("DtMPAgregados"), DataTable)
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("DtMPAgregados") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
#End Region
|
||||
|
||||
@@ -72,27 +92,37 @@ Partial Class OP_OP
|
||||
DtPS.Columns.Add("PSCodigo", GetType(String))
|
||||
DtPS.Columns.Add("UnidadMedida", GetType(String))
|
||||
DtPS.Columns.Add("Cantidad", GetType(Decimal))
|
||||
DtPS.Columns.Add("CveUM", GetType(Integer))
|
||||
DtPS.Columns.Add("Surtido", GetType(Decimal))
|
||||
DtPS.Columns.Add("Costo", GetType(Decimal))
|
||||
|
||||
DtMP = New DataTable()
|
||||
DtMP.Columns.Add("Tipo", GetType(String)) ' Producto, MP, MO, CI
|
||||
DtMP.Columns.Add("Clave", GetType(Integer))
|
||||
DtMP.Columns.Add("Producto", GetType(String))
|
||||
DtMP.Columns.Add("CvePSMateriaPrima", GetType(Integer))
|
||||
DtMP.Columns.Add("CveUM", GetType(Integer))
|
||||
DtMP.Columns.Add("CveUMMateriaPrima", GetType(Integer))
|
||||
DtMP.Columns.Add("PSCodigo", GetType(String))
|
||||
DtMP.Columns.Add("UnidadMedida", GetType(String))
|
||||
DtMP.Columns.Add("Cantidad", GetType(Decimal))
|
||||
DtMP.Columns.Add("Surtido", GetType(Decimal))
|
||||
'DtMP.Columns.Add("CveAlmacenDestino", GetType(Integer))
|
||||
|
||||
DtMO = New DataTable()
|
||||
DtMO.Columns.Add("Tipo", GetType(String)) ' Producto, MP, MO, CI
|
||||
DtMO.Columns.Add("Clave", GetType(Integer))
|
||||
DtMO.Columns.Add("CveUM", GetType(Integer))
|
||||
DtMO.Columns.Add("CvePuesto", GetType(Integer))
|
||||
DtMO.Columns.Add("Puesto", GetType(String))
|
||||
DtMO.Columns.Add("Cantidad", GetType(Decimal))
|
||||
|
||||
DtCI = New DataTable()
|
||||
DtCI.Columns.Add("Tipo", GetType(String)) ' Producto, MP, MO, CI
|
||||
DtCI.Columns.Add("Clave", GetType(Integer))
|
||||
DtCI.Columns.Add("Producto", GetType(String))
|
||||
'DtCI.Columns.Add("CveUM", GetType(Integer))
|
||||
'DtCI.Columns.Add("CvePSMateriaPrima", GetType(Integer))
|
||||
'DtCI.Columns.Add("CveUMMateriaPrima", GetType(Integer))
|
||||
DtCI.Columns.Add("productoMateriaPrima", GetType(String))
|
||||
DtCI.Columns.Add("Cantidad", GetType(Decimal))
|
||||
|
||||
|
||||
@@ -105,17 +135,20 @@ Partial Class OP_OP
|
||||
CargarProductos()
|
||||
|
||||
If CveOP = -1 Then
|
||||
' Modo registro: mostrar dropdowns y ocultar los TextBox
|
||||
|
||||
DdlClientes.Enabled = True
|
||||
DdlProyecto.Enabled = True
|
||||
DdlSubProyecto.Enabled = True
|
||||
DdlPS.Enabled = True
|
||||
|
||||
LnkSolicitarMP.Visible = False
|
||||
BtnSimularMP.Visible = True
|
||||
BtnFinalizarOP.Visible = False
|
||||
Else
|
||||
DdlClientes.Enabled = False
|
||||
DdlProyecto.Enabled = False
|
||||
DdlSubProyecto.Enabled = False
|
||||
DdlPS.Enabled = False
|
||||
LnkSolicitarMP.Visible = False
|
||||
BtnSimularMP.Visible = False
|
||||
BtnFinalizarOP.Visible = True
|
||||
CargaDatos()
|
||||
End If
|
||||
End Sub
|
||||
@@ -127,18 +160,76 @@ Partial Class OP_OP
|
||||
Dim DTOP As DataTable = ObjOP.DtResultados
|
||||
If DTOP.Rows.Count > 0 Then
|
||||
Dim dr As DataRow = DTOP.Rows(0)
|
||||
LblCveOP.Text = CveOP.ToString
|
||||
LblFolio.Text = dr("Folio").ToString
|
||||
DdlClientes.txtText.Value = dr("Cliente").ToString
|
||||
DdlClientes.txtValue.Value = dr("CveCliente").ToString
|
||||
TxtEstatus.Text = dr("Estatus").ToString
|
||||
DdlSubProyecto.SelectedValue = dr("CveSubProyecto").ToString
|
||||
DdlSubProyecto.SelectedValueExist(dr("CveSubProyecto").ToString)
|
||||
DdlPS.txtText.Value = dr("Producto").ToString
|
||||
DdlPS.txtValue.Value = dr("CvePS").ToString
|
||||
Txtfecha.Text = dr("Fecha").ToString
|
||||
TxtDescripcion.Text = dr("Descripcion").ToString
|
||||
|
||||
|
||||
If ObjOP.GetProductosOP(CveOP, UsuarioActual.CveEmpresa) Then
|
||||
DtPS.Rows.Clear()
|
||||
For Each rowProducto As DataRow In ObjOP.DtResultados.Rows
|
||||
Dim newRow As DataRow = DtPS.NewRow()
|
||||
newRow("Tipo") = "Producto"
|
||||
newRow("Clave") = rowProducto("CvePS").ToString.ToEntero
|
||||
newRow("PSCodigo") = rowProducto("Producto").ToString
|
||||
|
||||
newRow("UnidadMedida") = rowProducto("UnidadMedida").ToString
|
||||
newRow("Cantidad") = rowProducto("Cantidad").ToString.ToDecimal
|
||||
newRow("CveUM") = rowProducto("CveUM").ToString.ToEntero
|
||||
DtPS.Rows.Add(newRow)
|
||||
Next
|
||||
End If
|
||||
|
||||
If ObjOP.GetProductosMP(CveOP, UsuarioActual.CveEmpresa) Then
|
||||
DtMP.Rows.Clear()
|
||||
For Each rowMP As DataRow In ObjOP.DtResultados.Rows
|
||||
Dim newRow As DataRow = DtMP.NewRow()
|
||||
newRow("Tipo") = "MP"
|
||||
newRow("Clave") = rowMP("CvePS").ToString.ToEntero
|
||||
newRow("PSCodigo") = rowMP("Producto").ToString
|
||||
newRow("CvePSMateriaPrima") = rowMP("CvePS").ToString.ToEntero
|
||||
newRow("CveUMMateriaPrima") = rowMP("CveUM").ToString.ToEntero
|
||||
newRow("UnidadMedida") = rowMP("UnidadMedida").ToString
|
||||
newRow("Cantidad") = rowMP("Cantidad").ToString.ToDecimal
|
||||
newRow("Surtido") = rowMP("Surtido").ToString.ToDecimal()
|
||||
DtMP.Rows.Add(newRow)
|
||||
Next
|
||||
End If
|
||||
|
||||
'----- Cargar Mano de Obra -----
|
||||
If ObjOP.GetProductosMO(CveOP, UsuarioActual.CveEmpresa) Then
|
||||
DtMO.Rows.Clear()
|
||||
For Each rowMO As DataRow In ObjOP.DtResultados.Rows
|
||||
Dim newRow As DataRow = DtMO.NewRow()
|
||||
newRow("Tipo") = "MO"
|
||||
newRow("Puesto") = rowMO("Puesto").ToString
|
||||
newRow("Cantidad") = rowMO("Cantidad").ToString.ToDecimal
|
||||
DtMO.Rows.Add(newRow)
|
||||
Next
|
||||
End If
|
||||
|
||||
'----- Cargar Costos Indirectos -----
|
||||
If ObjOP.GetProductosCI(CveOP, UsuarioActual.CveEmpresa) Then
|
||||
DtCI.Rows.Clear()
|
||||
For Each rowCI As DataRow In ObjOP.DtResultados.Rows
|
||||
Dim newRow As DataRow = DtCI.NewRow()
|
||||
newRow("Tipo") = "CI"
|
||||
newRow("productoMateriaPrima") = rowCI("producto").ToString
|
||||
newRow("Cantidad") = rowCI("Cantidad").ToString.ToDecimal
|
||||
DtCI.Rows.Add(newRow)
|
||||
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
ObjOP.Dispose()
|
||||
ActualizarGrids()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
@@ -180,10 +271,11 @@ Partial Class OP_OP
|
||||
newRow("PSCodigo") = DrPS("PSCodigo")
|
||||
newRow("UnidadMedida") = DrPS("UnidadMedida")
|
||||
newRow("Cantidad") = 1
|
||||
newRow("CveUM") = DrPS("CveUnidadMedida").ToString.ToEntero
|
||||
newRow("Surtido") = 0
|
||||
newRow("Costo") = 0
|
||||
DtPS.Rows.Add(newRow)
|
||||
'consultas GetMPReceta, GetMOReceta, GetCIReceta
|
||||
|
||||
|
||||
|
||||
Dim CveUM As Integer = DrPS("CveUnidadMedida").ToString.ToEntero
|
||||
@@ -194,7 +286,10 @@ Partial Class OP_OP
|
||||
Dim rowMP As DataRow = DtMP.NewRow()
|
||||
rowMP("Tipo") = "MP"
|
||||
rowMP("Clave") = CvePS
|
||||
rowMP("Producto") = drMP("productoMateriaPrima").ToString()
|
||||
rowMP("CvePSMateriaPrima") = CvePS
|
||||
rowMP("CveUM") = CveUM
|
||||
rowMP("CveUMMateriaPrima") = CveUM 'drMP("CveUMMateriaPrima").ToString().ToEntero()
|
||||
rowMP("PSCodigo") = drMP("productoMateriaPrima").ToString()
|
||||
rowMP("UnidadMedida") = drMP("UnidadMedidaMateriaPrima").ToString()
|
||||
rowMP("Cantidad") = drMP("Cantidad").ToString().ToDecimal()
|
||||
rowMP("Surtido") = 0
|
||||
@@ -218,11 +313,13 @@ Partial Class OP_OP
|
||||
|
||||
Dim ObjCI As New ClsOP()
|
||||
If ObjCI.GetCIReceta(CvePS, CveUM, UsuarioActual.CveEmpresa) Then
|
||||
|
||||
For Each drCI As DataRow In ObjCI.DtResultados.Rows
|
||||
Dim rowCI As DataRow = DtCI.NewRow()
|
||||
rowCI("Tipo") = "CI"
|
||||
rowCI("Clave") = CvePS
|
||||
rowCI("Producto") = drCI("productoMateriaPrima").ToString()
|
||||
'rowCI("CvePSMateriaPrima") = drCI("CvePSMateriaPrima").ToString().ToEntero()
|
||||
rowCI("productoMateriaPrima") = drCI("productoMateriaPrima").ToString()
|
||||
rowCI("Cantidad") = drCI("Cantidad").ToString().ToDecimal()
|
||||
DtCI.Rows.Add(rowCI)
|
||||
Next
|
||||
@@ -232,42 +329,332 @@ Partial Class OP_OP
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnEliminarProducto_Click(sender As Object, e As EventArgs)
|
||||
If DdlPS.SelectedValue = "-1" Then
|
||||
Alert("Seleccione un producto del listado.", TipoMensaje.MsgAdvertencia)
|
||||
Return
|
||||
End If
|
||||
|
||||
Dim CveProducto As Integer = DdlPS.SelectedValue.ToEntero()
|
||||
Dim btnEliminar As LinkButton = DirectCast(sender, LinkButton)
|
||||
Dim CveProducto As Integer = btnEliminar.CommandArgument.ToEntero()
|
||||
|
||||
Dim filasProducto As DataRow() = DtPS.Select($"Clave = {CveProducto}")
|
||||
If filasProducto.Length > 0 Then
|
||||
DtPS.Rows.Remove(filasProducto(0))
|
||||
EliminarDatosRelacionados(CveProducto)
|
||||
ActualizarGrids()
|
||||
End If
|
||||
|
||||
EliminarDatosRelacionados(CveProducto)
|
||||
|
||||
ActualizarGrids()
|
||||
End Sub
|
||||
|
||||
Private Sub EliminarDatosRelacionados(CveProducto As Integer)
|
||||
|
||||
' Materia Prima
|
||||
Dim filasMP As DataRow() = DtMP.Select($"Clave = {CveProducto}")
|
||||
For Each fila As DataRow In filasMP
|
||||
DtMP.Rows.Remove(fila)
|
||||
Next
|
||||
|
||||
' Mano de Obra
|
||||
Dim filasMO As DataRow() = DtMO.Select($"Clave = {CveProducto}")
|
||||
For Each fila As DataRow In filasMO
|
||||
DtMO.Rows.Remove(fila)
|
||||
Next
|
||||
|
||||
' Costos Indirectos
|
||||
Dim filasCI As DataRow() = DtCI.Select($"Clave = {CveProducto}")
|
||||
For Each fila As DataRow In filasCI
|
||||
DtCI.Rows.Remove(fila)
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Protected Sub LnkSolicitarMP_Click(sender As Object, e As EventArgs)
|
||||
' Cargar almacenes
|
||||
DdlAlmacenOrigenMP.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 1")
|
||||
DdlAlmacenOrigenMP.DataBind()
|
||||
DdlAlmacenDestinoMP.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 28")
|
||||
DdlAlmacenDestinoMP.DataBind()
|
||||
|
||||
GvMPAgregados.DataKeyNames = New String() {"CvePSMateriaPrima", "CveUMMateriaPrima"}
|
||||
|
||||
' Filtrar MP no surtida
|
||||
Dim DtMPFaltante As DataTable = DtMP.FiltraParametros("Surtido = 0").Copy()
|
||||
GvMPAgregados.DataSource = DtMPFaltante
|
||||
GvMPAgregados.DataBind()
|
||||
|
||||
|
||||
' Mostrar modal
|
||||
RegistraScript("$('#DVModalSolicitarMP').modal('show');")
|
||||
UpModalMP.Update()
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnSimularMP_Click(sender As Object, e As EventArgs)
|
||||
If CveOP <> -1 Then Exit Sub
|
||||
If DdlPS.SelectedValue = "-1" Then Exit Sub
|
||||
|
||||
Dim nombreProducto As String = DdlPS.txtText.Value ' Ajusta según tu control
|
||||
Dim spanNombre As HtmlGenericControl = DirectCast(UpModalSimular.FindControl("SpanNombreProducto"), HtmlGenericControl)
|
||||
spanNombre.InnerText = nombreProducto
|
||||
|
||||
GvSimulacionMP.DataSource = Nothing
|
||||
GvSimulacionMP.DataBind()
|
||||
LblCantidadPosibleGlobal.Visible = False
|
||||
|
||||
' Cargar almacenes (sin borrar el ítem inicial)
|
||||
DdlAlmacenSimular.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 1")
|
||||
DdlAlmacenSimular.DataTextField = "Almacen" ' Nombre de la columna para mostrar
|
||||
DdlAlmacenSimular.DataValueField = "CveAlmacen" ' Columna para el valor
|
||||
DdlAlmacenSimular.DataBind()
|
||||
|
||||
CalcularSimulacion()
|
||||
|
||||
RegistraScript("$('#DVModalSimularMP').modal('show');")
|
||||
UpModalSimular.Update()
|
||||
End Sub
|
||||
|
||||
Protected Sub RblModoSimulacion_SelectedIndexChanged(sender As Object, e As EventArgs)
|
||||
' Controlar visibilidad del TextBox
|
||||
PnlCantidad.Visible = (RblModoSimulacion.SelectedValue = "1")
|
||||
|
||||
' Resetear valor si cambian de modo
|
||||
If RblModoSimulacion.SelectedValue = "2" Then
|
||||
TxtCantidadSimular.Text = "1"
|
||||
End If
|
||||
|
||||
UpModalSimular.Update()
|
||||
CalcularSimulacion()
|
||||
End Sub
|
||||
|
||||
Protected Sub DdlAlmacenSimular_SelectedIndexChanged(sender As Object, e As EventArgs)
|
||||
If DdlAlmacenSimular.SelectedValue = "-1" Then
|
||||
Alert("Por favor selecciona un almacén.", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
CalcularSimulacion()
|
||||
End Sub
|
||||
|
||||
Protected Sub TxtCantidadSimular_TextChanged(sender As Object, e As EventArgs)
|
||||
CalcularSimulacion()
|
||||
UpModalSimular.Update()
|
||||
End Sub
|
||||
|
||||
Private Sub CalcularSimulacion()
|
||||
If DdlAlmacenSimular.SelectedValue = "-1" Then Exit Sub
|
||||
If DdlPS.SelectedValue = "-1" Then Exit Sub
|
||||
|
||||
Dim CvePS As Integer = DdlPS.SelectedValue.ToEntero()
|
||||
Dim DtMP As DataTable = ObtenerMPRequerida(CvePS)
|
||||
AgregarColumnasSimulacion(DtMP)
|
||||
Dim listaCantidadesPosibles As New List(Of Decimal)
|
||||
Dim MinCantidadPosible As Decimal = 0D
|
||||
|
||||
For Each rowMP As DataRow In DtMP.Rows
|
||||
Dim CveMP As Integer = rowMP("CvePSMateriaPrima").ToString.ToEntero()
|
||||
Dim CveUMMP As Integer = rowMP("CveUMMateriaPrima").ToString.ToEntero()
|
||||
Dim CveAlmacen As Integer = DdlAlmacenSimular.SelectedValue.ToEntero()
|
||||
|
||||
Dim Existencia As Decimal = 0
|
||||
Using ObjInventario As New ClsInventarios()
|
||||
Existencia = ObjInventario.
|
||||
GetExistenciasPS(
|
||||
CvePS:=CveMP,
|
||||
CveUnidadMedida:=CveUMMP,
|
||||
CveEmpresa:=UsuarioActual.CveEmpresa,
|
||||
CveAlmacen:=CveAlmacen
|
||||
)
|
||||
End Using
|
||||
|
||||
rowMP("Disponible") = Existencia
|
||||
Dim CantidadUnitaria As Decimal = rowMP("Cantidad").ToString.ToDecimal()
|
||||
rowMP("CantidadUnitaria") = CantidadUnitaria ' Fija (no se modifica)
|
||||
|
||||
If RblModoSimulacion.SelectedValue = "1" Then
|
||||
Dim CantidadProducto As Decimal = TxtCantidadSimular.Text.ToDecimal()
|
||||
If RblModoSimulacion.SelectedValue = "1" AndAlso TxtCantidadSimular.Text.Trim() = "" Then
|
||||
Alert("Ingresa la cantidad a simular", TipoMensaje.MsgAdvertencia)
|
||||
Return
|
||||
End If
|
||||
Dim TotalRequerido As Decimal = CantidadUnitaria * CantidadProducto
|
||||
rowMP("TotalRequerido") = TotalRequerido
|
||||
rowMP("Faltante") = Math.Max(TotalRequerido - Existencia, 0D)
|
||||
|
||||
Else
|
||||
If CantidadUnitaria > 0 Then
|
||||
Dim CantidadProducible As Decimal = Math.Floor(Existencia / CantidadUnitaria)
|
||||
rowMP("CantidadPosible") = CantidadProducible ' ✔️ Valor individual por material
|
||||
listaCantidadesPosibles.Add(CantidadProducible)
|
||||
Else
|
||||
rowMP("CantidadPosible") = 0D
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
If RblModoSimulacion.SelectedValue = "2" AndAlso listaCantidadesPosibles.Count > 0 Then
|
||||
MinCantidadPosible = listaCantidadesPosibles.Min()
|
||||
Else
|
||||
MinCantidadPosible = 0D
|
||||
End If
|
||||
|
||||
GvSimulacionMP.Columns(3).Visible = (RblModoSimulacion.SelectedValue = "1") ' Total Requerido (Índice 3)
|
||||
GvSimulacionMP.Columns(4).Visible = (RblModoSimulacion.SelectedValue = "1") ' Faltante (Índice 4)
|
||||
GvSimulacionMP.Columns(5).Visible = (RblModoSimulacion.SelectedValue = "2") ' CantidadPosible (Índice 5)
|
||||
|
||||
' Asegurar visibilidad de columnas fijas
|
||||
GvSimulacionMP.Columns(0).Visible = True
|
||||
GvSimulacionMP.Columns(1).Visible = True
|
||||
GvSimulacionMP.Columns(2).Visible = True
|
||||
|
||||
GvSimulacionMP.DataSource = DtMP
|
||||
GvSimulacionMP.DataBind()
|
||||
LblCantidadPosibleGlobal.Text = $"Cantidad: {MinCantidadPosible:N0}"
|
||||
LblCantidadPosibleGlobal.Visible = (RblModoSimulacion.SelectedValue = "2")
|
||||
End Sub
|
||||
|
||||
Private Sub AgregarColumnasSimulacion(ByRef dt As DataTable)
|
||||
If Not dt.Columns.Contains("CantidadUnitaria") Then
|
||||
dt.Columns.Add("CantidadUnitaria", GetType(Decimal)).DefaultValue = 0D
|
||||
End If
|
||||
|
||||
If Not dt.Columns.Contains("TotalRequerido") Then
|
||||
dt.Columns.Add("TotalRequerido", GetType(Decimal)).DefaultValue = 0D
|
||||
End If
|
||||
|
||||
If Not dt.Columns.Contains("Disponible") Then
|
||||
dt.Columns.Add("Disponible", GetType(Decimal)).DefaultValue = 0D
|
||||
End If
|
||||
If Not dt.Columns.Contains("Faltante") Then
|
||||
dt.Columns.Add("Faltante", GetType(Decimal)).DefaultValue = 0D
|
||||
End If
|
||||
If Not dt.Columns.Contains("CantidadPosible") Then
|
||||
dt.Columns.Add("CantidadPosible", GetType(Decimal)).DefaultValue = 0D
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Function ObtenerMPRequerida(CvePS As Integer) As DataTable
|
||||
Dim ObjOP As New ClsOP()
|
||||
ObjOP.GetMPReceta(CvePS, -1, UsuarioActual.CveEmpresa)
|
||||
|
||||
' Verificar y convertir CvePSMateriaPrima a Integer
|
||||
For Each row As DataRow In ObjOP.DtResultados.Rows
|
||||
If Not IsDBNull(row("CvePSMateriaPrima")) Then
|
||||
row("CvePSMateriaPrima") = Convert.ToInt32(row("CvePSMateriaPrima"))
|
||||
Else
|
||||
row("CvePSMateriaPrima") = 0 ' Valor por defecto si es nulo
|
||||
End If
|
||||
Next
|
||||
|
||||
Return ObjOP.DtResultados.Copy()
|
||||
End Function
|
||||
|
||||
Protected Sub BtnGuardarSolicitudMP_Click(sender As Object, e As EventArgs)
|
||||
|
||||
Dim CveTraspasoSolicitud As Integer = -1
|
||||
|
||||
If DdlAlmacenOrigenMP.SelectedValue = DdlAlmacenDestinoMP.SelectedValue Then
|
||||
Alert("Los almacenes de origen y destino no pueden ser el mismo. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If Not GvMPAgregados.Rows.Count > 0 Then
|
||||
Alert("No se ha seleccionado ningún producto para trasladar.", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim EstatusAlmacen As Integer = 2
|
||||
Dim Estatus As Integer = If(UsuarioActual.Empresa.Funcionalidad(105) <> "", 1, 3)
|
||||
Dim ObjInventario As New ClsInventarios()
|
||||
Dim TieneErrorExistencia As Boolean = False
|
||||
Dim MensajeExistencia As New StringBuilder
|
||||
MensajeExistencia.Append("No hay la existencia suficiente de los siguientes productos:<br/>")
|
||||
|
||||
'✅ 1. Validar existencias de MP
|
||||
For Each row As GridViewRow In GvMPAgregados.Rows
|
||||
'✅ Obtener claves CORRECTAS de la materia prima
|
||||
Dim CveMP As Integer = GvMPAgregados.DataKeys(row.RowIndex)("CvePSMateriaPrima").ToString().ToEntero()
|
||||
Dim CveUMMP As Integer = GvMPAgregados.DataKeys(row.RowIndex)("CveUMMateriaPrima").ToString().ToEntero()
|
||||
Dim CantidadSolicitada As Decimal = DtMP.Rows(row.RowIndex)("Cantidad").ToString().ToDecimal()
|
||||
|
||||
'DtMP.Rows(row.RowIndex)("CveAlmacenDestino") = DdlAlmacenDestinoMP.SelectedValue.ToEntero()
|
||||
|
||||
'✅ Verificar existencias
|
||||
Dim Existencia As Decimal = ObjInventario.GetExistenciasPS(
|
||||
CvePS:=CveMP,
|
||||
CveUnidadMedida:=CveUMMP,
|
||||
CveEmpresa:=UsuarioActual.CveEmpresa,
|
||||
CveAlmacen:=DdlAlmacenOrigenMP.SelectedValue.ToEntero()
|
||||
)
|
||||
|
||||
If Existencia < CantidadSolicitada Then
|
||||
Dim NombreProducto As String = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveMP).FiltroPrimeroValor("Producto", "")
|
||||
Dim Faltante As Decimal = CantidadSolicitada - Existencia
|
||||
MensajeExistencia.AppendFormat(
|
||||
"<br/> - <b>{0} ({1})</b> Existencia: {2}, Faltante: {3}",
|
||||
NombreProducto,
|
||||
row.Cells(0).Text, ' Código del producto
|
||||
Existencia.ToString("N2"),
|
||||
Faltante.ToString("N2")
|
||||
)
|
||||
TieneErrorExistencia = True
|
||||
End If
|
||||
Next
|
||||
|
||||
If TieneErrorExistencia Then
|
||||
Alert(MensajeExistencia.ToString, TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
'✅ 2. Crear traspaso si todo está correcto
|
||||
ObjInventario.IniciaTransacSQL()
|
||||
Dim TieneError As Boolean = False
|
||||
|
||||
Dim FolioSolicitud As Integer = ObjInventario.AddTrasladoSolicitud(
|
||||
TxtObservacionesMP.Text.Trim(),
|
||||
DdlAlmacenOrigenMP.SelectedValue.ToEntero(),
|
||||
DdlAlmacenDestinoMP.SelectedValue.ToEntero(),
|
||||
Estatus,
|
||||
-1,
|
||||
NowADS,
|
||||
CveUsuario:=UsuarioActual.CveUsuario,
|
||||
CveEmpresa:=UsuarioActual.CveEmpresa,
|
||||
EstatusAlmacen:=EstatusAlmacen
|
||||
)
|
||||
|
||||
If FolioSolicitud > 0 Then
|
||||
CveTraspasoSolicitud = ObjInventario.CveTraspasoSolicitud
|
||||
Else
|
||||
TieneError = True
|
||||
End If
|
||||
|
||||
'✅ 3. Agregar detalles del traspaso
|
||||
If Not TieneError Then
|
||||
For Each row As GridViewRow In GvMPAgregados.Rows
|
||||
'✅ Usar claves de MATERIA PRIMA (CvePSMateriaPrima y CveUMMateriaPrima)
|
||||
Dim CveMP As Integer = GvMPAgregados.DataKeys(row.RowIndex)("CvePSMateriaPrima").ToString().ToEntero()
|
||||
Dim CveUMMP As Integer = GvMPAgregados.DataKeys(row.RowIndex)("CveUMMateriaPrima").ToString().ToEntero()
|
||||
Dim Cantidad As Decimal = DtMP.Rows(row.RowIndex)("Cantidad").ToString().ToDecimal()
|
||||
|
||||
If Not ObjInventario.AddTrasladoSolicitudDetalle(
|
||||
CveTraspasoSolicitud,
|
||||
Cantidad,
|
||||
CveUMMP, '✅ Unidad de medida de la MP
|
||||
CveMP, '✅ Clave de la MP
|
||||
0, "", -1, "-1", "-1", MinFecha
|
||||
) Then
|
||||
TieneError = True
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
'✅ 4. Confirmar o cancelar transacción
|
||||
If Not TieneError Then
|
||||
ObjInventario.Commit()
|
||||
Alert($"Solicitud de Traspaso guardada. Folio: <b>{FolioSolicitud}</b>", TipoMensaje.MsgInformacion)
|
||||
RegistraScript("$('#DVModalSolicitarMP').modal('hide');")
|
||||
CargaDatos()
|
||||
Else
|
||||
ObjInventario.RollBack()
|
||||
Alert("Error al guardar el traspaso.", TipoMensaje.MsgError)
|
||||
End If
|
||||
ObjInventario.Dispose()
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnGuardarOP_Click(sender As Object, e As EventArgs)
|
||||
' Validar campos obligatorios
|
||||
' Validaciones básicas
|
||||
If DdlClientes.SelectedValue = "-1" Then
|
||||
Alert("Seleccione un cliente.", TipoMensaje.MsgAdvertencia)
|
||||
Return
|
||||
@@ -278,94 +665,86 @@ Partial Class OP_OP
|
||||
Return
|
||||
End If
|
||||
|
||||
' Iniciar transacción
|
||||
Dim clsOP As New ClsOP()
|
||||
clsOP.IniciaTransacSQL()
|
||||
Dim transactionActive As Boolean = False
|
||||
|
||||
Try
|
||||
' Insertar/Actualizar cabecera de la OP usando UpdateOP
|
||||
Dim CveOP As Integer = Me.CveOP ' Si es nuevo, CveOP = -1
|
||||
Dim Success As Boolean = clsOP.UpdateOP(
|
||||
CveOP:=CveOP,
|
||||
Descripcion:=TxtDescripcion.Text,
|
||||
CveCliente:=DdlClientes.SelectedValue.ToEntero(),
|
||||
CvePS:=DdlPS.SelectedValue.ToEntero(),
|
||||
CveSubProyecto:=DdlSubProyecto.SelectedValue.ToEntero(),
|
||||
Cantidad:=1, ' Ajustar según lógica de negocio
|
||||
Fecha:=Convert.ToDateTime(Txtfecha.Text),
|
||||
CveEmpresa:=UsuarioActual.CveEmpresa,
|
||||
CveUsuario:=UsuarioActual.CveUsuario
|
||||
)
|
||||
|
||||
If Not Success Then
|
||||
Throw New Exception("Error al guardar la cabecera de la OP.")
|
||||
End If
|
||||
|
||||
' Obtener el CveOP generado (asumiendo que se actualiza en la propiedad)
|
||||
If Me.CveOP = -1 Then
|
||||
' Si es nuevo, recuperar el CveOP de la base de datos
|
||||
' (Requiere que el SP PA_OP_OrdendeProduccionUp devuelva el ID)
|
||||
' Esto depende de la implementación del SP.
|
||||
' Ejemplo hipotético:
|
||||
clsOP.GetOP(-1, DdlClientes.SelectedValue.ToEntero(), DdlSubProyecto.SelectedValue.ToEntero(), -1, -1, -1, MinFecha, MaxFecha, UsuarioActual.CveEmpresa)
|
||||
If clsOP.DtResultados.Rows.Count > 0 Then
|
||||
Me.CveOP = clsOP.DtResultados.Rows(0)("CveOP").ToString.ToEntero()
|
||||
|
||||
If Me.CveOP = -1 Then ' Modo CREACIÓN
|
||||
|
||||
Dim xmlProductos As String = DataTableToXML(DtPS)
|
||||
Dim CveOPGenerado As Integer = -1
|
||||
Dim FolioGenerado As Integer = -1
|
||||
|
||||
If clsOP.OPAdd(
|
||||
Descripcion:=TxtDescripcion.Text,
|
||||
CveCliente:=DdlClientes.SelectedValue.ToEntero(),
|
||||
CveEmpresa:=UsuarioActual.CveEmpresa,
|
||||
CveUsuario:=UsuarioActual.CveUsuario,
|
||||
Fecha:=Convert.ToDateTime(Txtfecha.Text),
|
||||
CveSubProyecto:=DdlSubProyecto.SelectedValue.ToEntero(),
|
||||
xmlproductos:=xmlProductos,
|
||||
CveOP:=CveOPGenerado,
|
||||
Folio:=FolioGenerado
|
||||
) Then
|
||||
Me.CveOP = CveOPGenerado
|
||||
LblFolio.Text = FolioGenerado.ToString
|
||||
Alert("Orden creada con Folio: " & FolioGenerado, TipoMensaje.MsgInformacion)
|
||||
End If
|
||||
Else ' Modo EDICIÓN
|
||||
Dim CvePS As Integer = DtPS.Rows(0)("Clave").ToString.ToEntero()
|
||||
Dim Cantidad As Integer = DtPS.Rows(0)("Cantidad").ToString.ToEntero()
|
||||
BtnFinalizarOP.Visible = True
|
||||
If Not clsOP.UpdateOP(
|
||||
CveOP:=Me.CveOP,
|
||||
Descripcion:=TxtDescripcion.Text,
|
||||
CveCliente:=DdlClientes.SelectedValue.ToEntero(),
|
||||
CvePS:=CvePS,
|
||||
CveSubProyecto:=DdlSubProyecto.SelectedValue.ToEntero(),
|
||||
Cantidad:=Cantidad,
|
||||
Fecha:=Convert.ToDateTime(Txtfecha.Text),
|
||||
CveEmpresa:=UsuarioActual.CveEmpresa,
|
||||
CveUsuario:=UsuarioActual.CveUsuario
|
||||
) Then
|
||||
Throw New Exception("Error al actualizar la OP")
|
||||
End If
|
||||
End If
|
||||
|
||||
' Insertar detalles de Productos, MP, MO, CI
|
||||
For Each drProducto As DataRow In DtPS.Rows
|
||||
Dim CvePS As Integer = drProducto("Clave").ToString().ToEntero()
|
||||
|
||||
' Insertar Materia Prima relacionada
|
||||
For Each drMP As DataRow In DtMP.Select($"Clave = {CvePS}")
|
||||
clsOP.AddMP(
|
||||
Cantidad:=drMP("Cantidad").ToString().ToDecimal(),
|
||||
CvePS:=CvePS,
|
||||
CvePSMateriaPrima:=drMP("CvePSMateriaPrima").ToString().ToEntero(),
|
||||
CveUM:=drMP("CveUM").ToString().ToEntero(),
|
||||
CveUMMateriaPrima:=drMP("CveUMMateriaPrima").ToString().ToEntero()
|
||||
)
|
||||
Next
|
||||
|
||||
' Insertar Mano de Obra relacionada
|
||||
For Each drMO As DataRow In DtMO.Select($"Clave = {CvePS}")
|
||||
clsOP.AddMO(
|
||||
Cantidad:=drMO("Cantidad").ToString().ToDecimal(),
|
||||
CvePS:=CvePS,
|
||||
CvePuesto:=drMO("CvePuesto").ToString().ToEntero(),
|
||||
CveUM:=drMO("CveUM").ToString().ToEntero()
|
||||
)
|
||||
Next
|
||||
|
||||
' Insertar Costos Indirectos relacionados
|
||||
For Each drCI As DataRow In DtCI.Select($"Clave = {CvePS}")
|
||||
clsOP.AddCI(
|
||||
Cantidad:=drCI("Cantidad").ToString().ToDecimal(),
|
||||
CvePS:=CvePS,
|
||||
CvePSMateriaPrima:=drCI("CvePSMateriaPrima").ToString().ToEntero(),
|
||||
CveUM:=drCI("CveUM").ToString().ToEntero(),
|
||||
CveUMMateriaPrima:=drCI("CveUMMateriaPrima").ToString().ToEntero()
|
||||
)
|
||||
Next
|
||||
Next
|
||||
|
||||
' Commit si todo es exitoso
|
||||
clsOP.Commit()
|
||||
Alert("Orden de Producción guardada correctamente.", TipoMensaje.MsgInformacion)
|
||||
Response.Redirect($"OP.aspx?CveOP={Me.CveOP}") ' Redirigir a la OP guardada
|
||||
transactionActive = False
|
||||
|
||||
|
||||
Response.Redirect($"OP.aspx?CveOP={Me.CveOP}", False)
|
||||
Context.ApplicationInstance.CompleteRequest()
|
||||
|
||||
Catch ex As Exception
|
||||
' Rollback en caso de error
|
||||
clsOP.RollBack()
|
||||
Alert($"Error al guardar: {ex.Message}", TipoMensaje.MsgError)
|
||||
If transactionActive Then
|
||||
clsOP.RollBack()
|
||||
End If
|
||||
Alert($"Error: {ex.Message}", TipoMensaje.MsgError)
|
||||
Finally
|
||||
clsOP.Dispose()
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Function DataTableToXML(dt As DataTable) As String
|
||||
Dim xmlDoc As New XmlDocument()
|
||||
xmlDoc.LoadXml("<Productos></Productos>")
|
||||
|
||||
For Each row As DataRow In dt.Rows
|
||||
Dim producto As XmlElement = xmlDoc.CreateElement("Producto")
|
||||
producto.InnerXml = $"<CvePS>{row("Clave")}</CvePS><Cantidad>{row("Cantidad")}</Cantidad><CveUM>{row("CveUM")}</CveUM>"
|
||||
xmlDoc.DocumentElement.AppendChild(producto)
|
||||
Next
|
||||
|
||||
Return xmlDoc.OuterXml
|
||||
End Function
|
||||
|
||||
Private Sub ActualizarGrids()
|
||||
Dim dtProductosFiltrados As DataTable = DtPS.Clone() ' Clona la estructura
|
||||
Dim dtProductosFiltrados As DataTable = DtPS.Clone()
|
||||
Dim rowsProductos As DataRow() = DtPS.Select("Tipo = 'Producto'")
|
||||
If rowsProductos.Length > 0 Then
|
||||
dtProductosFiltrados = rowsProductos.CopyToDataTable()
|
||||
@@ -397,11 +776,227 @@ Partial Class OP_OP
|
||||
GvCostosIndirectos.DataSource = dtCIFiltrados
|
||||
GvCostosIndirectos.DataBind()
|
||||
|
||||
' Calcular suma de "Surtido"
|
||||
Dim sumSurtido As Decimal = DtMP.AsEnumerable().Sum(Function(row) row.Field(Of Decimal)("Surtido"))
|
||||
|
||||
|
||||
LnkSolicitarMP.Visible = (CveOP > -1 AndAlso sumSurtido = 0)
|
||||
|
||||
UpGvDatosOP.Update()
|
||||
End Sub
|
||||
|
||||
Protected Sub DdlAlmacenOrigenMP_SelectedIndexChanged(sender As Object, e As EventArgs)
|
||||
' ✅ Mantener siempre el almacén de producción (tipo 28) en destino
|
||||
DdlAlmacenDestinoMP.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 28")
|
||||
DdlAlmacenDestinoMP.DataBind()
|
||||
|
||||
' ✅ Opcional: Seleccionar el primer almacén de producción por defecto
|
||||
If DdlAlmacenDestinoMP.Items.Count > 0 Then
|
||||
DdlAlmacenDestinoMP.SelectedIndex = 0
|
||||
End If
|
||||
End Sub
|
||||
|
||||
#Region "Eventos de Botones"
|
||||
|
||||
Protected Sub BtnFinalizarOP_Click(sender As Object, e As EventArgs)
|
||||
If CveOP = -1 Then Exit Sub
|
||||
|
||||
' 1. Cargar almacén de salida (Tipo 28)
|
||||
DdlAlmacenOrigenSalidaMP.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 28")
|
||||
DdlAlmacenOrigenSalidaMP.DataBind()
|
||||
|
||||
|
||||
' 2. Cargar almacén de producto terminado
|
||||
DdlAlmacenTerminado.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 1")
|
||||
DdlAlmacenTerminado.DataBind()
|
||||
DdlAlmacenTerminado.Items.Insert(0, New ListItem("Seleccionar almacén", "-1"))
|
||||
|
||||
' 3. Cargar GridViews
|
||||
GvProductoTerminado.DataSource = DtPS.FiltraParametros("Tipo = 'Producto'")
|
||||
GvProductoTerminado.DataBind()
|
||||
|
||||
GvMPUtilizada.DataSource = DtMP.FiltraParametros("Tipo = 'MP'").Copy()
|
||||
GvMPUtilizada.DataBind()
|
||||
|
||||
RegistraScript("$('#DVModalFinalizarOP').modal('show');")
|
||||
UpModalFinalizar.Update()
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnGuardarFinalizarOP_Click(sender As Object, e As EventArgs) Handles BtnGuardarFinalizarOP.Click
|
||||
If DdlAlmacenOrigenSalidaMP.SelectedValue = "-1" OrElse DdlAlmacenTerminado.SelectedValue = "-1" Then
|
||||
Alert("Selecciona ambos almacenes.", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
' Dim TotalCantidad As Decimal = DtMovimientos.SUMD("Cantidad")
|
||||
'Inicia la transacción
|
||||
|
||||
Dim CveMovimientoSalida As Integer = 0
|
||||
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 = Txtfecha.Text.ToDate
|
||||
Dim ErrorMovInv As Boolean = False
|
||||
Dim ErrorAC As Boolean = False
|
||||
Dim TextoError As String = ""
|
||||
Dim TipoMovimientoSalida As Integer = 8
|
||||
Dim CveConceptoEntrada As Integer = 9
|
||||
Dim TotalCostoMP As Decimal = 0
|
||||
|
||||
Dim ObjInventario As New ClsInventarios()
|
||||
|
||||
ObjInventario.IniciaTransacSQL()
|
||||
Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL())
|
||||
Try
|
||||
|
||||
CveMovimientoSalida = ObjInventario.AddMovimiento(
|
||||
CveAlmacen:=DdlAlmacenOrigenSalidaMP.SelectedValue.ToEntero(),
|
||||
CveConcepto:=TipoMovimientoSalida,
|
||||
CveMoneda:=1,
|
||||
FechaMovto:=Fecha,
|
||||
tFolio:=-1,
|
||||
CveUsuario:=UsuarioActual.CveUsuario,
|
||||
CveEmpresa:=UsuarioActual.CveEmpresa,
|
||||
CveCompra:=-1,
|
||||
CveVenta:=-1,
|
||||
CveSubProyecto:=-1,
|
||||
CveActivoFijo:=-1,
|
||||
Observaciones:="Finalización OP #" & LblFolio.Text,
|
||||
CveAlmacenDestino:=DdlAlmacenTerminado.SelectedValue.ToEntero(),
|
||||
Modulo:="OP/FinalizarOPSalida"
|
||||
)
|
||||
|
||||
|
||||
For Each rowMP As DataRow In DtMP.Select("Tipo = 'MP'")
|
||||
If Not ObjInventario.AddMovimientoDetalle(
|
||||
CveMovimientoSalida,
|
||||
rowMP("Cantidad").ToString.ToDecimal(),
|
||||
rowMP("CveUMMateriaPrima").ToString.ToEntero(),
|
||||
rowMP("CvePSMateriaPrima").ToString.ToEntero(),
|
||||
1
|
||||
) Then
|
||||
Throw New Exception("Error al agregar detalle de MP")
|
||||
End If
|
||||
TotalCostoMP += rowMP("Cantidad").ToString.ToDecimal()
|
||||
Next
|
||||
|
||||
|
||||
CveMovimientoEntrada = ObjInventario.AddMovimiento(
|
||||
CveAlmacen:=DdlAlmacenTerminado.SelectedValue.ToEntero(),
|
||||
CveConcepto:=CveConceptoEntrada,
|
||||
CveMoneda:=1,
|
||||
FechaMovto:=Fecha,
|
||||
tFolio:=-1,
|
||||
CveUsuario:=UsuarioActual.CveUsuario,
|
||||
CveEmpresa:=UsuarioActual.CveEmpresa,
|
||||
CveCompra:=-1, CveVenta:=-1, CveSubProyecto:=-1, CveActivoFijo:=-1,
|
||||
Observaciones:="Finalización OP #" & LblFolio.Text,
|
||||
Modulo:="OP/FinalizarOPEntrada",
|
||||
CveMovimientoRelacionado:=CveMovimientoSalida
|
||||
)
|
||||
|
||||
|
||||
Dim CantidadPT As Decimal = DtPS.AsEnumerable().Sum(Function(row) Convert.ToDecimal(row("Cantidad")))
|
||||
Dim PU_PT As Decimal = If(CantidadPT > 0, TotalCostoMP / CantidadPT, 1)
|
||||
|
||||
|
||||
For Each rowPT As DataRow In DtPS.Select("Tipo = 'Producto'")
|
||||
If Not ObjInventario.AddMovimientoDetalle(
|
||||
CveMovimientoEntrada,
|
||||
rowPT("Cantidad").ToString.ToDecimal(),
|
||||
rowPT("CveUM").ToString.ToEntero(),
|
||||
rowPT("Clave").ToString.ToEntero(),
|
||||
PU_PT
|
||||
) Then
|
||||
Throw New Exception("Error al agregar detalle de PT")
|
||||
End If
|
||||
Next
|
||||
|
||||
|
||||
Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas(
|
||||
Modulo:="Inventario/OPFinalizada",
|
||||
CvePlantillaPoliza:=53,
|
||||
Cargos:=0,
|
||||
Abonos:=0,
|
||||
CveMoneda:=1,
|
||||
Fecha:=Fecha,
|
||||
Concepto:="Producción OP #" & LblFolio.Text,
|
||||
CveUsuario:=UsuarioActual.CveUsuario,
|
||||
CveEmpresa:=UsuarioActual.CveEmpresa
|
||||
)
|
||||
|
||||
|
||||
If Not ObjConta.AddPrePolizasDetalle(
|
||||
CvePrePoliza,
|
||||
False,
|
||||
TotalCostoMP,
|
||||
TotalCostoMP,
|
||||
68,
|
||||
"Consumo MP OP #" & LblFolio.Text,
|
||||
"Consumo MP OP #" & LblFolio.Text,
|
||||
CveMovimientoAlmacen:=CveMovimientoSalida
|
||||
) Then ErrorMovInv = True
|
||||
|
||||
|
||||
If Not ObjConta.AddPrePolizasDetalle(
|
||||
CvePrePoliza,
|
||||
True,
|
||||
TotalCostoMP,
|
||||
TotalCostoMP,
|
||||
68,
|
||||
"Producción PT OP #" & LblFolio.Text,
|
||||
"Producción PT OP #" & LblFolio.Text,
|
||||
CveMovimientoAlmacen:=CveMovimientoEntrada
|
||||
) Then ErrorMovInv = True
|
||||
|
||||
|
||||
If Not ErrorMovInv Then
|
||||
Dim ObjOP As New ClsOP()
|
||||
If Not ObjOP.UpdateEstatusOP(CveOP, 3, UsuarioActual.CveEmpresa) Then
|
||||
ErrorMovInv = True
|
||||
TextoError = "Error al actualizar estatus de la OP"
|
||||
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
|
||||
|
||||
|
||||
If Not ErrorMovInv Then
|
||||
ObjInventario.Commit()
|
||||
Alert($"OP finalizada. Folio Contable: {ObjConta.ContaFolio}", TipoMensaje.MsgInformacion)
|
||||
Else
|
||||
ObjInventario.RollBack()
|
||||
Alert($"Error contable: {TextoError}", TipoMensaje.MsgError)
|
||||
End If
|
||||
|
||||
RegistraScript("$('#DVModalFinalizarOP').modal('hide');")
|
||||
CargaDatos()
|
||||
|
||||
Catch ex As Exception
|
||||
ObjInventario.RollBack()
|
||||
Alert($"Error crítico: {ex.Message}", TipoMensaje.MsgError)
|
||||
Finally
|
||||
ObjInventario.Dispose()
|
||||
ObjConta.Dispose()
|
||||
End Try
|
||||
|
||||
|
||||
End Sub
|
||||
#End Region
|
||||
End Class
|
||||
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@
|
||||
</asp:UpdatePanel>
|
||||
<asp:UpdatePanel ID="UPDatos" runat="server" UpdateMode="Conditional">
|
||||
<ContentTemplate>
|
||||
<asp:GridView ID="GvDatos" runat="server" DataKeysNames="CveOP" AutoGenerateColumns="False" EmptyDataText="No se encontraron Ventas con los filtros especificados" ToolTip="Listado de Ventas"
|
||||
<asp:GridView ID="GvDatos" runat="server" DataKeysNames="CveOP" AutoGenerateColumns="False" EmptyDataText="No se encontraron Ordenes de Producción con los filtros especificados" ToolTip="Listado de Ventas"
|
||||
CssClass="table table-striped table-advance table-hover Widthall ScrollAD" data-sort="true" Style="text-align: center;" GridLines="None" Width="99%">
|
||||
<Columns>
|
||||
<asp:HyperLinkField DataNavigateUrlFormatString="/OP/OP.aspx?CveOP={0}" DataNavigateUrlFields="CveOP" ControlStyle-CssClass="Texto" DataTextField="Folio" HeaderText="Folio"
|
||||
|
||||
Reference in New Issue
Block a user