3424 lines
154 KiB
VB.net
3424 lines
154 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports Extensiones
|
|
Imports System.IO
|
|
Imports System.Data
|
|
Imports Telerik.Web.UI
|
|
Imports System.Data.SqlClient
|
|
Imports Stimulsoft.Report.StiOptions.Export
|
|
|
|
Partial Class OS_OrdenesServicios
|
|
Inherits ClsPaginas
|
|
|
|
#Region "Propiedades"
|
|
Private Shared missing As Object = System.Reflection.Missing.Value
|
|
Private Property CveCliente As Integer
|
|
Get
|
|
Return ViewState("CveCliente").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveCliente") = value
|
|
End Set
|
|
End Property
|
|
Private Property TipoEstatus As Integer
|
|
Get
|
|
Return ViewState("TipoEstatus").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("TipoEstatus") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveFolio As Integer
|
|
Get
|
|
Return ViewState("CveFolio").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveFolio") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveSub As Integer
|
|
Get
|
|
Return ViewState("CveSub").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveSub") = value
|
|
End Set
|
|
End Property
|
|
Private Property TmpDT As DataTable
|
|
Get
|
|
Return CType(ViewState("TmpDT"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("TmpDT") = value
|
|
End Set
|
|
End Property
|
|
Private Property DTPS As DataTable
|
|
Get
|
|
Return CType(ViewState("DTPS"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTPS") = value
|
|
End Set
|
|
End Property
|
|
Private Property DtSubProyectos As DataTable
|
|
Get
|
|
Return CType(ViewState("DtSubProyectos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtSubProyectos") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveOS As Integer
|
|
Get
|
|
If ViewState("CveOS") Is Nothing Then
|
|
ViewState("CveOS") = -1
|
|
End If
|
|
|
|
Return ViewState("CveOS").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveOS") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Private Property CveVenta As Integer
|
|
Get
|
|
If ViewState("CveVenta") Is Nothing Then
|
|
ViewState("CveVenta") = -1
|
|
End If
|
|
|
|
Return ViewState("CveVenta").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveVenta") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Private Property CveOsDetalle As Integer
|
|
Get
|
|
Return ViewState("CveOsDetalle").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveOsDetalle") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveCaracteristicaValor As Integer
|
|
Get
|
|
Return ViewState("CveCaracteristicaValor").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveCaracteristicaValor") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveConsecutivo As Integer
|
|
Get
|
|
Return ViewState("CveConsecutivo").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveConsecutivo") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveUsuarioAtendio As Integer
|
|
Get
|
|
Return ViewState("CveUsuarioAtendio").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveUsuarioAtendio") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveUsuarioAtendioCount As Integer
|
|
Get
|
|
Return ViewState("CveUsuarioAtendioCount").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveUsuarioAtendioCount") = value
|
|
End Set
|
|
End Property
|
|
Private Property NombreCliente As String
|
|
Get
|
|
Return ViewState("NombreCliente").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("NombreCliente") = value
|
|
End Set
|
|
End Property
|
|
Private Property ClienteDireccion As String
|
|
Get
|
|
Return ViewState("ClienteDireccion").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("ClienteDireccion") = value
|
|
End Set
|
|
End Property
|
|
Private Property ClienteColonia As String
|
|
Get
|
|
Return ViewState("ClienteColonia").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("ClienteColonia") = value
|
|
End Set
|
|
End Property
|
|
Private Property ClienteCiudad As String
|
|
Get
|
|
Return ViewState("ClienteCiudad").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("ClienteCiudad") = value
|
|
End Set
|
|
End Property
|
|
Private Property ClienteEstado As String
|
|
Get
|
|
Return ViewState("ClienteEstado").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("ClienteEstado") = value
|
|
End Set
|
|
End Property
|
|
Private Property TelefonoCliente As String
|
|
Get
|
|
Return ViewState("TelefonoCliente").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("TelefonoCliente") = value
|
|
End Set
|
|
End Property
|
|
Private Property Materiales As String
|
|
Get
|
|
Return ViewState("Materiales").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("Materiales") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveCotizacion As Integer
|
|
Get
|
|
Return ViewState("CveCotizacion").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveCotizacion") = value
|
|
End Set
|
|
End Property
|
|
Private Property TmpDTCaracteristica As DataTable
|
|
Get
|
|
Return CType(ViewState("TmpDTCaracteristica"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("TmpDTCaracteristica") = value
|
|
End Set
|
|
End Property
|
|
Private Property TmpDTCuentaCaracteristica As DataTable
|
|
Get
|
|
Return CType(ViewState("TmpDTCuentaCaracteristica"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("TmpDTCuentaCaracteristica") = value
|
|
End Set
|
|
End Property
|
|
Private Property TmpDTMaterialesDetalle As DataTable
|
|
Get
|
|
Return CType(ViewState("TmpDTMaterialesDetalle"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("TmpDTMaterialesDetalle") = value
|
|
End Set
|
|
End Property
|
|
Private Property TmpDTSolicitarMaterial As DataTable
|
|
Get
|
|
Return CType(ViewState("TmpDTSolicitarMaterial"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("TmpDTSolicitarMaterial") = value
|
|
End Set
|
|
End Property
|
|
Private Property TmpDTCuentaEquipo As DataTable
|
|
Get
|
|
Return CType(ViewState("TmpDTCuentaEquipo"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("TmpDTCuentaEquipo") = value
|
|
End Set
|
|
End Property
|
|
Private Property EstatusOSDelUsuario As DataTable
|
|
Get
|
|
Return CType(ViewState("EstatusOSDelUsuario"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("EstatusOSDelUsuario") = value
|
|
End Set
|
|
End Property
|
|
Private Property MensajeAlert As StringBuilder
|
|
Get
|
|
Return CType(ViewState("MensajeAlert"), StringBuilder)
|
|
End Get
|
|
Set(value As StringBuilder)
|
|
ViewState("MensajeAlert") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveTecnico As Integer
|
|
Get
|
|
Return ViewState("CveTecnico").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveTecnico") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property ClienteRFC As String
|
|
Get
|
|
Return ViewState("ClienteRFC").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("ClienteRFC") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property ClienteMail As String
|
|
Get
|
|
Return ViewState("ClienteMail").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("ClienteMail") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property DTSolicitudDev As DataTable
|
|
Get
|
|
Return If(ViewState("DTSolicitudDev") Is Nothing, New DataTable, DirectCast(ViewState("DTSolicitudDev"), DataTable))
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTSolicitudDev") = 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
|
|
'DATOS CLIENTE
|
|
CveCliente = 0
|
|
NombreCliente = ""
|
|
ClienteDireccion = ""
|
|
ClienteCiudad = ""
|
|
ClienteEstado = ""
|
|
Materiales = "-1"
|
|
|
|
TipoEstatus = 1
|
|
CveConsecutivo = 0
|
|
CveOsDetalle = -1
|
|
CveVenta = -1
|
|
CveUsuarioAtendioCount = 0
|
|
ImgImprimir.Visible = False
|
|
|
|
CargaSubProyecto()
|
|
CargaTiposOrden()
|
|
CargaTecnico()
|
|
CargaPS(-1, DdlPSDetalle)
|
|
CargaPsMateriales()
|
|
'CargaClasificaciones()
|
|
CargaPSCaracteristicasOpciones()
|
|
CargaCuentasCaracteristicas()
|
|
CargaAlmacen()
|
|
CargaModelos()
|
|
|
|
CreaDT()
|
|
CreaDTPS()
|
|
CreaDtMaterialesDetalle()
|
|
CreaDtSolicitarMateriales()
|
|
CargaAgentes()
|
|
CargaProcedimientos()
|
|
CargaTiposVenta()
|
|
|
|
CveSub = -1
|
|
|
|
'Carga cliente
|
|
If Request("CveCliente") IsNot Nothing AndAlso IsNumeric(Request("CveCliente")) AndAlso Request("CveCliente").ToEntero > 0 Then
|
|
ViewState("CveCliente") = Request("CveCliente")
|
|
HdnCveCliente.Value = Request("CveCliente")
|
|
CargaCliente(CveCliente)
|
|
CargarCuentasEquipos(CveCliente)
|
|
Else
|
|
ViewState("CveCliente") = -1
|
|
HdnCveCliente.Value = "-1"
|
|
End If
|
|
|
|
If Request("CveOS") IsNot Nothing AndAlso IsNumeric(Request("CveOS")) AndAlso Request("CveOS").ToEntero > 0 Then
|
|
ViewState("CveOS") = Request("CveOS")
|
|
Else
|
|
ViewState("CveOS") = -1
|
|
End If
|
|
|
|
If Request("CveCotizacion") IsNot Nothing AndAlso IsNumeric(Request("CveCotizacion")) AndAlso Request("CveCotizacion").ToEntero > 0 Then
|
|
CveCotizacion = Request("CveCotizacion").ToEntero
|
|
CargaVenta()
|
|
Else
|
|
CveCotizacion = -1
|
|
End If
|
|
If Request("CveVenta") IsNot Nothing AndAlso IsNumeric(Request("CveVenta")) AndAlso Request("CveVenta").ToEntero > 0 Then
|
|
CveCotizacion = Request("CveVenta").ToEntero
|
|
CargaVenta()
|
|
Else
|
|
CveCotizacion = -1
|
|
End If
|
|
|
|
'Carga OS
|
|
If CveOS > 0 Then
|
|
|
|
'CargaEstatusOS()
|
|
CargaDatos()
|
|
'PermisosSegunEstatus()
|
|
CargaDetalles()
|
|
CargaMateriales()
|
|
|
|
DivSeFactura.Visible = True
|
|
BtnGuardar.Text = "Guardar Cambios"
|
|
LtlTitulo.Text = "Consulta del Orden de Servicio"
|
|
TxtFecha.Text = NowADS().ToString("dd/MM/yyy")
|
|
|
|
If UsuarioActual.TienePermisoProceso(198) Then
|
|
ChkSeFacturara.Visible = True
|
|
ChkSeFacturara.Checked = True
|
|
Else
|
|
ChkSeFacturara.Visible = False
|
|
ChkSeFacturara.Checked = False
|
|
End If
|
|
Else
|
|
DivSeFactura.Visible = False
|
|
TxtFechaRecibido.Text = NowADS().ToString("dd/MM/yyy")
|
|
ViewState("CveOS") = -1
|
|
DdlEstatusOS.Enabled = False
|
|
CargaEstatusOS()
|
|
End If
|
|
|
|
hdnEsThickbox.Value = "S"
|
|
hdnClientIDLink.Value = "NoDefinido"
|
|
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
|
|
DVDatosAdicionalesAcum1.Visible = True
|
|
DVDatosAdicionalesAcum2.Visible = True
|
|
DVDatosAdicionalesAcum3.Visible = True
|
|
|
|
If CveOS = -1 Then
|
|
CargaCliente(-1, 1, True)
|
|
End If
|
|
Else
|
|
LblCuentaEquipoTH.Visible = False
|
|
DdlCuentaEquipo.Visible = False
|
|
End If
|
|
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
|
|
|
|
DivMateriales.Attributes.Add("style", "display:none") 'No se usa .visible = false pora que la llamada a updatepanel no cause errores de js en el cliente
|
|
TREstatus.Visible = False
|
|
|
|
LblCuentaEquipoTH.Visible = False
|
|
DdlCuentaEquipo.Visible = False
|
|
|
|
|
|
|
|
|
|
|
|
TREstatus2.Visible = If(TipoEstatus.Contiene(4, 5), False, True)
|
|
|
|
DdlPsModalFinalizar.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1")
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then
|
|
DdlPsModalFinalizar.SelectedText = ""
|
|
DdlPsModalFinalizar.SelectedValue = "-1"
|
|
Else
|
|
DdlPS.ddl.Items.Clear()
|
|
|
|
DdlPsModalFinalizar.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa)
|
|
DdlPsModalFinalizar.ddl.DataBind()
|
|
DdlPsModalFinalizar.ddl.Items.Insert(0, New ListItem("Seleccione el Producto", "-1"))
|
|
End If
|
|
|
|
|
|
|
|
End If
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(578).ToEntero = 1 Then
|
|
DVAMedicoProcedimiento.Visible = True
|
|
DVTipoVenta.Visible = True
|
|
|
|
DvFechaRecivido1.Visible = False
|
|
DvFechaRecivido2.Visible = False
|
|
|
|
DVFechaCita1.Visible = True
|
|
DVFechaCita2.Visible = True
|
|
|
|
DVEpisodioPaciente.Visible = True
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaTiposVenta()
|
|
DdlTipoVenta.DataSource = GlobalDTTipoVenta().FiltraParametros("Estatus = 'True' ")
|
|
DdlTipoVenta.DataBind()
|
|
End Sub
|
|
|
|
Private Sub CargaProcedimientos()
|
|
DdlMedico.DataSource = GlobalDTMedicos(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'True' ")
|
|
DdlMedico.DataBind()
|
|
End Sub
|
|
|
|
Private Sub CargaAgentes()
|
|
DdlProcedimiento.DataSource = GlobalDTProcedimientos(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'True' ")
|
|
DdlProcedimiento.DataBind()
|
|
End Sub
|
|
|
|
|
|
|
|
#Region "DDL'S "
|
|
Protected Sub DdlPSDetalle_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPSDetalle.SelectedIndexChanged
|
|
If CveCliente > 0 OrElse DdlPSDetalle.SelectedValue = "-2" Then
|
|
If DdlPSDetalle.SelectedIndex > 1 Then
|
|
Dim drPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlPSDetalle.SelectedValue.ToEntero).FiltroPrimero("")
|
|
CargaPSCaracteristicas()
|
|
End If
|
|
End If
|
|
UpDetalleOS.Update()
|
|
End Sub
|
|
'Protected Sub DdlCCEdit_SelectedIndexChanged(sender As Object, e As System.EventArgs)
|
|
' Dim gvr As GridViewRow = DirectCast(DirectCast(sender, DropDownList).BindingContainer, GridViewRow)
|
|
' Dim CveProyecto As String = DirectCast(sender, DropDownList).SelectedValue
|
|
|
|
' gvr.FCDropDownList("DDlSubProyecto").Items.Clear()
|
|
' gvr.FCDropDownList("DDlSubProyecto").DataSource = GlobalDTSubProyectos(CveProyecto.ToEntero)
|
|
' gvr.FCDropDownList("DDlSubProyecto").DataBind()
|
|
' gvr.FCDropDownList("DDlSubProyecto").Items.Insert(0, New ListItem("Sin SubProyecto Asignado", "-1"))
|
|
|
|
'End Sub
|
|
Protected Sub DdlFR_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
Dim DdlFR_Gv As DropDownList = CType(sender, DropDownList)
|
|
Dim index As Integer = CType(DdlFR_Gv.NamingContainer, GridViewRow).FCLiteral("LtlConsecutivo").Text.ToString.ToEntero
|
|
|
|
If UsuarioActual.Empresa.UsaAC Then
|
|
TmpDT(index - 1)("CvePresupuestoIngreso") = DdlFR_Gv.SelectedValue
|
|
End If
|
|
TmpDT.AcceptChanges()
|
|
End Sub
|
|
Protected Sub DdlEstatusOS_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlEstatusOS.SelectedIndexChanged
|
|
|
|
'Dim tipoDeEstatusSeleccionado As String = EstatusOSDelUsuario.FiltroPrimero(String.Format("CveEstatusOrdenServicio = {0}", DdlEstatusOS.SelectedValue)).Item("TipoEstatusTexto").ToString
|
|
|
|
|
|
|
|
'Select Case tipoDeEstatusSeleccionado
|
|
' Case "Inicial"
|
|
' 'Proceso
|
|
|
|
' Case "Terminado"
|
|
' 'Terminada
|
|
' 'Checar que todos los detalles esten terminados para poder cambiar a terminada
|
|
' If TmpDT.COUNT("Estatus", "Estatus = 'False'").ToEntero > 0 Then
|
|
' Alert("No se puede cambiar a Terminada, aún tiene Detalles de Orden de Servicio por Atender", TipoMensaje.MsgAdvertencia)
|
|
|
|
' 'Regresar a estatus Atendiendo
|
|
' 'DdlEstatusOS.SelectedValue = "2"
|
|
' End If
|
|
' ' Case 4
|
|
' ' 'Cancelada
|
|
' ' Case 5
|
|
' ' 'Entregada
|
|
' ' Guardar(True)
|
|
' Case "Cancelada"
|
|
' Dim CanceladoOrdenMinimo As String = EstatusOSDelUsuario.FiltroPrimeroValor("CveEstatusOrdenServicio", "TipoEstatus = 5", "Orden ASC").ToString
|
|
' DdlEstatusOS.SelectedValue = CanceladoOrdenMinimo
|
|
|
|
' 'DdlEstatusOS.SelectedIndex = CanceladoOrdenMinimo
|
|
'End Select
|
|
|
|
''CargaEstatusOS(DdlEstatusOS.SelectedValue.ToEntero)
|
|
'PermisosSegunEstatus()
|
|
|
|
'GvPS.DataSource = TmpDT
|
|
'GvPS.DataBind()
|
|
|
|
|
|
|
|
Dim tmpTipoEstatus As Integer = GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("TipoEstatus", $" CveEstatusOrdenServicio = {DdlEstatusOS.SelectedValue}").ToEntero
|
|
Select Case tmpTipoEstatus
|
|
Case 1, 2, 3
|
|
'Proceso
|
|
|
|
Case 4
|
|
'Terminada
|
|
'Checar que todos los detalles esten terminados para poder cambiar a terminada
|
|
If TmpDT.COUNT("Estatus", "Estatus = 'False'").ToEntero > 0 Then
|
|
Alert("No se puede cambiar a Terminada, aún tiene Detalles de Orden de Servicio por Atender", TipoMensaje.MsgAdvertencia)
|
|
|
|
'Regresar a estatus Atendiendo
|
|
'DdlEstatusOS.SelectedValue = "2"
|
|
End If
|
|
' Case 4
|
|
' 'Cancelada
|
|
' Case 5
|
|
' 'Entregada
|
|
' Guardar(True)
|
|
Case 5
|
|
Dim CanceladoOrdenMinimo As String = EstatusOSDelUsuario.FiltroPrimeroValor("CveEstatusOrdenServicio", "TipoEstatus = 5", "Orden ASC").ToString
|
|
DdlEstatusOS.SelectedValue = CanceladoOrdenMinimo
|
|
|
|
'DdlEstatusOS.SelectedIndex = CanceladoOrdenMinimo
|
|
End Select
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "C A R G A S"
|
|
Private Sub CargaSubProyecto(Optional CveSubProyecto As Integer = -1)
|
|
|
|
'Dim ObjOS As New ClsOS
|
|
'If ObjOS.GetSubProyectosEstatusInicial(UsuarioActual.CveUsuario, 1, UsuarioActual.CveEmpresa) Then
|
|
' DdlSubProyecto.Items.Clear()
|
|
' DdlSubProyecto.SelectedValue = Nothing
|
|
' DdlSubProyecto.DataSource = ObjOS.DtResultados.FiltraParametros("", "", {"CveSubProyecto", "SubProyecto"})
|
|
|
|
' If CveSubProyecto > 0 Then DdlSubProyecto.SelectedValueExist(CveSubProyecto)
|
|
' DdlEstatusOS.DataSource = ObjOS.DtResultados.FiltraParametros(String.Format("CveSubProyecto = {0}", CveSubProyecto), "", {"CveEstatusOrdenServicio", "EstatusOrdenServicio"})
|
|
'End If
|
|
'ObjOS.Dispose()
|
|
'DdlSubProyecto.DataBind()
|
|
'DdlEstatusOS.DataBind()
|
|
|
|
CargarCentrosDeCosto(Nothing, DdlSubProyecto, Nothing, LblSubProyecto, AplicaTodos:="Seleccione Uno")
|
|
|
|
End Sub
|
|
Private Sub CargaTiposOrden()
|
|
Dim ObjOS As New ClsOS
|
|
DdlTipoOrdenOS.Items.Clear()
|
|
|
|
If ObjOS.GetTipoOrdenesServicios(UsuarioActual.CveEmpresa) Then
|
|
DdlTipoOrdenOS.DataSource = ObjOS.DtResultados
|
|
Else
|
|
DdlTipoOrdenOS.DataSource = Nothing
|
|
End If
|
|
ObjOS.Dispose()
|
|
DdlTipoOrdenOS.DataBind()
|
|
DdlTipoOrdenOS.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
End Sub
|
|
Private Sub CargaDatos()
|
|
Dim ObjOS As New ClsOS()
|
|
Dim IDOSDetalle As Integer = 1
|
|
Dim SeFacturara As String = ""
|
|
|
|
If ObjOS.GetOrdenesServicios(CveOS, -1, -1, -1, -1, UsuarioActual.CveEmpresa) Then
|
|
If ObjOS.DtResultados.Rows.Count > 0 Then
|
|
'Pestaña Datos Generales
|
|
ViewState("CveCliente") = ObjOS.CveCliente.ToString
|
|
CargaCliente(CveCliente)
|
|
|
|
TxtDescripcion.Text = ObjOS.Descripcion
|
|
TxtSolicito.Text = ObjOS.PersonaSolicito
|
|
CveOsDetalle = ObjOS.CveOSDetalle
|
|
|
|
TxtFechaRecibido.Text = ObjOS.FechaRecepcion.ToString("dd/MM/yyyy")
|
|
TxtFechaCita.Text = ObjOS.FechaCita.ToDateTime.ToString("yyyy-MM-dd HH:mm:ss").Replace(" ", "T")
|
|
CveFolio = ObjOS.Folio
|
|
LblFolio.Text = ObjOS.Folio.ToString
|
|
|
|
DdlSubProyecto.SelectedValueExist(ObjOS.CveSubProyecto)
|
|
DdlTipoOrdenOS.SelectedValueExist(ObjOS.CveOSTipo)
|
|
DdlSucursalCliente.SelectedValueExist(ObjOS.CveClienteSucursal)
|
|
|
|
TxtDireccion.Text = ObjOS.DtResultados.Rows(0)("DireccionOS").ToString
|
|
|
|
TipoEstatus = GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("TipoEstatus", String.Format("CveEstatusOrdenServicio = {0}", ObjOS.CveEstatusOrdenServicio), "CveEstatusOrdenServicio ASC").ToEntero
|
|
SeFacturara = GlobalDTTipoOrdenServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("SeFacturara", String.Format("CveOrdenServicioTipo = {0}", ObjOS.CveOSTipo))
|
|
CveTecnico = ObjOS.CveUsuarioAtendio
|
|
CargarEstatusDelUsuario(TipoEstatus)
|
|
CveVenta = ObjOS.CveVenta
|
|
|
|
'Dim validacionTieneEstatus As Integer = EstatusOSDelUsuario.FiltraParametros(String.Format("CveEstatusOrdenServicio = {0}", ObjOS.CveEstatusOrdenServicio)).Rows.Count
|
|
|
|
'If validacionTieneEstatus > 0 Then
|
|
' DdlEstatusOS.Items.Clear()
|
|
' DdlEstatusOS.DataSource = EstatusOSDelUsuario
|
|
' DdlEstatusOS.DataBind()
|
|
'Else
|
|
CargaEstatusOS()
|
|
'DdlEstatusOS.Enabled = False
|
|
'End If
|
|
|
|
DdlEstatusOS.SelectedValue = ObjOS.CveEstatusOrdenServicio.ToString
|
|
|
|
'If TipoEstatus = 2 Then
|
|
' LnkTecnico.Visible = True
|
|
'End If
|
|
|
|
If TipoEstatus = 3 Then
|
|
'DisableAll()
|
|
|
|
'If SeFacturara = "True" Then
|
|
' HplFacturar.Visible = True
|
|
' If ObjOS.CveCotizacion > 0 Then
|
|
' HplFacturar.NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveVenta={0}", ObjOS.CveCotizacion)
|
|
' Else
|
|
' HplFacturar.NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveOS={0}", CveOS)
|
|
' End If
|
|
'End If
|
|
|
|
ElseIf TipoEstatus = 4 Then
|
|
'DisableAll()
|
|
If SeFacturara = "True" Then
|
|
HplFacturar.Visible = True
|
|
If ObjOS.CveCotizacion > 0 Then
|
|
HplFacturar.NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveVenta={0}", ObjOS.CveCotizacion)
|
|
Else
|
|
HplFacturar.NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveOS={0}", CveOS)
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
DivCliente.Attributes.Add("class", "col-md-8")
|
|
DivFolio.Visible = True
|
|
DivEstatus.Visible = True
|
|
DivMateriales.Visible = True
|
|
ImgImprimir.Visible = True
|
|
|
|
|
|
|
|
TxtTelefono.Text = ObjOS.Telefono
|
|
DdlModeloAuto.SelectedValueExist(ObjOS.CveModeloAuto)
|
|
TxtAnio.Text = ObjOS.Año
|
|
|
|
|
|
DdlMedico.SelectedValueExist(ObjOS.CveMedico)
|
|
DdlProcedimiento.SelectedValueExist(ObjOS.CveProcedimiento)
|
|
DdlTipoVenta.SelectedValueExist(ObjOS.CveTipoVenta)
|
|
|
|
TxtPaciente.Text = ObjOS.Paciente
|
|
TxtIdentificadorCliente.Text = ObjOS.IdentificadorCliente
|
|
|
|
CargaEventoBitacora()
|
|
CargaHistorial()
|
|
|
|
|
|
If CveVenta > 0 And TipoEstatus.Contiene(1, 2, 3) Then
|
|
LnkAccionesDevolucion.Visible = True
|
|
End If
|
|
Else
|
|
Alert("La Orden de Servicio Solicitado no existe, por favor revise su búsqueda.", TipoMensaje.MsgAdvertencia)
|
|
BtnGuardar.Enabled = False
|
|
End If
|
|
End If
|
|
ObjOS.Dispose()
|
|
End Sub
|
|
Private Sub CargaVenta()
|
|
Dim ObjVentas As New ClsVentas
|
|
If ObjVentas.GetVenta(CveCotizacion, UsuarioActual.CveEmpresa) Then
|
|
If ObjVentas.DtResultados IsNot Nothing AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then
|
|
'Carga Cliente
|
|
ViewState("CveCliente") = ObjVentas.DtResultados.Rows(0)("CveCliente").ToString.ToEntero
|
|
CargaCliente(CveCliente)
|
|
End If
|
|
If ObjVentas.GetVentaDetalle(CveCotizacion) Then
|
|
Dim Cons As Integer = 1
|
|
For Each dr As DataRow In ObjVentas.DtResultados.Rows
|
|
Dim drt As DataRow = TmpDT.NewRow
|
|
|
|
If dr("CveTipoPS").ToString.ToEntero = 2 Then
|
|
drt("Consecutivo") = Cons
|
|
drt("CveOSDetalle") = -1
|
|
drt("CvePS") = dr("CvePS")
|
|
drt("PS") = dr("PS")
|
|
drt("Cantidad") = dr("Cantidad")
|
|
drt("Observaciones") = dr("Obs")
|
|
drt("SeFacturara") = True
|
|
drt("SeSuperviso") = False
|
|
drt("Archivo") = -1
|
|
drt("CveCuentaEquipo") = "-1"
|
|
drt("CuentaEquipoMostrar") = "Cuentas y/o Equipos"
|
|
drt("Especificaciones") = "-1"
|
|
|
|
TmpDT.Rows.Add(drt)
|
|
Cons = Cons + 1
|
|
Else
|
|
|
|
End If
|
|
|
|
Next
|
|
GvPS.DataSource = TmpDT
|
|
GvPS.DataBind()
|
|
End If
|
|
'CargaDetalle
|
|
End If
|
|
|
|
'BtnVerCotizacion.Visible = True
|
|
|
|
ObjVentas.Dispose()
|
|
End Sub
|
|
Private Sub CargaDetalles()
|
|
Dim ObjOrdenServicio As New ClsOS()
|
|
Dim IDOSDetalle As Integer = 1
|
|
|
|
CreaDT()
|
|
|
|
|
|
If ObjOrdenServicio.GetOrdenesServiciosDetalle(CveOS) Then
|
|
If ObjOrdenServicio.DtResultados IsNot Nothing Then
|
|
For Each Row As DataRow In ObjOrdenServicio.DtResultados.Rows
|
|
CveOsDetalle = Row("CveOSDetalle").ToString.ToEntero
|
|
Dim ComentarioTecnico As String = Row("ComentarioTecnico").ToString
|
|
Dim Especificaciones As String = "-1"
|
|
Dim EspecificacionesLink As String = ""
|
|
|
|
Dim SeFacturara As Boolean
|
|
Dim Estatus As Boolean
|
|
Dim SeSuperviso As Boolean
|
|
|
|
|
|
If Row("SeFacturaraTexto").ToString = "Sí" Then SeFacturara = True Else SeFacturara = False
|
|
If Row("Estatus").ToString = "Activo" Then Estatus = True Else Estatus = False
|
|
If Row("SeSuperviso").ToString = "Sí" Then SeSuperviso = True Else SeSuperviso = False
|
|
|
|
|
|
CargaMaterialesDetalle(CveOsDetalle, IDOSDetalle, IDOSDetalle)
|
|
For Each R As DataRow In TmpDTMaterialesDetalle.FiltraParametros(String.Format("CveConsecutivoDetalle = {0}", IDOSDetalle)).Rows
|
|
If Materiales = "-1" Then Materiales = "" Else Materiales = Materiales + "<br>"
|
|
Materiales = Materiales + String.Format("{0} {1}", R("Cantidad").ToString, R("PS").ToString)
|
|
Next
|
|
|
|
CargaEspecificaciones(CveOsDetalle, IDOSDetalle, IDOSDetalle)
|
|
For Each R As DataRow In TmpDTCaracteristica.FiltraParametros(String.Format("CveConsecutivoDetalle = {0}", IDOSDetalle)).Rows
|
|
If Especificaciones = "-1" Then Especificaciones = "" Else Especificaciones = Especificaciones + ","
|
|
Especificaciones = Especificaciones + String.Format("{0}:{1}:{2}:{3}:{4}:{5}", R("CveCaracteristica").ToString, R("Caracteristica").ToString, R("CveCaracteristicaTipo"), R("CveOpcion").ToString, R("Opcion").ToString, R("Valor").ToString)
|
|
Next
|
|
RegistraScript(String.Format("CargaEspecificacionesPop('{0}');", Especificaciones))
|
|
|
|
AddPS(IDOSDetalle, Row("CveOSDetalle").ToString.ToEntero, Row("CvePS").ToString.ToEntero, Row("PS").ToString, Row("Cantidad").ToString.ToEntero, Row("ObservacionesServicio").ToString, Especificaciones, EspecificacionesLink, ComentarioTecnico,
|
|
Row("CveCuentaEquipo").ToString.ToEntero, Row("CuentaEquipo").ToString, Row("FechaAtencion").ToString, Row("CveUsuarioAtendio").ToString.ToEntero, Row("UsuarioAtendio").ToString, Row("FechaTermino").ToString, Row("FechaEntrega").ToString, Row("CveUsuarioEntrego").ToString.ToEntero,
|
|
Row("UsuarioEntrego").ToString, SeFacturara, SeSuperviso, Estatus, Row("Archivo").ToString, If(Materiales = "-1", "", Materiales), Row("CveUsuarioRecibio").ToString.ToEntero)
|
|
IDOSDetalle = IDOSDetalle + 1
|
|
Next
|
|
End If
|
|
End If
|
|
|
|
ObjOrdenServicio.Dispose()
|
|
End Sub
|
|
Private Sub CargaEspecificaciones(CveOsDetalle As Integer, Consecutivo As Integer, CveConsecutivoDetalle As Integer)
|
|
Dim ObjEspecificaciones As New ClsGenerales
|
|
|
|
If ObjEspecificaciones.GetCaracteristicasValores(-1, -1, -1, CveOsDetalle, -1, -1, 5, UsuarioActual.CveEmpresa, OpcionListado:=1) Then
|
|
For Each RowE As DataRow In ObjEspecificaciones.DtResultados.Rows
|
|
|
|
Dim Row As DataRow = Nothing
|
|
Row = TmpDTCaracteristica.NewRow()
|
|
|
|
Row("CveCaracteristicaValor") = RowE("CveCaracteristicaValor").ToString.ToEntero
|
|
Row("CveConsecutivo") = Consecutivo
|
|
Row("CveConsecutivoDetalle") = CveConsecutivoDetalle
|
|
Row("CveOSDetalle") = CveOsDetalle
|
|
Row("CveConsecutivo") = Consecutivo
|
|
Row("CveCaracteristica") = RowE("CveCaracteristica")
|
|
Row("Caracteristica") = RowE("Caracteristica")
|
|
Row("CveCaracteristicaTipo") = RowE("CveCaracteristicaTipo")
|
|
Row("CveOpcion") = RowE("CveCaracteristicaOpcion")
|
|
Row("Opcion") = RowE("CaracteristicaOpcion")
|
|
Row("Valor") = RowE("CaracteristicaValor")
|
|
|
|
TmpDTCaracteristica.Rows.Add(Row)
|
|
Consecutivo = Consecutivo + 1
|
|
Next
|
|
End If
|
|
|
|
UpBodyGv.Update()
|
|
ObjEspecificaciones.Dispose()
|
|
End Sub
|
|
Private Sub CargaMaterialesDetalle(CveOsDetalle As Integer, Consecutivo As Integer, CveConsecutivoDetalle As Integer)
|
|
Dim ObjMateriales As New ClsOS
|
|
|
|
If ObjMateriales.GetDetalleMateriales(CveOsDetalle, CveOS, -1) Then
|
|
|
|
For Each RowE As DataRow In ObjMateriales.DtResultados.Rows
|
|
|
|
Dim Row As DataRow = Nothing
|
|
Row = TmpDTMaterialesDetalle.NewRow()
|
|
|
|
|
|
|
|
Row("CveConsecutivo") = Consecutivo
|
|
Row("CveConsecutivoDetalle") = CveConsecutivoDetalle
|
|
Row("CveOSDetalle") = CveOsDetalle
|
|
Row("CveMaterial") = RowE("CveMaterial")
|
|
Row("Cantidad") = RowE("Cantidad")
|
|
Row("CveClasificacion") = RowE("CveClasificacion")
|
|
Row("CvePS") = RowE("CvePS")
|
|
Row("CveUM") = RowE("CveUM")
|
|
Row("CveMovimiento") = RowE("CveMovimiento")
|
|
Row("Clasificacion") = RowE("Clasificacion")
|
|
Row("PS") = RowE("PS")
|
|
Row("UM") = RowE("UM")
|
|
|
|
TmpDTMaterialesDetalle.Rows.Add(Row)
|
|
Consecutivo = Consecutivo + 1
|
|
Next
|
|
End If
|
|
UpAddMateriales.Update()
|
|
ObjMateriales.Dispose()
|
|
End Sub
|
|
Private Sub CargaMateriales()
|
|
Dim objOS As New ClsOS
|
|
Dim Opcion As Integer = If(DdlTipoVenta.SelectedValue.Contiene("2", "3"), 2, 1)
|
|
If objOS.GetDetalleMateriales(-1, CveOS, Opcion, True) Then
|
|
GvMateriales.DataSource = objOS.DtResultados
|
|
End If
|
|
objOS.Dispose()
|
|
GvMateriales.DataBind()
|
|
|
|
If (GvMateriales.Rows.Count > 0) Then
|
|
GvMateriales.UseAccessibleHeader = True
|
|
GvMateriales.HeaderRow.TableSection = TableRowSection.TableHeader
|
|
RegistraScript("OrdenarGVMateriales();")
|
|
End If
|
|
End Sub
|
|
Private Sub CargaEstatusOS()
|
|
DdlEstatusOS.Items.Clear()
|
|
DdlEstatusOS.DataSource = GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa)
|
|
DdlEstatusOS.DataBind()
|
|
'DdlEstatusOS.SelectedValue = GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveEstatusOrdenServicio", "TipoEstatus = 1", "Orden ASC")
|
|
End Sub
|
|
Private Sub CargaPS(CveClasificacion As Integer, Objeto As DropDownList)
|
|
Objeto.Items.Clear()
|
|
Objeto.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacion, Estatus:=1, AplicaParaVenta:=1).FiltraParametros(" CveTipoPS=1")
|
|
Objeto.DataBind()
|
|
Objeto.Items.Insert(0, New ListItem("*** Actualizar listado de Productos o Servicios ***", "-2"))
|
|
Objeto.Items.Insert(0, New ListItem("Seleccione el Servicio", "-1"))
|
|
End Sub
|
|
Private Sub CargaPsMateriales()
|
|
'Objeto.Items.Clear()
|
|
'Objeto.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacion, Estatus:=1)
|
|
'Objeto.DataBind()
|
|
'Objeto.Items.Insert(0, New ListItem("*** Actualizar listado de Productos o Servicios ***", "-2"))
|
|
'Objeto.Items.Insert(0, New ListItem("Seleccione el Producto", "-1"))
|
|
'Carga Productos
|
|
|
|
DdlPS.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1")
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then
|
|
'DdlPS.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacion.SelectedValue)
|
|
DdlPS.SelectedText = ""
|
|
DdlPS.SelectedValue = "-1"
|
|
Else
|
|
DdlPS.ddl.Items.Clear()
|
|
'DdlPS.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacion.SelectedValue.ToEntero)
|
|
DdlPS.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa)
|
|
DdlPS.ddl.DataBind()
|
|
DdlPS.ddl.Items.Insert(0, New ListItem("Seleccione el Producto", "-1"))
|
|
End If
|
|
End Sub
|
|
Private Sub CargaCliente(CveCliente As Integer, Optional Estatus As Integer = 1, Optional CargaPublicoGeneral As Boolean = False)
|
|
|
|
|
|
|
|
Dim ObjCliente As New ClsClientes()
|
|
|
|
Dim NombreCliente As String = "-1"
|
|
|
|
|
|
If CargaPublicoGeneral Then
|
|
NombreCliente = "PUBLICO EN GENERAL"
|
|
End If
|
|
|
|
If ObjCliente.GetClientes(CveCliente, NombreCliente, "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, Estatus) Then
|
|
If ObjCliente.DtResultados.Rows.Count > 0 Then
|
|
|
|
If CargaPublicoGeneral Then
|
|
Me.CveCliente = ObjCliente.CveCliente
|
|
End If
|
|
|
|
TxtCodigo.Text = ObjCliente.Codigo
|
|
LblCliente.Text = String.Format("<a Class=""Texto"" href=""/Ventas/Clientes.aspx?CveCliente={0}"">{1}</a>", CveCliente, ObjCliente.Nombre)
|
|
NombreCliente = ObjCliente.Nombre
|
|
ClienteDireccion = ObjCliente.Direccion
|
|
ClienteCiudad = ObjCliente.Ciudad
|
|
ClienteColonia = ObjCliente.Colonia
|
|
ClienteEstado = ObjCliente.Estado
|
|
TelefonoCliente = ObjCliente.Telefono
|
|
TxtSolicito.Text = ObjCliente.Contacto
|
|
ClienteRFC = ObjCliente.RFC
|
|
ClienteMail = ObjCliente.Mail
|
|
|
|
|
|
|
|
If ObjCliente.GetSucursales(CveCliente) Then
|
|
DdlSucursalCliente.DataSource = ObjCliente.DtResultados
|
|
DdlClienteSucursalCuenta.DataSource = ObjCliente.DtResultados
|
|
|
|
If ObjCliente.DtResultados.Rows.Count > 0 Then
|
|
DivClienteSucursal.Visible = True
|
|
DivClienteSucursalCuenta.Visible = True
|
|
Else
|
|
DivClienteSucursal.Visible = False
|
|
DivClienteSucursalCuenta.Visible = False
|
|
End If
|
|
Else
|
|
DivClienteSucursal.Visible = False
|
|
DdlSucursalCliente.DataSource = Nothing
|
|
|
|
DivClienteSucursalCuenta.Visible = False
|
|
DdlClienteSucursalCuenta.DataSource = Nothing
|
|
End If
|
|
DdlSucursalCliente.DataBind()
|
|
DdlClienteSucursalCuenta.DataBind()
|
|
|
|
CargarCuentasEquipos(CveCliente)
|
|
CargaCuentas()
|
|
Else
|
|
Alert("El cliente solicitado no existe, por favor intente de nuevo.", TipoMensaje.MsgError)
|
|
End If
|
|
End If
|
|
ObjCliente.Dispose()
|
|
UpDetalleOS.Update()
|
|
End Sub
|
|
Private Sub CreaDT()
|
|
TmpDT = New DataTable
|
|
TmpDT.Columns.Add("Consecutivo", GetType(Integer))
|
|
TmpDT.Columns.Add("CveOSDetalle", GetType(Integer))
|
|
TmpDT.Columns.Add("CvePS", GetType(Integer))
|
|
TmpDT.Columns.Add("Cantidad", GetType(Integer))
|
|
TmpDT.Columns.Add("PS", GetType(String))
|
|
TmpDT.Columns.Add("CveCuentaEquipo", GetType(Integer))
|
|
TmpDT.Columns.Add("CuentaEquipoMostrar", GetType(String))
|
|
TmpDT.Columns.Add("FechaAtencion", GetType(String))
|
|
TmpDT.Columns.Add("CveUsuarioAtendio", GetType(Integer))
|
|
TmpDT.Columns.Add("UsuarioAtendio", GetType(String))
|
|
TmpDT.Columns.Add("FechaTermino", GetType(String))
|
|
TmpDT.Columns.Add("FechaEntrega", GetType(String))
|
|
TmpDT.Columns.Add("CveUsuarioEntrego", GetType(Integer))
|
|
TmpDT.Columns.Add("CveUsuarioRecibio", GetType(Integer))
|
|
TmpDT.Columns.Add("UsuarioEntrego", GetType(String))
|
|
TmpDT.Columns.Add("SeFacturara", GetType(String))
|
|
TmpDT.Columns.Add("SeSuperviso", GetType(String))
|
|
TmpDT.Columns.Add("Archivo", GetType(String))
|
|
TmpDT.Columns.Add("Especificaciones", GetType(String))
|
|
TmpDT.Columns.Add("EspecificacionesLink", GetType(String))
|
|
TmpDT.Columns.Add("EspecificacionesMostrar", GetType(String))
|
|
TmpDT.Columns.Add("Materiales", GetType(String))
|
|
TmpDT.Columns.Add("MaterialesLink", GetType(String))
|
|
TmpDT.Columns.Add("Observaciones", GetType(String))
|
|
TmpDT.Columns.Add("Estatus", GetType(String))
|
|
TmpDT.Columns.Add("ComentarioTecnico", GetType(String))
|
|
End Sub
|
|
Private Sub AddPS(Consecutivo As Integer, CveOSDetalle As Integer, CvePS As Integer, PS As String, Cantidad As Integer, Observaciones As String, Especificaciones As String, EspecificacionesLink As String, ComentarioTecnico As String,
|
|
CveCuentaEquipo As Integer, CuentaEquipoMostrar As String, FechaAtencion As String, CveUsuarioAtendio As Integer, UsuarioAtendio As String, FechaTermino As String, FechaEntrega As String, CveUsuarioEntrego As Integer,
|
|
UsuarioEntrego As String, SeFacturara As Boolean, SeSuperviso As Boolean, Estatus As Boolean, Archivo As String, Materiales As String, CveUsuarioRecibio As Integer)
|
|
|
|
Dim Row As DataRow = Nothing
|
|
Row = TmpDT.NewRow()
|
|
|
|
Row("Consecutivo") = Consecutivo
|
|
Row("CveOSDetalle") = CveOSDetalle
|
|
Row("CvePS") = CvePS
|
|
Row("Cantidad") = Cantidad
|
|
Row("PS") = PS
|
|
Row("CveCuentaEquipo") = If(CveCuentaEquipo > 0, CveCuentaEquipo, -1)
|
|
If CveCuentaEquipo <> -1 Then Row("CuentaEquipoMostrar") = CuentaEquipoMostrar Else Row("CuentaEquipoMostrar") = "Cuentas y/o Equipos"
|
|
Row("FechaAtencion") = FechaAtencion
|
|
Row("CveUsuarioAtendio") = CveUsuarioAtendio
|
|
Row("UsuarioAtendio") = UsuarioAtendio
|
|
Row("FechaTermino") = FechaTermino
|
|
Row("FechaEntrega") = FechaEntrega
|
|
Row("CveUsuarioRecibio") = CveUsuarioRecibio
|
|
Row("CveUsuarioEntrego") = CveUsuarioEntrego
|
|
Row("UsuarioEntrego") = UsuarioEntrego
|
|
Row("SeFacturara") = SeFacturara.ToString
|
|
Row("SeSuperviso") = SeSuperviso.ToString
|
|
Row("Archivo") = Archivo
|
|
Row("Observaciones") = Observaciones
|
|
If Especificaciones <> "-1" Then
|
|
Row("EspecificacionesMostrar") = EspecificacionesParaMostrar(Especificaciones, "<br />")
|
|
End If
|
|
Row("Especificaciones") = Especificaciones
|
|
Row("ComentarioTecnico") = ComentarioTecnico
|
|
Row("Estatus") = Estatus.ToString
|
|
Row("Materiales") = Materiales
|
|
CveConsecutivo = Consecutivo
|
|
|
|
TmpDT.Rows.Add(Row)
|
|
|
|
'Dim DR = TmpDT.Select($"CveOSDetalle = {CveOSDetalle}")
|
|
'DR(0)("Observaciones") = String.Format("{0} <br> {1}", DR(0)("Observaciones"), ComentarioTecnico)
|
|
'TmpDT.AcceptChanges()
|
|
|
|
If CveOSDetalle > 0 Then
|
|
GvPSTecnico.DataSource = TmpDT
|
|
GvPSTecnico.DataBind()
|
|
End If
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(151).ToString = "1" Then
|
|
LblTecnicoActual.Text = TmpDT.MAX("UsuarioAtendio")
|
|
DivTecnicoGV.Visible = False
|
|
Else
|
|
DivTecnicoGV.Visible = True
|
|
End If
|
|
|
|
GvPS.DataSource = TmpDT
|
|
GvPS.DataBind()
|
|
End Sub
|
|
'Private Sub CargaClasificaciones()
|
|
' DdlClasificacion.DataSource = GlobalDTClasificaciones.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
' DdlClasificacion.DataBind()
|
|
' '' DdlClasificacion.Items.Insert(0, New ListItem("Seleccione la Clasificación", "-1"))
|
|
'End Sub
|
|
Private Sub CargaFolios(CveSub As Integer)
|
|
Dim ObjFolios As New ClsGralFolios()
|
|
If ObjFolios.GetFolios() Then
|
|
Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa & " AND CveSubProyecto = " & CveSub & " AND TipoDocto = 'OS' AND Estado = 'Activo'")
|
|
If DT.Rows.Count > 0 Then
|
|
ViewState("CveFolio") = DT.Rows(0)("CveFolio").ToString.ToEntero
|
|
ViewState("FolioActual") = DT.Rows(0)("FActual").ToString
|
|
'ltlFolio.Text = DT.Rows(0)("FActual").ToString
|
|
'BtnEmitirImprimir.Enabled = True
|
|
'UpFacturar.Update()
|
|
Else
|
|
Alert("No tiene registrados Folios para Órdenes de Servicio en este subproyecto.", TipoMensaje.MsgAdvertencia)
|
|
'BtnEmitir.Enabled = False
|
|
'UpFacturar.Update()
|
|
End If
|
|
DT.Dispose()
|
|
End If
|
|
ObjFolios.Dispose()
|
|
End Sub
|
|
Private Sub UpdatePS(Consecutivo As Integer, CveOSDetalle As Integer, CvePS As Integer, PS As String, Cantidad As Integer, Observaciones As String, Especificaciones As String, EspecificacionesLink As String, Materiales As String, MaterialesLink As String,
|
|
ComentarioTecnico As String, CveCuentaEquipo As Integer, CuentaEquipoMostrar As String, FechaAtencion As String, CveUsuarioAtendio As Integer, UsuarioAtendio As String, FechaTermino As String, FechaEntrega As String, CveUsuarioEntrego As Integer,
|
|
UsuarioEntrego As String, SeFacturara As Boolean, SeSuperviso As Boolean, Estatus As Boolean, Archivo As String)
|
|
|
|
TmpDT.Rows(Consecutivo)("CveOSDetalle") = CveOSDetalle
|
|
TmpDT.Rows(Consecutivo)("CvePS") = CvePS
|
|
|
|
TmpDT.Rows(Consecutivo)("PS") = PS
|
|
TmpDT.Rows(Consecutivo)("Observaciones") = Observaciones
|
|
TmpDT(Consecutivo)("EspecificacionesMostrar") = EspecificacionesParaMostrar(Especificaciones, "<br />")
|
|
TmpDT.Rows(Consecutivo)("Especificaciones") = Especificaciones
|
|
TmpDT.Rows(Consecutivo)("EspecificacionesLink") = EspecificacionesLink.Replace("EsThickbox", "ClientIDLink=@ClientIDLink&EsThickbox")
|
|
|
|
If Materiales <> "-1" Then
|
|
TmpDT.Rows(Consecutivo)("MaterialesMostrar") = MaterialesParaMostrar(Materiales, "<br />")
|
|
Else
|
|
TmpDT.Rows(Consecutivo)("Materiales") = ""
|
|
End If
|
|
|
|
TmpDT.Rows(Consecutivo)("ComentarioTecnico") = ComentarioTecnico
|
|
TmpDT.Rows(Consecutivo)("CveCuentaEquipo") = If(CveCuentaEquipo > 0, CveCuentaEquipo, -1)
|
|
If CveCuentaEquipo <> -1 Then TmpDT(Consecutivo)("CuentaEquipoMostrar") = CuentaEquipoMostrar Else TmpDT(Consecutivo)("CuentaEquipoMostrar") = "Cuentas y/o Equipos"
|
|
|
|
TmpDT.Rows(Consecutivo)("FechaAtencion") = FechaAtencion
|
|
TmpDT.Rows(Consecutivo)("CveUsuarioAtendio") = CveUsuarioAtendio
|
|
TmpDT.Rows(Consecutivo)("UsuarioAtendio") = UsuarioAtendio
|
|
TmpDT.Rows(Consecutivo)("FechaTermino") = FechaTermino
|
|
TmpDT.Rows(Consecutivo)("FechaEntrega") = FechaEntrega
|
|
TmpDT.Rows(Consecutivo)("CveUsuarioEntrego") = CveUsuarioEntrego
|
|
TmpDT.Rows(Consecutivo)("UsuarioEntrego") = UsuarioEntrego
|
|
TmpDT.Rows(Consecutivo)("SeFacturara") = SeFacturara.ToString
|
|
TmpDT.Rows(Consecutivo)("SeSuperviso") = SeSuperviso.ToString
|
|
TmpDT.Rows(Consecutivo)("Estatus") = Estatus.ToString
|
|
TmpDT.Rows(Consecutivo)("Archivo") = Archivo
|
|
TmpDT.Rows(Consecutivo)("Cantidad") = Cantidad
|
|
|
|
GvPS.DataSource = TmpDT
|
|
GvPS.DataBind()
|
|
End Sub
|
|
|
|
Private Sub CargarEstatusDelUsuario(tipoEstatus As Integer)
|
|
|
|
'Dim ObjEstatusPermisos As New ClsOS
|
|
|
|
'If ObjEstatusPermisos.GetEstatusUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveSubProyecto:=DdlSubProyecto.SelectedValue.ToEntero) Then
|
|
' EstatusOSDelUsuario = ObjEstatusPermisos.DtResultados
|
|
' Dim PermisoEstatus As New DataTable
|
|
' PermisoEstatus = ObjEstatusPermisos.DtResultados.FiltraParametros("TipoEstatus = 1")
|
|
' If PermisoEstatus.Rows.Count = 0 Then
|
|
' UpGuardar.Visible = False
|
|
' End If
|
|
'End If
|
|
|
|
'ObjEstatusPermisos.Dispose()
|
|
|
|
|
|
|
|
|
|
|
|
'OS Estatus Inicial
|
|
If tipoEstatus = 1 And UsuarioActual.TienePermisoProceso(366) Then
|
|
Exit Sub
|
|
End If
|
|
|
|
'OS Estatus Asignación
|
|
If tipoEstatus = 2 And UsuarioActual.TienePermisoProceso(367) Then
|
|
Exit Sub
|
|
End If
|
|
|
|
'OS Estatus Proceso
|
|
If tipoEstatus = 3 And UsuarioActual.TienePermisoProceso(368) Then
|
|
Exit Sub
|
|
End If
|
|
|
|
'OS Estatus Terminado
|
|
If tipoEstatus = 4 And UsuarioActual.TienePermisoProceso(369) Then
|
|
Exit Sub
|
|
End If
|
|
|
|
'OS Estatus Cancelada
|
|
If tipoEstatus = 5 And UsuarioActual.TienePermisoProceso(370) Then
|
|
Exit Sub
|
|
End If
|
|
|
|
UpGuardar.Visible = False
|
|
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "BUSCAR CLIENTE "
|
|
Protected Sub BtnBuscarCliente_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnBuscarCliente.Click
|
|
ViewState("CveCliente") = HdnCveCliente.Value.ToEntero
|
|
CargaCliente(HdnCveCliente.Value.ToEntero)
|
|
If DdlPSDetalle.SelectedIndex > 0 Then
|
|
DdlPSDetalle_SelectedIndexChanged(sender, e)
|
|
DdlPSDetalle.Focus()
|
|
Else
|
|
TxtCantidad.Focus()
|
|
End If
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "P E R M I S O S"
|
|
Private Sub PermisosSegunEstatus()
|
|
Dim TipoEstatus = GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor(String.Format("TipoEstatus", "CveEstatusOrdenServicio = {0}", "CveEstatusOrdenServicio ASC", DdlEstatusOS.SelectedValue.ToEntero))
|
|
|
|
Select Case TipoEstatus.ToEntero
|
|
Case 1
|
|
'Inicial
|
|
Case 2
|
|
'Proceso
|
|
Case 3
|
|
'Terminada
|
|
GvPS.Columns(10).Visible = False
|
|
Case 4, 5
|
|
'4-Cancelada, 5-Entregada
|
|
BtnGuardar.Enabled = False
|
|
GvPS.Enabled = False
|
|
|
|
BtnBuscarCliente.Enabled = False
|
|
TxtSolicito.Enabled = False
|
|
TxtDescripcion.Enabled = False
|
|
TxtFechaRecibido.Enabled = False
|
|
DdlPSDetalle.Enabled = False
|
|
TxtObservacionesServicioDetalle.Enabled = False
|
|
|
|
TxtComentarioTecnico.ReadOnly = True
|
|
BtnComentarioTecnico.Enabled = False
|
|
|
|
GvPS.Columns(6).Visible = False
|
|
GvPS.Columns(7).Visible = False
|
|
GvPS.Columns(8).Visible = False
|
|
GvPS.Columns(9).Visible = False
|
|
GvPS.Columns(10).Visible = False
|
|
GvPS.Columns(11).Visible = False
|
|
GvPS.Columns(12).Visible = False
|
|
GvPS.Columns(13).Visible = False
|
|
End Select
|
|
|
|
'permitir avanzar el estatus solo uno adelante
|
|
For i As Integer = 0 To DdlEstatusOS.Items.Count - 1
|
|
If DdlEstatusOS.Items.IndexOf(DdlEstatusOS.Items(i)) <> DdlEstatusOS.SelectedIndex And
|
|
DdlEstatusOS.Items.IndexOf(DdlEstatusOS.Items(i)) <> DdlEstatusOS.SelectedIndex + 1 Then
|
|
DdlEstatusOS.Items(i).Enabled = False
|
|
End If
|
|
Next
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "M E T O D O S"
|
|
Protected Sub Guardar(Entregar As Boolean)
|
|
|
|
Dim FechaCita As DateTime = MinFecha
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(578).ToEntero = 1 Then
|
|
If Not IsDate(TxtFechaCita.Text.Replace(",", "")) Then
|
|
Alert("El campo Fecha De Cita no es valido.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
FechaCita = TxtFechaCita.Text.Replace(",", "").ToDateTime
|
|
End If
|
|
|
|
|
|
|
|
Dim ObjOrdenServicio As New ClsOS()
|
|
Dim ObjGenerales As New ClsGenerales(ObjOrdenServicio.IniciaTransacSQL)
|
|
MensajeAlert = New StringBuilder
|
|
|
|
Dim Errores As Boolean = False
|
|
Dim EstatusOrdenServicio As Integer = GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveEstatusOrdenServicio", "TipoEstatus = 1").ToEntero
|
|
Dim DirectorioEmpresa = UsuarioActual.Empresa.Ruta
|
|
|
|
|
|
If Not CveOS > 0 Then
|
|
Dim bandera As Integer = DdlEstatusOS.SelectedValue.ToEntero
|
|
If Not ObjOrdenServicio.AddOrdenesServicios(CveCliente, DdlSubProyecto.SelectedValue.ToEntero, TxtSolicito.Text, TxtFechaRecibido.Text.ToDateTime, TxtDescripcion.Text, UsuarioActual.CveUsuario, EstatusOrdenServicio,
|
|
UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCotizacion, -1, -1, DdlTipoOrdenOS.SelectedValue.ToEntero, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero,
|
|
Direccion:=TxtDireccion.Text, Telefono:=TxtTelefono.Text, CveModeloAuto:=DdlModeloAuto.SelectedValue.ToEntero, Año:=TxtAnio.Text, CveMedico:=DdlMedico.SelectedValue.ToEntero,
|
|
CveProcedimiento:=DdlProcedimiento.SelectedValue.ToEntero, CveTipoVenta:=DdlTipoVenta.SelectedValue.ToEntero, FechaCita:=FechaCita,
|
|
Paciente:=TxtPaciente.Text.Trim, IdentificadorCliente:=TxtIdentificadorCliente.Text.Trim) Then
|
|
Errores = True
|
|
End If
|
|
CargaCliente(CveCliente)
|
|
For Each Row As DataRow In TmpDT.Rows
|
|
If Not Errores Then
|
|
Dim Consecutivo As Integer = Row("Consecutivo").ToString.ToEntero
|
|
Dim CvePS As Integer = Row("CvePS").ToString.ToEntero
|
|
Dim Observaciones As String = Row("Observaciones").ToString
|
|
Dim SeFacturara As Boolean = CBool(Row("SeFacturara").ToString)
|
|
Dim CveCuentaEquipo As Integer = Row("CveCuentaEquipo").ToString.ToEntero
|
|
Dim ComentarioTecnico As String = Row("ComentarioTecnico").ToString
|
|
Dim Cantidad As Integer = Row("Cantidad").ToString.ToEntero
|
|
Dim Archivo As New System.IO.FileInfo(String.Format("{0}OS\Temp\{1}", UsuarioActual.Empresa.Ruta, Row("Archivo").ToString))
|
|
|
|
CveOsDetalle = ObjOrdenServicio.AddOrdenesServiciosDetalle(ObjOrdenServicio.CveOS, CvePS, Cantidad, -1, -1, Observaciones, False, True, False, CveCuentaEquipo, "-1", "-1", "-1", ComentarioTecnico, UsuarioActual.CveUsuario, Archivo:=Archivo.Name)
|
|
|
|
If CveOsDetalle > 0 Then
|
|
If Archivo.Name <> "-1" AndAlso Archivo.Exists Then
|
|
'Cambiar el nombre del archivo de CveUsuario-Consecutivo.ext a CveOS-Consecutivo.ext
|
|
Dim ArchivoFinal As String = String.Format("OS{0}-{1}{2}", ObjOrdenServicio.CveOS, Consecutivo, System.IO.Path.GetExtension(Archivo.Extension))
|
|
'Mover el archivo de los temporales a OS
|
|
System.IO.File.Move(UsuarioActual.Empresa.Ruta & "\OS\Temp\" & Archivo.Name, UsuarioActual.Empresa.Ruta & "\OS\Archivos\" & ArchivoFinal)
|
|
|
|
If Not ObjOrdenServicio.UpdateOrdenesServiciosDetalleArchivo(ArchivoFinal, ObjOrdenServicio.CveOSDetalle) Then
|
|
Errores = True
|
|
End If
|
|
End If
|
|
|
|
For Each RowE As DataRow In TmpDTCaracteristica.FiltraParametros(String.Format("CveConsecutivoDetalle = {0}", Consecutivo)).Rows
|
|
Dim CveCaracteristica As Integer = RowE("CveCaracteristica").ToString.ToEntero
|
|
Dim CveOpcion As Integer = RowE("CveOpcion").ToString.ToEntero
|
|
Dim Valor As String = RowE("Valor").ToString
|
|
|
|
If Not ObjGenerales.AddUpdateCaracteristicasValores(CveCaracteristica, CveOpcion, Valor, UsuarioActual.CveUsuario, CveOSDetalle:=CveOsDetalle, CvePs:=CvePS) Then
|
|
Errores = True
|
|
End If
|
|
|
|
Next
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(578) = "" Then
|
|
For Each RowM As DataRow In TmpDTMaterialesDetalle.FiltraParametros(String.Format("CveConsecutivoDetalle = {0}", Consecutivo)).Rows
|
|
Dim CveClasificacion As Integer = RowM("CveClasificacion").ToString.ToEntero
|
|
Dim CvePSMaterial As Integer = RowM("CvePS").ToString.ToEntero
|
|
Dim CveUnidadMedidaM As Integer = RowM("CveUM").ToString.ToEntero
|
|
Dim CantidadMaterial As Integer = RowM("Cantidad").ToString.ToEntero
|
|
|
|
If Not ObjOrdenServicio.AddUpdateDetalleMateriales(-1, CveOsDetalle, CantidadMaterial, CveUnidadMedidaM, CveClasificacion, CvePSMaterial, True) Then
|
|
Errores = True
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
|
|
Else
|
|
Errores = True
|
|
End If
|
|
|
|
End If
|
|
Next
|
|
|
|
|
|
|
|
'If Not Errores Then
|
|
|
|
' Dim TipoEstatusSeleccionado As Integer = EstatusOSDelUsuario.FiltroPrimeroValor("TipoEstatus", String.Format("CveEstatusOrdenServicio = {0}", DdlEstatusOS.SelectedValue), "Orden ASC").ToEntero
|
|
' If TipoEstatusSeleccionado = 3 Then
|
|
|
|
' Dim objEventos As New ClsOIEventos(ObjOrdenServicio.IniciaTransacSQL)
|
|
|
|
' If Not objEventos.FinalizaEvento(NowADS(), 3, "", -1, CveOS) Then
|
|
' Errores = True
|
|
' End If
|
|
|
|
|
|
' End If
|
|
'End If
|
|
|
|
If Not Errores Then
|
|
ViewState("CveOS") = ObjOrdenServicio.CveOS
|
|
ViewState("Folio") = ObjOrdenServicio.Folio
|
|
CveFolio = ObjOrdenServicio.Folio
|
|
|
|
'MENSAJE PRINCIPAL
|
|
MensajeAlert.AppendFormat(String.Format("<br/>La Orden de Servicio: <b>{0}</b> se generó correctamente.<br/><br/>", ObjOrdenServicio.Folio))
|
|
MensajeAlert.AppendFormat("<ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar PDF</a></li></ul><br/>", Encripta(String.Format("OP=OS&CVEOS={0}", ObjOrdenServicio.CveOS)))
|
|
|
|
|
|
Dim Liga = $"document.location.href=""/OS/RepOrdenesServicios.aspx"";"
|
|
|
|
ObjOrdenServicio.Commit()
|
|
|
|
Alert(MensajeAlert.ToString, TipoMensaje.MsgInformacion, Liga)
|
|
LimpiaDatos()
|
|
Else
|
|
ObjOrdenServicio.RollBack()
|
|
End If
|
|
|
|
Else
|
|
If CveTecnico = UsuarioActual.CveUsuario Or UpGuardar.Visible Then
|
|
|
|
If ObjOrdenServicio.UpdateOrdenesServicios(TxtSolicito.Text, TxtFechaRecibido.Text, TxtDescripcion.Text, UsuarioActual.CveUsuario, DdlEstatusOS.SelectedValue.ToEntero, CveOS, UsuarioActual.CveUsuario,
|
|
DdlTipoOrdenOS.SelectedValue.ToEntero, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero, Direccion:=TxtDireccion.Text, Telefono:=TxtTelefono.Text,
|
|
CveModeloAuto:=DdlModeloAuto.SelectedValue.ToEntero, Año:=TxtAnio.Text, CveMedico:=DdlMedico.SelectedValue.ToEntero,
|
|
CveProcedimiento:=DdlProcedimiento.SelectedValue.ToEntero, CveTipoVenta:=DdlTipoVenta.SelectedValue.ToEntero, FechaCita:=FechaCita,
|
|
Paciente:=TxtPaciente.Text.Trim, IdentificadorCliente:=TxtIdentificadorCliente.Text.Trim) Then
|
|
For Each Row As DataRow In TmpDT.Rows
|
|
If Not Errores Then
|
|
Dim CvePS As Integer = Row("CvePS").ToString.ToEntero
|
|
Dim CveOSDetalle As Integer = Row("CveOSDetalle").ToString.ToEntero
|
|
Dim Observaciones As String = Row("Observaciones").ToString
|
|
Dim SeFacturara As Boolean = CBool(Row("SeFacturara").ToString)
|
|
Dim Estatus As Boolean = CBool(Row("Estatus").ToString)
|
|
Dim SeSuperviso As Boolean = CBool(Row("SeSuperviso").ToString)
|
|
Dim CveCuentaEquipo As Integer = Row("CveCuentaEquipo").ToString.ToEntero
|
|
Dim Especificaciones As String = Row("Especificaciones").ToString
|
|
Dim ComentarioTecnico As String = Row("ComentarioTecnico").ToString
|
|
Dim Cantidad As Integer = Row("Cantidad").ToString.ToEntero
|
|
|
|
|
|
|
|
Dim fname As String = ""
|
|
|
|
If File.Exists(Row("Archivo").ToString) Then
|
|
Dim Archivo As New System.IO.FileInfo("")
|
|
fname = Archivo.Name
|
|
End If
|
|
|
|
|
|
Dim CveUsuarioEntrego As Integer = If(Entregar = True, UsuarioActual.CveUsuario, -1)
|
|
Dim FechaEntrega As String = If(Entregar = True, NowADS().ToString("dd/MM/yyy"), "-1")
|
|
Dim Consecutivo As Integer = Row("Consecutivo").ToString.ToEntero
|
|
CveConsecutivo = Consecutivo
|
|
|
|
If CveOSDetalle > 0 Then
|
|
If Not ObjOrdenServicio.UpdateOrdenesServiciosDetalle(CvePS, Cantidad, CveUsuarioEntrego, Observaciones, SeSuperviso, SeFacturara, Estatus, ComentarioTecnico, CveCuentaEquipo, fname, "-1", FechaEntrega, CveOSDetalle, CveOS) Then
|
|
Errores = True
|
|
End If
|
|
Else
|
|
CveOSDetalle = ObjOrdenServicio.AddOrdenesServiciosDetalle(CveOS, CvePS, Cantidad, -1, CveUsuarioEntrego, Observaciones, SeSuperviso, SeFacturara, Estatus, CveCuentaEquipo, "-1", "-1", FechaEntrega, ComentarioTecnico, UsuarioActual.CveUsuario, Archivo:=fname)
|
|
If Not CveOSDetalle > 0 Then Errores = True
|
|
|
|
End If
|
|
|
|
|
|
|
|
If File.Exists(Row("Archivo").ToString) Then
|
|
Dim Archivo As New System.IO.FileInfo("")
|
|
If Archivo.Name <> "-1" Then
|
|
'Cambiar el nombre del archivo de CveUsuario-Consecutivo.ext a CveOS-Consecutivo.ext
|
|
Dim ArchivoFinal As New System.IO.FileInfo(String.Format("{0}OS\Archivos\OS{1}-{2}{3}", UsuarioActual.Empresa.Ruta, CveOS, Consecutivo, System.IO.Path.GetExtension(Archivo.Extension)))
|
|
|
|
If ArchivoFinal.Exists() Then
|
|
ArchivoFinal.Delete()
|
|
End If
|
|
|
|
'Mover el archivo de los temporales a OS
|
|
System.IO.File.Move(UsuarioActual.Empresa.Ruta & "\OS\Temp\" & Archivo.Name, UsuarioActual.Empresa.Ruta & "\OS\Archivos\" & ArchivoFinal.Name)
|
|
|
|
If Not ObjOrdenServicio.UpdateOrdenesServiciosDetalleArchivo(ArchivoFinal.Name, ObjOrdenServicio.CveOSDetalle) Then
|
|
Errores = True
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
|
|
If TmpDTCaracteristica.FiltraParametros(String.Format("CveConsecutivoDetalle = {0}", Consecutivo)).Rows.Count > 0 Then
|
|
|
|
For Each RowE As DataRow In TmpDTCaracteristica.FiltraParametros(String.Format("CveConsecutivoDetalle = {0}", Consecutivo)).Rows
|
|
Dim CveCaracteristicaValor As Integer = RowE("CveCaracteristicaValor").ToString.ToEntero
|
|
Dim CveCaracteristica As Integer = RowE("CveCaracteristica").ToString.ToEntero
|
|
Dim CveOpcion As Integer = RowE("CveOpcion").ToString.ToEntero
|
|
Dim Valor As String = RowE("Valor").ToString
|
|
|
|
If Not ObjGenerales.AddUpdateCaracteristicasValores(CveCaracteristica, CveOpcion, Valor, UsuarioActual.CveUsuario, CveCaracteristicaValor:=CveCaracteristicaValor, CveOSDetalle:=CveOSDetalle) Then
|
|
Errores = True
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(578) = "" Then
|
|
If TmpDTMaterialesDetalle.FiltraParametros(String.Format("CveOSDetalle = {0}", CveOSDetalle)).Rows.Count > 0 Then
|
|
For Each RowM As DataRow In TmpDTMaterialesDetalle.FiltraParametros(String.Format("CveOSDetalle = {0}", CveOSDetalle)).Rows
|
|
Dim CveMaterial As Integer = RowM("CveMaterial").ToString.ToEntero
|
|
|
|
Dim CveClasificacion As Integer = RowM("CveClasificacion").ToString.ToEntero
|
|
Dim CvePSMaterial As Integer = RowM("CvePS").ToString.ToEntero
|
|
Dim CveUnidadMedidaM As Integer = RowM("CveUM").ToString.ToEntero
|
|
Dim CantidadMaterial As Integer = RowM("Cantidad").ToString.ToEntero
|
|
|
|
If Not ObjOrdenServicio.AddUpdateDetalleMateriales(CveMaterial, CveOSDetalle, CantidadMaterial, CveUnidadMedidaM, CveClasificacion, CvePSMaterial, SeFacturara) Then
|
|
Errores = True
|
|
End If
|
|
Next
|
|
End If
|
|
End If
|
|
|
|
|
|
|
|
End If
|
|
|
|
Next
|
|
Else
|
|
Errores = True
|
|
End If
|
|
Else
|
|
Alert("No tienes permisos para modificar esta Orden de Servicio", TipoMensaje.MsgAdvertencia)
|
|
Errores = True
|
|
End If
|
|
|
|
|
|
If Not Errores Then
|
|
|
|
Dim TipoEstatusSeleccionado As Integer = EstatusOSDelUsuario.FiltroPrimeroValor("TipoEstatus", String.Format("CveEstatusOrdenServicio = {0}", DdlEstatusOS.SelectedValue), "Orden ASC").ToEntero
|
|
If TipoEstatusSeleccionado = 4 Then
|
|
|
|
Dim objEventos As New ClsOIEventos(ObjOrdenServicio.IniciaTransacSQL)
|
|
|
|
If Not objEventos.FinalizaEvento(NowADS(), 3, "", -1, CveOS, UsuarioActual.CveUsuario) Then
|
|
Errores = True
|
|
End If
|
|
|
|
|
|
End If
|
|
End If
|
|
|
|
|
|
|
|
If Not Errores Then
|
|
ObjOrdenServicio.Commit()
|
|
|
|
Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion)
|
|
UpDatos.Update()
|
|
CargaHistorial()
|
|
UpHistorial.Update()
|
|
Else
|
|
ObjOrdenServicio.RollBack()
|
|
End If
|
|
End If
|
|
ObjOrdenServicio.Dispose()
|
|
ObjGenerales.Dispose()
|
|
|
|
End Sub
|
|
Protected Sub BtnBuscarEspecificaciones_Click(sender As Object, e As EventArgs)
|
|
Dim btn As Button = DirectCast(sender, Button)
|
|
Dim DdlGVPS As DropDownList = Nothing
|
|
|
|
Dim gvr As GridViewRow = DirectCast(btn.NamingContainer, GridViewRow)
|
|
|
|
Dim ClientIDLink As String = GvPS.Rows(gvr.RowIndex).FCButton("BtnBuscarEspecificaciones").ClientID
|
|
GvPS.Rows(gvr.RowIndex).FCHiddenField("HndEspecificaciones").Value = HdnEspecificaciones.Value
|
|
|
|
Dim Especificaciones As String = HdnEspecificaciones.Value.ToString
|
|
Dim EspecificacionesMostrar As String
|
|
If Especificaciones <> "-1" Then
|
|
EspecificacionesMostrar = EspecificacionesParaMostrar(Especificaciones, "<br />")
|
|
Else
|
|
EspecificacionesMostrar = "ESPECIFICACIONES"
|
|
End If
|
|
End Sub
|
|
Protected Function EspecificacionesParaMostrar(Especificaciones As String, CambioLinea As String) As String
|
|
Dim Mostrar As String = ""
|
|
If Especificaciones <> "-1" Then
|
|
For Each S As String In Especificaciones.Split(CChar(","))
|
|
If Mostrar <> "" Then
|
|
Mostrar = Mostrar + CambioLinea
|
|
End If
|
|
Dim Esp As String() = S.Split(CChar(":"))
|
|
If Esp(2) = "Sí" Then
|
|
Mostrar = String.Format("{0} {1}-{2}", Mostrar, S.Split(CChar(":"))(1), S.Split(CChar(":"))(4))
|
|
Else
|
|
Mostrar = String.Format("{0} {1}-{2}", Mostrar, S.Split(CChar(":"))(1), S.Split(CChar(":"))(5))
|
|
End If
|
|
Next
|
|
End If
|
|
Return Mostrar
|
|
End Function
|
|
Protected Function MaterialesParaMostrar(Materiales As String, CambioLinea As String) As String
|
|
Dim Mostrar As String = ""
|
|
If Materiales <> "-1" Then
|
|
For Each S As String In Materiales.Split(CChar(","))
|
|
If Mostrar <> "" Then
|
|
Mostrar = Mostrar + CambioLinea
|
|
End If
|
|
Dim Esp As String() = S.Split(CChar(":"))
|
|
' Mostrar = String.Format("{0} {1}-{2}", Mostrar, S.Split(CChar(":"))(2), S.Split(CChar(":"))(4))
|
|
Mostrar = String.Format("{0} {1}", Mostrar, S)
|
|
Next
|
|
End If
|
|
Return Mostrar
|
|
End Function
|
|
Protected Sub DownloadFile(ByVal sender As Object, ByVal e As EventArgs)
|
|
Dim filePath As String = String.Format("{0}{1}", UsuarioActual.Empresa.Ruta, CType(sender, LinkButton).CommandArgument)
|
|
Dim Archivo As New System.IO.FileInfo(filePath)
|
|
|
|
HttpContext.Current.Response.Clear()
|
|
HttpContext.Current.Response.ClearContent()
|
|
HttpContext.Current.Response.ContentType = "application/octet-stream"
|
|
HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" + Path.GetFileName(filePath))
|
|
HttpContext.Current.Response.AddHeader("Content-Length", Archivo.Length.ToString())
|
|
HttpContext.Current.Response.TransmitFile(filePath)
|
|
HttpContext.Current.Response.Flush()
|
|
HttpContext.Current.Response.End()
|
|
|
|
Archivo = Nothing
|
|
End Sub
|
|
Protected Sub BtnPSEspecificaciones_Click(sender As Object, e As EventArgs) Handles BtnPSEspecificaciones.Click
|
|
Dim Especificaciones As String = ""
|
|
Dim Mostrar As String = ""
|
|
Especificaciones = HdnEspecificaciones.Value.ToString
|
|
Dim EspecificacionesMostrar As String
|
|
If Especificaciones <> "-1" Then
|
|
EspecificacionesMostrar = EspecificacionesParaMostrar(Especificaciones, "<br />")
|
|
Else
|
|
EspecificacionesMostrar = "ESPECIFICACIONES"
|
|
End If
|
|
LtlPSEspecificaciones.Text = EspecificacionesMostrar
|
|
End Sub
|
|
Protected Sub BtnGuardar_Click(sender As Object, e As System.EventArgs) Handles BtnGuardar.Click
|
|
Guardar(False)
|
|
End Sub
|
|
Private Sub LimpiaDatos()
|
|
LblCliente.Text = ""
|
|
TxtSolicito.Text = ""
|
|
TxtFechaRecibido.Text = ""
|
|
TxtDescripcion.Text = ""
|
|
CargaEstatusOS()
|
|
|
|
GvPS.DataSource = Nothing
|
|
GvPS.DataBind()
|
|
|
|
UpDatos.Update()
|
|
End Sub
|
|
Protected Sub imgEstatus_Click(sender As Object, e As EventArgs)
|
|
Dim Row As GridViewRow = DirectCast(DirectCast(sender, Control).NamingContainer, GridViewRow)
|
|
|
|
Dim Estatus = TmpDT(Row.RowIndex)("Estatus").ToString
|
|
|
|
If Estatus = "False" Then
|
|
TmpDT.Rows(Row.RowIndex)("Estatus") = "True"
|
|
Row.FCLinkButton("imgEstatus").CssClass = "btn btn-circle btn-sm green"
|
|
Else
|
|
Row.FCLinkButton("imgEstatus").Enabled = False
|
|
TmpDT.Rows(Row.RowIndex)("Estatus") = "False"
|
|
Row.FCLinkButton("imgEstatus").CssClass = "btn btn-circle btn-sm red"
|
|
End If
|
|
End Sub
|
|
Private Sub BtnAddGvDetalle_Click(sender As Object, e As EventArgs) Handles BtnAddGvDetalle.Click
|
|
Dim ObjOS As New ClsOS
|
|
Dim TieneError = False
|
|
|
|
If CveCliente > 0 Then
|
|
If DdlPSDetalle.SelectedValue.ToEntero > 0 Then
|
|
Dim FileExtension As String = ""
|
|
Dim Filesgral As List(Of Archivo) = TxtArchivo.getfiles().Archivos
|
|
Dim Filename As String = ""
|
|
|
|
For Each fileItem As Archivo In Filesgral
|
|
FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "")
|
|
Filename = fileItem.filename
|
|
Next
|
|
|
|
If HdnModalidad.Value = "I" Then
|
|
|
|
Dim Consecutivo As Integer = TmpDT.Rows.Count + 1
|
|
|
|
Dim Archivo As New System.IO.FileInfo(String.Format("{0}OS\Temp\OS{1}-{2}.{3}", UsuarioActual.Empresa.Ruta, UsuarioActual.CveUsuario, Consecutivo, FileExtension))
|
|
If Archivo.Exists() Then
|
|
Archivo.Delete()
|
|
End If
|
|
|
|
If Filename <> "" Then
|
|
Filename.FilesMove(String.Format("OS{0}-{1}", UsuarioActual.CveUsuario, Consecutivo), String.Format("{0}OS\Temp", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:=False)
|
|
End If
|
|
|
|
AddPS(Consecutivo, -1, DdlPSDetalle.SelectedValue.ToEntero, DdlPSDetalle.SelectedItem.Text, TxtCantidad.Text.ToEntero, TxtObservacionesServicioDetalle.Text, HdnEspecificaciones.Value.ToString, LtlPSEspecificaciones.Text, "",
|
|
DdlIdentificador.SelectedValue.ToEntero, DdlIdentificador.SelectedItem.Text, "-1", -1, "-1", "-1", "-1", -1, "-1", ChkSeFacturara.Checked, ChkSeSuperviso.Checked, False, If(Filename <> "", Archivo.Name, "-1"), "", UsuarioActual.CveUsuario)
|
|
|
|
|
|
|
|
Else
|
|
Dim Consecutivo As Integer = TmpDT.Rows.Count - 1
|
|
|
|
Dim Archivo As New System.IO.FileInfo(String.Format("{0}OS\Temp\OS{1}-{2}.{3}", UsuarioActual.Empresa.Ruta, UsuarioActual.CveUsuario, Consecutivo, FileExtension))
|
|
If Archivo.Exists() Then
|
|
Archivo.Delete()
|
|
'File.Delete(String.Format("\Empresas\{0}\OI\Temp\OI{1}{2}.{3}", CveEmpresaActual, UsuarioActual.CveUsuario, DtDetalle.Rows.Count, FileExtension))
|
|
End If
|
|
|
|
If Filename <> "" Then
|
|
Filename.FilesMove(String.Format("OS{0}-{1}", UsuarioActual.CveUsuario, Consecutivo), String.Format("Empresas\{0}\OS\Temp", UsuarioActual.CveEmpresa))
|
|
End If
|
|
|
|
UpdatePS(Consecutivo, CveOsDetalle, DdlPSDetalle.SelectedValue.ToEntero, DdlPSDetalle.SelectedItem.Text, TxtCantidad.Text.ToEntero, TxtObservacionesServicioDetalle.Text, HdnEspecificaciones.Value.ToString, LtlPSEspecificaciones.Text, "-1", "-1", "",
|
|
DdlIdentificador.SelectedValue.ToEntero, DdlIdentificador.SelectedItem.Text, "-1", CveUsuarioAtendio, "-1", "-1", "-1", -1, "-1", True, False, False, If(Filename <> "", Archivo.Name, "-1"))
|
|
End If
|
|
|
|
If Not TieneError Then
|
|
DdlPSDetalle.SelectedIndex = 0
|
|
LtlPSEspecificaciones.Text = ""
|
|
|
|
GvValoresCaracteristicas.DataSource = Nothing
|
|
GvValoresCaracteristicas.DataBind()
|
|
|
|
TxtObservacionesServicioDetalle.Text = ""
|
|
TxtArchivo.Text = "[]"
|
|
Session("OS") = String.Empty
|
|
UpDatos.Update()
|
|
UpBodyGv.Update()
|
|
RegistraScript("$('#DivGvDetalle').modal('hide');LimpiaModalGv();")
|
|
End If
|
|
|
|
Else
|
|
Alert("Seleccione un Producto o Servicio", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
Else
|
|
Alert("Seleccione el cliente", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End Sub
|
|
Public Sub imgE_Click(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
HdnModalidad.Value = "U"
|
|
TxtCantidad.Text = (GvRow.DataKey("Cantidad"))
|
|
TxtObservacionesServicioDetalle.Text = (GvRow.DataKey("Observaciones"))
|
|
DdlPSDetalle.SelectedValueExist(GvRow.DataKey("CvePS"))
|
|
DdlIdentificador.SelectedValueExist(GvRow.DataKey("CveCuentaEquipo"))
|
|
ChkSeFacturara.Checked = If(GvRow.DataKey("SeFacturara").ToString = "True", True, False)
|
|
ChkSeSuperviso.Checked = If(GvRow.DataKey("SeSuperviso").ToString = "True", True, False)
|
|
CveUsuarioAtendio = GvRow.DataKey("CveUsuarioAtendio").ToEntero
|
|
|
|
LtlPSEspecificaciones.Text = (GvRow.DataKey("EspecificacionesMostrar"))
|
|
|
|
If GvRow.DataKey("CveOSDetalle").ToString.ToEntero > 0 Then CveOsDetalle = GvRow.DataKey("CveOSDetalle").ToEntero Else CveOsDetalle = -1
|
|
For Each RowE As DataRow In TmpDTCaracteristica.Rows
|
|
If GvRow.DataKey("CveOSDetalle").ToString.ToEntero > 0 Then
|
|
GvValoresCaracteristicas.DataSource = TmpDTCaracteristica.FiltraParametros(String.Format("CveOSDetalle = {0}", GvRow.DataKey("CveOSDetalle")))
|
|
Else
|
|
GvValoresCaracteristicas.DataSource = TmpDTCaracteristica.FiltraParametros(String.Format("CveConsecutivoDetalle = {0}", GvRow.DataKey("Consecutivo")))
|
|
End If
|
|
Next
|
|
GvValoresCaracteristicas.DataBind()
|
|
|
|
BtnAddGvDetalle.Text = "Actualizar"
|
|
UpAddGvDetalle.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivGvDetalle"))
|
|
End Sub
|
|
Public Sub showDivGV_Click(sender As Object, e As EventArgs)
|
|
'Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
|
|
If CveOS > 0 And TipoEstatus > 1 And CveUsuarioAtendioCount < 0 Then
|
|
Alert("Ya no se pueden registrar detalles en esta orden de servicio", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
If CveCliente > 0 Then
|
|
HdnModalidad.Value = "I"
|
|
CveOsDetalle = -1
|
|
GvValoresCaracteristicas.DataSource = Nothing
|
|
GvValoresCaracteristicas.DataBind()
|
|
BtnAddGvDetalle.Text = "Agregar"
|
|
CveConsecutivo += 1
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(136) = "1" Then
|
|
DivCuentaDetalle.Visible = False
|
|
DdlCuentaEquipo.Visible = False
|
|
Else
|
|
DivCuentaDetalle.Visible = True
|
|
DivCuentaDetalle.Visible = True
|
|
End If
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
|
|
DivCuentaDetalle.Visible = False
|
|
End If
|
|
|
|
UpBodyGv.Update()
|
|
UpFooterGv.Update()
|
|
RegistraScript("showDivGv();")
|
|
Else
|
|
Alert("Ingrese un Cliente", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End Sub
|
|
Private Sub ChkArchivo_CheckedChanged(sender As Object, e As EventArgs) Handles ChkArchivo.CheckedChanged
|
|
TabArchivo.Visible = ChkArchivo.Checked
|
|
|
|
UpBodyGv.Update()
|
|
End Sub
|
|
Private Sub DisableAll()
|
|
TxtCodigo.Enabled = False
|
|
TxtSolicito.Enabled = False
|
|
TxtDescripcion.Enabled = False
|
|
TxtFechaRecibido.Enabled = False
|
|
DdlSubProyecto.Enabled = False
|
|
DdlEstatusOS.Enabled = False
|
|
DdlTipoOrdenOS.Enabled = False
|
|
DdlSucursalCliente.Enabled = False
|
|
GvPS.Enabled = False
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "E V E N T O - B I T A C O R A"
|
|
Protected Sub GVEventoBitacora_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEB.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.RowIndex = 0 Then
|
|
e.Row.Cells(0).Width = 200
|
|
e.Row.Cells(1).Width = 200
|
|
e.Row.Cells(2).Width = 100
|
|
e.Row.Cells(3).Width = 500
|
|
End If
|
|
e.Row.Cells(2).HorizontalAlign = HorizontalAlign.Left
|
|
End If
|
|
End Sub
|
|
Protected Sub BtnGuardarEventoBitacora_Click(sender As Object, e As EventArgs) Handles BtnGuardarEventoBitacora.Click
|
|
Dim ObjEventoBitacora As New ClsOIEventos
|
|
|
|
Dim FileExtension As String = "-1"
|
|
Dim filesgral As List(Of Archivo) = Anexo.getfiles().Archivos
|
|
Dim filemove As String = ""
|
|
|
|
For Each fileItem As Archivo In filesgral
|
|
FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "")
|
|
filemove = fileItem.filename
|
|
Next
|
|
|
|
If ObjEventoBitacora.AddEventoBitacora(TxtEventoDescripcion.Text.Trim, String.Format(".{0}", FileExtension), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, CveOS, -1, -1, -1, -1) Then
|
|
If filemove <> "" Then
|
|
filemove.FilesMove(String.Format("OI{0}", ObjEventoBitacora.CveEvento.ToString), String.Format("{0}OI", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:=False)
|
|
End If
|
|
|
|
GvEB.DataSource = ObjEventoBitacora.DtResultados
|
|
TxtEventoDescripcion.Text = ""
|
|
Anexo.Text = "[]"
|
|
Alert("La bitácora/observación se guardó correctamente", TipoMensaje.MsgInformacion)
|
|
RegistraScript("$('#ModalBitacora').modal('hide')", "hidemodal")
|
|
End If
|
|
ObjEventoBitacora.Dispose()
|
|
GvEB.DataBind()
|
|
|
|
UPEventoBitacora.Update()
|
|
CargaEventoBitacora()
|
|
UPAddEventoBitacora.Update()
|
|
End Sub
|
|
Private Sub CargaEventoBitacora()
|
|
Dim ObjEventoBitacora As New ClsOIEventos()
|
|
If ObjEventoBitacora.GetAgendaBitacora(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveOS:=CveOS) Then
|
|
GvEB.DataSource = ObjEventoBitacora.DtResultados.FiltraParametros("CveTipoEvento = 6 OR CveTipoEvento = 2")
|
|
Else
|
|
GvEB.DataSource = Nothing
|
|
End If
|
|
GvEB.DataBind()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "H I S T O R I A L"
|
|
Private Sub CargaHistorial()
|
|
Dim ObjGral As New ClsGenerales
|
|
If ObjGral.GetHistorialBitacora(-1, -1, -1, CveOS, -1, -1, -1, UsuarioActual.CveEmpresa) Then
|
|
GvHistorial.DataSource = ObjGral.DtResultados
|
|
Else
|
|
GvHistorial.DataSource = Nothing
|
|
End If
|
|
GvHistorial.DataBind()
|
|
ObjGral.Dispose()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "GV PS"
|
|
Protected Sub GvPS_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles GvPS.RowCommand
|
|
If e.CommandName = "Estatus" Then
|
|
Dim objOrdenServicio As New ClsOS
|
|
|
|
Dim index As Integer = (e.CommandArgument).ToString.ToEntero
|
|
Dim gvr As GridViewRow = GvPS.Rows(index)
|
|
|
|
Dim Consecutivo As Integer = gvr.FCLiteral("LtlConsecutivo").Text.ToEntero
|
|
Dim Row As DataRow = TmpDT.FiltraParametros("Consecutivo = " + Consecutivo.ToString).Rows(0)
|
|
|
|
Dim Estatus As Boolean = CBool(Row("Estatus"))
|
|
'Dim CveUsuarioAtendio As Integer = If(Estatus = True, UsuarioActual.CveUsuario, -1)
|
|
Dim CveUsuarioAtendio As Integer = Row("CveUsuarioAtendio").ToString.ToEntero
|
|
Dim CveOSDetalle As Integer = Row("CveOSDetalle").ToString.ToEntero
|
|
|
|
If CveUsuarioAtendio > 0 Then
|
|
If objOrdenServicio.UpdateOrdenesServiciosDetalleEstatus(Estatus, CveUsuarioAtendio, "-1", CveOSDetalle) Then
|
|
For i As Integer = 0 To TmpDT.Rows.Count - 1
|
|
If TmpDT.Rows(i)("Consecutivo").ToString.ToEntero = Consecutivo Then
|
|
TmpDT.Rows(i)("Estatus") = Estatus
|
|
TmpDT.Rows(i)("CveUsuarioAtendio") = CveUsuarioAtendio
|
|
End If
|
|
Next
|
|
GvPS.DataSource = TmpDT
|
|
GvPS.DataBind()
|
|
|
|
Dim DetallesPendientes As Integer = TmpDT.COUNT("Estatus", "Estatus = 'False'").ToEntero
|
|
|
|
Dim TipoEstatusSeleccionado As Integer = EstatusOSDelUsuario.FiltroPrimeroValor("TipoEstatus", String.Format("CveEstatusOrdenServicio = {0}", DdlEstatusOS.SelectedValue), "Orden ASC").ToEntero
|
|
|
|
If DetallesPendientes = 0 AndAlso TipoEstatusSeleccionado = 2 Then
|
|
'Se estatus de OS a TERMINADO
|
|
DdlEstatusOS.SelectedValueExist(GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveEstatusOrdenServicio", "TipoEstatus = 3", "CveEstatusOrdenServicio ASC"))
|
|
DdlEstatusOS_SelectedIndexChanged(sender, New EventArgs)
|
|
|
|
Dim Liga As String = $"document.location.href=""/OS/RepOrdenesServicios.aspx"";"
|
|
If objOrdenServicio.UpdateOrdenesServiciosEstatus(GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveEstatusOrdenServicio", "TipoEstatus = 3", "CveEstatusOrdenServicio ASC").ToEntero, UsuarioActual.CveUsuario, CveOS) Then
|
|
Alert("Se cambió el Estatus de la Orden de Servicio", TipoMensaje.MsgInformacion, Liga)
|
|
End If
|
|
Else
|
|
'Se estatus de OS a En PROCESO
|
|
DdlEstatusOS.SelectedValueExist(GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveEstatusOrdenServicio", "TipoEstatus = 2", "CveEstatusOrdenServicio ASC"))
|
|
DdlEstatusOS_SelectedIndexChanged(sender, New EventArgs)
|
|
End If
|
|
UpDatos.Update()
|
|
UpEstatus.Update()
|
|
End If
|
|
Else
|
|
Alert("No tiene asignada esta tarea", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
|
|
objOrdenServicio.Dispose()
|
|
|
|
|
|
|
|
|
|
End If
|
|
End Sub
|
|
Protected Sub GvPS_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvPS.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If CveOS < 0 Then
|
|
e.Row.FCLinkButton("imgE").Visible = True
|
|
Else
|
|
If e.Row.DataKey("CveUsuarioAtendio").ToEntero = UsuarioActual.CveUsuario Then
|
|
Dim URL As String = String.Format("javascript:LimpiaModal();SetValue('hdnCveOSDetalle', '{0}');SetObjects('{1}');ShowDivRegistro();return false;", e.Row.DBCampo("CveOSDetalle").ToEntero, e.Row.DBCampo("ComentarioTecnico").ToString)
|
|
'GeneroLigas
|
|
Dim Liga As String = String.Format("<a class=""LinkBlanco"" href=""{0}"">", URL)
|
|
e.Row.VerticalAlign = VerticalAlign.Middle
|
|
e.Row.FCLinkButton("imgComentario").OnClientClick = URL
|
|
|
|
'Cambia Estatus
|
|
Dim Estado As String = TmpDT(e.Row.RowIndex)("Estatus").ToString
|
|
|
|
e.Row.FCLinkButton("imgEstatus").Attributes.Add("data-toggle", "confirmation")
|
|
If Estado = "False" Then
|
|
e.Row.FCLinkButton("imgEstatus").Attributes.Add("data-original-title", "¿Está seguro que ya esta terminada en su totalidad esta tarea?")
|
|
Else
|
|
e.Row.FCLinkButton("imgEstatus").Enabled = False
|
|
e.Row.FCLinkButton("imgEstatus").Attributes.Remove("data-toggle")
|
|
End If
|
|
|
|
e.Row.FCLinkButton("imgE").Visible = True
|
|
e.Row.FCLinkButton("imgD").Visible = False
|
|
e.Row.FCLinkButton("imgComentario").Visible = True
|
|
e.Row.FCLinkButton("imgEstatus").Visible = True
|
|
e.Row.FCLinkButton("LtlMateriales").Visible = True
|
|
Else
|
|
If e.Row.DataKey("CveUsuarioRecibio").ToEntero = UsuarioActual.CveUsuario And TipoEstatus = 1 Then
|
|
e.Row.FCLinkButton("imgE").Visible = True
|
|
e.Row.FCLinkButton("imgD").Visible = False
|
|
Else
|
|
e.Row.FCLinkButton("imgE").Visible = False
|
|
e.Row.FCLinkButton("imgD").Visible = False
|
|
End If
|
|
|
|
e.Row.FCLinkButton("imgComentario").Visible = False
|
|
e.Row.FCLinkButton("imgEstatus").Visible = False
|
|
e.Row.FCLinkButton("LtlMateriales").Visible = False
|
|
End If
|
|
End If
|
|
|
|
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
|
|
e.Row.FCLabel("LtlCuentaEquipoS").Visible = False
|
|
End If
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(578) = "1" Then
|
|
e.Row.FCHtmlTableRow("TREspecificaiones").Visible = False
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
Protected Sub GvPS_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvPS.RowDeleting
|
|
Dim TieneError As Boolean = False
|
|
Dim DbRow As DataRow = Nothing
|
|
Dim ObjOS As New ClsOS
|
|
ObjOS.IniciaTransacSQL()
|
|
|
|
Dim CveOSDetalle As Integer = GvPS.Rows(e.RowIndex).DataKey("CveOSDetalle").ToEntero
|
|
|
|
If CveOSDetalle > 0 Then
|
|
If TmpDTMaterialesDetalle.FiltraParametros(String.Format("CveOSDetalle = {0}", CveOSDetalle)).Rows.Count > 0 Then
|
|
For Each RowM As DataRow In TmpDTMaterialesDetalle.FiltraParametros(String.Format("CveOSDetalle = {0}", CveOSDetalle)).Rows
|
|
Dim CveMaterial As Integer = RowM("CveMaterial").ToString.ToEntero
|
|
If Not ObjOS.RemoveDetalleMateriales(CveMaterial, CveOSDetalle) Then
|
|
TieneError = True
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
If ObjOS.RemoveOrdenesServiciosDetalle(CveOSDetalle) Then
|
|
GvPS.EditIndex = -1
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
|
|
End If
|
|
|
|
If Not TieneError Then
|
|
ObjOS.Commit()
|
|
DbRow = TmpDT.Rows(e.RowIndex)
|
|
TmpDT.Rows.Remove(DbRow)
|
|
Else
|
|
ObjOS.RollBack()
|
|
End If
|
|
|
|
GvPS.DataSource = TmpDT
|
|
GvPS.DataBind()
|
|
ObjOS.Dispose()
|
|
UpDetalleOS.Update()
|
|
End Sub
|
|
Protected Sub GvPS_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GvPS.RowUpdating
|
|
Dim CveClasificacion As Integer = GvPS.Rows(e.RowIndex).FCDropDownList("DdlClasificacion").SelectedValue.ToEntero
|
|
Dim Clasificacion As String = GvPS.Rows(e.RowIndex).FCDropDownList("DdlClasificacion").SelectedItem.Text
|
|
Dim CvePS As Integer = GvPS.Rows(e.RowIndex).FCDropDownList("DdlPS").SelectedValue.ToEntero
|
|
Dim PS As String = GvPS.Rows(e.RowIndex).FCDropDownList("DdlPS").SelectedItem.Text
|
|
Dim Observaciones As String = GvPS.Rows(e.RowIndex).FCTextBox("TxtObservacionesServicio").Text
|
|
|
|
Dim Ddl As DropDownList = GvPS.Rows(e.RowIndex).FCDropDownList("DdlUnidadMedida")
|
|
|
|
Dim Cantidad As String = GvPS.Rows(e.RowIndex).FCTextBox("TxtCantidad").Text
|
|
Dim CveUM As Integer = Ddl.SelectedValue.ToEntero
|
|
Dim UM As String = Ddl.SelectedItem.Text
|
|
|
|
Dim CveCuentaEquipo As Integer = GvPS.Rows(e.RowIndex).FCHiddenField("HndCveCuentaEquipo").Value.ToEntero
|
|
Dim CuentaEquipoLink As String = GvPS.Rows(e.RowIndex).FCLiteral("LtlCuentaEquipo").Text
|
|
Dim CuentaEquipoMostrar As String = GvPS.Rows(e.RowIndex).FCButton("BtnBuscarCuentaEquipo").Text
|
|
|
|
Dim Especificaciones As String = GvPS.Rows(e.RowIndex).FCHiddenField("HndEspecificaciones").Value.ToString
|
|
Dim EspecificacionesLink As String = GvPS.Rows(e.RowIndex).FCLiteral("LtlEspecificaciones").Text
|
|
|
|
Dim SeFacturara As Boolean = GvPS.Rows(e.RowIndex).FCCheckBox("ChkSeFacturara").Checked
|
|
|
|
TmpDT.Rows(e.RowIndex)("CveClasificacion") = CveClasificacion
|
|
TmpDT.Rows(e.RowIndex)("Clasificacion") = Clasificacion
|
|
TmpDT.Rows(e.RowIndex)("CvePS") = CvePS
|
|
TmpDT.Rows(e.RowIndex)("PS") = PS
|
|
TmpDT.Rows(e.RowIndex)("Observaciones") = Observaciones
|
|
|
|
TmpDT.Rows(e.RowIndex)("Cantidad") = Cantidad
|
|
TmpDT.Rows(e.RowIndex)("CveUM") = CveUM
|
|
TmpDT.Rows(e.RowIndex)("UM") = UM
|
|
|
|
TmpDT.Rows(e.RowIndex)("CveCuentaEquipo") = CveCuentaEquipo
|
|
TmpDT.Rows(e.RowIndex)("CuentaEquipoLink") = CuentaEquipoLink
|
|
TmpDT.Rows(e.RowIndex)("CuentaEquipoMostrar") = CuentaEquipoMostrar
|
|
|
|
If Especificaciones <> String.Empty Then
|
|
TmpDT.Rows(e.RowIndex)("Especificaciones") = Especificaciones
|
|
TmpDT.Rows(e.RowIndex)("EspecificacionesMostrar") = EspecificacionesParaMostrar(Especificaciones, "<br />")
|
|
End If
|
|
TmpDT.Rows(e.RowIndex)("EspecificacionesLink") = EspecificacionesLink
|
|
|
|
TmpDT.Rows(e.RowIndex)("SeFacturara") = SeFacturara.ToString
|
|
|
|
Dim Archivo As String = If(Not Session("OS") Is Nothing AndAlso Session("OS").ToString <> String.Empty, Session("OS").ToString, "-1")
|
|
|
|
If Archivo <> "-1" Then
|
|
'cambiar el nombre a el archivo
|
|
Dim DirectorioEmpresa As String = UsuarioActual.Empresa.Ruta
|
|
Archivo = String.Format("{0}-{1}{2}", CveOS, TmpDT.Rows(e.RowIndex)("Consecutivo"), System.IO.Path.GetExtension(Archivo))
|
|
|
|
Rename(DirectorioEmpresa & "\OS\temp\" & Session("OS").ToString, DirectorioEmpresa & "\OS\temp\" & Archivo)
|
|
TmpDT.Rows(e.RowIndex)("Archivo") = Archivo
|
|
End If
|
|
|
|
Session("OS") = String.Empty
|
|
|
|
GvPS.EditIndex = -1
|
|
GvPS.DataSource = TmpDT
|
|
GvPS.DataBind()
|
|
|
|
' UpDatos.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "COMENTARIO TECNICO"
|
|
Public Sub Comentario_Click(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
|
|
'hdnCveOSDetalle.Value = GvRow.DBCampo("CveOSDetalle").ToString
|
|
TxtComentarioTecnico.Text = GvRow.DataKey("ComentarioTecnico")
|
|
UpAddComentario.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivComentarioTecnico"))
|
|
End Sub
|
|
Protected Sub BtnComentarioTecnico_Click(sender As Object, e As EventArgs) Handles BtnComentarioTecnico.Click
|
|
Dim objOrdenServicio As New ClsOS
|
|
Dim CveOSDetalle As Integer = hdnCveOSDetalle.Value.ToEntero
|
|
Dim ComentarioTecnico As String = TxtComentarioTecnico.Text.Trim
|
|
|
|
If objOrdenServicio.UpdateOrdenesServiciosDetalleComentarioTecnico(ComentarioTecnico, CveOSDetalle) Then
|
|
For i As Integer = 0 To TmpDT.Rows.Count - 1
|
|
If TmpDT.Rows(i)("CveOSDetalle").ToString.ToEntero = CveOSDetalle Then
|
|
TmpDT.Rows(i)("ComentarioTecnico") = ComentarioTecnico
|
|
End If
|
|
Next
|
|
|
|
'Dim DR = TmpDT.Select($"CveOSDetalle = {CveOSDetalle}")
|
|
'DR(0)("Observaciones") = String.Format("{0} <br> {1}", DR(0)("Observaciones"), ComentarioTecnico)
|
|
'TmpDT.AcceptChanges()
|
|
|
|
GvPS.DataSource = TmpDT
|
|
GvPS.DataBind()
|
|
|
|
UpDatos.Update()
|
|
End If
|
|
|
|
objOrdenServicio.Dispose()
|
|
RegistraScript("$('#DivComentarioTecnico').modal('hide');")
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "CUENTAS Y EQUIPOS MODAL"
|
|
Private Sub CreaDTCuentaCaracteristicas()
|
|
TmpDTCuentaCaracteristica = New DataTable
|
|
TmpDTCuentaCaracteristica.Columns.Add("CveCaracteristicaValor", GetType(Integer))
|
|
TmpDTCuentaCaracteristica.Columns.Add("CveCaracteristica", GetType(Integer))
|
|
TmpDTCuentaCaracteristica.Columns.Add("Caracteristica", GetType(String))
|
|
TmpDTCuentaCaracteristica.Columns.Add("CveCaracteristicaTipo", GetType(String))
|
|
TmpDTCuentaCaracteristica.Columns.Add("CveOpcion", GetType(Integer))
|
|
TmpDTCuentaCaracteristica.Columns.Add("Opcion", GetType(String))
|
|
TmpDTCuentaCaracteristica.Columns.Add("Valor", GetType(String))
|
|
End Sub
|
|
Private Sub AddCuentas(CveOSDetalle As Integer, CveTipoCuentaEquipo As Integer, TipoCuentaEquipo As String, CveCuentaEquipo As Integer, CuentaEquipo As String)
|
|
Dim Row As DataRow = Nothing
|
|
Row = TmpDTCuentaEquipo.NewRow()
|
|
|
|
Row("CveOSDetalle") = CveOSDetalle
|
|
Row("CveConsecutivo") = CveConsecutivo
|
|
Row("CveTipoCuentaEquipo") = CveTipoCuentaEquipo
|
|
Row("CveCuentaEquipo") = CveCuentaEquipo
|
|
Row("TipoCuentaEquipo") = TipoCuentaEquipo
|
|
Row("CuentaEquipo") = CuentaEquipo
|
|
|
|
TmpDTCuentaEquipo.Rows.Add(Row)
|
|
|
|
End Sub
|
|
Protected Sub CargarCuentasEquipos(CveCliente As Integer)
|
|
Dim ObjGenerales As New ClsGenerales
|
|
DdlTipoCuentaDetalle.Items.Clear()
|
|
|
|
If ObjGenerales.GetTipoCuentasEquipos() Then
|
|
DdlTipoCuentaDetalle.DataSource = ObjGenerales.DtResultados.FiltraParametros(String.Format("CveEmpresa = {0}", UsuarioActual.CveEmpresa))
|
|
DdlTipoCuentaDetalle.DataBind()
|
|
End If
|
|
|
|
UpBodyAgregarCuenta.Update()
|
|
ObjGenerales.Dispose()
|
|
End Sub
|
|
Protected Sub BtnAgregarCuenta_Click(sender As Object, e As EventArgs)
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarCuenta"))
|
|
End Sub
|
|
Private Sub BtnGuardarCuenta_Click(sender As Object, e As EventArgs) Handles BtnGuardarCuenta.Click
|
|
Dim TieneError As Boolean = False
|
|
Dim objCuentasEquipos As New ClsGenerales()
|
|
|
|
objCuentasEquipos.IniciaTransacSQL()
|
|
|
|
If Not objCuentasEquipos.AddCuentaEquipo(CveCliente, DdlTipoCuentaDetalle.SelectedValue.ToEntero, TxtCuentaEquipo.Text.Trim, TxtNoSerie.Text.Trim, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCuentaEquipoRelacionado:=DdlCuentaRelacionado.SelectedValue.ToEntero) Then
|
|
TieneError = True
|
|
End If
|
|
|
|
For Each gvr As GridViewRow In GvCuentasCaracteristicas.Rows
|
|
If gvr.RowType = DataControlRowType.DataRow Then
|
|
Dim CveCaracteristica As Integer = gvr.DataKey("CveCaracteristica").ToEntero
|
|
Dim CveCaracteristicaOpcion As Integer = If(gvr.FCDropDownList("DdlCarcateristicaOpcion").Visible = True, gvr.FCDropDownList("DdlCarcateristicaOpcion").SelectedValue.ToEntero, -1)
|
|
Dim Valor As String = If(gvr.FCTextBox("TxtCuentaValor").Visible = True, gvr.FCTextBox("TxtCuentaValor").Text, gvr.FCDropDownList("DdlCarcateristicaOpcion").SelectedItem.Text)
|
|
|
|
If Not objCuentasEquipos.AddUpdateCaracteristicasValores(CveCaracteristica, CveCaracteristicaOpcion, Valor, UsuarioActual.CveUsuario, CveCuentaEquipo:=objCuentasEquipos.CveCuentaEquipo) Then
|
|
TieneError = True
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
If Not TieneError Then
|
|
objCuentasEquipos.Commit()
|
|
CargarCuentasEquipos(CveCliente)
|
|
TxtCuentaEquipo.Text = ""
|
|
TxtNoSerie.Text = ""
|
|
DdlTipoCuentaDetalle.SelectedValueExist(-1)
|
|
CargaCuentas()
|
|
DdlIdentificador.SelectedValueExist(objCuentasEquipos.CveCuentaEquipo)
|
|
UpBodyAgregarCuenta.Update()
|
|
Else
|
|
objCuentasEquipos.RollBack()
|
|
End If
|
|
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarCuenta"))
|
|
UpDetalleOS.Update()
|
|
objCuentasEquipos.Dispose()
|
|
End Sub
|
|
Protected Sub CargaCuentas()
|
|
Dim ObjCuentasEquipos As New ClsGenerales()
|
|
DdlIdentificador.Items.Clear()
|
|
DdlCuentaEquipo.Items.Clear()
|
|
DdlCuentaRelacionado.Items.Clear()
|
|
|
|
If ObjCuentasEquipos.GetCuentasEquipos(CveCliente, -1) Then
|
|
DdlIdentificador.DataSource = ObjCuentasEquipos.DtResultados
|
|
DdlCuentaEquipo.DataSource = ObjCuentasEquipos.DtResultados
|
|
DdlCuentaRelacionado.DataSource = ObjCuentasEquipos.DtResultados
|
|
End If
|
|
UpBodyGv.Update()
|
|
UpDetalleOS.Update()
|
|
|
|
ObjCuentasEquipos.Dispose()
|
|
|
|
DdlIdentificador.DataBind()
|
|
DdlCuentaEquipo.DataBind()
|
|
DdlCuentaRelacionado.DataBind()
|
|
DdlIdentificador.Items.Insert(0, New ListItem(" - ", "-1"))
|
|
DdlCuentaEquipo.Items.Insert(0, New ListItem(" - ", "-1"))
|
|
DdlCuentaRelacionado.Items.Insert(0, New ListItem(" - ", "-1"))
|
|
End Sub
|
|
Private Sub BtaAgregarCuentaEquipo_Click(sender As Object, e As EventArgs) Handles BtaAgregarCuentaEquipo.Click
|
|
DdlClienteSucursalCuenta.SelectedValueExist(DdlSucursalCliente.SelectedValue)
|
|
UpBodyAgregarCuenta.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarCuenta"))
|
|
End Sub
|
|
Private Sub CargaCuentasCaracteristicas()
|
|
Dim ObjCaracteristicas As New ClsGenerales
|
|
|
|
If ObjCaracteristicas.GetCaracteristicas(-1, 6, UsuarioActual.CveEmpresa) Then
|
|
GvCuentasCaracteristicas.DataSource = ObjCaracteristicas.DtResultados
|
|
Else
|
|
GvCuentasCaracteristicas.DataSource = Nothing
|
|
End If
|
|
GvCuentasCaracteristicas.DataBind()
|
|
|
|
ObjCaracteristicas.Dispose()
|
|
End Sub
|
|
Private Sub GvCuentasCaracteristicas_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvCuentasCaracteristicas.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
Dim CveCaracteristicaTipo As Integer = e.Row.DataKey("CveCaracteristicaTipo").ToEntero
|
|
Dim dtTemp As New DataTable
|
|
Dim objCaracteristicas As New ClsGenerales
|
|
|
|
Dim CveCaracteristica As Integer = e.Row.DataKey("CveCaracteristica").ToEntero
|
|
Dim DdlCarcateristicaOpcion As DropDownList = e.Row.FCDropDownList("DdlCarcateristicaOpcion")
|
|
Dim TxtCuentaValor As TextBox = e.Row.FCTextBox("TxtCuentaValor")
|
|
|
|
If objCaracteristicas.GetCaracteriscasOpciones(-1, UsuarioActual.Empresa.CveEmpresa) Then
|
|
dtTemp = objCaracteristicas.DtResultados
|
|
End If
|
|
|
|
Select Case CveCaracteristicaTipo
|
|
Case 0
|
|
TxtCuentaValor.Visible = True
|
|
Case 1
|
|
DdlCarcateristicaOpcion.Visible = True
|
|
dtTemp = dtTemp.FiltraParametros(" CveCaracteristica = " & CveCaracteristica)
|
|
DdlCarcateristicaOpcion.DataSource = dtTemp
|
|
DdlCarcateristicaOpcion.DataBind()
|
|
DdlCarcateristicaOpcion.Items.Insert(0, New ListItem("-", "-1"))
|
|
End Select
|
|
|
|
objCaracteristicas.Dispose()
|
|
End If
|
|
End Sub
|
|
Private Sub DdlCuentaEquipo_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuentaEquipo.SelectedIndexChanged
|
|
DdlIdentificador.SelectedValueExist(DdlCuentaEquipo.SelectedValue)
|
|
UpBodyGv.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "ESPECIFICACIONES MODAL"
|
|
Private Sub CreaDTPS()
|
|
TmpDTCaracteristica = New DataTable
|
|
TmpDTCaracteristica.Columns.Add("CveConsecutivo", GetType(Integer))
|
|
TmpDTCaracteristica.Columns.Add("CveConsecutivoDetalle", GetType(Integer))
|
|
TmpDTCaracteristica.Columns.Add("CveOSDetalle", GetType(Integer))
|
|
TmpDTCaracteristica.Columns.Add("CveCaracteristicaValor", GetType(Integer))
|
|
TmpDTCaracteristica.Columns.Add("CveCaracteristica", GetType(Integer))
|
|
TmpDTCaracteristica.Columns.Add("Caracteristica", GetType(String))
|
|
TmpDTCaracteristica.Columns.Add("CveCaracteristicaTipo", GetType(String))
|
|
TmpDTCaracteristica.Columns.Add("CveOpcion", GetType(Integer))
|
|
TmpDTCaracteristica.Columns.Add("Opcion", GetType(String))
|
|
TmpDTCaracteristica.Columns.Add("Valor", GetType(String))
|
|
End Sub
|
|
Private Sub CargaPSCaracteristicasOpciones()
|
|
Dim ObjCuentasEquipos As New ClsGenerales
|
|
DdlOpcion.Items.Clear()
|
|
If DdlCaracteristica.SelectedValue.ToString <> "" Then
|
|
If ObjCuentasEquipos.GetCaracteristicasValores(-1, -1, DdlPSDetalle.SelectedValue.ToEntero, -1, -1, -1, 5, UsuarioActual.CveEmpresa, OpcionListado:=1) Then
|
|
DdlOpcion.DataSource = ObjCuentasEquipos.DtResultados.FiltraParametros("CveCaracteristica = " + DdlCaracteristica.SelectedValue.ToString)
|
|
DdlOpcion.DataBind()
|
|
End If
|
|
End If
|
|
ObjCuentasEquipos.Dispose()
|
|
End Sub
|
|
Private Sub CargaPSCaracteristicas()
|
|
Dim ObjCaracteristicas As New ClsGenerales
|
|
DdlCaracteristica.Items.Clear()
|
|
|
|
If ObjCaracteristicas.GetCaracteristicasValores(-1, -1, DdlPSDetalle.SelectedValue.ToEntero, -1, -1, -1, 5, UsuarioActual.CveEmpresa, OpcionListado:=1) Then
|
|
If ObjCaracteristicas.DtResultados.Rows.Count > 0 Then
|
|
DdlCaracteristica.DataSource = ObjCaracteristicas.DtResultados
|
|
TabEspecificaciones.Visible = True
|
|
Else
|
|
DdlCaracteristica.DataSource = Nothing
|
|
TabEspecificaciones.Visible = False
|
|
End If
|
|
End If
|
|
ObjCaracteristicas.Dispose()
|
|
DdlCaracteristica.DataBind()
|
|
|
|
CambioProductosServiciosCaracteristicas(DdlCaracteristica.SelectedValue.ToEntero)
|
|
|
|
End Sub
|
|
Protected Sub DdlCaracteristica_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCaracteristica.SelectedIndexChanged
|
|
CambioProductosServiciosCaracteristicas(DdlCaracteristica.SelectedValue.ToEntero)
|
|
End Sub
|
|
Protected Sub CambioProductosServiciosCaracteristicas(Caracteristica As Integer)
|
|
Dim ObjCaracteristicas As New ClsGenerales
|
|
Dim DV As New DataView
|
|
|
|
If DdlCaracteristica.SelectedValue <> "" Then
|
|
If ObjCaracteristicas.GetCaracteristicas(-1, 5, UsuarioActual.CveEmpresa) Then
|
|
DV = ObjCaracteristicas.DtResultados.FiltraParametros("CveCaracteristica = " + DdlCaracteristica.SelectedValue.ToString).AsDataView
|
|
End If
|
|
|
|
If DV(0)("CveCaracteristicaTipo").ToString = "1" Then
|
|
DdlOpcion.Visible = True
|
|
CargaPSCaracteristicasOpciones()
|
|
txtValor.Visible = False
|
|
ElseIf DV(0)("CveCaracteristicaTipo").ToString = "0" Then
|
|
DdlOpcion.Visible = False
|
|
txtValor.Visible = True
|
|
End If
|
|
Else
|
|
DdlOpcion.ClearSelection()
|
|
DdlOpcion.DataSource = ""
|
|
DdlOpcion.DataBind()
|
|
End If
|
|
ObjCaracteristicas.Dispose()
|
|
End Sub
|
|
Protected Sub LbAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click
|
|
Dim Consecutivo As Integer = TmpDTCaracteristica.Rows.Count + 1
|
|
|
|
If DdlCaracteristica.SelectedValue <> "" Then
|
|
|
|
Dim EsOpcion As String
|
|
Dim CveCaracteristicaTipo As Integer
|
|
Dim Opcion As String
|
|
Dim Valor As String
|
|
|
|
If DdlOpcion.Visible = True Then
|
|
EsOpcion = "Sí"
|
|
CveCaracteristicaTipo = DdlOpcion.SelectedValue.ToEntero
|
|
Opcion = DdlOpcion.SelectedItem.Text
|
|
Valor = "-1"
|
|
Else
|
|
EsOpcion = "No"
|
|
CveCaracteristicaTipo = -1
|
|
Opcion = "-1"
|
|
Valor = txtValor.Text
|
|
End If
|
|
|
|
AddEspecificacion(DdlCaracteristica.SelectedValue.ToEntero, DdlCaracteristica.SelectedItem.Text, EsOpcion, CveCaracteristicaTipo, Opcion, Valor, Consecutivo)
|
|
End If
|
|
End Sub
|
|
Private Sub AddEspecificacion(CveCaracteristica As Integer, Caracteristica As String, CveCaracteristicaTipo As String, CveOpcion As Integer, Opcion As String, Valor As String, Consecutivo As Integer)
|
|
|
|
Dim Row As DataRow = Nothing
|
|
Row = TmpDTCaracteristica.NewRow()
|
|
|
|
Row("CveConsecutivo") = Consecutivo
|
|
Row("CveConsecutivoDetalle") = CveConsecutivo
|
|
Row("CveOSDetalle") = CveOsDetalle
|
|
Row("CveCaracteristica") = CveCaracteristica
|
|
Row("Caracteristica") = Caracteristica
|
|
Row("CveCaracteristicaTipo") = CveCaracteristicaTipo
|
|
Row("CveOpcion") = CveOpcion
|
|
Row("Opcion") = Opcion
|
|
|
|
If CveCaracteristicaTipo = "Sí" Then
|
|
Row("Valor") = Opcion
|
|
Else
|
|
Row("Valor") = Valor
|
|
End If
|
|
|
|
TmpDTCaracteristica.Rows.Add(Row)
|
|
For Each RowE As DataRow In TmpDTCaracteristica.Rows
|
|
If RowE("CveOSDetalle").ToString.ToEntero > 0 Then
|
|
GvValoresCaracteristicas.DataSource = TmpDTCaracteristica.FiltraParametros(String.Format("CveOSDetalle = {0}", CveOsDetalle))
|
|
Else
|
|
GvValoresCaracteristicas.DataSource = TmpDTCaracteristica.FiltraParametros(String.Format("CveConsecutivoDetalle = {0}", CveConsecutivo))
|
|
End If
|
|
Next
|
|
GvValoresCaracteristicas.DataBind()
|
|
|
|
|
|
Dim Especificaciones As String = "-1"
|
|
|
|
If CveOsDetalle > 0 Then
|
|
For Each R As DataRow In TmpDTCaracteristica.FiltraParametros(String.Format("CveOSDetalle = {0}", CveOsDetalle)).Rows
|
|
If Especificaciones = "-1" Then Especificaciones = "" Else Especificaciones = Especificaciones + ","
|
|
Especificaciones = Especificaciones + String.Format("{0}:{1}:{2}:{3}:{4}:{5}", R("CveCaracteristica").ToString, R("Caracteristica").ToString, R("CveCaracteristicaTipo"), R("CveOpcion").ToString, R("Opcion").ToString, R("Valor").ToString)
|
|
Next
|
|
Else
|
|
For Each R As DataRow In TmpDTCaracteristica.FiltraParametros(String.Format("CveConsecutivoDetalle = {0}", CveConsecutivo)).Rows
|
|
If Especificaciones = "-1" Then Especificaciones = "" Else Especificaciones = Especificaciones + ","
|
|
Especificaciones = Especificaciones + String.Format("{0}:{1}:{2}:{3}:{4}:{5}", R("CveCaracteristica").ToString, R("Caracteristica").ToString, R("CveCaracteristicaTipo"), R("CveOpcion").ToString, R("Opcion").ToString, R("Valor").ToString)
|
|
Next
|
|
End If
|
|
|
|
RegistraScript(String.Format("CargaEspecificacionesPop('{0}');", Especificaciones))
|
|
|
|
UpBodyGv.Update()
|
|
End Sub
|
|
Private Sub GvValoresCaracteristicas_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvValoresCaracteristicas.RowDeleting
|
|
Dim ObjGenerales As New ClsGenerales
|
|
Dim DbRow As DataRow = Nothing
|
|
|
|
Dim CveCaracteristica As Integer = GvValoresCaracteristicas.Rows(e.RowIndex).DataKey("CveCaracteristica").ToEntero
|
|
Dim CveOSDetalle As Integer = GvValoresCaracteristicas.Rows(e.RowIndex).DataKey("CveOSDetalle").ToEntero
|
|
|
|
If CveOSDetalle > 0 Then
|
|
If ObjGenerales.RemoveCaracteristicasValores(CveCaracteristica, CveOSDetalle) Then
|
|
GvValoresCaracteristicas.EditIndex = -1
|
|
End If
|
|
Else
|
|
DbRow = TmpDTCaracteristica.Rows(e.RowIndex)
|
|
TmpDTCaracteristica.Rows.Remove(DbRow)
|
|
End If
|
|
|
|
CargaGridValores()
|
|
|
|
Dim Especificaciones As String = "-1"
|
|
|
|
For Each R As DataRow In TmpDTCaracteristica.FiltraParametros(String.Format("CveConsecutivo = {0}", CveConsecutivo)).Rows
|
|
If Especificaciones = "-1" Then Especificaciones = "" Else Especificaciones = Especificaciones + ","
|
|
Especificaciones = Especificaciones + String.Format("{0}:{1}:{2}:{3}:{4}:{5}", R("CveCaracteristica").ToString, R("Caracteristica").ToString, R("CveCaracteristicaTipo"), R("CveOpcion").ToString, R("Opcion").ToString, R("Valor").ToString)
|
|
Next
|
|
|
|
RegistraScript(String.Format("CargaEspecificacionesPop('{0}');", Especificaciones))
|
|
ObjGenerales.Dispose()
|
|
End Sub
|
|
Private Sub CargaGridValores()
|
|
GvValoresCaracteristicas.DataSource = TmpDTCaracteristica
|
|
GvValoresCaracteristicas.DataBind()
|
|
UpCaracteristicas.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "MATERIALES MODAL"
|
|
Private Sub CreaDtMaterialesDetalle()
|
|
TmpDTMaterialesDetalle = New DataTable
|
|
TmpDTMaterialesDetalle.Columns.Add("CveOSDetalle", GetType(Integer))
|
|
TmpDTMaterialesDetalle.Columns.Add("CveConsecutivo", GetType(Integer))
|
|
TmpDTMaterialesDetalle.Columns.Add("CveConsecutivoDetalle", GetType(Integer))
|
|
TmpDTMaterialesDetalle.Columns.Add("CveMaterial", GetType(Integer))
|
|
TmpDTMaterialesDetalle.Columns.Add("CveMovimiento", GetType(Integer))
|
|
TmpDTMaterialesDetalle.Columns.Add("Cantidad", GetType(Integer))
|
|
TmpDTMaterialesDetalle.Columns.Add("CveClasificacion", GetType(Integer))
|
|
TmpDTMaterialesDetalle.Columns.Add("CvePS", GetType(String))
|
|
TmpDTMaterialesDetalle.Columns.Add("CveUM", GetType(String))
|
|
TmpDTMaterialesDetalle.Columns.Add("Clasificacion", GetType(String))
|
|
TmpDTMaterialesDetalle.Columns.Add("PS", GetType(String))
|
|
TmpDTMaterialesDetalle.Columns.Add("UM", GetType(String))
|
|
End Sub
|
|
Protected Sub LtlMateriales_Click(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
|
|
If GvRow.DataKey("CveOSDetalle").ToString.ToEntero > 0 Then CveOsDetalle = GvRow.DataKey("CveOSDetalle").ToEntero Else CveOsDetalle = -1
|
|
|
|
For Each RowE As DataRow In TmpDTMaterialesDetalle.Rows
|
|
If GvRow.DataKey("CveOSDetalle").ToString.ToEntero > 0 Then
|
|
GvMaterialesModal.DataSource = TmpDTMaterialesDetalle.FiltraParametros(String.Format("CveOSDetalle = {0}", GvRow.DataKey("CveOSDetalle")))
|
|
|
|
Else
|
|
GvMaterialesModal.DataSource = TmpDTMaterialesDetalle.FiltraParametros(String.Format("CveConsecutivoDetalle = {0}", GvRow.DataKey("Consecutivo")))
|
|
End If
|
|
Next
|
|
GvMaterialesModal.DataBind()
|
|
|
|
UpAddMateriales.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivGvMateriales"))
|
|
End Sub
|
|
'Private Sub DdlClasificacion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlClasificacion.SelectedIndexChanged
|
|
' CargaPsMateriales()
|
|
' UpAddMateriales.Update()
|
|
'End Sub
|
|
Private Sub DdlPS_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPS.selectedindexchange
|
|
If CveCliente > 0 OrElse DdlPS.SelectedValue = "-2" Then
|
|
If DdlPS.SelectedValue.ToEntero > 1 Then
|
|
Dim drPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlPS.SelectedValue.ToEntero).FiltroPrimero("")
|
|
|
|
If drPS IsNot Nothing Then
|
|
DdlUnidadMedidaM.Items.Clear()
|
|
DdlUnidadMedidaM.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CveUnidadMedida = {0}", drPS("CveUM")))
|
|
DdlUnidadMedidaM.DataBind()
|
|
DdlUnidadMedidaM.SelectedValueExist(drPS("CveUnidadMedida").ToString)
|
|
|
|
'If DdlClasificacion.SelectedIndex = 0 Then
|
|
' If drPS("CveClasificacion").ToString IsNot Nothing Then
|
|
' DdlClasificacion.SelectedValueExist(drPS("CveClasificacion").ToString)
|
|
' Else
|
|
|
|
' Alert("El Productos/Servicio no tiene asignada una Clasificación.")
|
|
' End If
|
|
'End If
|
|
End If
|
|
End If
|
|
End If
|
|
End Sub
|
|
Private Sub LbAgregarMaterial_Click(sender As Object, e As EventArgs) Handles LbAgregarMaterial.Click
|
|
Dim ObjPS As New ClsProductosServicios
|
|
Dim Clasificacion As String = ""
|
|
Dim CveClasificacion As Integer
|
|
If ObjPS.GetPS(DdlPS.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) Then
|
|
Clasificacion = ObjPS.DtResultados.Rows(0)("Clasificacion").ToString
|
|
CveClasificacion = ObjPS.CveClasificacion
|
|
End If
|
|
Dim Consecutivo As Integer = TmpDTMaterialesDetalle.Rows.Count + 1
|
|
AddMaterial(CveOsDetalle, CveClasificacion, TxtCantidadM.Text.ToEntero, Clasificacion,
|
|
DdlPS.SelectedValue.ToEntero, DdlPS.SelectedText, DdlUnidadMedidaM.SelectedValue.ToEntero, DdlUnidadMedidaM.SelectedItem.Text, Consecutivo)
|
|
TxtCantidadM.Text = ""
|
|
CargaPsMateriales()
|
|
End Sub
|
|
Private Sub AddMaterial(CveOSDetalle As Integer, CveClasificacion As Integer, Cantidad As Integer, Clasificacion As String, CvePS As Integer, PS As String, CveUM As Integer, UM As String, Consecutivo As Integer)
|
|
|
|
Dim Row As DataRow = Nothing
|
|
Row = TmpDTMaterialesDetalle.NewRow()
|
|
|
|
Row("CveConsecutivo") = Consecutivo
|
|
Row("CveConsecutivoDetalle") = CveConsecutivo
|
|
Row("CveOSDetalle") = CveOSDetalle
|
|
Row("CveMaterial") = -1
|
|
Row("Cantidad") = Cantidad
|
|
Row("CveClasificacion") = CveClasificacion
|
|
Row("CvePS") = CvePS
|
|
Row("CveUM") = CveUM
|
|
Row("Clasificacion") = Clasificacion
|
|
Row("PS") = PS
|
|
Row("UM") = UM
|
|
|
|
TmpDTMaterialesDetalle.Rows.Add(Row)
|
|
For Each RowE As DataRow In TmpDTMaterialesDetalle.Rows
|
|
If RowE("CveOSDetalle").ToString.ToEntero > 0 Then
|
|
GvMaterialesModal.DataSource = TmpDTMaterialesDetalle.FiltraParametros(String.Format("CveOSDetalle = {0}", CveOSDetalle))
|
|
Else
|
|
GvMaterialesModal.DataSource = TmpDTMaterialesDetalle.FiltraParametros(String.Format("CveConsecutivoDetalle = {0}", CveConsecutivo))
|
|
End If
|
|
Next
|
|
GvMaterialesModal.DataBind()
|
|
|
|
Materiales = "-1"
|
|
If CveOSDetalle > 0 Then
|
|
For Each R As DataRow In TmpDTMaterialesDetalle.FiltraParametros(String.Format("CveOSDetalle = {0}", CveOSDetalle)).Rows
|
|
If Materiales = "-1" Then Materiales = "" Else Materiales = Materiales + "<br>"
|
|
Materiales = Materiales + String.Format("{0} {1}", R("Cantidad").ToString, R("PS").ToString)
|
|
Next
|
|
Else
|
|
For Each R As DataRow In TmpDTCaracteristica.FiltraParametros(String.Format("CveConsecutivoDetalle = {0}", CveConsecutivo)).Rows
|
|
If Materiales = "-1" Then Materiales = "" Else Materiales = Materiales + "<br>"
|
|
Materiales = Materiales + String.Format("{0} {1}", R("Cantidad").ToString, R("PS").ToString)
|
|
Next
|
|
End If
|
|
|
|
Dim DR As DataRow() = TmpDT.Select($"Consecutivo = {CveConsecutivo}")
|
|
DR(0)("Materiales") = Materiales
|
|
TmpDT.AcceptChanges()
|
|
|
|
GvPS.DataSource() = TmpDT
|
|
GvPS.DataBind()
|
|
|
|
UpDetalleOS.Update()
|
|
UpAddMateriales.Update()
|
|
End Sub
|
|
Private Sub BtnGuardarMateriales_Click(sender As Object, e As EventArgs) Handles BtnGuardarMateriales.Click
|
|
'VALIDA ALMACEN ORIGEN Y DESTINO
|
|
Dim ErrorEncontrado As New StringBuilder
|
|
|
|
If DdlAlmacenOrigen.SelectedValue = DdlAlmacenDestino.SelectedValue Then
|
|
Alert("No se puede realizar un traspaso entre el mismo almacén.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
If GvMaterialesModal.Rows.Count > 0 Then
|
|
Dim ObjInventario As New ClsInventarios
|
|
ObjInventario.IniciaTransacSQL()
|
|
|
|
Dim CveTraspasoSolicitud As Integer = 0
|
|
|
|
Dim TieneError As Boolean = False
|
|
Dim ErrorExistencia As Boolean = False
|
|
Dim TextoExistencia As StringBuilder = New StringBuilder
|
|
|
|
'VALIDA LA EXISTENCIA DEL ALMACEN DE ORIGEN
|
|
Dim Existencia As Double
|
|
TextoExistencia.Append("Los siguiente productos se ajustaron por falta de exitencia:<br/>")
|
|
|
|
For Each dr As DataRow In TmpDTMaterialesDetalle.Rows
|
|
Existencia = ObjInventario.GetExistenciasPS(dr("CvePS").ToString.ToEntero, dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"))
|
|
Existencia -= TmpDTMaterialesDetalle.SUM("Cantidad", $"CvePS = {dr("CvePS").ToString.ToEntero} AND CveUM = {dr("CveUM").ToString.ToEntero} ")
|
|
|
|
If Existencia < 0 Then
|
|
ErrorExistencia = True
|
|
dr("Cantidad") = Existencia
|
|
TextoExistencia.AppendFormat("- #{0}<br/>", dr("PS").ToString)
|
|
End If
|
|
Next
|
|
|
|
Dim Estatus As Integer = -1
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(105) <> "" Then
|
|
Estatus = 1
|
|
Else
|
|
Estatus = 3
|
|
End If
|
|
|
|
Dim Folio As Integer = ObjInventario.AddTrasladoSolicitud($"Solicitud de traspaso OS#{LblFolio.Text}", DdlAlmacenOrigen.SelectedValue.ToEntero, DdlAlmacenDestino.SelectedValue.ToEntero, Estatus, -1, TxtFecha.Text.ToDate, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveOS:=CveOS)
|
|
|
|
If Folio > 0 Then
|
|
CveTraspasoSolicitud = ObjInventario.CveTraspasoSolicitud
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
|
|
'SI OCURRIO UN ERROR EN LA EXISTENCIA RECARGAMOS EL GRID PARA COLOREAR LOS DETALLES CON ERROR
|
|
If ErrorExistencia Then
|
|
Alert("Ocurrió un error en la existencia", TipoMensaje.MsgError)
|
|
TieneError = True
|
|
End If
|
|
|
|
If Not TieneError Then
|
|
Dim ObjOS As New ClsOS
|
|
Dim MaterialesDetalleNuevos As DataTable = TmpDTMaterialesDetalle.FiltraParametros("CveMaterial = -1")
|
|
For Each Row As DataRow In MaterialesDetalleNuevos.Rows
|
|
Dim CveUM As Integer = Row("CveUM").ToString.ToEntero
|
|
Dim CvePS As Integer = Row("CvePS").ToString.ToEntero
|
|
Dim Cantidad As Integer = Row("Cantidad").ToString.ToEntero
|
|
Dim CveClasificacion As Integer = Row("CveClasificacion").ToString.ToEntero
|
|
|
|
If Not ObjOS.AddUpdateDetalleMateriales(-1, CveOsDetalle, Cantidad, CveUM, CveClasificacion, CvePS, True) Then
|
|
TieneError = True
|
|
ErrorEncontrado.AppendFormat("Ocurrió un Error al agregar los materiales.<br/>")
|
|
Exit For
|
|
End If
|
|
If Not ObjInventario.AddTrasladoSolicitudDetalle(CveTraspasoSolicitud, Cantidad, CveUM, CvePS, 0, "", -1) Then
|
|
ErrorEncontrado.AppendFormat("Ocurrió un Error al guardar el traspaso.")
|
|
TieneError = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
ObjOS.Dispose()
|
|
End If
|
|
|
|
If Not TieneError Then
|
|
ObjInventario.Commit()
|
|
Alert($"El Traspaso se guardó correctamente con el folio #: <b>{Folio}</b>.", TipoMensaje.MsgInformacion, $"document.location.href=""/Inventarios/TrasladoSolicitud.aspx?CveTraspasoSolicitud={CveTraspasoSolicitud}""")
|
|
Else
|
|
ObjInventario.RollBack()
|
|
Alert(ErrorEncontrado.ToString, TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjInventario.Dispose()
|
|
End If
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivGvMateriales"))
|
|
End Sub
|
|
Private Sub GvMaterialesModal_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvMaterialesModal.RowDeleting
|
|
Dim ObjMateriales As New ClsOS
|
|
Dim ObjInventario As New ClsInventarios(ObjMateriales.IniciaTransacSQL)
|
|
Dim TieneError As Boolean = False
|
|
Dim DbRow As DataRow = Nothing
|
|
|
|
Dim CveMaterial As Integer = GvMaterialesModal.Rows(e.RowIndex).DataKey("CveMaterial").ToEntero
|
|
Dim CveOSDetalle As Integer = GvMaterialesModal.Rows(e.RowIndex).DataKey("CveOSDetalle").ToEntero
|
|
Dim CveMovimiento As Integer = GvMaterialesModal.Rows(e.RowIndex).DataKey("CveMovimiento").ToEntero
|
|
Dim CveConsecutivo As Integer = GvMaterialesModal.Rows(e.RowIndex).DataKey("CveConsecutivo").ToEntero
|
|
|
|
|
|
If CveMaterial > 0 Then
|
|
Dim CveMovimientoSalida As Integer = 0
|
|
Dim CveMovimientoEntrada As Integer = 0
|
|
|
|
Dim CveMovimientoSalida2 As Integer = 0
|
|
Dim CveMovimientoEntrada2 As Integer = 0
|
|
|
|
Dim CveMovimientoSalida3 As Integer = 0
|
|
Dim CveMovimientoEntrada3 As Integer = 0
|
|
|
|
Dim AlmacenEntrada As Integer = -1
|
|
Dim FolioSalida As Integer = 0
|
|
Dim FolioEntrada As Integer = 0
|
|
|
|
Dim ErrorMovInv As Boolean = False
|
|
Dim ErrorAC As Boolean = False
|
|
Dim ErrorExistencia As Boolean = False
|
|
|
|
Dim TextoError As String = ""
|
|
Dim TextoExistencia As StringBuilder = New StringBuilder
|
|
|
|
'Obtenemos los movimientos detalle
|
|
If ObjInventario.GetMovimientosOS(9, CveOS, UsuarioActual.CveEmpresa) Then
|
|
If ObjInventario.DtResultados.Rows.Count > 0 Then
|
|
Dim CveAlmacenOrigen As Integer = ObjInventario.DtResultados(0)("CveAlmacen").ToString.ToEntero
|
|
Dim CveAlmacenDestino As Integer = ObjInventario.DtResultados(0)("AlmacenDestino2").ToString.ToEntero
|
|
Dim CveMoneda As Integer = ObjInventario.DtResultados(0)("CveMoneda").ToString.ToEntero
|
|
Dim CveTipoAlmacen As Integer = ObjInventario.DtResultados(0)("CveTipoAlmacen").ToString.ToEntero
|
|
|
|
'AGREGAMOS LA ENTRADA Movto 1
|
|
If Not TieneError Then
|
|
AlmacenEntrada = CveAlmacenOrigen
|
|
|
|
CveMovimientoEntrada = ObjInventario.AddMovimiento(AlmacenEntrada, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, CveAlmacenDestino:=CveAlmacenDestino, CveMovimientoRelacionado:=CveMovimientoSalida, CveOS:=CveOS)
|
|
FolioEntrada = ObjInventario.Folio
|
|
|
|
If CveMovimientoEntrada <= 0 Then
|
|
TextoError = "No se pudo generar el movimiento de entrada correctamente"
|
|
TieneError = True
|
|
Else
|
|
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
|
|
|
For Each Dr As DataRow In ObjInventario.DtResultados.Rows
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, -1, -1) Then
|
|
TieneError = True
|
|
TextoError = "Ocurrió un error al guardar los movimientos de entrada"
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
|
|
'AGREGAMOS LA ENTRADA Movto 2
|
|
If Not TieneError Then
|
|
AlmacenEntrada = CveAlmacenDestino
|
|
|
|
CveMovimientoEntrada2 = ObjInventario.AddMovimiento(AlmacenEntrada, 9, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, CveAlmacenDestino:=-1, CveMovimientoRelacionado:=CveMovimientoEntrada, CveOS:=CveOS)
|
|
FolioEntrada = ObjInventario.Folio
|
|
|
|
If CveMovimientoEntrada2 <= 0 Then
|
|
TextoError = "No se pudo generar el movimiento de entrada correctamente"
|
|
TieneError = True
|
|
Else
|
|
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimientoEntrada, UsuarioActual.CveEmpresa) Then
|
|
|
|
For Each Dr As DataRow In ObjInventario.DtResultados.Rows
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada2, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, -1, -1) Then
|
|
TieneError = True
|
|
TextoError = "Ocurrió un error al guardar los movimientos de entrada"
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
|
|
|
|
If Not TieneError Then
|
|
If ObjMateriales.RemoveDetalleMateriales(CveMaterial, CveOSDetalle) Then
|
|
GvMaterialesModal.EditIndex = -1
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
Else
|
|
ObjMateriales.RollBack()
|
|
Alert(TextoError, TipoMensaje.MsgError)
|
|
RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
|
|
If Not TieneError Then
|
|
ObjMateriales.Commit()
|
|
DbRow = TmpDTMaterialesDetalle.Rows(e.RowIndex)
|
|
TmpDTMaterialesDetalle.Rows.Remove(DbRow)
|
|
|
|
If CveOSDetalle > 0 Then
|
|
CargaGvMateriales(String.Format("CveOSDetalle = {0}", CveOSDetalle))
|
|
Else
|
|
CargaGvMateriales(String.Format("CveConsecutivo = {0}", CveConsecutivo))
|
|
End If
|
|
Else
|
|
ObjMateriales.RollBack()
|
|
Alert("No se pudo eliminar el material", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjMateriales.Dispose()
|
|
ObjInventario.Dispose()
|
|
UpGvMateriales.Update()
|
|
End Sub
|
|
Private Sub CargaGvMateriales(Filtro As String)
|
|
GvMaterialesModal.DataSource = TmpDTMaterialesDetalle.FiltraParametros(Filtro)
|
|
GvMaterialesModal.DataBind()
|
|
UpGvMateriales.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "I M P R I M I R PDF"
|
|
Private Sub ImgImprimir_Click(sender As Object, e As EventArgs) Handles ImgImprimir.Click
|
|
Dim mensajeImprimir As New StringBuilder
|
|
mensajeImprimir.AppendFormat(String.Format("<br/>Descargar Orden de Servicio con Folio: <a class=""Texto"" href='/OS/OrdenesServicios.aspx?CveOS={0}'>{1}</a><br/>", CveOS, CveFolio))
|
|
mensajeImprimir.AppendFormat("<ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar PDF</a></li></ul><br/>", Encripta(String.Format("OP=OS&CVEOS={0}", CveOS)))
|
|
Alert(mensajeImprimir.ToString, TipoMensaje.MsgInformacion)
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "S O L I C I T A R M A T E R I A L"
|
|
Private Sub CreaDtSolicitarMateriales()
|
|
TmpDTSolicitarMaterial = New DataTable
|
|
TmpDTSolicitarMaterial.Columns.Add("CveConsecutivo", GetType(Integer))
|
|
TmpDTSolicitarMaterial.Columns.Add("Cantidad", GetType(Integer))
|
|
TmpDTSolicitarMaterial.Columns.Add("CveClasificacion", GetType(Integer))
|
|
TmpDTSolicitarMaterial.Columns.Add("CvePS", GetType(String))
|
|
TmpDTSolicitarMaterial.Columns.Add("CveUM", GetType(String))
|
|
TmpDTSolicitarMaterial.Columns.Add("Clasificacion", GetType(String))
|
|
TmpDTSolicitarMaterial.Columns.Add("PS", GetType(String))
|
|
TmpDTSolicitarMaterial.Columns.Add("UM", GetType(String))
|
|
End Sub
|
|
Public Sub CargaAlmacen()
|
|
DdlAlmacenOrigen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen IN (1)") 'GlobalDTAlmacen(UsuarioActual.CveEmpresa)
|
|
DdlAlmacenOrigen.DataBind()
|
|
DdlAlmacenOrigen.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
DdlAlmacenDestino.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen IN (23)") 'GlobalDTAlmacen(UsuarioActual.CveEmpresa)
|
|
DdlAlmacenDestino.DataBind()
|
|
DdlAlmacenDestino.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End Sub
|
|
|
|
|
|
Private Sub CargaModelos()
|
|
Dim ObjGral As New ClsGenerales
|
|
If ObjGral.ModelosAutosGet(1, UsuarioActual.CveEmpresa) Then
|
|
DdlModeloAuto.DataSource = ObjGral.DtResultados
|
|
End If
|
|
DdlModeloAuto.DataBind()
|
|
DdlModeloAuto.Items.Insert(0, New ListItem("Sin Asignar", "-1"))
|
|
End Sub
|
|
Public Sub ShowDivSolicitarMaterial_Click(sender As Object, e As EventArgs)
|
|
RegistraScript("ShowDivGvSolicitarMaterial();")
|
|
End Sub
|
|
Private Sub CargaPsSoliciarMaterial(CveClasificacion As Integer, Objeto As DropDownList)
|
|
Objeto.Items.Clear()
|
|
Objeto.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacion, Estatus:=1).FiltraParametros("CveTipoPS=2")
|
|
Objeto.DataBind()
|
|
Objeto.Items.Insert(0, New ListItem("*** Actualizar listado de Productos o Servicios ***", "-2"))
|
|
Objeto.Items.Insert(0, New ListItem("Seleccione el Producto", "-1"))
|
|
End Sub
|
|
|
|
'Private Sub LbGuardaSolicitarMaterial_Click(sender As Object, e As EventArgs) Handles LbGuardaSolicitarMaterial.Click
|
|
' 'VALIDA ALMACEN ORIGEN Y DESTINO
|
|
' If DdlAlmacenOrigen.SelectedValue = DdlAlmacenDestino.SelectedValue Then
|
|
' Alert("No se puede realizar un traspaso entre el mismo almacén.", TipoMensaje.MsgAdvertencia)
|
|
' Exit Sub
|
|
' End If
|
|
|
|
' If GvSolicitarMaterial.Rows.Count > 0 Then
|
|
' Dim ObjInventario As New ClsInventarios
|
|
|
|
' Dim CveMovimientoSalida = 0
|
|
' Dim CveMovimientoEntrada = 0
|
|
' Dim IDPoliza As Integer = 0
|
|
' Dim FolioSalida = 0
|
|
' Dim FolioEntrada = 0
|
|
' Dim AlmacenEntrada = -1
|
|
|
|
' Dim ErrorMovInv As Boolean = False
|
|
' Dim ErrorAC As Boolean = False
|
|
' Dim ErrorExistencia = False
|
|
|
|
' Dim TextoError = ""
|
|
' Dim TextoExistencia As StringBuilder = New StringBuilder
|
|
|
|
' 'VALIDA LA EXISTENCIA DEL ALMACEN DE ORIGEN
|
|
' Dim Existencia As Double
|
|
' TextoExistencia.Append("Los siguiente productos se ajustaron por falta de exitencia:<br/>")
|
|
|
|
|
|
' For Each dr As DataRow In TmpDTSolicitarMaterial.Rows
|
|
' Existencia = ObjInventario.GetExistenciasPS(dr("CvePS").ToString.ToEntero, dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, -1, TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), "-1")
|
|
' Existencia -= TmpDTSolicitarMaterial.SUM("Cantidad", $"CvePS = {dr("CvePS").ToString.ToEntero} AND CveUM = {dr("CveUM").ToString.ToEntero} ")
|
|
|
|
' If Existencia < 0 Then
|
|
' ErrorExistencia = True
|
|
' dr("Cantidad") = Existencia
|
|
' TextoExistencia.AppendFormat("- #{0}<br/>", dr("PS").ToString)
|
|
' End If
|
|
' Next
|
|
|
|
' 'REGISTRA LA SALIDA Y ENTRADA (TRASPASO)
|
|
' If Not ErrorExistencia Then
|
|
' ObjInventario.IniciaTransacSQL() 'Inicia la transacción
|
|
' Dim Fecha As Date = TxtFecha.Text.ToDate
|
|
|
|
' 'AGREGAMOS LA SALIDA DEL ALMACEN ORIGEN
|
|
' CveMovimientoSalida = ObjInventario.AddMovimiento(DdlAlmacenOrigen.SelectedValue.ToEntero, 8, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, CveAlmacenDestino:=DdlAlmacenDestino.SelectedValue.ToEntero, CveOS:=CveOS)
|
|
' FolioSalida = ObjInventario.Folio
|
|
|
|
' If CveMovimientoSalida <= 0 Then
|
|
' TextoError = "No se pudo generar el movimiento de salida correctamente"
|
|
' ErrorMovInv = True
|
|
' Else
|
|
|
|
' For Each Dr As DataRow In TmpDTSolicitarMaterial.Rows
|
|
' If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, -1) Then
|
|
' ErrorMovInv = True
|
|
' TextoError = "Ocurrió un error al guardar los movimientos de salida"
|
|
' Exit For
|
|
' End If
|
|
' Next
|
|
' End If
|
|
|
|
' 'AGREGAMOS LA ENTRADA
|
|
' If Not ErrorMovInv Then
|
|
' AlmacenEntrada = DdlAlmacenDestino.SelectedValue.ToEntero
|
|
|
|
' CveMovimientoEntrada = ObjInventario.AddMovimiento(AlmacenEntrada, 9, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, CveAlmacenDestino:=-1, CveMovimientoRelacionado:=CveMovimientoSalida, CveOS:=CveOS)
|
|
' FolioEntrada = ObjInventario.Folio
|
|
|
|
' If CveMovimientoEntrada <= 0 Then
|
|
' TextoError = "No se pudo generar el movimiento de entrada correctamente"
|
|
' ErrorMovInv = True
|
|
' Else
|
|
|
|
' If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
|
|
|
|
' For Each Dr As DataRow In ObjInventario.DtResultados.Rows
|
|
' If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, -1, -1) Then
|
|
' ErrorMovInv = True
|
|
' TextoError = "Ocurrió un error al guardar los movimientos de entrada"
|
|
' Exit For
|
|
' End If
|
|
' Next
|
|
|
|
' End If
|
|
|
|
' End If
|
|
' End If
|
|
|
|
|
|
' If Not ErrorMovInv Then
|
|
' ObjInventario.Commit()
|
|
' Dim Mensaje As StringBuilder = New StringBuilder
|
|
|
|
' Mensaje.Append("Se realizó con éxito el traspaso.")
|
|
|
|
' Mensaje.AppendFormat("<br/> Folio de Salida: <b><a href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={1}"" target=""_blank"">{0}</a></b>", FolioSalida, CveMovimientoSalida)
|
|
' Mensaje.AppendFormat("<br/><a target='_blank' href='/Compras/PopUpVerFactura.aspx?P={0}'>Imprimir Reporte</a>", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoSalida)))
|
|
|
|
' LimpiaMovimiento()
|
|
' Alert(Mensaje.ToString, TipoMensaje.MsgInformacion)
|
|
' Else
|
|
' ObjInventario.RollBack()
|
|
' Alert(TextoError, TipoMensaje.MsgError)
|
|
' RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
|
|
' End If
|
|
' Else
|
|
' Alert(TextoExistencia.ToString, TipoMensaje.MsgError)
|
|
' RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
|
|
' End If
|
|
|
|
|
|
' 'SI OCURRIO UN ERROR EN LA EXISTENCIA RECARGAMOS EL GRID PARA COLOREAR LOS DETALLES CON ERROR
|
|
' If ErrorExistencia Then
|
|
' Alert("Ocurrió un error en la existencia", TipoMensaje.MsgError)
|
|
' End If
|
|
|
|
' ObjInventario.Dispose()
|
|
' End If
|
|
'End Sub
|
|
Private Sub LimpiaMovimiento()
|
|
CargaAlmacen()
|
|
TxtFecha.Text = NowADS().ToShortDateString
|
|
UpAddMateriales.Update()
|
|
End Sub
|
|
Private Sub DdlSubProyecto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlSubProyecto.SelectedIndexChanged
|
|
CargaFolios(DdlSubProyecto.SelectedValue.ToEntero)
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
#Region "C A M B I A R T E C N I C O"
|
|
Private Sub CargaTecnico()
|
|
DdlTecnico.DataSource = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa)
|
|
DdlTecnico.DataBind()
|
|
DdlTecnico.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End Sub
|
|
Private Sub LnkTecnico_Click(sender As Object, e As EventArgs) Handles LnkTecnico.Click
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "DivCambiarTecnico"))
|
|
End Sub
|
|
Private Sub BtnCambiarTecnico_Click(sender As Object, e As EventArgs) Handles BtnCambiarTecnico.Click
|
|
Dim ObjOS As New ClsOS
|
|
Dim TieneError = False
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(151).ToString = "1" Then
|
|
If Not ObjOS.UpdateTecnicoOS(DdlTecnico.SelectedValue.ToEntero, CveOS) Then
|
|
TieneError = True
|
|
End If
|
|
Else
|
|
For Each row As GridViewRow In GvPSTecnico.Rows
|
|
If row.RowType = DataControlRowType.DataRow Then
|
|
If row.FCCheckBox("ChbxAsignar").Checked Then
|
|
|
|
If Not ObjOS.UpdateTecnicoOSGV(DdlTecnico.SelectedValue.ToEntero, row.DataKey("CveOSDetalle").ToEntero) Then
|
|
TieneError = True
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
|
|
If Not TieneError Then
|
|
Alert("Se asignaron las ordenes de servicio correctamente", TipoMensaje.MsgInformacion)
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivCambiarTecnico"))
|
|
CargaDetalles()
|
|
CargaDatos()
|
|
End If
|
|
|
|
ObjOS.Dispose()
|
|
|
|
End Sub
|
|
Private Sub GvPSTecnico_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvPSTecnico.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.DataKey("CveUsuarioAtendio").ToEntero > 0 Then
|
|
CveUsuarioAtendioCount += 1
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
Protected Sub LnkFinalizar_Click(sender As Object, e As EventArgs)
|
|
RegistraScript("$('#DVModalFinalizarOrden').modal('show');")
|
|
End Sub
|
|
|
|
Protected Sub LnkModalFinalizarOrden_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim TieneError As Boolean = True
|
|
|
|
Dim CvePsFinalizar As Integer = DdlPsModalFinalizar.SelectedValue.ToEntero
|
|
|
|
If Not CvePsFinalizar > 0 Then
|
|
Alert("El proiducto es requerido.", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
|
|
Dim objOS As New ClsOS
|
|
If objOS.UpdateOrdenesServiciosFinaliza(CveOS, CveOsDetalle, CvePsFinalizar, UsuarioActual.CveEmpresa) Then
|
|
TieneError = False
|
|
End If
|
|
objOS.Dispose()
|
|
|
|
If Not TieneError Then
|
|
Alert("Orden Finalizada Correctamente", TipoMensaje.MsgInformacion, "location.reload(true);")
|
|
RegistraScript("$('#DVModalFinalizarOrden').modal('hide');")
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Sub LnkAccionesDevolucion_Click(sender As Object, e As EventArgs)
|
|
|
|
LnkModalSolicitarDevolucion.Visible = True
|
|
|
|
GvSolicitarDevolucion.DataSource = Nothing
|
|
DTSolicitudDev = New DataTable
|
|
|
|
GvSolicitarDevolucion.Columns(3).Visible = False 'Lote
|
|
GvSolicitarDevolucion.Columns(4).Visible = False 'Serie
|
|
GvSolicitarDevolucion.Columns(5).Visible = False 'Fecha Caducidad
|
|
|
|
Dim ObjOS As New ClsOS
|
|
|
|
If ObjOS.GetOrdenesServicioDevolucionMaterial(CveOS, CveVenta, UsuarioActual.CveEmpresa) Then
|
|
DTSolicitudDev = ObjOS.DtResultados
|
|
GvSolicitarDevolucion.DataSource = DTSolicitudDev
|
|
End If
|
|
|
|
GvSolicitarDevolucion.Columns(3).Visible = DTSolicitudDev.MAX("Lote").ToString.Trim().Length > 0
|
|
GvSolicitarDevolucion.Columns(4).Visible = DTSolicitudDev.MAX("Serie").ToString.Trim().Length > 0
|
|
GvSolicitarDevolucion.Columns(5).Visible = DTSolicitudDev.MAX("FechaCaducidad").ToString.Trim().Length > 0
|
|
|
|
|
|
ObjOS.Dispose()
|
|
GvSolicitarDevolucion.DataBind()
|
|
|
|
Dim EsDevolucionVenta As Boolean = (DTSolicitudDev.FiltroPrimeroValor("EsDevolucionVenta", "").ToEntero > 0)
|
|
|
|
RegistraScript("$('#DVModalSolicitarDevolucion').modal();")
|
|
|
|
If EsDevolucionVenta Then
|
|
Alert("Ya existe una solicitud de devolución", TipoMensaje.MsgAdvertencia)
|
|
LnkModalSolicitarDevolucion.Visible = False
|
|
End If
|
|
|
|
UpModalSolicitarDevolucion.Update()
|
|
|
|
End Sub
|
|
|
|
Protected Sub GvSolicitarDevolucion_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
|
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
e.Row.FCTextBox("TxtDev").Attributes.Add("onblur", String.Format("ValidarCantidad(this, {0})", e.Row.DataKey("Cantidad")))
|
|
|
|
'AplicaSerie, AplicaLote, AplicaCaducidad
|
|
'If Boolean.Parse(e.Row.DataKey("AplicaSerie")) Then
|
|
' e.Row.FCTextBox("TxtSerie").Visible = True
|
|
'End If
|
|
|
|
'If Boolean.Parse(e.Row.DataKey("AplicaLote")) Then
|
|
' e.Row.FCTextBox("TxtLote").Visible = True
|
|
'End If
|
|
|
|
'If Boolean.Parse(e.Row.DataKey("AplicaCaducidad")) Then
|
|
|
|
' e.Row.FCHtmlGenericControl("DVFechaCaducidad").Visible = True
|
|
' 'e.Row.FCTextBox("TxtFechaCaducidad").Visible = True
|
|
' 'e.Row.FCMaskedEditExtender("METxtFechaCaducidad").Visible = True
|
|
' 'e.Row.FCCalendarExtender("CCTxtFechaCaducidad").Visible = True
|
|
' 'e.Row.FCCompareValidator("CVTxtFechaCaducidad").Visible = True
|
|
' 'e.Row.FCValidatorCalloutExtender("VCTxtFechaCaducidad").Visible = True
|
|
|
|
'End If
|
|
|
|
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub LnkModalSolicitarDevolucion_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim CveAlmacenActual As Integer = DTSolicitudDev.FiltroPrimeroValor("CveAlmacenActual").ToEntero
|
|
Dim CveMoneda As Integer = DTSolicitudDev.FiltroPrimeroValor("CveMoneda").ToEntero
|
|
Dim CveSubProyectoPedido As Integer = DTSolicitudDev.FiltroPrimeroValor("CveSubProyecto").ToEntero
|
|
Dim CveVentaPedido As Integer = DTSolicitudDev.FiltroPrimeroValor("CveVenta").ToEntero
|
|
|
|
|
|
|
|
Dim CveAlmacenDestino As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, 10).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto = {CveSubProyectoPedido}").ToEntero
|
|
|
|
If Not CveAlmacenDestino > 0 Then
|
|
Alert("No se encontro almacen de entrega por adelantado")
|
|
Exit Sub
|
|
End If
|
|
|
|
|
|
|
|
'Dim SbErroresDev As New StringBuilder
|
|
'Dim CantidadSeleccion As Integer = 0
|
|
|
|
'For Each GvRow As GridViewRow In GvSolicitarDevolucion.Rows
|
|
|
|
|
|
' If GvRow.DataKey("Cantidad").ToDecimal > 0 Then
|
|
|
|
' Dim sbTemperror As New StringBuilder
|
|
' Dim ErrorCountDev As Integer = 0
|
|
|
|
' sbTemperror.Append($"Producto: {GvRow.DataKey("CodigoPS") } requiere: ")
|
|
|
|
|
|
' If Boolean.Parse(GvRow.DataKey("AplicaSerie")) Then
|
|
' If GvRow.FCTextBox("TxtSerie").Text.Trim = String.Empty Then
|
|
' sbTemperror.Append($" Serie, ")
|
|
' ErrorCountDev = ErrorCountDev + 1
|
|
' End If
|
|
' End If
|
|
|
|
' If Boolean.Parse(GvRow.DataKey("AplicaLote")) Then
|
|
' If GvRow.FCTextBox("TxtLote").Text = String.Empty Then
|
|
' sbTemperror.Append($" Lote, ")
|
|
' ErrorCountDev = ErrorCountDev + 1
|
|
' End If
|
|
' End If
|
|
|
|
' If Boolean.Parse(GvRow.DataKey("AplicaCaducidad")) Then
|
|
' If Not IsDate(GvRow.FCTextBox("TxtFechaCaducidad").Text) Then
|
|
' sbTemperror.Append($" Fecha de caducidad")
|
|
' ErrorCountDev = ErrorCountDev + 1
|
|
' End If
|
|
' End If
|
|
|
|
' If ErrorCountDev > 0 Then
|
|
' sbTemperror.Append($"<br/>")
|
|
' SbErroresDev.AppendLine(sbTemperror.ToString)
|
|
' End If
|
|
|
|
' CantidadSeleccion = CantidadSeleccion + 1
|
|
|
|
' End If
|
|
|
|
'Next
|
|
|
|
''If CantidadSeleccion = 0 Then
|
|
'' Alert($"No se selecciono nigun producto", TipoMensaje.MsgAdvertencia)
|
|
'' Exit Sub
|
|
''End If
|
|
|
|
'If SbErroresDev.ToString.Length > 0 Then
|
|
' Alert($"Se encontraron los siguientes errores: <br> {SbErroresDev.ToString}", TipoMensaje.MsgAdvertencia)
|
|
' Exit Sub
|
|
'End If
|
|
|
|
Dim PropcesoOK As Boolean = True
|
|
Dim ObjV As New ClsVentas
|
|
ObjV.IniciaTransacSQL()
|
|
|
|
If Not ObjV.UpdateVentasDevolucionAlmacen(1, CveVenta) Then
|
|
PropcesoOK = False
|
|
End If
|
|
|
|
If PropcesoOK Then
|
|
For Each GvRow As GridViewRow In GvSolicitarDevolucion.Rows
|
|
|
|
Dim CveVentaDetalle As Integer = GvRow.DataKey("CveVentaDetalle").ToEntero
|
|
Dim CantidadDev As Decimal = GvRow.FCTextBox("TxtDev").Text.ToDecimal
|
|
|
|
If CantidadDev > 0 Then
|
|
If Not ObjV.UpdateVentasDetalleCantidadDevolucion(CveVentaDetalle, CantidadDev) Then
|
|
PropcesoOK = False
|
|
Exit For
|
|
End If
|
|
End If
|
|
|
|
Next
|
|
End If
|
|
|
|
|
|
Dim Respuesta = New RespuestaFacturacion()
|
|
|
|
If PropcesoOK Then
|
|
|
|
Respuesta = GeneraRemision(CveVentaPedido, ObjV.IniciaTransacSQL())
|
|
If Not Respuesta.CveVenta > 0 Then
|
|
PropcesoOK = False
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
|
|
If PropcesoOK Then
|
|
|
|
Dim ObjInventario As New ClsInventarios(ObjV.IniciaTransacSQL())
|
|
|
|
Dim CveMovimiento As Integer = ObjInventario.AddMovimiento(CveAlmacenActual, 8, CveMoneda, ClsPaginas.NowADS(), -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, Respuesta.CveVenta, CveSubProyectoPedido, -1, CveOS:=CveOS, CveAlmacenDestino:=CveAlmacenDestino)
|
|
Dim Folio As Integer = ObjInventario.Folio
|
|
|
|
If CveMovimiento > 0 Then
|
|
|
|
For Each GvRow As GridViewRow In GvSolicitarDevolucion.Rows
|
|
|
|
Dim Cantidad As Decimal = GvRow.DataKey("Cantidad").ToDecimal
|
|
Dim CantidadDev As Decimal = GvRow.FCTextBox("TxtDev").Text.ToDecimal
|
|
Dim CantidadRegistro = Cantidad - CantidadDev
|
|
Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero
|
|
Dim CveUM As Integer = GvRow.DataKey("CveUM").ToEntero
|
|
Dim PU As Decimal = GvRow.DataKey("PU").ToDecimal
|
|
Dim CveVentaDetalle As Integer = GvRow.DataKey("CveVentaDetalle").ToEntero
|
|
Dim CveMovimientoDetalle As Integer = GvRow.DataKey("CveMovimientoDetalle").ToEntero
|
|
|
|
Dim Lote As String = GvRow.DataKey("Lote")
|
|
Dim Serie As String = GvRow.DataKey("Serie")
|
|
Dim FechaCaducidad As DateTime = GvRow.DataKey("FechaCaducidad").ToDate
|
|
|
|
|
|
|
|
If CantidadRegistro > 0 Then
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, CantidadRegistro, CveUM, CvePS, PU, CveVentaDetalle:=CveVentaDetalle, CveMovimientoDetalleEntrada:=CveMovimientoDetalle, Lote:=Lote, Serie:=Serie, FechaCaducidad:=FechaCaducidad) Then
|
|
Alert("Error al agregar detalle de movimiento.", TipoMensaje.MsgAdvertencia)
|
|
PropcesoOK = False
|
|
Exit For
|
|
End If
|
|
End If
|
|
|
|
Next
|
|
|
|
If PropcesoOK Then
|
|
|
|
Dim CveMovimientoSalida As Integer = ObjInventario.AddMovimiento(CveAlmacenDestino, 9, CveMoneda, ClsPaginas.NowADS(), -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, Respuesta.CveVenta, CveSubProyectoPedido, -1, CveOS:=CveOS, CveMovimientoRelacionado:=CveMovimiento)
|
|
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then
|
|
|
|
For Each dRow As DataRow In ObjInventario.DtResultados.Rows
|
|
|
|
Dim Cantidad As Decimal = dRow("Cantidad").ToString.ToDecimal
|
|
Dim CvePS As Integer = dRow("CvePS").ToString.ToEntero
|
|
Dim CveUM As Integer = dRow("CveUM").ToString.ToEntero
|
|
Dim PU As Decimal = dRow("PU").ToString.ToDecimal
|
|
Dim CveVentaDetalle As Integer = dRow("CveVentaDetalle").ToString.ToEntero
|
|
Dim CveMovimientoDetalle As Integer = dRow("CveMovimientoDetalle").ToString.ToEntero
|
|
|
|
Dim Lote As String = dRow("Lote").ToString
|
|
Dim Serie As String = dRow("Serie").ToString
|
|
Dim FechaCaducidad As DateTime = dRow("FechaCaducidad").ToString.ToDateTime
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Cantidad, CveUM, CvePS, PU, CveVentaDetalle:=CveVentaDetalle, CveMovimientoDetalleEntrada:=CveMovimientoDetalle, Lote:=Lote, Serie:=Serie, FechaCaducidad:=FechaCaducidad) Then
|
|
Alert("Error al agregar detalle de movimiento.", TipoMensaje.MsgAdvertencia)
|
|
PropcesoOK = False
|
|
Exit For
|
|
End If
|
|
|
|
Next
|
|
|
|
If PropcesoOK Then
|
|
|
|
Dim ObjEventos As New ClsOIEventos(ObjInventario.IniciaTransacSQL)
|
|
Dim LigaVenta As String = String.Format("Venta {2} en Folio: <a href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}"" target=""_blank"">{1}</a>", CveMovimiento, Folio, "Material utilizado")
|
|
|
|
If Not ObjEventos.AddEventoBitacora(LigaVenta, "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=Respuesta.CveVenta, CveOS:=CveOS) Then
|
|
PropcesoOK = False
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
Else
|
|
PropcesoOK = False
|
|
End If
|
|
|
|
End If
|
|
|
|
Else
|
|
PropcesoOK = False
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
If PropcesoOK Then
|
|
|
|
ObjV.Commit()
|
|
|
|
Alert($"Proceso finalizado correctamente Remision generada <a class=""Texto"" href=""/Ventas/Ventas.aspx?CveVenta={Respuesta.CveVenta}"">{Respuesta.SerieFolio}</a> ")
|
|
|
|
RegistraScript("$('#DVModalSolicitarDevolucion').modal('hide');")
|
|
Else
|
|
ObjV.RollBack()
|
|
End If
|
|
|
|
|
|
|
|
ObjV.Dispose()
|
|
|
|
End Sub
|
|
|
|
Private Function GeneraRemision(CveVentaPedido As Integer, ByRef TransaccionSQL As SqlTransaction) As RespuestaFacturacion
|
|
|
|
Dim Respuesta = New RespuestaFacturacion()
|
|
|
|
Dim CveRemiocionGenerada As Integer = -1
|
|
|
|
Dim ObjVentas As New ClsVentas(TransaccionSQL)
|
|
Dim ProcesoOK As Boolean = True
|
|
|
|
Dim CveSubProyectoPedido As Integer = -1
|
|
Dim CveMoneda As Integer = -1
|
|
|
|
If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa, VerificaAlmacen:=False) Then
|
|
Dim DbRowVenta As DataRow = ObjVentas.DtResultados.Copy().Rows(0)
|
|
CveMoneda = DbRowVenta("CveMoneda").ToString.ToEntero
|
|
CveSubProyectoPedido = DbRowVenta("CveSubProyecto").ToString().ToEntero()
|
|
End If
|
|
|
|
Dim ObjFactura = Modelos.Factura.CrearVentaNueva(UsuarioActual, CveSubProyectoPedido, CveCliente, CveMoneda, "Rem")
|
|
|
|
If ObjFactura IsNot Nothing Then
|
|
|
|
If ProcesoOK Then
|
|
|
|
For Each GvRow As GridViewRow In GvSolicitarDevolucion.Rows
|
|
|
|
Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero
|
|
Dim Cantidad As Decimal = GvRow.DataKey("Cantidad").ToDecimal
|
|
Dim CantidadDev As Decimal = GvRow.FCTextBox("TxtDev").Text.ToDecimal
|
|
Dim CantidadRegistro = Cantidad - CantidadDev
|
|
Dim PU As Decimal = GvRow.DataKey("PU").ToDecimal
|
|
Dim Descuento As Decimal = GvRow.DataKey("Descuento").ToDecimal
|
|
Dim Obs As String = GvRow.DataKey("Observaciones")
|
|
|
|
If Not ObjFactura.AgregarPS(CvePS, CantidadRegistro, PU, Descuento, Obs, CveSubProyecto:=CveSubProyectoPedido) Then
|
|
Alert("Error al agregar producto", TipoMensaje.MsgAdvertencia)
|
|
ProcesoOK = False
|
|
Exit For
|
|
End If
|
|
|
|
Next
|
|
|
|
If ProcesoOK Then
|
|
ObjFactura.CalculaTotales()
|
|
|
|
|
|
Dim Resp As New Modelos.Factura.MMensajeFactura
|
|
Resp = ObjFactura.EmitirFactura(False, Transac:=TransaccionSQL)
|
|
|
|
If Resp.CveVenta > 0 Then
|
|
Respuesta.CveVenta = Resp.CveVenta
|
|
Respuesta.SerieFolio = Resp.SerieFolio
|
|
Else
|
|
ProcesoOK = False
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
End If
|
|
|
|
Else
|
|
ProcesoOK = False
|
|
End If
|
|
|
|
Return Respuesta
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Friend Class RespuestaFacturacion
|
|
Public Property CveVenta As Integer = -1
|
|
Public Property SerieFolio As String = "-1"
|
|
Public Sub New()
|
|
|
|
End Sub
|
|
End Class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
End Class |