diff --git a/App_Code/ClsInventarios.vb b/App_Code/ClsInventarios.vb index e0e8b665d..f014d0ed2 100644 --- a/App_Code/ClsInventarios.vb +++ b/App_Code/ClsInventarios.vb @@ -325,7 +325,7 @@ Public Class ClsInventarios End Function Public Function GetRepAlmacenes(FechaInicio As String, FechaFin As String, CveEmpresa As Integer, CveTipoAlmacen As String, Contabilizable As Integer, Inventariable As Integer, Optional SoloMovimientosContables As Boolean = False, Optional Almacenes As String = "-1", Optional CveSubProyecto As Integer = -1, - Optional CveUsuarioConsulta As Integer = -1) As Boolean + Optional CveUsuarioConsulta As Integer = -1, Optional Gpo As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Inv_AlmacenesRepGet") @@ -340,6 +340,7 @@ Public Class ClsInventarios .Add("@Almacenes", SqlDbType.VarChar).Value = Almacenes .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + .Add("@Gpo", SqlDbType.Int).Value = Gpo End With Try SqlAdapter.Fill(Data) diff --git a/App_Code/ClsOP.vb b/App_Code/ClsOP.vb index 16b22fa7b..8688a3969 100644 --- a/App_Code/ClsOP.vb +++ b/App_Code/ClsOP.vb @@ -2,6 +2,7 @@ Imports System.Data Imports System.Data.SqlClient Imports Microsoft.VisualBasic +Imports Telerik.Web.UI.ImageEditor Public Class ClsOP Implements IDisposable @@ -112,7 +113,55 @@ Public Class ClsOP Public Function GetProductosOP(CveOP As Integer, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False - DataAdapter("PA_OP_ProductosGET") + DataAdapter("PA_OP_ProductosGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveOP", SqlDbType.Int).Value = CveOP + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los productos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function GetProductosMO(CveOP As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_OP_ProductosMOGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveOP", SqlDbType.Int).Value = CveOP + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los productos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function GetProductosMP(CveOP As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_OP_ProductosMPGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveOP", SqlDbType.Int).Value = CveOP + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los productos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function GetProductosCI(CveOP As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_OP_ProductosCIGet") With SqlAdapter.SelectCommand.Parameters .Add("@CveOP", SqlDbType.Int).Value = CveOP .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa @@ -359,7 +408,7 @@ Public Class ClsOP #Region "O R D E N E S D E P R O D U C C I O N" - Public Function GetReportesOP(CveOP As Integer, CveCliente As Integer, CveSubProyecto As Integer, CvePS As Integer, CveEstatus As Integer, Asignado As Integer, FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer) As Boolean + Public Function GetReportesOP(CveOP As Integer, CveCliente As Integer, CveSubProyecto As Integer, CvePS As Integer, CveEstatus As Integer, Asignado As Integer, FechaI As Date, FechaF As Date, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_OP_OrdendeProduccionGet") With SqlAdapter.SelectCommand.Parameters @@ -369,8 +418,8 @@ Public Class ClsOP .Add("@CvePS", SqlDbType.Int).Value = CvePS .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus .Add("@Asignado", SqlDbType.Int).Value = Asignado - .Add("@FechaI", SqlDbType.Date).Value = FechaInicio - .Add("@FechaF", SqlDbType.Date).Value = FechaFin + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa End With Try @@ -382,6 +431,75 @@ Public Class ClsOP Return Retorno End Function + Public Function GetOP(CveOP As Integer, CveCliente As Integer, CveSubProyecto As Integer, CvePS As Integer, CveEstatus As Integer, Asignado As Integer, FechaI As Date, FechaF As Date, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_OP_OrdendeProduccionGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveOP", SqlDbType.Int).Value = CveOP + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus + .Add("@Asignado", SqlDbType.Int).Value = Asignado + .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaF", SqlDbType.Date).Value = FechaF + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los productos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function GetEstatusOP(CveEmpresa As Integer, Optional CveEstatusOP As Integer = -1, Optional TipoEstatus As Integer = -1, Optional Estatus As Integer = -1) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_OP_EstatusOPGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveEstatusOP", SqlDbType.Int).Value = CveEstatusOP + .Add("@TipoEstatus", SqlDbType.Int).Value = TipoEstatus + .Add("@Estatus", SqlDbType.Int).Value = Estatus + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As SqlException + OnError("Ocurrió un error al consultar los Estatus de Factura.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdateOP(CveOP As Integer, Descripcion As String, CveCliente As Integer, CvePS As Integer, CveSubProyecto As Integer, Cantidad As Integer, Fecha As Date, CveEmpresa As Integer, CveUsuario As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_OP_OrdendeProduccionUp") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveOP", SqlDbType.Int).Value = CveOP + .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@Cantidad", SqlDbType.Int).Value = Cantidad + .Add("@Fecha", SqlDbType.Date).Value = Fecha + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al guardar la orden de producción.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + + #End Region #Region "IDisposable Support" ' IDisposable diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index c884bbe5d..ddd289dc0 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -403,6 +403,33 @@ Public Class ClsPaginas Application("GlobalDTEstatus") = value End Set End Property + +#Region "ordenes de producción" + Property GlobalDTOPEstatus(CveEmpresa As Integer, Optional Estatus As Integer = -1) As DataTable + Get + Dim AppNombre As String = $"GlobalDTOPEstatus-{CveEmpresa}" + If HttpContext.Current.Application(AppNombre) Is Nothing Then + Using ObjOP As New ClsOP + If ObjOP.GetEstatusOP(CveEmpresa) Then Application(AppNombre) = ObjOP.DtResultados + End Using + End If + Dim filtros As New List(Of String) + If Estatus <> -1 Then filtros.Add($"Estatus = {Estatus}") + + If filtros.Count > 0 Then + Dim Dv As New DataView(DirectCast(HttpContext.Current.Application(AppNombre), DataTable), String.Join(" AND ", filtros), "", DataViewRowState.CurrentRows) + GlobalDTOPEstatus = Dv.ToTable + Dv.Dispose() + Else + GlobalDTOPEstatus = DirectCast(HttpContext.Current.Application(AppNombre), DataTable) + End If + End Get + Set(value As DataTable) + Dim AppNombre As String = $"GlobalDTOPEstatus-{CveEmpresa}" + Application(AppNombre) = value + End Set + End Property +#End Region Property DtFacturaDefault() As DataTable Get DtFacturaDefault = DirectCast(Application("DtFacturaDefault"), DataTable) @@ -9908,6 +9935,7 @@ Public Class ClsPaginas PaginaDict.Add("/OI/ConvocatoriaDetalle.aspx".ToUpper(), 908) PaginaDict.Add("/OI/RepReuniones.aspx".ToUpper(), 908) PaginaDict.Add("/AdSistemasTeam/ProcedimientosAlmacenados.aspx".ToUpper(), -1) + PaginaDict.Add("/OS/CatOrdenesServiciosCaracteristicas.aspx".ToUpper(), -1) PaginaDict.Add("/OS/CatOSCaracteristicasOpciones.aspx".ToUpper(), -1) PaginaDict.Add("/OS/CatSubTiposOrdenesServicios.aspx".ToUpper(), -1) @@ -11141,6 +11169,8 @@ Public Class ClsPaginas #Region "Ordenes de Produccion" PaginaDict.Add("/OP/CatConfiguracionProducto.aspx".ToUpper(), 790) PaginaDict.Add("/OP/RepOS.aspx".ToUpper(), 791) + PaginaDict.Add("/OP/OP.aspx".ToUpper(), -1) + PaginaDict.Add("/OP/RepOP.aspx".ToUpper(), -1) #End Region 'Antes de aquí. diff --git a/Inventarios/KardexAlmacenHorizontal.aspx b/Inventarios/KardexAlmacenHorizontal.aspx index 164c6990a..2d344c96a 100644 --- a/Inventarios/KardexAlmacenHorizontal.aspx +++ b/Inventarios/KardexAlmacenHorizontal.aspx @@ -348,7 +348,7 @@ table.adssigscroll { " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> - +
diff --git a/Inventarios/KardexAlmacenHorizontal.aspx.vb b/Inventarios/KardexAlmacenHorizontal.aspx.vb index bc9f5654a..39b1117ca 100644 --- a/Inventarios/KardexAlmacenHorizontal.aspx.vb +++ b/Inventarios/KardexAlmacenHorizontal.aspx.vb @@ -161,6 +161,9 @@ Partial Class Inventarios_KardexAlmacenHorizontal End Sub Private Sub CargarKardex(CvePS As Integer) + 'GvDatos.Columns.Clear() + 'GvDatos.AutoGenerateColumns = True + Dim dt As New DataTable Dim ObjMovimientos As New ClsInventarios Dim FechaI As String = "-1" ' If(TxtFechaI.Text <> "" AndAlso TxtFechaI.Text <> "__/__/____", TxtFechaI.Text, "-1") @@ -202,13 +205,16 @@ Partial Class Inventarios_KardexAlmacenHorizontal GvDatos.DataSource = dt Else Alert("La búsqueda no contiene resultados.", TipoMensaje.MsgAdvertencia) - GvDatos.Columns.Clear() - dt = Nothing + GvDatos.DataSource = dt + GvDatos.DataBind() + UpDatos.Update() + Exit Sub End If Else ObjMovimientos.Dispose() Alert("Ocurrió un error al consultar el Kardex.", TipoMensaje.MsgError) + UpDatos.Update() Exit Sub End If GvDatos.DataBind() @@ -232,6 +238,7 @@ Partial Class Inventarios_KardexAlmacenHorizontal Next + UpDatos.Update() End Sub Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound diff --git a/Inventarios/RepAlmacen.aspx b/Inventarios/RepAlmacen.aspx index b470d529a..06e760204 100644 --- a/Inventarios/RepAlmacen.aspx +++ b/Inventarios/RepAlmacen.aspx @@ -140,17 +140,35 @@
Tipo Almacen:
-
+
Aplica Almacen
-
+
- +
+ + + + + +
Grupo:
+
+ + + + +
+ + + + + +
@@ -159,11 +177,12 @@ - + - <%# Eval("Almacen") %> + <%--<%# Eval("Almacen") %>--%> diff --git a/Inventarios/RepAlmacen.aspx.vb b/Inventarios/RepAlmacen.aspx.vb index 8164a5732..ee1a1501b 100644 --- a/Inventarios/RepAlmacen.aspx.vb +++ b/Inventarios/RepAlmacen.aspx.vb @@ -54,7 +54,7 @@ Partial Class Inventarios_RepAlmacen Dim CveSubProyecto As Integer = DdlSucursal.SelectedValue.ToEntero() If objInv.GetRepAlmacenes(FechaI, FechaF, UsuarioActual.CveEmpresa, TipoAlmacen, DdlModalidadFiltro.SelectedValue.ToEntero, DdlAplicaInventario.SelectedValue.ToEntero, - Almacenes:=Almacenes, CveSubProyecto:=CveSubProyecto, CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then + Almacenes:=Almacenes, CveSubProyecto:=CveSubProyecto, CveUsuarioConsulta:=UsuarioActual.CveUsuario, Gpo:=DdlGrupo.SelectedValue.ToEntero) Then GVAlmacen.DataSource = objInv.DtResultados TmpDT = objInv.DtResultados End If @@ -103,12 +103,28 @@ Partial Class Inventarios_RepAlmacen Protected Sub LnkPdf_Click(sender As Object, e As EventArgs) Handles LnkPdf.Click GenerarPDF() End Sub - Private Sub GVAlmacen_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVAlmacen.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - If e.Row.FCLabel("LtlAlmacen").Text = "" Then + Private Sub GVAlmacen_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVAlmacen.RowDataBound + + If e.Row.RowType = DataControlRowType.DataRow Then + + 'If e.Row.FCLabel("LtlAlmacen").Text = "" Then + ' e.Row.CssClass = "Totales" + 'End If + + If e.Row.Cells(0).Text = "" Then e.Row.CssClass = "Totales" End If + + If e.Row.DataKey("CveAlmacen").ToEntero > 0 Then + Dim Liga As String = $"./RepEntradasSalidas.aspx?CveAlmacen={e.Row.DataKey("CveAlmacen").ToEntero}&FechaInicio={1:d}&FechaCorte={2:d}&Tipo=-1" + e.Row.Cells(0).Text = $"{e.Row.DataKey("Gpo")}" + + <%# Eval("Almacen") %>- + End If + + End If + End Sub #End Region @@ -169,4 +185,6 @@ Partial Class Inventarios_RepAlmacen #End Region Public Overrides Sub VerifyRenderingInServerForm(control As Control) End Sub + + End Class diff --git a/OP/OP.aspx b/OP/OP.aspx new file mode 100644 index 000000000..f42a51846 --- /dev/null +++ b/OP/OP.aspx @@ -0,0 +1,253 @@ +<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="OP.aspx.vb" Inherits="OP_OP" %> + + + + + + + + + Orden de Producción + + + + + + + + + + + +
+ +
+

