Cambios al Finalizar OP
This commit is contained in:
@@ -505,7 +505,7 @@
|
|||||||
<asp:TemplateField>
|
<asp:TemplateField>
|
||||||
<ItemTemplate>
|
<ItemTemplate>
|
||||||
<asp:LinkButton ID="BtnEliminar" runat="server"
|
<asp:LinkButton ID="BtnEliminar" runat="server"
|
||||||
CommandArgument='<%# Eval("Clave") %>'
|
CommandArgument='<%# Eval("CvePS") %>'
|
||||||
OnClick="BtnEliminarProducto_Click"
|
OnClick="BtnEliminarProducto_Click"
|
||||||
CssClass="btn btn-circle btn-xs red"
|
CssClass="btn btn-circle btn-xs red"
|
||||||
Text="<i class='icon-trash'></i>" />
|
Text="<i class='icon-trash'></i>" />
|
||||||
@@ -591,7 +591,7 @@
|
|||||||
CssClass="table table-striped table-hover" GridLines="None" Width="100%">
|
CssClass="table table-striped table-hover" GridLines="None" Width="100%">
|
||||||
<Columns>
|
<Columns>
|
||||||
<asp:BoundField DataField="productoMateriaPrima" HeaderText="Producto" />
|
<asp:BoundField DataField="productoMateriaPrima" HeaderText="Producto" />
|
||||||
<asp:BoundField DataField="Cantidad" HeaderText="Costo" DataFormatString="{0:#,##0.####}" ItemStyle-HorizontalAlign="Right" />
|
<asp:BoundField DataField="ImporteCostoIndirecto" HeaderText="Costo" DataFormatString="{0:#,##0.####}" ItemStyle-HorizontalAlign="Right" />
|
||||||
</Columns>
|
</Columns>
|
||||||
</asp:GridView>
|
</asp:GridView>
|
||||||
</div>
|
</div>
|
||||||
@@ -842,7 +842,7 @@
|
|||||||
|
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="section-title">Materia Prima</div>
|
<div class="section-title">Materia Prima</div>
|
||||||
<asp:GridView ID="GvMPUtilizada" runat="server" AutoGenerateColumns="False" DataKeyNames="CvePSMateriaPrima, CveUMMateriaPrima"
|
<asp:GridView ID="GvMPUtilizada" runat="server" AutoGenerateColumns="False" DataKeyNames="CvePS, CvePSMateriaPrima, CveUMMateriaPrima"
|
||||||
CssClass="table table-striped table-hover" GridLines="None" Width="100%">
|
CssClass="table table-striped table-hover" GridLines="None" Width="100%">
|
||||||
<Columns>
|
<Columns>
|
||||||
<asp:BoundField DataField="PSCodigo" HeaderText="Producto" />
|
<asp:BoundField DataField="PSCodigo" HeaderText="Producto" />
|
||||||
|
|||||||
133
OP/OP.aspx.vb
133
OP/OP.aspx.vb
@@ -41,15 +41,7 @@ Partial Class OP_OP
|
|||||||
|
|
||||||
Private Property DtMO As DataTable
|
Private Property DtMO As DataTable
|
||||||
Get
|
Get
|
||||||
If ViewState("DtMO") Is Nothing Then
|
Return DirectCast(ViewState("DtMO"), DataTable)
|
||||||
DtMO = New DataTable()
|
|
||||||
DtMO.Columns.Add("CvePS", GetType(Integer)) ' Producto asociado
|
|
||||||
DtMO.Columns.Add("CvePuesto", GetType(Integer))
|
|
||||||
DtMO.Columns.Add("Puesto", GetType(String))
|
|
||||||
DtMO.Columns.Add("CostoHora", GetType(Decimal))
|
|
||||||
DtMO.Columns.Add("Total", GetType(Decimal))
|
|
||||||
End If
|
|
||||||
Return CType(ViewState("DtMO"), DataTable)
|
|
||||||
End Get
|
End Get
|
||||||
Set(value As DataTable)
|
Set(value As DataTable)
|
||||||
ViewState("DtMO") = value
|
ViewState("DtMO") = value
|
||||||
@@ -58,16 +50,7 @@ Partial Class OP_OP
|
|||||||
|
|
||||||
Private Property DtCI As DataTable
|
Private Property DtCI As DataTable
|
||||||
Get
|
Get
|
||||||
If ViewState("DtCI") Is Nothing Then
|
Return DirectCast(ViewState("DtCI"), DataTable)
|
||||||
DtCI = New DataTable()
|
|
||||||
DtCI.Columns.Add("CvePS", GetType(Integer)) ' Producto asociado
|
|
||||||
DtCI.Columns.Add("CvePSMateriaPrima", GetType(Integer))
|
|
||||||
DtCI.Columns.Add("productoMateriaPrima", GetType(String))
|
|
||||||
DtCI.Columns.Add("Cantidad", GetType(Decimal))
|
|
||||||
DtCI.Columns.Add("PU", GetType(Decimal))
|
|
||||||
DtCI.Columns.Add("Total", GetType(Decimal))
|
|
||||||
End If
|
|
||||||
Return CType(ViewState("DtCI"), DataTable)
|
|
||||||
End Get
|
End Get
|
||||||
Set(value As DataTable)
|
Set(value As DataTable)
|
||||||
ViewState("DtCI") = value
|
ViewState("DtCI") = value
|
||||||
@@ -87,7 +70,7 @@ Partial Class OP_OP
|
|||||||
Get
|
Get
|
||||||
If ViewState("DtMPAgregados") Is Nothing Then
|
If ViewState("DtMPAgregados") Is Nothing Then
|
||||||
DtMPAgregados = New DataTable()
|
DtMPAgregados = New DataTable()
|
||||||
DtMPAgregados.Columns.Add("Clave", GetType(Integer))
|
DtMPAgregados.Columns.Add("CvePS", GetType(Integer))
|
||||||
DtMPAgregados.Columns.Add("PSCodigo", GetType(String))
|
DtMPAgregados.Columns.Add("PSCodigo", GetType(String))
|
||||||
DtMPAgregados.Columns.Add("CveUM", GetType(Integer))
|
DtMPAgregados.Columns.Add("CveUM", GetType(Integer))
|
||||||
DtMPAgregados.Columns.Add("UnidadMedida", GetType(String))
|
DtMPAgregados.Columns.Add("UnidadMedida", GetType(String))
|
||||||
@@ -129,7 +112,7 @@ Partial Class OP_OP
|
|||||||
Private Sub CreaPS()
|
Private Sub CreaPS()
|
||||||
DtPS = New DataTable()
|
DtPS = New DataTable()
|
||||||
DtPS.Columns.Add("Tipo", GetType(String)) ' Producto, MP, MO, CI
|
DtPS.Columns.Add("Tipo", GetType(String)) ' Producto, MP, MO, CI
|
||||||
DtPS.Columns.Add("Clave", GetType(Integer))
|
DtPS.Columns.Add("CvePS", GetType(Integer))
|
||||||
DtPS.Columns.Add("PSCodigo", GetType(String))
|
DtPS.Columns.Add("PSCodigo", GetType(String))
|
||||||
DtPS.Columns.Add("UnidadMedida", GetType(String))
|
DtPS.Columns.Add("UnidadMedida", GetType(String))
|
||||||
DtPS.Columns.Add("Cantidad", GetType(Decimal))
|
DtPS.Columns.Add("Cantidad", GetType(Decimal))
|
||||||
@@ -139,7 +122,7 @@ Partial Class OP_OP
|
|||||||
|
|
||||||
DtMP = New DataTable()
|
DtMP = New DataTable()
|
||||||
DtMP.Columns.Add("Tipo", GetType(String)) ' Producto, MP, MO, CI
|
DtMP.Columns.Add("Tipo", GetType(String)) ' Producto, MP, MO, CI
|
||||||
DtMP.Columns.Add("Clave", GetType(Integer))
|
DtMP.Columns.Add("CvePS", GetType(Integer))
|
||||||
DtMP.Columns.Add("CvePSMateriaPrima", GetType(Integer))
|
DtMP.Columns.Add("CvePSMateriaPrima", GetType(Integer))
|
||||||
DtMP.Columns.Add("CveUM", GetType(Integer))
|
DtMP.Columns.Add("CveUM", GetType(Integer))
|
||||||
DtMP.Columns.Add("CveUMMateriaPrima", GetType(Integer))
|
DtMP.Columns.Add("CveUMMateriaPrima", GetType(Integer))
|
||||||
@@ -152,7 +135,7 @@ Partial Class OP_OP
|
|||||||
|
|
||||||
DtMO = New DataTable()
|
DtMO = New DataTable()
|
||||||
DtMO.Columns.Add("Tipo", GetType(String)) ' Producto, MP, MO, CI
|
DtMO.Columns.Add("Tipo", GetType(String)) ' Producto, MP, MO, CI
|
||||||
DtMO.Columns.Add("Clave", GetType(Integer))
|
DtMO.Columns.Add("CvePS", GetType(Integer))
|
||||||
DtMO.Columns.Add("CveUM", GetType(Integer))
|
DtMO.Columns.Add("CveUM", GetType(Integer))
|
||||||
DtMO.Columns.Add("CvePuesto", GetType(Integer))
|
DtMO.Columns.Add("CvePuesto", GetType(Integer))
|
||||||
DtMO.Columns.Add("Puesto", GetType(String))
|
DtMO.Columns.Add("Puesto", GetType(String))
|
||||||
@@ -163,10 +146,12 @@ Partial Class OP_OP
|
|||||||
|
|
||||||
DtCI = New DataTable()
|
DtCI = New DataTable()
|
||||||
DtCI.Columns.Add("Tipo", GetType(String)) ' Producto, MP, MO, CI
|
DtCI.Columns.Add("Tipo", GetType(String)) ' Producto, MP, MO, CI
|
||||||
DtCI.Columns.Add("Clave", GetType(Integer))
|
DtCI.Columns.Add("CvePS", GetType(Integer))
|
||||||
DtCI.Columns.Add("productoMateriaPrima", GetType(String))
|
DtCI.Columns.Add("productoMateriaPrima", GetType(String))
|
||||||
|
DtCI.Columns.Add("CvePSProducto", GetType(Integer))
|
||||||
DtCI.Columns.Add("Cantidad", GetType(Decimal))
|
DtCI.Columns.Add("Cantidad", GetType(Decimal))
|
||||||
DtCI.Columns.Add("PU", GetType(Decimal))
|
'DtCI.Columns.Add("Costo", GetType(Decimal))
|
||||||
|
DtCI.Columns.Add("ImporteCostoIndirecto", GetType(Decimal))
|
||||||
DtCI.Columns.Add("Total", GetType(Decimal))
|
DtCI.Columns.Add("Total", GetType(Decimal))
|
||||||
|
|
||||||
|
|
||||||
@@ -262,7 +247,7 @@ Partial Class OP_OP
|
|||||||
For Each rowProducto As DataRow In ObjOP.DtResultados.Rows
|
For Each rowProducto As DataRow In ObjOP.DtResultados.Rows
|
||||||
Dim newRow As DataRow = DtPS.NewRow()
|
Dim newRow As DataRow = DtPS.NewRow()
|
||||||
newRow("Tipo") = "Producto"
|
newRow("Tipo") = "Producto"
|
||||||
newRow("Clave") = rowProducto("CvePS").ToString.ToEntero
|
newRow("CvePS") = rowProducto("CvePS").ToString.ToEntero
|
||||||
newRow("PSCodigo") = rowProducto("Producto").ToString
|
newRow("PSCodigo") = rowProducto("Producto").ToString
|
||||||
|
|
||||||
newRow("UnidadMedida") = rowProducto("UnidadMedida").ToString
|
newRow("UnidadMedida") = rowProducto("UnidadMedida").ToString
|
||||||
@@ -277,9 +262,9 @@ Partial Class OP_OP
|
|||||||
For Each rowMP As DataRow In ObjOP.DtResultados.Rows
|
For Each rowMP As DataRow In ObjOP.DtResultados.Rows
|
||||||
Dim newRow As DataRow = DtMP.NewRow()
|
Dim newRow As DataRow = DtMP.NewRow()
|
||||||
newRow("Tipo") = "MP"
|
newRow("Tipo") = "MP"
|
||||||
newRow("Clave") = rowMP("CvePS").ToString.ToEntero
|
newRow("CvePS") = rowMP("CvePS").ToString.ToEntero
|
||||||
newRow("PSCodigo") = rowMP("Producto").ToString
|
newRow("PSCodigo") = rowMP("Producto").ToString
|
||||||
newRow("CvePSMateriaPrima") = rowMP("CvePS").ToString.ToEntero
|
newRow("CvePSMateriaPrima") = rowMP("CvePSMateriaPrima").ToString.ToEntero
|
||||||
newRow("CveUMMateriaPrima") = rowMP("CveUM").ToString.ToEntero
|
newRow("CveUMMateriaPrima") = rowMP("CveUM").ToString.ToEntero
|
||||||
newRow("UnidadMedida") = rowMP("UnidadMedida").ToString
|
newRow("UnidadMedida") = rowMP("UnidadMedida").ToString
|
||||||
newRow("Cantidad") = rowMP("Cantidad").ToString.ToDecimal
|
newRow("Cantidad") = rowMP("Cantidad").ToString.ToDecimal
|
||||||
@@ -294,8 +279,11 @@ Partial Class OP_OP
|
|||||||
For Each rowMO As DataRow In ObjOP.DtResultados.Rows
|
For Each rowMO As DataRow In ObjOP.DtResultados.Rows
|
||||||
Dim newRow As DataRow = DtMO.NewRow()
|
Dim newRow As DataRow = DtMO.NewRow()
|
||||||
newRow("Tipo") = "MO"
|
newRow("Tipo") = "MO"
|
||||||
|
newRow("CvePS") = rowMO("CvePS").ToString().ToEntero()
|
||||||
newRow("Puesto") = rowMO("Puesto").ToString
|
newRow("Puesto") = rowMO("Puesto").ToString
|
||||||
newRow("Cantidad") = rowMO("Cantidad").ToString.ToDecimal
|
newRow("Cantidad") = rowMO("Cantidad").ToString.ToDecimal
|
||||||
|
newRow("CostoHora") = rowMO("precioHora").ToString.ToDecimal()
|
||||||
|
newRow("Total") = rowMO("Cantidad").ToString().ToDecimal() * rowMO("precioHora").ToString().ToDecimal()
|
||||||
DtMO.Rows.Add(newRow)
|
DtMO.Rows.Add(newRow)
|
||||||
Next
|
Next
|
||||||
End If
|
End If
|
||||||
@@ -306,8 +294,12 @@ Partial Class OP_OP
|
|||||||
For Each rowCI As DataRow In ObjOP.DtResultados.Rows
|
For Each rowCI As DataRow In ObjOP.DtResultados.Rows
|
||||||
Dim newRow As DataRow = DtCI.NewRow()
|
Dim newRow As DataRow = DtCI.NewRow()
|
||||||
newRow("Tipo") = "CI"
|
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("productoMateriaPrima") = rowCI("producto").ToString
|
||||||
newRow("Costo") = rowCI("Costo").ToString.ToDecimal
|
newRow("ImporteCostoIndirecto") = rowCI("ImporteCostoIndirecto").ToString.ToDecimal()
|
||||||
|
newRow("Total") = rowCI("ImporteCostoIndirecto")
|
||||||
DtCI.Rows.Add(newRow)
|
DtCI.Rows.Add(newRow)
|
||||||
|
|
||||||
Next
|
Next
|
||||||
@@ -353,7 +345,7 @@ Partial Class OP_OP
|
|||||||
Dim DrPS As DataRow = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
|
Dim DrPS As DataRow = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
|
||||||
|
|
||||||
newRow("Tipo") = "Producto"
|
newRow("Tipo") = "Producto"
|
||||||
newRow("Clave") = CvePS
|
newRow("CvePS") = CvePS
|
||||||
newRow("PSCodigo") = DrPS("PSCodigo")
|
newRow("PSCodigo") = DrPS("PSCodigo")
|
||||||
newRow("UnidadMedida") = DrPS("UnidadMedida")
|
newRow("UnidadMedida") = DrPS("UnidadMedida")
|
||||||
newRow("Cantidad") = 1
|
newRow("Cantidad") = 1
|
||||||
@@ -371,14 +363,14 @@ Partial Class OP_OP
|
|||||||
For Each drMP As DataRow In ObjMP.DtResultados.Rows
|
For Each drMP As DataRow In ObjMP.DtResultados.Rows
|
||||||
Dim rowMP As DataRow = DtMP.NewRow()
|
Dim rowMP As DataRow = DtMP.NewRow()
|
||||||
rowMP("Tipo") = "MP"
|
rowMP("Tipo") = "MP"
|
||||||
rowMP("Clave") = CvePS
|
rowMP("CvePS") = CvePS
|
||||||
rowMP("CvePSMateriaPrima") = CvePS
|
rowMP("CvePSMateriaPrima") = drMP("CvePSMateriaPrima").ToString().ToEntero()
|
||||||
rowMP("CveUM") = CveUM
|
rowMP("CveUM") = CveUM
|
||||||
rowMP("CveUMMateriaPrima") = CveUM 'drMP("CveUMMateriaPrima").ToString().ToEntero()
|
rowMP("CveUMMateriaPrima") = drMP("CveUMMateriaPrima").ToString().ToEntero()
|
||||||
rowMP("PSCodigo") = drMP("productoMateriaPrima").ToString()
|
rowMP("PSCodigo") = drMP("productoMateriaPrima").ToString()
|
||||||
rowMP("UnidadMedida") = drMP("UnidadMedidaMateriaPrima").ToString()
|
rowMP("UnidadMedida") = drMP("UnidadMedidaMateriaPrima").ToString()
|
||||||
rowMP("Cantidad") = drMP("Cantidad").ToString().ToDecimal()
|
rowMP("Cantidad") = drMP("Cantidad").ToString().ToDecimal()
|
||||||
'rowMP("CvePSProducto") = CvePS
|
|
||||||
rowMP("Surtido") = 0
|
rowMP("Surtido") = 0
|
||||||
DtMP.Rows.Add(rowMP)
|
DtMP.Rows.Add(rowMP)
|
||||||
Next
|
Next
|
||||||
@@ -390,7 +382,7 @@ Partial Class OP_OP
|
|||||||
For Each drMO As DataRow In ObjMO.DtResultados.Rows
|
For Each drMO As DataRow In ObjMO.DtResultados.Rows
|
||||||
Dim rowMO As DataRow = DtMO.NewRow()
|
Dim rowMO As DataRow = DtMO.NewRow()
|
||||||
rowMO("Tipo") = "MO"
|
rowMO("Tipo") = "MO"
|
||||||
rowMO("Clave") = CvePS
|
rowMO("CvePS") = CvePS
|
||||||
rowMO("Puesto") = drMO("Puesto").ToString()
|
rowMO("Puesto") = drMO("Puesto").ToString()
|
||||||
rowMO("Cantidad") = drMO("Cantidad").ToString().ToDecimal()
|
rowMO("Cantidad") = drMO("Cantidad").ToString().ToDecimal()
|
||||||
rowMO("CostoHora") = drMO("precioHora").ToString.ToDecimal()
|
rowMO("CostoHora") = drMO("precioHora").ToString.ToDecimal()
|
||||||
@@ -406,12 +398,12 @@ Partial Class OP_OP
|
|||||||
For Each drCI As DataRow In ObjCI.DtResultados.Rows
|
For Each drCI As DataRow In ObjCI.DtResultados.Rows
|
||||||
Dim rowCI As DataRow = DtCI.NewRow()
|
Dim rowCI As DataRow = DtCI.NewRow()
|
||||||
rowCI("Tipo") = "CI"
|
rowCI("Tipo") = "CI"
|
||||||
rowCI("Clave") = CvePS
|
rowCI("CvePS") = CvePS
|
||||||
|
rowCI("CvePSProducto") = drCI("CvePSProducto").ToString()
|
||||||
'rowCI("CvePSMateriaPrima") = drCI("CvePSMateriaPrima").ToString().ToEntero()
|
'rowCI("CvePSMateriaPrima") = drCI("CvePSMateriaPrima").ToString().ToEntero()
|
||||||
rowCI("productoMateriaPrima") = drCI("productoMateriaPrima").ToString()
|
rowCI("productoMateriaPrima") = drCI("productoMateriaPrima").ToString()
|
||||||
rowCI("Cantidad") = drCI("Cantidad").ToString().ToDecimal()
|
rowCI("ImporteCostoIndirecto") = drCI("ImporteCostoIndirecto").ToString().ToDecimal()
|
||||||
rowCI("PU") = drCI("ImporteCostoIndirecto").ToString().ToDecimal()
|
rowCI("Total") = rowCI("ImporteCostoIndirecto")
|
||||||
rowCI("Total") = rowCI("Cantidad").ToString().ToDecimal() * rowCI("PU").ToString().ToDecimal()
|
|
||||||
DtCI.Rows.Add(rowCI)
|
DtCI.Rows.Add(rowCI)
|
||||||
Next
|
Next
|
||||||
End If
|
End If
|
||||||
@@ -429,7 +421,7 @@ Partial Class OP_OP
|
|||||||
Dim btnEliminar As LinkButton = DirectCast(sender, LinkButton)
|
Dim btnEliminar As LinkButton = DirectCast(sender, LinkButton)
|
||||||
Dim CveProducto As Integer = btnEliminar.CommandArgument.ToEntero()
|
Dim CveProducto As Integer = btnEliminar.CommandArgument.ToEntero()
|
||||||
|
|
||||||
Dim filasProducto As DataRow() = DtPS.Select($"Clave = {CveProducto}")
|
Dim filasProducto As DataRow() = DtPS.Select($"CvePS = {CveProducto}")
|
||||||
If filasProducto.Length > 0 Then
|
If filasProducto.Length > 0 Then
|
||||||
DtPS.Rows.Remove(filasProducto(0))
|
DtPS.Rows.Remove(filasProducto(0))
|
||||||
EliminarDatosRelacionados(CveProducto)
|
EliminarDatosRelacionados(CveProducto)
|
||||||
@@ -440,19 +432,19 @@ Partial Class OP_OP
|
|||||||
Private Sub EliminarDatosRelacionados(CveProducto As Integer)
|
Private Sub EliminarDatosRelacionados(CveProducto As Integer)
|
||||||
|
|
||||||
' Materia Prima
|
' Materia Prima
|
||||||
Dim filasMP As DataRow() = DtMP.Select($"Clave = {CveProducto}")
|
Dim filasMP As DataRow() = DtMP.Select($"CvePS = {CveProducto}")
|
||||||
For Each fila As DataRow In filasMP
|
For Each fila As DataRow In filasMP
|
||||||
DtMP.Rows.Remove(fila)
|
DtMP.Rows.Remove(fila)
|
||||||
Next
|
Next
|
||||||
|
|
||||||
' Mano de Obra
|
' Mano de Obra
|
||||||
Dim filasMO As DataRow() = DtMO.Select($"Clave = {CveProducto}")
|
Dim filasMO As DataRow() = DtMO.Select($"CvePS = {CveProducto}")
|
||||||
For Each fila As DataRow In filasMO
|
For Each fila As DataRow In filasMO
|
||||||
DtMO.Rows.Remove(fila)
|
DtMO.Rows.Remove(fila)
|
||||||
Next
|
Next
|
||||||
|
|
||||||
' Costos Indirectos
|
' Costos Indirectos
|
||||||
Dim filasCI As DataRow() = DtCI.Select($"Clave = {CveProducto}")
|
Dim filasCI As DataRow() = DtCI.Select($"CvePS = {CveProducto}")
|
||||||
For Each fila As DataRow In filasCI
|
For Each fila As DataRow In filasCI
|
||||||
DtCI.Rows.Remove(fila)
|
DtCI.Rows.Remove(fila)
|
||||||
Next
|
Next
|
||||||
@@ -791,7 +783,7 @@ Partial Class OP_OP
|
|||||||
Alert("Orden creada con Folio: " & FolioGenerado, TipoMensaje.MsgInformacion)
|
Alert("Orden creada con Folio: " & FolioGenerado, TipoMensaje.MsgInformacion)
|
||||||
End If
|
End If
|
||||||
Else ' Modo EDICIÓN
|
Else ' Modo EDICIÓN
|
||||||
Dim CvePS As Integer = DtPS.Rows(0)("Clave").ToString.ToEntero()
|
Dim CvePS As Integer = DtPS.Rows(0)("CvePS").ToString.ToEntero()
|
||||||
Dim Cantidad As Integer = DtPS.Rows(0)("Cantidad").ToString.ToEntero()
|
Dim Cantidad As Integer = DtPS.Rows(0)("Cantidad").ToString.ToEntero()
|
||||||
BtnFinalizarOP.Visible = True
|
BtnFinalizarOP.Visible = True
|
||||||
If Not clsOP.UpdateOP(
|
If Not clsOP.UpdateOP(
|
||||||
@@ -832,7 +824,7 @@ Partial Class OP_OP
|
|||||||
|
|
||||||
For Each row As DataRow In dt.Rows
|
For Each row As DataRow In dt.Rows
|
||||||
Dim producto As XmlElement = xmlDoc.CreateElement("Producto")
|
Dim producto As XmlElement = xmlDoc.CreateElement("Producto")
|
||||||
producto.InnerXml = $"<CvePS>{row("Clave")}</CvePS><Cantidad>{row("Cantidad")}</Cantidad><CveUM>{row("CveUM")}</CveUM>"
|
producto.InnerXml = $"<CvePS>{row("CvePS")}</CvePS><Cantidad>{row("Cantidad")}</Cantidad><CveUM>{row("CveUM")}</CveUM>"
|
||||||
xmlDoc.DocumentElement.AppendChild(producto)
|
xmlDoc.DocumentElement.AppendChild(producto)
|
||||||
Next
|
Next
|
||||||
|
|
||||||
@@ -1004,7 +996,7 @@ Partial Class OP_OP
|
|||||||
|
|
||||||
Try
|
Try
|
||||||
'Salida de MP
|
'Salida de MP
|
||||||
CveMovimientoSalida = ObjInventario.AddMovimiento(DdlAlmacenOrigenSalidaMP.SelectedValue.ToEntero(), TipoMovimientoSalida, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:="Finalización OP #" & LblFolio.Text, Modulo:="OP/FinalizarOPSalida")
|
CveMovimientoSalida = ObjInventario.AddMovimiento(DdlAlmacenOrigenSalidaMP.SelectedValue.ToEntero(), TipoMovimientoSalida, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:="Finalización OP #" & LblFolio.Text, Modulo:="OP/FinalizarOPSalida", CveOP:=CveOP)
|
||||||
FolioEntrada = ObjInventario.Folio
|
FolioEntrada = ObjInventario.Folio
|
||||||
Dim DtMPAlmacen As DataTable = Nothing
|
Dim DtMPAlmacen As DataTable = Nothing
|
||||||
If CveMovimientoSalida > 0 Then
|
If CveMovimientoSalida > 0 Then
|
||||||
@@ -1014,6 +1006,7 @@ Partial Class OP_OP
|
|||||||
Dim CveUM As Integer = rowMP("CveUMMateriaPrima").ToString.ToEntero
|
Dim CveUM As Integer = rowMP("CveUMMateriaPrima").ToString.ToEntero
|
||||||
Dim Cantidad As Decimal = rowMP("Cantidad").ToString.ToDecimal
|
Dim Cantidad As Decimal = rowMP("Cantidad").ToString.ToDecimal
|
||||||
|
|
||||||
|
|
||||||
' Registrar detalle
|
' Registrar detalle
|
||||||
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Cantidad, CveUM, CvePS, 0) Then
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Cantidad, CveUM, CvePS, 0) Then
|
||||||
ErrorMovInv = True
|
ErrorMovInv = True
|
||||||
@@ -1031,35 +1024,44 @@ Partial Class OP_OP
|
|||||||
|
|
||||||
' 1. Recorrer cada Producto Terminado en la OP
|
' 1. Recorrer cada Producto Terminado en la OP
|
||||||
For Each rowProducto As DataRow In DtPS.Select("Tipo = 'Producto'")
|
For Each rowProducto As DataRow In DtPS.Select("Tipo = 'Producto'")
|
||||||
Dim CvePSProducto As Integer = rowProducto("Clave").ToString.ToEntero()
|
Dim CvePSProducto As Integer = rowProducto("CvePS").ToString.ToEntero()
|
||||||
Dim CantidadProducto As Decimal = rowProducto("Cantidad").ToString.ToDecimal()
|
Dim CantidadProducto As Decimal = rowProducto("Cantidad").ToString.ToDecimal()
|
||||||
|
Dim MPProducto As Decimal = 0
|
||||||
|
Dim MOProducto As Decimal = 0
|
||||||
|
Dim CIProducto As Decimal = 0
|
||||||
|
|
||||||
' 2. Calcular Costo de Materias Primas por Producto
|
' 2. Calcular Costo de Materias Primas por Producto
|
||||||
For Each rowMP As DataRow In DtMP.Select($"Clave = {CvePSProducto}")
|
For Each rowMP As DataRow In DtMP.FiltraParametros($"CvePS = {CvePSProducto}").Rows
|
||||||
Dim CvePSMP As Integer = rowMP("CvePSMateriaPrima").ToString.ToEntero()
|
Dim CvePSMP As Integer = rowMP("CvePSMateriaPrima").ToString.ToEntero()
|
||||||
Dim CveUMMP As Integer = rowMP("CveUMMateriaPrima").ToString.ToEntero()
|
Dim CveUMMP As Integer = rowMP("CveUMMateriaPrima").ToString.ToEntero()
|
||||||
Dim PU As Decimal = DtMPAlmacen.FiltroPrimeroValor("PU", $"CvePS = {CvePSMP} AND CveUM = {CveUMMP}").ToDecimal()
|
Dim PU As Decimal = DtMPAlmacen.FiltroPrimeroValor("PU", $"CvePS = {CvePSMP}").ToDecimal()
|
||||||
TotalMPProducto += rowMP("Cantidad").ToString().ToDecimal() * PU
|
MPProducto += rowMP("Cantidad").ToString().ToDecimal() * PU
|
||||||
Next
|
Next
|
||||||
|
|
||||||
' 3. Calcular Mano de Obra por Producto
|
' 3. Calcular Mano de Obra por Producto
|
||||||
For Each rowMO As DataRow In DtMO.Select($"Clave = {CvePSProducto}")
|
For Each rowMO As DataRow In DtMO.FiltraParametros($"CvePS = {CvePSProducto}").Rows
|
||||||
TotalMOProducto += rowMO("Total").ToString.ToDecimal()
|
MOProducto += rowMO("Total").ToString.ToDecimal()
|
||||||
Next
|
Next
|
||||||
|
|
||||||
' 4. Calcular Costos Indirectos por Producto
|
' 4. Calcular Costos Indirectos por Producto
|
||||||
For Each rowCI As DataRow In DtCI.Select($"Clave = {CvePSProducto}")
|
For Each rowCI As DataRow In DtCI.FiltraParametros($"CvePSProducto = {CvePSProducto}").Rows
|
||||||
TotalCIProducto += rowCI("Total").ToString.ToDecimal()
|
CIProducto += rowCI("Total").ToString.ToDecimal()
|
||||||
Next
|
Next
|
||||||
' 5. Determinar las devoluciones del Producto
|
' 5. Determinar las devoluciones del Producto
|
||||||
Dim TotalDevPT As Decimal = GvMPUtilizada.Rows.Cast(Of GridViewRow)().Where($"datakey.cvepspt = {CvePSProducto}").Sum(Function(row) DirectCast(row.FindControl("TxtDevolucionMP"), TextBox).Text.ToDecimal())
|
Dim TotalDevPT As Decimal = GvMPUtilizada.Rows.Cast(Of GridViewRow)().Where(Function(row) GvMPUtilizada.DataKeys(row.RowIndex).Values(0).ToString().ToEntero() = CvePSProducto).Sum(Function(row) DirectCast(row.FindControl("TxtDevolucionMP"), TextBox).Text.ToDecimal())
|
||||||
|
|
||||||
' 6. Sumar Total por Producto (MP + MO + CI)
|
' 6. Sumar Total por Producto (MP + MO + CI)
|
||||||
Dim TotalProducto As Decimal = TotalMPProducto + TotalMOProducto + TotalCIProducto - TotalDevPT
|
Dim TotalProducto As Decimal = MPProducto + MOProducto + CIProducto - TotalDevPT
|
||||||
|
|
||||||
rowProducto("Costo") = TotalProducto
|
rowProducto("Costo") = TotalProducto
|
||||||
|
|
||||||
|
TotalMPProducto += MPProducto
|
||||||
|
TotalMOProducto += MOProducto
|
||||||
|
TotalCIProducto += CIProducto
|
||||||
Next
|
Next
|
||||||
|
|
||||||
|
DtPS.AcceptChanges()
|
||||||
|
|
||||||
' 2. PROCESAR DEVOLUCIONES SI EXISTEN
|
' 2. PROCESAR DEVOLUCIONES SI EXISTEN
|
||||||
If Not ErrorMovInv Then
|
If Not ErrorMovInv Then
|
||||||
Dim TotalDevoluciones As Decimal = GvMPUtilizada.Rows.Cast(Of GridViewRow)().Sum(Function(row) DirectCast(row.FindControl("TxtDevolucionMP"), TextBox).Text.ToDecimal())
|
Dim TotalDevoluciones As Decimal = GvMPUtilizada.Rows.Cast(Of GridViewRow)().Sum(Function(row) DirectCast(row.FindControl("TxtDevolucionMP"), TextBox).Text.ToDecimal())
|
||||||
@@ -1070,7 +1072,7 @@ Partial Class OP_OP
|
|||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
CveMovimientoDev = ObjInventario.AddMovimiento(DdlAlmacenDevolucion.SelectedValue.ToEntero(), TipoMovimientoDev, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=$"Devolución OP #{LblFolio.Text}", Modulo:="OP/Devoluciones", CveMovimientoRelacionado:=CveMovimientoSalida)
|
CveMovimientoDev = ObjInventario.AddMovimiento(DdlAlmacenDevolucion.SelectedValue.ToEntero(), TipoMovimientoDev, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=$"Devolución OP #{LblFolio.Text}", Modulo:="OP/Devoluciones", CveMovimientoRelacionado:=CveMovimientoSalida, CveOP:=CveOP)
|
||||||
|
|
||||||
If CveMovimientoDev > 0 Then
|
If CveMovimientoDev > 0 Then
|
||||||
For Each row As GridViewRow In GvMPUtilizada.Rows
|
For Each row As GridViewRow In GvMPUtilizada.Rows
|
||||||
@@ -1101,16 +1103,17 @@ Partial Class OP_OP
|
|||||||
|
|
||||||
'ENTRADA DE PRODUCTO TERMINADO
|
'ENTRADA DE PRODUCTO TERMINADO
|
||||||
If Not ErrorMovInv Then
|
If Not ErrorMovInv Then
|
||||||
CveMovimientoEntrada = ObjInventario.AddMovimiento(DdlAlmacenTerminado.SelectedValue.ToEntero(), CveConceptoEntrada, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:="Finalización OP #" & LblFolio.Text, Modulo:="OP/FinalizarOPEntrada", CveMovimientoRelacionado:=CveMovimientoSalida)
|
CveMovimientoEntrada = ObjInventario.AddMovimiento(DdlAlmacenTerminado.SelectedValue.ToEntero(), CveConceptoEntrada, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:="Finalización OP #" & LblFolio.Text, Modulo:="OP/FinalizarOPEntrada", CveMovimientoRelacionado:=CveMovimientoSalida, CveOP:=CveOP)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If CveMovimientoEntrada > 0 AndAlso Not ErrorMovInv Then
|
If CveMovimientoEntrada > 0 AndAlso Not ErrorMovInv Then
|
||||||
Dim CostoPTAjustado As Decimal = TotalCostoMP - CostoDevoluciones
|
Dim CostoTotalProduccion As Decimal = TotalMPProducto + TotalMOProducto + TotalCIProducto
|
||||||
Dim CantidadPT As Decimal = DtPS.AsEnumerable().Sum(Function(r) r.Field(Of Decimal)("Cantidad"))
|
Dim CostoPTAjustado As Decimal = CostoTotalProduccion - CostoDevoluciones
|
||||||
Dim PU_PT As Decimal = If(CantidadPT > 0, CostoPTAjustado / CantidadPT, 0)
|
'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'")
|
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(), rowPT("Costo").ToString.ToDecimal()) Then
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, rowPT("Cantidad").ToString.ToDecimal(), rowPT("CveUM").ToString.ToEntero(), rowPT("CvePS").ToString.ToEntero(), rowPT("Costo").ToString.ToDecimal()) Then
|
||||||
ErrorMovInv = True : TextoError = "x" : Exit For
|
ErrorMovInv = True : TextoError = "x" : Exit For
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
@@ -1129,15 +1132,15 @@ Partial Class OP_OP
|
|||||||
ErrorMovInv = True
|
ErrorMovInv = True
|
||||||
End If
|
End If
|
||||||
'dev MP
|
'dev MP
|
||||||
If Not ErrorMovInv AndAlso CostoDevoluciones <> 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, CostoDevoluciones, CostoDevoluciones, 95, "", $"OP #{LblFolio.Text}", CveMovimientoAlmacen:=CveMovimientoDev) Then
|
If Not ErrorMovInv AndAlso CostoDevoluciones <> 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, CostoDevoluciones, CostoDevoluciones, 68, "Devoluciones PT OP #" & LblFolio.Text, "Devoluciones PT OP #" & LblFolio.Text, CveMovimientoAlmacen:=CveMovimientoDev) Then
|
||||||
ErrorMovInv = True
|
ErrorMovInv = True
|
||||||
End If
|
End If
|
||||||
'costo indirecto
|
'costo indirecto
|
||||||
If Not ErrorMovInv AndAlso TotalCIProducto <> 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TotalCIProducto, TotalCIProducto, 95, "Producción PT OP #" & LblFolio.Text, "Producción PT OP #" & LblFolio.Text) Then
|
If Not ErrorMovInv AndAlso TotalCIProducto <> 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TotalCIProducto, TotalCIProducto, 95, "Costo Indirecto PT OP #" & LblFolio.Text, "Costo Indirecto PT OP #" & LblFolio.Text) Then
|
||||||
ErrorMovInv = True
|
ErrorMovInv = True
|
||||||
End If
|
End If
|
||||||
'mano de obra
|
'mano de obra
|
||||||
If Not ErrorMovInv AndAlso TotalCIProducto <> 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TotalMOProducto, TotalCIProducto, 95, "Producción PT OP #" & LblFolio.Text, "Producción PT OP #" & LblFolio.Text) Then
|
If Not ErrorMovInv AndAlso TotalCIProducto <> 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TotalMOProducto, TotalMOProducto, 95, "Mano de Obra PT OP #" & LblFolio.Text, "Mano de Obra PT OP #" & LblFolio.Text) Then
|
||||||
ErrorMovInv = True
|
ErrorMovInv = True
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|||||||
Reference in New Issue
Block a user