From db978c769e57036bb6524ccf615065a92fbe70c9 Mon Sep 17 00:00:00 2001 From: rakcsle Date: Thu, 3 Apr 2025 13:35:46 -0700 Subject: [PATCH] Rep Agro Precios Ventas --- Agropecuaria/RepPreciosVentaManifiesto.aspx | 381 +++++++++++++---- .../RepPreciosVentaManifiesto.aspx.vb | 403 ++++++++++-------- App_Code/ClsVentas.vb | 176 ++++++++ Compras/Compras.aspx.vb | 2 +- 4 files changed, 712 insertions(+), 250 deletions(-) diff --git a/Agropecuaria/RepPreciosVentaManifiesto.aspx b/Agropecuaria/RepPreciosVentaManifiesto.aspx index d61fd61be..053da4e12 100644 --- a/Agropecuaria/RepPreciosVentaManifiesto.aspx +++ b/Agropecuaria/RepPreciosVentaManifiesto.aspx @@ -1,30 +1,40 @@ -<%@ Page Title="Reporte de Ordenes de Servicio Médicas" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RepPreciosVentaManifiesto.aspx.vb" Inherits="Agrupecuaria_RepPreciosVentaManifiesto" %> +<%@ Page Title="Precios Ventas" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RepPreciosVentaManifiesto.aspx.vb" Inherits="Agrupecuaria_RepPreciosVentaManifiesto" %> + + + +
  • + + Agregar Precio + +
  • +
    +
    - Reporte de Ordenes de Servicio Médicas + Precios Ventas - - -
  • - Excel -
  • -
    - - - -
    +
    @@ -37,17 +47,13 @@
    -
    - - - +
    - Fecha Inicio: - + Fecha Inicio:
    -
    +
    - + @@ -60,12 +66,11 @@
    - Fecha Fin: - + Fecha Fin:
    -
    +
    - + @@ -78,26 +83,28 @@
    - SubProyecto: -
    - +
    + : +
    +
    +
    - - + +
    + +
    +
    @@ -110,48 +117,272 @@ - - - <%--0--%> - - <%----%> - <%--1--%> - - <%--2--%> - - <%--3--%> - - <%--4--%> - - <%--5--%> - - <%--6--%> - - <%--7--%> - - <%--8--%> - - <%--9--%> - - <%--10--%> - - <%--11--%> - - <%--12--%> - - <%--13--%> - - <%--14--%> - - - - - +
    +
    + + + + + + + + + + + + + + + + + + + +
    +
    +
    + +<%-- POPUP Modal GV Precios Venta Fecha --%> + + + +<%-- POPUP AGREGAR Precios Venta Fecha --%> + + + + + diff --git a/Agropecuaria/RepPreciosVentaManifiesto.aspx.vb b/Agropecuaria/RepPreciosVentaManifiesto.aspx.vb index 53e5f678f..83e69a17a 100644 --- a/Agropecuaria/RepPreciosVentaManifiesto.aspx.vb +++ b/Agropecuaria/RepPreciosVentaManifiesto.aspx.vb @@ -2,260 +2,315 @@ Option Strict On Imports System.Data +Imports System.DirectoryServices.ActiveDirectory Imports Extensiones Partial Class Agrupecuaria_RepPreciosVentaManifiesto Inherits ClsPaginas + Private Property CvePrecioVentaFecha As Integer + Get + If ViewState("CvePrecioVentaFecha") Is Nothing Then + ViewState("CvePrecioVentaFecha") = -1 + End If + Return ViewState("CvePrecioVentaFecha").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CvePrecioVentaFecha") = value + End Set + End Property + + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then If UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario.Contiene(77, 21) Then Response.Redirect("/Inicio.aspx") + txtFechaI.Text = $"01/{Now.Month.ToString("0#")}/{Now.Year}" + txtFechaF.Text = Now.ToString("dd/MM/yyyy") + + TxtModalFechaInicio.Text = $"01/{Now.Month.ToString("0#")}/{Now.Year}" + TxtModalFechaFin.Text = Now.ToString("dd/MM/yyyy") + CargaCombos() CargaDatos() End If End Sub - #Region " CARGA COMBOS " - Private Sub CargaCombos() + CargarCentrosDeCosto(Nothing, DdlSubProyecto, Nothing, LblSubProyecto) + CargaManifiesto(-1) + CargaCultivo(-1) + End Sub - CargarCentrosDeCosto(DdlProyecto, DdlSubProyecto, LblProyecto, LblSubProyecto, divProyecto:=DivProyecto) + Private Sub CargaManifiesto(CveSubProyecto As Integer) - CargaCultivo() + DdlManifiesto.ClearSelection() + DdlManifiesto.SelectedValue = Nothing + DdlManifiesto.Items.Clear() - 'CargaEstatus - DdlEstatusOS.DataSource = GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa) - DdlEstatusOS.DataBind() - DdlEstatusOS.Items.Insert(0, New ListItem("Todos", "-1")) - Dim DTTecnicos As DataTable = Nothing + Dim objNow As New ClsNominas - Dim ObjOS As New ClsOS - If ObjOS.GetSubProyectosEstatusInicial(-1, 3, UsuarioActual.CveEmpresa) Then - DTTecnicos = ObjOS.DtResultados - End If - ObjOS.Dispose() - - DdlTecnico.DataSource = DTTecnicos - DdlTecnico.DataBind() - DdlTecnico.Items.Insert(0, New ListItem("Todos", "-1")) - DdlTecnico.Items.Insert(1, New ListItem("Sin Asignar", "-2")) - - '376 - If UsuarioActual.TienePermisoProceso(376) Then - DdlTecnico.Enabled = False - DdlTecnico.SelectedValueExist(UsuarioActual.CveUsuario) + If objNow.EmbarqueManifiestoGet(CveSubProyecto, -1, UsuarioActual.CveEmpresa, -1) Then + DdlManifiesto.DataSource = objNow.DtResultados.FiltraParametros("", "", {"CveEmbarqueManifiesto", "NoEmbarque"}) End If + objNow.Dispose() - If IfNull(Request("CveUsuarioTecnico"), 0).ToString.ToEntero > 0 Then - DdlTecnico.SelectedValueExist(Request("CveUsuarioTecnico").ToString) - Else - ViewState("CveUsuarioTecnico") = -1 - End If + DdlManifiesto.DataBind() + DdlManifiesto.Items.Insert(0, New ListItem("Todos", "-1")) - 'CargaClientes - Dim EsWS As Boolean = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False) - 'If EsWS Then - ' DdlClientes.setEsWebService(True) - 'Else - ' DdlClientes.setEsWebService(False) - ' DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1) - ' DdlClientes.DataBind() - ' DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1")) - 'End If + End Sub + Private Sub CargaCultivo(CveSubProyecto As Integer) - 'Vendedor - DdlVendedor.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa, VendedorTipo:=-1).FiltraParametros("VendedorTipo in (1,4)") 'vendedores y vendedores de piso - DdlVendedor.DataBind() - DdlVendedor.Items.Insert(0, New ListItem("Todos", "-1")) - DdlVendedor.Items.Insert(1, New ListItem("Sin Vendedor", "-2")) - - If UsuarioActual.CveVendedor > 0 Then - DdlVendedor.SelectedValueExist(UsuarioActual.CveVendedor) - DdlVendedor.Enabled = False - End If - - txtFechaI.Text = NowADS().FirstDayOfMonth.ToShortDateString - txtFechaF.Text = NowADS().AddDays(2).ToShortDateString - - - DdlMedico.DataSource = If(UsuarioActual.CveVendedor > 0, GlobalDTMedicos(UsuarioActual.CveEmpresa).FiltraParametros($" Estatus = 'True' AND CveVendedor = {UsuarioActual.CveVendedor} "), GlobalDTMedicos(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'True' ")) - DdlMedico.DataBind() - - DdlProcedimiento.DataSource = GlobalDTProcedimientos(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'True' ") - DdlProcedimiento.DataBind() - - DdlTipoVenta.DataSource = GlobalDTTipoVenta(UsuarioActual.CveEmpresa) - DdlTipoVenta.DataBind + DdlCultivo.ClearSelection() + DdlCultivo.SelectedValue = Nothing + DdlCultivo.Items.Clear() Dim ObjVentas As New ClsVentas - If ObjVentas.GetMedicosEspecialidades(-1, UsuarioActual.CveEmpresa, -1) Then - DdlEspecialidad.DataSource = ObjVentas.DtResultados + If ObjVentas.GetCultivos(-1, UsuarioActual.CveEmpresa) Then + DdlCultivo.DataSource = ObjVentas.DtResultados Else - DdlEspecialidad.DataSource = Nothing + DdlCultivo.DataSource = Nothing End If ObjVentas.Dispose() - DdlEspecialidad.DataBind() - DdlEspecialidad.Items.Insert(0, New ListItem("Todas", "-1")) + DdlCultivo.DataBind() + DdlCultivo.Items.Insert(0, New ListItem("Todos", "-1")) - DdlClienteSucursal.DataSource = GlobalDTClientesTodosSucursales(UsuarioActual.CveEmpresa) - DdlClienteSucursal.DataBind() - DdlClienteSucursal.Items.Insert(0, New ListItem("Todos", "-1")) - - 'Dim EsWS As Boolean = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False) - 'If EsWS Then - ' DdlCliente.setEsWebService(True) - - 'Else - ' DdlCliente.setEsWebService(False) - ' DdlCliente.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1) - ' DdlCliente.DataBind() - ' DdlCliente.ddl.Items.Insert(0, New ListItem("Seleccione Uno", "-1")) - 'End If - - End Sub - - Private Sub CargaCultivo() - DdlCultivo.Items.Clear() - If DdlSubProyecto.GetSelectedValuesM(True) <> "" Then - DdlCultivo.DataSource = GlobalDTCultivosCuadro(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CveSubProyecto IN ({0})", DdlSubProyecto.GetSelectedValuesM(True))) - DdlCultivo.DataBind() - Else - DdlCultivo.DataSource = Nothing - DdlCultivo.DataBind() - End If End Sub #End Region + Protected Sub DdlSubProyecto_SelectedIndexChanged(sender As Object, e As EventArgs) + CargaCultivo(DdlSubProyecto.SelectedValue.ToEntero) + CargaManifiesto(DdlSubProyecto.SelectedValue.ToEntero) + UPFiltros.Update() + End Sub + #Region " CARGA DATOS " Protected Sub BtnConsultar_Click(sender As Object, e As System.EventArgs) Handles BtnConsultar.Click - CargaDatos() - End Sub Private Sub CargaDatos() - Dim ObjOS As New ClsOS - Dim FechaI As Date = If(txtFechaI.Text.Trim = "", MinFecha, txtFechaI.Text.ToDate) - Dim FechaF As Date = If(txtFechaF.Text.Trim = "", MaxFecha, txtFechaF.Text.ToDate) - Dim Cvecliente As Integer = DdlClienteSucursalCliente() - Dim CveClienteSucursal As Integer = DdlClienteSucursalSucursal() - LnkPersonalizar.Visible = False + Dim objVenas As New ClsVentas - If ObjOS.GetRepOrdenesServicioMedicasRep(FechaI, FechaF, Cvecliente, DdlVendedor.SelectedValue.ToEntero, DdlEstatusOS.SelectedValue.ToEntero, DdlTecnico.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, - CveMedico:=DdlMedico.SelectedValue.ToEntero, CveProcedimiento:=DdlProcedimiento.SelectedValue.ToEntero, CveEspecialidad:=DdlEspecialidad.SelectedValue.ToEntero, - CveClienteSucursal:=CveClienteSucursal, CveUsuario:=UsuarioActual.CveUsuario, CveTipoVenta:=DdlTipoVenta.SelectedValue.ToEntero) Then - GvDatos.DataSource = ObjOS.DtResultados - If ObjOS.DtResultados IsNot Nothing AndAlso ObjOS.DtResultados.Rows.Count > 0 Then - LnkPersonalizar.Visible = True - End If + If objVenas.GetPreciosVentaManifiesto(txtFechaI.Text.ToDate, txtFechaF.Text.ToDate, DdlManifiesto.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, DdlCultivo.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then + GvDatos.DataSource = objVenas.DtResultados Else GvDatos.DataSource = Nothing End If - - ObjOS.Dispose() + objVenas.Dispose() GvDatos.DataBind() - - LnkExportar.Visible = If(GvDatos.Rows.Count > 0, True, False) UpAcciones.Update() - - UPDatos.Update() End Sub - #End Region - 'Private Sub CargaClientes() - ' DdlClientes.ddl.Items.Clear() - ' DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1) '.FiltraParametros($"CveClienteClasificacion = {DdlClienteClasificacion.SelectedValue.ToEntero} OR {DdlClienteClasificacion.SelectedValue.ToEntero} = -1") - ' DdlClientes.DataBind() - ' DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1")) - 'End Sub - - Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlProyecto.SelectedIndexChanged - CargarSubProyecto(DdlSubProyecto, DdlProyecto.SelectedValue) - End Sub - - #Region " GV DATOS - ROW DATABOUND " Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - e.Row.Cells(1).Attributes.Add("data-order", e.Row.DBCampo("FechaCita").ToDateTime.ToString("yyyyMMddHHmm")) - If e.Row.DBCampo("CveOS") = "" Then - e.Row.CssClass = "Totales" - End If - End If End Sub #End Region - Private Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click + Protected Sub LnkAddPreciosVentaFecha_Click(sender As Object, e As EventArgs) - Dim SubProyecto As String = "" + CargaCultivoModal(-1) + CargaPreciosVentaFecha() + CargaTamaños() - If DdlSubProyecto.SelectedValue.ToEntero > 0 Then - SubProyecto = DdlSubProyecto.SelectedItem.Text - End If - - Dim SbFiltros As New StringBuilder() - SbFiltros.AppendFormat($"Fecha Inicio: {txtFechaI.Text} Fecha Fin: {txtFechaF.Text}|") - SbFiltros.AppendFormat("SubProyecto: {0}|", SubProyecto) - - - GvDatos.ExportToExcelGembox("OrdenesServicio", UsuarioActual, "Ordenes de Servicio Medicas", DatoTituloExtra:=$"", DatosFiltros:=SbFiltros.ToString()) + RegistraScript("$('#DVModalGVPreciosVentaFecha').modal('show');") End Sub - Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control) - End Sub + Private Sub CargaCultivoModal(CveSubProyecto As Integer) - Protected Sub LnkPersonalizar_Click(sender As Object, e As EventArgs) + DdlModalCultivo.ClearSelection() + DdlModalCultivo.SelectedValue = Nothing + DdlModalCultivo.Items.Clear() - ' ChkGuardarPersonalizacion.Checked = False - RegistraScript("$('#DivPersonalizar').modal('show')") + Dim ObjVentas As New ClsVentas - End Sub - - Protected Sub BtnPersonalizar_Click(sender As Object, e As System.EventArgs) Handles BtnPersonalizar.Click - Personaliza() - End Sub - - Private Sub Personaliza() - GvDatos.Columns(13).Visible = ChkObservaciones.Checked - GvDatos.Columns(14).Visible = ChkFolioAdicional.Checked - CargaDatos() - End Sub - - Private Function DdlClienteSucursalCliente() As Integer - If DdlClienteSucursal.SelectedValue = "-1" Then - Return -1 + If ObjVentas.GetCultivos(-1, UsuarioActual.CveEmpresa) Then + DdlModalCultivo.DataSource = ObjVentas.DtResultados Else - Dim array As String() = DdlClienteSucursal.SelectedValue.Split("|"c) - Return If(array(0).ToEntero > 0, array(0).ToEntero, -1) + DdlModalCultivo.DataSource = Nothing End If - End Function - Private Function DdlClienteSucursalSucursal() As Integer - If DdlClienteSucursal.SelectedValue = "-1" Then - Return -1 + ObjVentas.Dispose() + + DdlModalCultivo.DataBind() + DdlModalCultivo.Items.Insert(0, New ListItem("Seleccione", "-1")) + + End Sub + + Private Sub CargaCultivoVariedadModal(CveCultivo As Integer) + + DdlModalCultivoVariedad.ClearSelection() + DdlModalCultivoVariedad.SelectedValue = Nothing + DdlModalCultivoVariedad.Items.Clear() + + Dim objVentas As New ClsVentas + + If objVentas.GetCultivosVariedad(CveCultivo, -1, UsuarioActual.CveEmpresa) Then + DdlModalCultivoVariedad.DataSource = objVentas.DtResultados + End If + + objVentas.Dispose() + + DdlModalCultivoVariedad.DataBind() + DdlModalCultivoVariedad.Items.Insert(0, New ListItem("Seleccione", "-1")) + + End Sub + + Private Sub CargaTamaños() + + DdlModalTamaño.ClearSelection() + DdlModalTamaño.SelectedValue = Nothing + DdlModalTamaño.Items.Clear() + + Dim objVentas As New ClsVentas + + If objVentas.GetEmbarqueTamaño(-1, -1, UsuarioActual.CveEmpresa) Then + DdlModalTamaño.DataSource = objVentas.DtResultados + End If + + objVentas.Dispose() + + DdlModalTamaño.DataBind() + DdlModalTamaño.Items.Insert(0, New ListItem("Seleccione", "-1")) + + End Sub + Protected Sub DdlModalCultivo_SelectedIndexChanged(sender As Object, e As EventArgs) + CargaCultivoVariedadModal(DdlModalCultivo.SelectedValue.ToEntero) + UpModalPreciosVentaFecha.Update() + End Sub + + + Protected Sub LnkModalBuscar_Click(sender As Object, e As EventArgs) + CargaPreciosVentaFecha() + End Sub + + Private Sub CargaPreciosVentaFecha() + + Dim objVentas As New ClsVentas + Dim FechaInicio As Date = If(TxtModalFechaInicio.Text.ToDate > MinFecha, TxtModalFechaInicio.Text.ToDate, MinFecha) + Dim FechaFin As Date = If(TxtModalFechaFin.Text.ToDate > MinFecha, TxtModalFechaFin.Text.ToDate, MaxFecha) + + If objVentas.GetPreciosVentaFecha(FechaInicio, FechaFin, -1, -1, -1, UsuarioActual.CveEmpresa) Then + GVPrecioVentaFecha.DataSource = objVentas.DtResultados Else - Dim array As String() = DdlClienteSucursal.SelectedValue.Split("|"c) - Return If(array(1).ToEntero > 0, array(1).ToEntero, -1) + GVPrecioVentaFecha.DataSource = Nothing End If - End Function + + objVentas.Dispose() + + GVPrecioVentaFecha.DataBind() + + UpModalGVPreciosVentaFecha.Update() + + End Sub + + Protected Sub LnkModalGuardarPreciosVentaFecha_Click(sender As Object, e As EventArgs) + + Dim objVentas As New ClsVentas + Dim ProcesoOC As Boolean = True + + If CvePrecioVentaFecha > 0 Then + + If Not objVentas.UpdatePreciosVentaFecha(CvePrecioVentaFecha, DdlModalCultivo.SelectedValue.ToEntero, DdlModalTamaño.SelectedValue.ToEntero, TxtModalDescripcion.Text.Trim, TxtModalFecha.Text.ToDate, DdlModalCultivoVariedad.SelectedValue.ToEntero, + TxtPrecioVentaFecha.Text.ToDecimal, UsuarioActual.CveEmpresa, UsuarioActual.CveEmpresa) Then + ProcesoOC = False + End If + + Else + If Not objVentas.AddPreciosVentaFecha(DdlModalCultivo.SelectedValue.ToEntero, TxtModalDescripcion.Text.Trim, TxtModalFecha.Text.ToDate, DdlModalCultivoVariedad.SelectedValue.ToEntero, + DdlModalTamaño.SelectedValue.ToEntero, TxtPrecioVentaFecha.Text.ToDecimal, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + ProcesoOC = False + End If + End If + + objVentas.Dispose() + + If ProcesoOC Then + CargaPreciosVentaFecha() + Alert("Precio Guardado correctamente.") + End If + + End Sub + + Protected Sub LnkEditarPrecioVentaFecha_Click(sender As Object, e As EventArgs) + + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Dim ProcesoOK As Boolean = True + + CvePrecioVentaFecha = GvRow.DataKey("CvePrecioVentaFecha").ToEntero + + DdlModalCultivo.SelectedValueExist(GvRow.DataKey("CveCultivo")) + CargaCultivoVariedadModal(DdlModalCultivo.SelectedValue.ToEntero) + DdlModalTamaño.SelectedValueExist(GvRow.DataKey("CveTamaño")) + TxtModalDescripcion.Text = GvRow.DataKey("Descripcion") + TxtModalFecha.Text = GvRow.DataKey("Fecha").ToDate.ToString("dd/MM/yyyy") + DdlModalCultivoVariedad.SelectedValueExist(GvRow.DataKey("CveCultivoVariedad")) + + 'If ProcesoOK Then + ' CargaPreciosVentaFecha() + 'End If + + UpModalPreciosVentaFecha.Update() + RegistraScript("$('#DVModalPreciosVentaFecha').modal('show');") + + End Sub + + Protected Sub LnkEliminarPrecioVentaFecha_Click(sender As Object, e As EventArgs) + + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Dim ProcesoOK As Boolean = True + Dim CvePrecioVentaFechaElimianr As Integer = GvRow.DataKey("CvePrecioVentaFecha").ToEntero + Dim objVentas As New ClsVentas + + If Not objVentas.DeletePreciosVentaFecha(CvePrecioVentaFechaElimianr, UsuarioActual.CveEmpresa) Then + ProcesoOK = False + End If + + objVentas.Dispose() + + If ProcesoOK Then + CargaPreciosVentaFecha() + UpModalPreciosVentaFecha.Update() + RegistraScript("$('#DVModalPreciosVentaFecha').modal('hide');") + Alert("Precio eliminado correctamente.") + End If + + + + End Sub + + Protected Sub LnkModalMuestraAdd_Click(sender As Object, e As EventArgs) + + CvePrecioVentaFecha = -1 + + DdlModalCultivo.SelectedValueExist(-1) + DdlModalTamaño.SelectedValueExist(-1) + TxtModalDescripcion.Text = "" + TxtModalFecha.Text = "" + DdlModalCultivoVariedad.SelectedValueExist(-1) + + UpModalPreciosVentaFecha.Update() + + RegistraScript("$('#DVModalPreciosVentaFecha').modal('show');") + + End Sub End Class diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index 81ca7b875..fc516e130 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -3,6 +3,7 @@ Option Strict On Imports System.Data Imports System.Data.SqlClient +Imports System.Runtime.CompilerServices Imports Extensiones Imports Profact.TimbraCFDI40 @@ -7715,6 +7716,181 @@ Public Class ClsVentas Return Retorno End Function + + Public Function GetPreciosVentaManifiesto(FechaInicio As Date, FechaFin As Date, CveEmbarqueManifiesto As Integer, CveSubProyecto As Integer, CveCultivo As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Agro_PreciosVentaManifiestoGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@CveEmbarqueManifiesto", SqlDbType.Int).Value = CveEmbarqueManifiesto + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveCultivo", SqlDbType.Int).Value = CveCultivo + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los indicadores de venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + + End Function + + + Public Function AddPreciosVentaFecha(CveCultivo As Integer, Descripcion As String, Fecha As Date, CveCultivoVariedad As Integer, CveTamaño As Integer, PrecioVenta As Decimal, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Agro_PreciosVentaFechaAdd") + With SqlAdapter.SelectCommand.Parameters + + .Add("@CveCultivo", SqlDbType.Int).Value = CveCultivo + .Add("@CveTamaño", SqlDbType.Int).Value = CveTamaño + .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion + .Add("@Fecha", SqlDbType.Date).Value = Fecha + .Add("@CveCultivoVariedad", SqlDbType.Int).Value = CveCultivoVariedad + .Add("@PrecioVenta", SqlDbType.Money).Value = PrecioVenta + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar los precios del día.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + + End Function + + Public Function UpdatePreciosVentaFecha(CvePrecioVentaFecha As Integer, CveCultivo As Integer, CveTamaño As Integer, Descripcion As String, Fecha As Date, CveCultivoVariedad As Integer, PrecioVenta As Decimal, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Agro_PreciosVentaFechaUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrecioVentaFecha", SqlDbType.Int).Value = CvePrecioVentaFecha + .Add("@CveCultivo", SqlDbType.Int).Value = CveCultivo + .Add("@CveTamaño", SqlDbType.Int).Value = CveTamaño + .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion + .Add("@Fecha", SqlDbType.Date).Value = Fecha + .Add("@CveCultivoVariedad", SqlDbType.Int).Value = CveCultivoVariedad + .Add("@PrecioVenta", SqlDbType.Money).Value = PrecioVenta + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar los precios del día.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + + End Function + + + Public Function GetPreciosVentaFecha(FechaInicio As Date, FechaFin As Date, CvePrecioVentaFecha As Integer, CveCultivo As Integer, CveCultivoVariedad As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Agro_PreciosVentaFechaGet") + With SqlAdapter.SelectCommand.Parameters + + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@CvePrecioVentaFecha", SqlDbType.Int).Value = CvePrecioVentaFecha + .Add("@CveCultivo", SqlDbType.Int).Value = CveCultivo + .Add("@CveCultivoVariedad", SqlDbType.Int).Value = CveCultivoVariedad + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los precios del día.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + + End Function + + + Public Function DeletePreciosVentaFecha(CvePrecioVentaFecha As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Agro_PreciosVentaFechaDelete") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrecioVentaFecha", SqlDbType.Int).Value = CvePrecioVentaFecha + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar los precios del día.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + + End Function + + + + + Public Function GetCultivos(CveCultivo As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AgroCultivoGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@cveCultivo", SqlDbType.Int).Value = CveCultivo + .Add("@cveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los cultivos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + + End Function + + Public Function GetCultivosVariedad(CveCultivo As Integer, cveCultivosVariedad As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Agro_CultivosVariedadGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCultivo", SqlDbType.Int).Value = CveCultivo + .Add("@cveCultivosVariedad", SqlDbType.Int).Value = cveCultivosVariedad + .Add("@cveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los precios del día.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + + End Function + + Public Function GetEmbarqueTamaño(CveTamaño As Integer, Estatus As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Agro_Embarque_TamañoGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveTamaño", SqlDbType.Int).Value = CveTamaño + .Add("@Estatus", SqlDbType.Int).Value = Estatus + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los tamaños del día.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + + End Function + + + + + + + + #Region "IDisposable Support" diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 986c618b0..a948d5b24 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -15627,7 +15627,7 @@ Partial Class Compras_Compras Amortizacion = TmpDT.SUMD("ImporteSinImpuestos") End If Dim SubTotalCompra As Decimal = Amortizacion - Dim DiferenciaPermitida As Decimal = 1 + Dim DiferenciaPermitida As Decimal = 5 Dim Cont As Integer = 0 'Dim ProductosCodigoSATNoPermitidos As New StringBuilder("") For Each gvr As GridViewRow In GvOC1.Rows