From dcbff66a3be4cf5101c11079980e3f9af39bd5e2 Mon Sep 17 00:00:00 2001 From: Oscar Irigoyen Date: Tue, 20 Sep 2022 18:33:53 -0700 Subject: [PATCH] RepLienasAdicionales --- App_Code/ClsPaginas.vb | 3 + Compras/Compras.aspx.vb | 2 +- Ventas/Clientes.aspx | 89 ++++++---- Ventas/Clientes.aspx.vb | 18 +- Ventas/RepLineasAdicionales.aspx | 208 +++++++++++++++++++++++ Ventas/RepLineasAdicionales.aspx.cs | 254 ++++++++++++++++++++++++++++ 6 files changed, 529 insertions(+), 45 deletions(-) create mode 100644 Ventas/RepLineasAdicionales.aspx create mode 100644 Ventas/RepLineasAdicionales.aspx.cs diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 51c7abcef..7a15cb5e1 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -5663,6 +5663,9 @@ Public Class ClsPaginas PaginaDict.Add("/Acumuladores/RepPolizasVirtuales.aspx".ToUpper(), 1322) + PaginaDict.Add("/Ventas/RepLineasAdicionales.aspx".ToUpper(), -1) + PaginaDict.Add("/Ventas/RepLineasAdicionales.aspx?OP=LI".ToUpper(), -1) + PaginaDict.Add("/Ventas/RepLineasAdicionales.aspx?OP=OP".ToUpper(), -1) 'Antes de aquí. diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 52b2f120a..40961615d 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -6133,7 +6133,7 @@ Partial Class Compras_Compras ConceptoContable = 333 End If - importeMovimiento = CompraActual.retiva + importeMovimiento = CompraActual.RetIVA importeMN = (importeMovimiento * tipoCambioActual * Multiplicador).RoundSQL If tipoCambioActual > 1 Then Concepto += $" TC{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" diff --git a/Ventas/Clientes.aspx b/Ventas/Clientes.aspx index 521cfb842..f33de6445 100644 --- a/Ventas/Clientes.aspx +++ b/Ventas/Clientes.aspx @@ -4585,7 +4585,7 @@ - + @@ -6723,8 +6723,8 @@
-
- +
+
@@ -6732,7 +6732,7 @@
- + @@ -6741,61 +6741,76 @@
-
- - +
+
+
+
+ + + + -
- +
+
+
- - - - -
- -
- - - - - - - +
+ + + + + + + +
+
-
- -
- - - - + + + + + +
+
+ +
+ + + + +
+ + +
+
+ + +
+
-
+
- + <%----%>
diff --git a/Ventas/Clientes.aspx.vb b/Ventas/Clientes.aspx.vb index dff5190cb..46b242070 100644 --- a/Ventas/Clientes.aspx.vb +++ b/Ventas/Clientes.aspx.vb @@ -10345,20 +10345,24 @@ Partial Class Clientes If (UsuarioActual.Empresa.Funcionalidad(105) = "1") Then DdlProveedorLineaAdicionalModal.setEsWebService(True) DdlProveedorLineaAdicionalModal.Attributes.Add("data-metodo", "getproveedores") - DdlProveedorLineaAdicionalModal.SelectedText = "Todos" + DdlProveedorLineaAdicionalModal.SelectedText = "-" DdlProveedorLineaAdicionalModal.SelectedValue = "-1" + DdlProveedorLineaAdicionalModal.txtText.Value = "-" + DdlProveedorLineaAdicionalModal.txtValue.Value = "-1" + + Else DdlProveedorLineaAdicionalModal.setEsWebService(False) DdlProveedorLineaAdicionalModal.ddl.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa) DdlProveedorLineaAdicionalModal.ddl.DataBind() - DdlProveedorLineaAdicionalModal.ddl.Items.Insert(0, New ListItem("Todos", "-1")) + DdlProveedorLineaAdicionalModal.ddl.Items.Insert(0, New ListItem("-", "-1")) End If DdlClasificacionLienaAdicionalModal.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa) DdlClasificacionLienaAdicionalModal.DataBind() - DdlClasificacionLienaAdicionalModal.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlClasificacionLienaAdicionalModal.Items.Insert(0, New ListItem("-", "-1")) @@ -10405,10 +10409,10 @@ Partial Class Clientes Protected Sub LnkAgregarLineaAdicionalModal_Click(sender As Object, e As EventArgs) Dim ErrorAgregar As Boolean = False - If DdlProveedorLineaAdicionalModal.SelectedValue.ToEntero <= 0 Then - Alert("El proveedor es requerido", TipoMensaje.MsgAdvertencia) - Exit Sub - End If + 'If DdlProveedorLineaAdicionalModal.SelectedValue.ToEntero <= 0 Then + ' Alert("El proveedor es requerido", TipoMensaje.MsgAdvertencia) + ' Exit Sub + 'End If Dim ObjVentas As New ClsVentas diff --git a/Ventas/RepLineasAdicionales.aspx b/Ventas/RepLineasAdicionales.aspx new file mode 100644 index 000000000..099f0709d --- /dev/null +++ b/Ventas/RepLineasAdicionales.aspx @@ -0,0 +1,208 @@ +<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="RepLineasAdicionales.aspx.cs" Inherits="Ventas_RepLineasAdicionales" %> + + + + + + + + + + + + + + + + + + +
  • + Excel +
  • +
    + + + +
    + +
    + + + + + + +
    +
    +
    + + +
    +
    +
    + +
    Proveedor:
    +
    + +
    + +
    Cliente:
    +
    + +
    + +
    Fecha Inicio:
    +
    +
    + + + + +
    + + + + + + +
    +
    Fecha Fin:
    +
    +
    + + + + +
    + + + + + + +
    + +
    +
    +
    + +
    +
    +
    + + + + +
    +
    + +
    +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    +
    + + + + + <%-- MODAL COMPROBANTE --%> + + <%-- FIN MODAL COMPROBANTE --%> + + + + + + +
    + + + + + + diff --git a/Ventas/RepLineasAdicionales.aspx.cs b/Ventas/RepLineasAdicionales.aspx.cs new file mode 100644 index 000000000..51f634d90 --- /dev/null +++ b/Ventas/RepLineasAdicionales.aspx.cs @@ -0,0 +1,254 @@ +using System; using System.Web.UI.WebControls; using Extensiones; using System.Data; using static Extensiones.ModExtensiones; +using System.Collections.Generic; +using System.IO; +using ListItem = System.Web.UI.WebControls.ListItem; + +public partial class Ventas_RepLineasAdicionales : ClsPaginas +{ + #region PROPIEDADES + + private int CveLineaAdicional + { + get { return (ViewState["CveLineaAdicional"] == null) ? 0 : int.Parse(ViewState["CveLineaAdicional"].ToString()); } + set { ViewState["CveLineaAdicional"] =(int) value; } + } + + private string Comprobante + { + get { + + if(ViewState["Comprobante"] == null) + { + ViewState["Comprobante"] = ""; + } + + return ViewState["Comprobante"].ToString(); + } + set { ViewState["Comprobante"] = value; } + } + + #endregion + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + InicializaValores(); + } + } + + private void InicializaValores() + { + + if (Request["OP"] != null && Request["OP"].ToString() == "PO") + { + DVProveedor1.Visible = true; + DVProveedor2.Visible = true; + GvLineasAdicionales.Columns[9].Visible = true; + } + + //Carga Clientes + DdlClientes.DataSource = get_GlobalDTCliente(UsuarioActual.CveEmpresa, -1); + DdlClientes.DataBind(); + + + + if(UsuarioActual.Empresa.Funcionalidad(105) == "1") { + DdlProveedor.setEsWebService(true); + DdlProveedor.Attributes.Add("data-metodo", "getproveedores"); + DdlProveedor.SelectedText = "Todos"; + DdlProveedor.SelectedValue = "-1"; + + + + }else { + DdlProveedor.setEsWebService(false); + DdlProveedor.ddl.DataSource = get_GlobalDTCompProveedores(UsuarioActual.CveEmpresa); + DdlProveedor.ddl.DataBind(); + DdlProveedor.ddl.Items.Insert(0, new ListItem("-", "-1")); + } + + DdlClientes.setEsWebService(true); + DdlClientes.Attributes.Add("data-metodo", "getcliente"); + DdlClientes.SelectedText = "Todos"; + DdlClientes.SelectedValue = "-1"; + + txtFechaI.Text = DateTime.Now.FirstDayOfMonth().ToShortDateString(); + txtFechaF.Text = DateTime.Now.ToShortDateString(); + + } + + + protected void BtnConsultar_Click(object sender, EventArgs e) + { + CargaDatos(); + } + + private void CargaDatos() + { + LnkDescargaExcel.Visible = false; + + ClsVentas objVentas = new ClsVentas(); + + int CveProveedor = DdlProveedor.SelectedValue.ToEntero() > 0 ? DdlProveedor.SelectedValue.ToEntero() : -1; + + if(objVentas.GetLineasAdicionales(-1,DdlClientes.SelectedValue.ToEntero(),CveProveedor,-1,-1,txtFechaI.Text.ToDate(), txtFechaF.Text.ToDate(), -1, UsuarioActual.CveEmpresa)){ + GvLineasAdicionales.DataSource = objVentas.DtResultados; + + if( objVentas.DtResultados.Rows.Count > 0) + { + LnkDescargaExcel.Visible = true; + UpAcciones.Update(); + } + } + else + { + GvLineasAdicionales.DataSource = null; + } + + objVentas.Dispose(); + + GvLineasAdicionales.DataBind(); + UpLineasAdicionales.Update(); + } + + + protected void LnkCargarComprobante_Click(object sender, EventArgs e) + { + GridViewRow GvRow = (GridViewRow) ((LinkButton) sender).NamingContainer; + + CveLineaAdicional = GvRow.DataKey("CveLineaAdicional").ToString().ToEntero(); + Comprobante = GvRow.DataKey("Comprobante").ToString(); + + RegistraScript("$('#ModalComprobante').modal('show');",""); + } + + protected void BtnAddComprobante_Click(object sender, EventArgs e) + { + bool errorCargaComprobante = false; + string FileExtension = "-1"; + List filesgral = Anexo.getfiles().Archivos; + string filemove = ""; + FileInfo fiNuevo; + + DirectoryInfo df = new DirectoryInfo($@"{UsuarioActual.Empresa.Ruta}\LineasAdicionales\"); + + + //Crea directorio si no existe + if (!df.Exists) + { + try + { + Directory.CreateDirectory(df.FullName); + } + catch + { + errorCargaComprobante = true; + } + } + + //borrar archivo anterior + if((!errorCargaComprobante) && Comprobante.Length > 0) + { + FileInfo fiAnterior = new FileInfo($@"{df.FullName}{Comprobante}"); + if (fiAnterior.Exists) + { + try + { + File.Delete(fiAnterior.FullName); + } + catch + { + errorCargaComprobante = true; + } + } + } + + if(!errorCargaComprobante){ + + string RutaArchivoTemp = ""; + foreach (Archivo fileItem in filesgral) + { + FileExtension = System.IO.Path.GetExtension(string.Format(@"{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", ""); + filemove = fileItem.filename; + RutaArchivoTemp = $@"{AppDomain.CurrentDomain.BaseDirectory}\Temp\{fileItem.filename}"; + + break; + } + + if((!errorCargaComprobante) && RutaArchivoTemp.Length > 0) + { + fiNuevo = new FileInfo(RutaArchivoTemp); + + if (fiNuevo.Exists) + { + try + { + + if (File.Exists($@"{df.FullName}\{CveLineaAdicional}{fiNuevo.Extension}")) + { + File.Delete($@"{df.FullName}\{CveLineaAdicional}{fiNuevo.Extension}"); + } + + File.Move(fiNuevo.FullName, $@"{df.FullName}\{CveLineaAdicional}{fiNuevo.Extension}"); + errorCargaComprobante = false; + } + catch + { + errorCargaComprobante = true; + } + + if (!errorCargaComprobante) + { + ClsVentas objVentas = new ClsVentas(); + if (!objVentas.UpdateLineasAdicionales(CveLineaAdicional, "-1", -1, -1, -1, -1, -1, MinFecha, 100, -1, -1, UsuarioActual.CveEmpresa, Comprobante: $@"{CveLineaAdicional}{fiNuevo.Extension}")) + { + errorCargaComprobante = true; + } + objVentas.Dispose(); + } + } + } + + } + + + if (!errorCargaComprobante) + { + CargaDatos(); + Anexo.Text = "[]"; + RegistraScript("$('#ModalComprobante').modal('hide');", ""); + Alert("Comprbante actualizado correctamente."); + } + + UpAddComprobancte.Update(); + } + + protected void LnkCambiarEstatus_Click(object sender, EventArgs e) + { + GridViewRow GvRow = (GridViewRow)((LinkButton)sender).NamingContainer; + int CveLineaAdicionalActualzarEstatus = GvRow.DataKey("CveLineaAdicional").ToString().ToEntero(); + bool errorCambioEstatus = false; + + ClsVentas objVentas = new ClsVentas(); + + if (!objVentas.UpdateLineasAdicionales(CveLineaAdicionalActualzarEstatus, "-1", -1, -1, -1, -1, -1, MinFecha, 100, -1, 3, UsuarioActual.CveEmpresa)) + { + errorCambioEstatus = true; + } + + if (!errorCambioEstatus) + { + CargaDatos(); + } + + objVentas.Dispose(); + } + + + protected void LnkDescargaExcel_Click(object sender, EventArgs e) + { + GvLineasAdicionales.ExportToExcel2("RepLineas"); + } + + +} \ No newline at end of file