Orden de producción #

+
+ + + +
+
+ +
+
+ + +
+
+ + +
+ +
+ + Proyecto: + +
+ +
+ + Subproyecto: + +
+ +
+
+ +
+ + +
+ + + +
+ + +
+
+ +
+
+
+ + + + +
+ + + + + + +
+
+ + +
+ +
+ +
+ + +
+ + + + +
+
+
Productos
+ + + + + + + +
+
+
+
+
Materia prima
+ + + + + + + + +
+
+ +
+
Mano de obra
+ + + + + + +
+ +
+
+
Costo indirecto
+ + + + + + +
+
+
+
+ + +
+ +
+
+
+
+
+ + + + + diff --git a/OP/OP.aspx.vb b/OP/OP.aspx.vb new file mode 100644 index 000000000..912e1f845 --- /dev/null +++ b/OP/OP.aspx.vb @@ -0,0 +1,407 @@ +Imports System.Data +Imports System.Drawing +Imports DocumentFormat.OpenXml.Drawing.Diagrams +Imports System.IO +Imports Extensiones +Imports Microsoft.Reporting.WebForms +Imports Org.BouncyCastle.Asn1.Utilities +Partial Class OP_OP + Inherits ClsPaginas + +#Region "Propiedades" + Private Property CveOP As Integer + Get + Return ViewState("CveOP").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveOP") = value + End Set + End Property + + Private Property DtPS As DataTable + Get + Return DirectCast(ViewState("DtPS"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtPS") = value + End Set + End Property + + Private Property DtMP As DataTable + Get + Return DirectCast(ViewState("DtMP"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtMP") = value + End Set + End Property + + Private Property DtMO As DataTable + Get + Return DirectCast(ViewState("DtMO"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtMO") = value + End Set + End Property + + Private Property DtCI As DataTable + Get + Return DirectCast(ViewState("DtCI"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtCI") = value + End Set + End Property + + +#End Region + + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load + If Not IsPostBack Then + CveOP = If(Request("CveOP") <> "", Request("CveOP").ToString.ToEntero, "-1".ToEntero) + CreaPS() + SetValues() + End If + End Sub + + Private Sub CreaPS() + DtPS = New DataTable() + DtPS.Columns.Add("Tipo", GetType(String)) ' Producto, MP, MO, CI + DtPS.Columns.Add("Clave", GetType(Integer)) + DtPS.Columns.Add("PSCodigo", GetType(String)) + DtPS.Columns.Add("UnidadMedida", GetType(String)) + DtPS.Columns.Add("Cantidad", GetType(Decimal)) + 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("UnidadMedida", GetType(String)) + DtMP.Columns.Add("Cantidad", GetType(Decimal)) + DtMP.Columns.Add("Surtido", GetType(Decimal)) + + DtMO = New DataTable() + DtMO.Columns.Add("Tipo", GetType(String)) ' Producto, MP, MO, CI + DtMO.Columns.Add("Clave", 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("Cantidad", GetType(Decimal)) + + + End Sub + + Private Sub SetValues() + + CargarClientes() + CargarCentrosDeCosto(DdlProyecto, DdlSubProyecto, LblProyecto, LblSubProyecto, divProyecto:=DivProyecto, VisualizacionReporte:=1) + 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 + + Else + DdlClientes.Enabled = False + DdlProyecto.Enabled = False + DdlSubProyecto.Enabled = False + DdlPS.Enabled = False + CargaDatos() + End If + End Sub + + Private Sub CargaDatos() + If CveOP > 0 Then + Dim ObjOP As New ClsOP() + If ObjOP.GetOP(CveOP, -1, -1, -1, -1, -1, MinFecha, MaxFecha, UsuarioActual.CveEmpresa) Then + Dim DTOP As DataTable = ObjOP.DtResultados + If DTOP.Rows.Count > 0 Then + Dim dr As DataRow = DTOP.Rows(0) + LblCveOP.Text = CveOP.ToString + DdlClientes.txtText.Value = dr("Cliente").ToString + DdlClientes.txtValue.Value = dr("CveCliente").ToString + TxtEstatus.Text = dr("Estatus").ToString + DdlSubProyecto.SelectedValue = 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 + End If + End If + ObjOP.Dispose() + End If + End Sub + + Private Sub CargarClientes() + Dim EsWS As Boolean = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or + UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False) + If EsWS Then + DdlClientes.setEsWebService(True) + Else + DdlClientes.setEsWebService(False) + DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1) + DdlClientes.DataBind() + DdlClientes.ddl.Items.Insert(0, New ListItem("Seleccione Cliente", "-1")) + End If + End Sub + + Private Sub CargarProductos() + DdlPS.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") + + If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then + DdlPS.SelectedText = "" + DdlPS.SelectedValue = "-1" + Else + DdlPS.ddl.Items.Clear() + DdlPS.ddl.DataBind() + DdlPS.ddl.Items.Insert(0, New ListItem("Seleccione el Producto", "-1")) + End If + End Sub + + Protected Sub BtnAgregarProducto_Click(sender As Object, e As EventArgs) Handles BtnAgregarProducto.Click + If DdlPS.SelectedValue = "-1" Then Exit Sub + + Dim newRow As DataRow = DtPS.NewRow() + Dim CvePS As Integer = DdlPS.SelectedValue.ToEntero + Dim DrPS As DataRow = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") + + newRow("Tipo") = "Producto" + newRow("Clave") = CvePS + newRow("PSCodigo") = DrPS("PSCodigo") + newRow("UnidadMedida") = DrPS("UnidadMedida") + newRow("Cantidad") = 1 + newRow("Surtido") = 0 + newRow("Costo") = 0 + DtPS.Rows.Add(newRow) + 'consultas GetMPReceta, GetMOReceta, GetCIReceta + + + Dim CveUM As Integer = DrPS("CveUnidadMedida").ToString.ToEntero + + Dim ObjMP As New ClsOP() + If ObjMP.GetMPReceta(CvePS, CveUM, UsuarioActual.CveEmpresa) Then + For Each drMP As DataRow In ObjMP.DtResultados.Rows + Dim rowMP As DataRow = DtMP.NewRow() + rowMP("Tipo") = "MP" + rowMP("Clave") = CvePS + rowMP("Producto") = drMP("productoMateriaPrima").ToString() + rowMP("UnidadMedida") = drMP("UnidadMedidaMateriaPrima").ToString() + rowMP("Cantidad") = drMP("Cantidad").ToString().ToDecimal() + rowMP("Surtido") = 0 + DtMP.Rows.Add(rowMP) + Next + End If + + + Dim ObjMO As New ClsOP() + If ObjMO.GetMOReceta(CvePS, CveUM, UsuarioActual.CveEmpresa) Then + For Each drMO As DataRow In ObjMO.DtResultados.Rows + Dim rowMO As DataRow = DtMO.NewRow() + rowMO("Tipo") = "MO" + rowMO("Clave") = CvePS + rowMO("Puesto") = drMO("Puesto").ToString() + rowMO("Cantidad") = drMO("Cantidad").ToString().ToDecimal() + DtMO.Rows.Add(rowMO) + Next + End If + + + 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("Cantidad") = drCI("Cantidad").ToString().ToDecimal() + DtCI.Rows.Add(rowCI) + Next + End If + + ActualizarGrids() + 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 filasProducto As DataRow() = DtPS.Select($"Clave = {CveProducto}") + If filasProducto.Length > 0 Then + DtPS.Rows.Remove(filasProducto(0)) + End If + + EliminarDatosRelacionados(CveProducto) + + ActualizarGrids() + End Sub + + Private Sub EliminarDatosRelacionados(CveProducto As Integer) + Dim filasMP As DataRow() = DtMP.Select($"Clave = {CveProducto}") + For Each fila As DataRow In filasMP + DtMP.Rows.Remove(fila) + Next + + Dim filasMO As DataRow() = DtMO.Select($"Clave = {CveProducto}") + For Each fila As DataRow In filasMO + DtMO.Rows.Remove(fila) + Next + + Dim filasCI As DataRow() = DtCI.Select($"Clave = {CveProducto}") + For Each fila As DataRow In filasCI + DtCI.Rows.Remove(fila) + Next + End Sub + + Protected Sub BtnGuardarOP_Click(sender As Object, e As EventArgs) + ' Validar campos obligatorios + If DdlClientes.SelectedValue = "-1" Then + Alert("Seleccione un cliente.", TipoMensaje.MsgAdvertencia) + Return + End If + + If DtPS.Rows.Count = 0 Then + Alert("Agregue al menos un producto.", TipoMensaje.MsgAdvertencia) + Return + End If + + ' Iniciar transacción + Dim clsOP As New ClsOP() + clsOP.IniciaTransacSQL() + + 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() + 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 + + Catch ex As Exception + ' Rollback en caso de error + clsOP.RollBack() + Alert($"Error al guardar: {ex.Message}", TipoMensaje.MsgError) + Finally + clsOP.Dispose() + End Try + End Sub + + Private Sub ActualizarGrids() + Dim dtProductosFiltrados As DataTable = DtPS.Clone() ' Clona la estructura + Dim rowsProductos As DataRow() = DtPS.Select("Tipo = 'Producto'") + If rowsProductos.Length > 0 Then + dtProductosFiltrados = rowsProductos.CopyToDataTable() + End If + GvProductos.DataSource = dtProductosFiltrados + GvProductos.DataBind() + + Dim dtMPFiltrados As DataTable = DtMP.Clone() + Dim rowsMP As DataRow() = DtMP.Select("Tipo = 'MP'") + If rowsMP.Length > 0 Then + dtMPFiltrados = rowsMP.CopyToDataTable() + End If + GvMateriaPrima.DataSource = dtMPFiltrados + GvMateriaPrima.DataBind() + + Dim dtMOFiltrados As DataTable = DtMO.Clone() + Dim rowsMO As DataRow() = DtMO.Select("Tipo = 'MO'") + If rowsMO.Length > 0 Then + dtMOFiltrados = rowsMO.CopyToDataTable() + End If + GvManoObra.DataSource = dtMOFiltrados + GvManoObra.DataBind() + + Dim dtCIFiltrados As DataTable = DtCI.Clone() + Dim rowsCI As DataRow() = DtCI.Select("Tipo = 'CI'") + If rowsCI.Length > 0 Then + dtCIFiltrados = rowsCI.CopyToDataTable() + End If + GvCostosIndirectos.DataSource = dtCIFiltrados + GvCostosIndirectos.DataBind() + + UpGvDatosOP.Update() + End Sub + + + +End Class + + diff --git a/OP/RepOP.aspx b/OP/RepOP.aspx new file mode 100644 index 000000000..43dfa4ed2 --- /dev/null +++ b/OP/RepOP.aspx @@ -0,0 +1,216 @@ +<%@ Page Title="Orden de Produccion" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RepOP.aspx.vb" Inherits="OP_RepOP" %> + +<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> + + + + + + + + +
+ <%-- --%> +
+
+
+
+ +
  • + Agregar Orden de Producción +
  • +
    + + Orden de Producción + + + + + + +
    +
    +
    + + +
    + +
    +
    + +
    + +
    + + + Proyecto: + +
    + +
    + + Subproyecto: + +
    + +
    + + +
    + + + +
    +
    +
    +
    + + +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + diff --git a/OP/RepOP.aspx.vb b/OP/RepOP.aspx.vb new file mode 100644 index 000000000..5522baed5 --- /dev/null +++ b/OP/RepOP.aspx.vb @@ -0,0 +1,161 @@ +Option Explicit On +Option Strict On + +Imports System.Data +Imports Extensiones +Imports Ionic.Zlib +Imports Microsoft.Reporting.WebForms + +Partial Class OP_RepOP + Inherits ClsPaginas + +#Region "PROPIEDADES" + + Private Property DtOp As DataTable + Get + Return DirectCast(ViewState("DtOp"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtOp") = value + End Set + End Property + Private Property Agrupador As String + Get + Return ViewState("Agrupador").ToString + End Get + + Set(value As String) + ViewState("Agrupador") = value + End Set + End Property + Private Property TCEspecifico As Double + Get + Return ViewState("TCEspecifico").ToString.ToDouble + End Get + + Set(value As Double) + ViewState("TCEspecifico") = value + End Set + End Property + Private Property TipoCambio As Integer + Get + Return ViewState("TipoCambio").ToString.ToEntero + End Get + + Set(value As Integer) + ViewState("TipoCambio") = value + End Set + End Property + +#End Region + + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load + If Not IsPostBack Then + If UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario.Contiene(77, 21) Then Response.Redirect("/Inicio.aspx") + 'CargarMarcas() + SetValues() + End If + End Sub + + +#Region " CARGA DATOS INICIALES " + Private Sub SetValues() + 'Carga Productos + DdlPS.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") + + If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then + DdlPS.SelectedText = "" + DdlPS.SelectedValue = "-1" + Else + DdlPS.ddl.Items.Clear() + DdlPS.ddl.DataBind() + DdlPS.ddl.Items.Insert(0, New ListItem("Seleccione el Producto", "-1")) + End If + + 'CargaEstatus + DdlEstatusOP.DataSource = GlobalDTOPEstatus(UsuarioActual.CveEmpresa) + DdlEstatusOP.DataBind() + DdlEstatusOP.Items.Add(New ListItem("Canceladas", "4")) + DdlEstatusOP.SelectedValue = "-1" + + + 'Carga Clasificacion del cliente + CargarCentrosDeCosto(DdlProyecto, DdlSubProyecto, LblProyecto, LblSubProyecto, divProyecto:=DivProyecto, VisualizacionReporte:=1) + + Dim EsWS As Boolean = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False) + If EsWS Then + DdlClientes.setEsWebService(True) + Else + DdlClientes.setEsWebService(False) + DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1) + DdlClientes.DataBind() + DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1")) + End If + + DdlEstatusOP.DataSource = GlobalDTOPEstatus(UsuarioActual.CveEmpresa) + DdlEstatusOP.DataBind() + + txtFechaI.Text = NowADS().FirstDayOfMonth.ToShortDateString + txtFechaF.Text = NowADS().ToShortDateString + + If UsuarioActual.TienePermisoProceso(339) Then + GvDatos.Columns(3).Visible = False + GvDatos.Columns(4).Visible = False + GvDatos.Columns(5).Visible = False + GvDatos.Columns(6).Visible = False + End If + + End Sub +#End Region + + +#Region " CARGA DATOS " + Protected Sub BtnConsultar_Click(sender As Object, e As System.EventArgs) Handles BtnConsultar.Click + CargaDatos() + UPDatos.Update() + End Sub + + Private Sub CargaDatos() + Dim FechaI, FechaF As Date + FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.ToDate, MinFecha) + FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.ToDate, MaxFecha) + Dim CveCliente As Integer = If(DdlClientes.SelectedValue.ToEntero > 0, DdlClientes.SelectedValue.ToEntero, -1) + + Dim ObjOP As New ClsOP() + If ObjOP.GetReportesOP(-1, DdlClientes.SelectedValue.ToEntero, + DdlSubProyecto.SelectedValue.ToEntero, + DdlPS.SelectedValue.ToEntero, + DdlEstatusOP.SelectedValue.ToEntero, + -1, + FechaI, FechaF, + UsuarioActual.CveEmpresa) Then + GvDatos.DataSource = ObjOP.DtResultados + DtOp = ObjOP.DtResultados + + Else + GvDatos.DataSource = Nothing + End If + ObjOP.Dispose() + GvDatos.DataBind() + End Sub + +#End Region + +#Region "Gv Datos" + Protected Sub GvDatos_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GvDatos.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + 'Verificar si el DataKey existe + If e.Row.DataItem IsNot Nothing AndAlso GvDatos.DataKeys.Count > e.Row.RowIndex Then + Dim CveOP As Integer = GvDatos.DataKeys(e.Row.RowIndex).Value.ToString().ToEntero() + Dim Liga As String = $"/OP/OP.aspx?CveOP={CveOP}" + + 'Acceder al control solo si existe + Dim hl As HyperLink = TryCast(e.Row.FindControl("HlAgregarOrdenOP"), HyperLink) + If hl IsNot Nothing Then + hl.NavigateUrl = Liga + End If + End If + End If + End Sub +#End Region +End Class diff --git a/Sistemas/RolesDetalle.aspx b/Sistemas/RolesDetalle.aspx index 49659bde2..ca62e6793 100644 --- a/Sistemas/RolesDetalle.aspx +++ b/Sistemas/RolesDetalle.aspx @@ -1,317 +1,317 @@ -<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RolesDetalle.aspx.vb" Inherits="Sistemas_RolesDetalle" %> + <%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RolesDetalle.aspx.vb" Inherits="Sistemas_RolesDetalle" %> - - - - - - Rol: - - - - - - - - - + + + + + + Rol: + + + + + + + + + - - - + + + - - - - -
    -
    -
    -
    -
    - - General -
    -
    -
    + + + + +
    +
    +
    +
    +
    + + General
    -
    -
    - -
    -
    -
    -
    - - -
    -
    - - - <%-- --%> - -
    -
    -
    - -
    - -
    - -   - +
    +
    +
    + +
    +
    +
    +
    + + +
    +
    + + + <%-- --%> + +
    +
    +
    + +
    + +
    + +   + +
    +
    + +
    +
    + + +
    +
    + + +
    -
    - - -
    -
    - - -
    -
    -
    - - - - - - - - - - - -
    - " style="display: inline-block; margin-right: -20px; width: 150px;" /> - " class="btn btn-circle btn-sm label-info"> -
    - -
    -
    - - - - - - - - - - - - - P - - - - - - - - - - - + + + + + + + + +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " class="btn btn-circle btn-sm label-info">
    -
    - - - - + +
    +
    + + + + + + + + + + + + + P + + + + + + + + + - - - - -
    - " style="display: inline-block; margin-right: -20px; width: 150px;" /> - " class="btn btn-circle btn-sm label-info"> -
    - -
    -
    - - - - - - - - - - - - - P - - - - - - - - - - +
    -
    - - - - + + + + + + + + + + + + +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " class="btn btn-circle btn-sm label-info"> +
    + +
    +
    + + + + + + + + + + + + + P + + + + + + + + + + + +
    +
    +
    +
    +
    +
    - - - - -
    -
    -
    -
    -
    - - Indicadores + + + + +
    +
    +
    +
    +
    + + Indicadores +
    +
    +
    +
    +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    + +
    +
    +
    +
    +
    -
    -
    -
    -
    - " style="display: inline-block; margin-right: -20px; width: 150px;" /> - " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    + + + + + + + + + + + + +
    +
    +
    +
    + + + + + + + + + + +
    +
    + +
    +
    +
    + + Usuarios +
    +
    +
    +
    +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    +
    -
    -
    -
    -
    -
    - - - - - - - - - - - - -
    -
    -
    -
    - - - - - - - - - - -
    -
    - -
    -
    -
    - - Usuarios -
    -
    -
    -
    -
    - " style="display: inline-block; margin-right: -20px; width: 150px;" /> - " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> -
    - -
    - +
    -
    +
    + + + + + +
    -
    - - - - - - -
    -
    - - - - + + + + - -
    + +
    - - - - -
    - -
    + + + + +
    + +
    - - + + - <%--MODAL ADJUNTAR--%> -