diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index 5839b9a96..cf9ba7c1b 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -576,7 +576,7 @@ Public Class ClsVentas Optional AtencionA As String = "", Optional PedidoContrato As String = "", Optional CveFormaPago33 As Integer = -1, Optional CveMetodoPago33 As Integer = -1, Optional CveCliente As Integer = -1, Optional CveClienteSucursal As Integer = -1, Optional OrdenCompra As String = "-1", Optional RetIVA As Decimal = -1, Optional RetISR As Decimal = -1, Optional Kilometraje As Decimal = 0, Optional CveUsoCFDi As Integer = -1, Optional ServicioDomicilio As Boolean = False, Optional CveVendedor As Integer = -1, - Optional RequiereOS As Boolean = False, Optional CveMedico As Integer = -1, Optional CveProcedimiento As Integer = -1) As Boolean + Optional RequiereOS As Boolean = False, Optional CveMedico As Integer = -1, Optional CveProcedimiento As Integer = -1, Optional FechaParaSurtir As DateTime = MinFecha) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Vta_VentasUpdate") @@ -612,6 +612,7 @@ Public Class ClsVentas .Add("@RequiereOS", SqlDbType.Int).Value = RequiereOS .Add("@CveMedico", SqlDbType.Int).Value = CveMedico .Add("@CveProcedimiento", SqlDbType.Int).Value = CveProcedimiento + .Add("@FechaParaSurtir", SqlDbType.DateTime).Value = FechaParaSurtir End With Try @@ -625,7 +626,8 @@ Public Class ClsVentas End Function Public Function UpdateObservacionesVenta(CveVenta As Integer, CveEmpresa As Integer, CveVendedor As Integer, Observaciones As String, FormaPaqueteria As Integer, CorreoNotificaciones As String, ObservacionesAlm As String, - Pedido As String, OrdenCompra As String, FechaPago As String, CveUsoCFDI As Integer, Optional DescripcionVenta As String = "-1", Optional CveMedico As Integer = -1, Optional CveProcedimiento As Integer = -1) As Boolean + Pedido As String, OrdenCompra As String, FechaPago As String, CveUsoCFDI As Integer, Optional DescripcionVenta As String = "-1", Optional CveMedico As Integer = -1, Optional CveProcedimiento As Integer = -1, + Optional FechaParaSurtir As DateTime = MinFecha) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Vta_VentasObservacionesUpdate") With SqlAdapter.SelectCommand.Parameters @@ -643,8 +645,42 @@ Public Class ClsVentas .Add("@DescripcionVenta", SqlDbType.VarChar).Value = DescripcionVenta .Add("@CveMedico", SqlDbType.Int).Value = CveMedico .Add("@CveProcedimiento", SqlDbType.Int).Value = CveProcedimiento + .Add("@FechaParaSurtir", SqlDbType.DateTime).Value = FechaParaSurtir + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar las observaciones de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + Public Function UpdateEstatusOCRelacionada(CveVenta As Integer, CveEstatusOrdenServicio As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasOSEstatusUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@CveEstatusOrdenServicio", SqlDbType.Int).Value = CveEstatusOrdenServicio + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar las observaciones de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + Public Function UpdateFechaOSVenta(CveVenta As Integer, FechaCita As DateTime, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasOSFechaCitaUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@FechaCita", SqlDbType.DateTime).Value = FechaCita + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa End With Try SqlAdapter.Fill(Data) diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index df92c7193..ebd40bcc6 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -6221,6 +6221,17 @@ Namespace Modelos End If End If + 'CANCELAR ORDEN DE SERVICIO + If Not ErrorCancelar Then + If ObjFactura.CveMedico > 0 Then + Dim CveEstatusCancelacion As Integer = ClsPaginas.GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveEstatusOrdenServicio", "TipoEstatus = 5", "Orden ASC").ToString().ToEntero() + If Not ObjVentas.UpdateEstatusOCRelacionada(ObjFactura.CveVenta, CveEstatusCancelacion, ObjFactura.CveEmpresa) Then + ErrorCancelar = True + MensajeError = "Ocurrió un error al cancelar la orden de servicio" + End If + End If + End If + End If 'MARCA LA VENTA PARA REALIZAR LA DEVOLUCION POSTERIORMENTE diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 9282f899e..4c5688448 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -2448,8 +2448,6 @@ Partial Class Ventas CveAlmacenDevolucion = 0 Me.CveEstadoCancelacion = 0 - TxtFechaOS.Text = NowADS().ToDateTime.ToString("yyyy-MM-dd HH:mm:ss").Replace(" ", "T") - txtFechaICot.Text = NowADS().AddMonths(-3).ToShortDateString TxtFechaIRem.Text = NowADS().AddMonths(-3).ToShortDateString TxtFechaIPed.Text = NowADS().AddMonths(-3).ToShortDateString @@ -2831,6 +2829,8 @@ Partial Class Ventas End If Else + TxtFechaOS.Text = NowADS().ToDateTime.ToString("yyyy-MM-dd HH:mm").Replace(" ", "T") + If Request("CveOS") IsNot Nothing AndAlso IsNumeric(Request("CveOS")) AndAlso Request("CveOS").ToEntero() > 0 Then ViewState("CveOS") = Request("CveOS") CargaOS(CveOS) @@ -5869,21 +5869,28 @@ Partial Class Ventas CveTipoVenta = If(DbRowVenta("CveTipoVenta").ToString.ToEntero > 0, DbRowVenta("CveTipoVenta").ToString.ToEntero, -1) - If DbRowVenta("CveMedico").ToString.ToEntero > 0 AndAlso CveTipoVenta.Contiene(1, 3, 5) Then + If DbRowVenta("CveMedico").ToString.ToEntero > 0 AndAlso CveTipoVenta.Contiene(1, 2, 3, 5) Then TrVentasMedicas1.Visible = True DdlMedico.SelectedValueExist(DbRowVenta("CveMedico").ToString) DdlProcedimiento.SelectedValueExist(DbRowVenta("CveProcedimiento").ToString) - DdlMedico.Enabled = False DdlProcedimiento.Enabled = False + If DbRowVenta("FechaParaSurtir").ToString().ToDate() > DateTime.MinValue Then + TrVentasMedicas2.Visible = True + ChkRequiereTecnico.Enabled = False + TxtFechaOS.Enabled = False + + TxtFechaOS.Text = DbRowVenta("FechaParaSurtir").ToString().ToDateTime().ToString("yyyy-MM-dd HH:mm").Replace(" ", "T") + End If + End If + + End If - - End If Return Retorno End Function @@ -21676,6 +21683,12 @@ Partial Class Ventas DdlMetodoPago33.Enabled = True End If + If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then + If DdlMedico.SelectedValue.ToEntero() > 0 Then + TxtFechaOS.Enabled = True + End If + End If + UPPVentas.Update() UpPS.Update() UpCliente.Update() @@ -21775,10 +21788,18 @@ Partial Class Ventas PedidoContrato:=TxtPedidoContrato.Text, AtencionA:=TxtAtencionA.Text.Trim, CveMetodoPago33:=DdlMetodoPago33.SelectedValue.ToEntero(), CveFormaPago33:=DdlFormaPago33.SelectedValue.ToEntero(), TipoDocto:=DdlTipoComprobante.SelectedValue, CveCliente:=CveCliente, CveClienteSucursal:=CveClienteSucursal, OrdenCompra:=TxtOrdenCompra.Text, RetIVA:=TxtRetIVA.Text.ToDecimal, RetISR:=TxtRetISR.Text.ToDecimal, Kilometraje:=TxtKilometraje.Text.ToDecimal, CveUsoCFDi:=DdlUsoCFDI.SelectedValue.ToEntero(), - CveVendedor:=DdlVendedor.SelectedValue.ToEntero(), ServicioDomicilio:=TrServicioDomicilio.Visible, CveMedico:=DdlMedico.SelectedValue.ToEntero, CveProcedimiento:=DdlProcedimiento.SelectedValue.ToEntero) Then + CveVendedor:=DdlVendedor.SelectedValue.ToEntero(), ServicioDomicilio:=TrServicioDomicilio.Visible, CveMedico:=DdlMedico.SelectedValue.ToEntero, CveProcedimiento:=DdlProcedimiento.SelectedValue.ToEntero, FechaParaSurtir:=TxtFechaOS.Text.Replace(",", "").ToDateTime()) Then OcurrioError = True End If + If Not OcurrioError Then + If DdlMedico.SelectedValue.ToEntero() > 0 Then + If Not ObjVentas.UpdateFechaOSVenta(CveVenta, TxtFechaOS.Text.Replace(",", "").ToDateTime(), UsuarioActual.CveEmpresa) Then + OcurrioError = True + End If + End If + End If + 'Cargo de nueva cuenta el detalle de Ventas (Conceptos) If Not OcurrioError Then Dim index As Integer = 0 @@ -33603,6 +33624,12 @@ Partial Class Ventas TxtDescripcionVenta.Enabled = True + If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then + If DdlMedico.SelectedValue.ToEntero() > 0 Then + TxtFechaOS.Enabled = True + End If + End If + UpCliente.Update() UpParametros.Update() UPObservaciones.Update() @@ -33626,10 +33653,18 @@ Partial Class Ventas If Not ObjVentas.UpdateObservacionesVenta(Me.CveVenta, UsuarioActual.CveEmpresa, DdlVendedor.SelectedValue.ToEntero(), TxtObsFact.Text, RblPaqueteria.SelectedValue.ToEntero(), TxtCorreoNotificaciones.Text, TxtObsAlmacen.Text, TxtPedidoContrato.Text, TxtOrdenCompra.Text, TxtFechaPago.Text, DdlUsoCFDI.SelectedValue.ToEntero, DescripcionVenta:=TxtDescripcionVenta.Text.Trim, - CveMedico:=DdlMedico.SelectedValue.ToEntero, CveProcedimiento:=DdlProcedimiento.SelectedValue.ToEntero) Then + CveMedico:=DdlMedico.SelectedValue.ToEntero, CveProcedimiento:=DdlProcedimiento.SelectedValue.ToEntero, FechaParaSurtir:=TxtFechaOS.Text.Replace(",", "").ToDateTime()) Then TieneError = True End If + If Not TieneError Then + If DdlMedico.SelectedValue.ToEntero() > 0 Then + If Not ObjVentas.UpdateFechaOSVenta(CveVenta, TxtFechaOS.Text.Replace(",", "").ToDateTime(), UsuarioActual.CveEmpresa) Then + TieneError = True + End If + End If + End If + If Not TieneError AndAlso AplicaUpdateTC Then If Not ObjVentas.UpdateVentaTC(Me.CveVenta, UsuarioActual.CveEmpresa, TxtTipoCambio.Text.ToDecimal()) Then TieneError = True @@ -36373,7 +36408,7 @@ Partial Class Ventas Dim EstatusOrdenServicio As Integer = GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveEstatusOrdenServicio", "TipoEstatus = 1").ToEntero If ObjOrdenServicio.AddOrdenesServicios(CveCliente, DdlSubProyectoDatos.SelectedValue.ToEntero, UsuarioActual.Nombre, TxtFechaOS.Text.Replace(",", "").ToDateTime, $"Venta: {LblSerie.Text}-{TxtFolio.Text}", UsuarioActual.CveUsuario, EstatusOrdenServicio, - UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, CveOSTipo, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero, + UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVentaOS, -1, -1, CveOSTipo, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero, Direccion:="", Telefono:="", CveModeloAuto:=-1, Año:="", CveMedico:=DdlMedico.SelectedValue.ToEntero, CveProcedimiento:=DdlProcedimiento.SelectedValue.ToEntero, CveTipoVenta:=RBLTipoVenta.SelectedValue.ToEntero, FechaCita:=TxtFechaOS.Text.Replace(",", "").ToDateTime) Then CveOSVentaMedica = ObjOrdenServicio.CveOS