diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 0b524ae8f..277b6fbf5 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -10670,7 +10670,6 @@ Public Class ClsPaginas PaginaDict.Add("/Sistemas/CatProcesos.aspx".ToUpper(), 69) PaginaDict.Add("/Sistemas/CatParametros.aspx".ToUpper(), 143) PaginaDict.Add("/Sistemas/PopUpCargaCertificados.aspx".ToUpper(), 144) - PaginaDict.Add("/Sistemas/CatNotificaciones.aspx".ToUpper(), 146) PaginaDict.Add("/Sistemas/EmpresasModulos.aspx".ToUpper(), 346) PaginaDict.Add("/Sistemas/CatSesiones.aspx".ToUpper(), 374) PaginaDict.Add("/Sistemas/CatFuncionalidades.aspx".ToUpper(), 568) @@ -10789,10 +10788,7 @@ Public Class ClsPaginas PaginaDict.Add("/Ventas/CatEspecialidadesSubEspecialidades.aspx".ToUpper(), 1346) PaginaDict.Add("/Ventas/FacturacionGlobal.aspx".ToUpper(), 546) PaginaDict.Add("/Ventas/RepComisionesSMS.aspx".ToUpper(), 1347) - - - - + PaginaDict.Add("/Ventas/RepVencimientosCredito.aspx".ToUpper(), 146) diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index ab0b16d22..844dbb8db 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -5983,6 +5983,30 @@ Public Class ClsVentas End Function + Public Function GetLineasAdicionalesVencimientos(CveCliente As Integer, TipoLinea As Integer, FechaInicio As Date, FechaFin As Date, CveMoneda As Integer, CveEmpresa As Integer) As Boolean + + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_LineasAdicionalesVencimientosGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@TipoLinea", SqlDbType.Int).Value = TipoLinea + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error obtener las lineas de adicionales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + + + End Function + + Public Function CambioClientesVendedor(CveCliente As Integer, CveVendedor As Integer, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False diff --git a/Ventas/RepVencimientosCredito.aspx b/Ventas/RepVencimientosCredito.aspx new file mode 100644 index 000000000..8c3639ca1 --- /dev/null +++ b/Ventas/RepVencimientosCredito.aspx @@ -0,0 +1,233 @@ +<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="RepVencimientosCredito.aspx.cs" Inherits="Ventas_RepVencimientosCredito" %> + + + + + + + + + + + + + + + + + Excel + + + + + + + + + + + + + + + + + + + + + + + + Comercializador: + + + + + Cliente: + + + + + Estatus: + + + + <%-- --%> + + + + + Agrupador: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> + + + + + + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- MODAL COMPROBANTE --%> + + + + + + + × + Agregar Comprbante + + + + + + + + + + + + + + + + + + + + + <%-- FIN MODAL COMPROBANTE --%> + + + + + + + + + + + + + diff --git a/Ventas/RepVencimientosCredito.aspx.cs b/Ventas/RepVencimientosCredito.aspx.cs new file mode 100644 index 000000000..e40e21656 --- /dev/null +++ b/Ventas/RepVencimientosCredito.aspx.cs @@ -0,0 +1,409 @@ +using System; using System.Web.UI.WebControls; using Extensiones; using System.Data; using static Extensiones.ModExtensiones; +using System.Collections.Generic; +using System.IO; +using System.Web.UI; + + +public partial class Ventas_RepVencimientosCredito : ClsPaginas +{ + #region PROPIEDADES + + + private int CveLineaAdicional + { + get { return (ViewState["CveLineaAdicional"] == null) ? 0 : int.Parse(ViewState["CveLineaAdicional"].ToString()); } + set { ViewState["CveLineaAdicional"] = (int)value; } + } + + private int CveVenta + { + get { return (ViewState["CveVenta"] == null) ? 0 : int.Parse(ViewState["CveVenta"].ToString()); } + set { ViewState["CveVenta"] =(int) value; } + } + + private int TipoLinea + { + get { return (ViewState["TipoLinea"] == null) ? 1: int.Parse(ViewState["TipoLinea"].ToString()); } + set { ViewState["TipoLinea"] = (int)value; } + } + + private DataTable DTDatosGvLineasAdicionales + { + get + { + if (ViewState["DTDatosGvLineasAdicionales"] == null) + { + ViewState["DTDatosGvLineasAdicionales"] = new DataTable(); + } + return (DataTable)ViewState["DTDatosGvLineasAdicionales"]; + } + set { ViewState["DTDatosGvLineasAdicionales"] = (DataTable)value; } + } + + private string LineaAdicionalComprobante + { + get { + + if(ViewState["LineaAdicionalComprobante"] == null) + { + ViewState["LineaAdicionalComprobante"] = ""; + } + + return ViewState["LineaAdicionalComprobante"].ToString(); + } + set { ViewState["LineaAdicionalComprobante"] = value; } + } + + #endregion + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + InicializaValores(); + CargaDatos(); + } + } + + private void InicializaValores() + { + + if (Request["OP"] != null && Request["OP"].ToString() == "PO") + { + DVProveedor1.Visible = true; + DVProveedor2.Visible = true; + TipoLinea = 2; + LtlEncabezado.Text = "Reporte PO"; + GvLAPO.Visible = true; + DvLineaPO.Visible = true; + DVAgrupador1.Visible = true; + DVAgrupador2.Visible = true; + + } + else + { + DvLinea.Visible = true; + GvLineasAdicionales.Visible = true; + } + + + 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"; + + + + } + + + protected void BtnConsultar_Click(object sender, EventArgs e) + { + CargaDatos(); + } + + private void CargaDatos() + { + DTDatosGvLineasAdicionales = new DataTable(); + LnkDescargaExcel.Visible = false; + + ClsVentas objVentas = new ClsVentas(); + + int CveProveedor = DdlProveedor.SelectedValue.ToEntero() > 0 ? DdlProveedor.SelectedValue.ToEntero() : -1; + + if(TipoLinea == 1) + { + if (objVentas.RepLineasAdicionales(-1,-1, DdlClientes.SelectedValue.ToEntero(), CveProveedor, 1, -1, MinFecha, MaxFecha, DdlEstatus.SelectedValue.ToEntero(), UsuarioActual.CveEmpresa)) + { + GvLineasAdicionales.DataSource = objVentas.DtResultados; + + if (objVentas.DtResultados.Rows.Count > 0) + { + DTDatosGvLineasAdicionales = objVentas.DtResultados; + LnkDescargaExcel.Visible = true; + UpAcciones.Update(); + } + } + else + { + GvLineasAdicionales.DataSource = null; + } + } + else + { + + if (DdlAgrupador.SelectedValue.ToEntero()== 1){ + GvLAPO.Columns[0].HeaderText = "Comercializador"; + } + else + { + GvLAPO.Columns[0].HeaderText = "Cliente"; + } + + if (objVentas.RepLineasAdicionales(DdlAgrupador.SelectedValue.ToEntero(), -1, DdlClientes.SelectedValue.ToEntero(), CveProveedor, 2, -1, MinFecha, MaxFecha, DdlEstatus.SelectedValue.ToEntero(), UsuarioActual.CveEmpresa)) + { + GvLAPO.DataSource = objVentas.DtResultados; + + if (objVentas.DtResultados.Rows.Count > 0) + { + DTDatosGvLineasAdicionales = objVentas.DtResultados; + LnkDescargaExcel.Visible = true; + UpAcciones.Update(); + } + } + else + { + GvLAPO.DataSource = null; + } + } + + objVentas.Dispose(); + GvLineasAdicionales.DataBind(); + GvLAPO.DataBind(); + UpLineasAdicionales.Update(); + } + + + protected void LnkCargarComprobante_Click(object sender, EventArgs e) + { + GridViewRow GvRow = (GridViewRow) ((LinkButton) sender).NamingContainer; + + CveLineaAdicional = GvRow.DataKey("CveLineaAdicional").ToString().ToEntero(); + CveVenta = GvRow.DataKey("CveVenta").ToString().ToEntero(); + LineaAdicionalComprobante = GvRow.DataKey("LineaAdicionalComprobante").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) && LineaAdicionalComprobante.Length > 0) + { + FileInfo fiAnterior = new FileInfo($@"{df.FullName}{LineaAdicionalComprobante}"); + 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}\{CveVenta}{fiNuevo.Extension}")) + { + File.Delete($@"{df.FullName}\{CveVenta}{fiNuevo.Extension}"); + } + File.Move(fiNuevo.FullName, $@"{df.FullName}\{CveVenta}{fiNuevo.Extension}"); + errorCargaComprobante = false; + } + catch + { + errorCargaComprobante = true; + } + if (!errorCargaComprobante) + { + ClsVentas objVentas = new ClsVentas(); + if (!objVentas.UpdateVentaLineaAdicional(CveLineaAdicional, CveVenta, $@"{CveVenta}{fiNuevo.Extension}", -1, UsuarioActual.CveEmpresa)) + { + errorCargaComprobante = true; + } + objVentas.Dispose(); + } + } + } + } + + if (!errorCargaComprobante) + { + CargaDatos(); + Anexo.Text = "[]"; + RegistraScript("$('#ModalComprobante').modal('hide');", ""); + Alert("Comprobante actualizado correctamente."); + } + UpAddComprobancte.Update(); + } + + protected void LnkCambiarEstatus_Click(object sender, EventArgs e) + { + GridViewRow GvRow = (GridViewRow)((LinkButton)sender).NamingContainer; + int CveLineaAdicionalActualzarEstatus = GvRow.DataKey("CveLineaAdicional").ToEntero(); + int CveVenta = GvRow.DataKey("CveVenta").ToEntero(); + bool errorCambioEstatus = false; + ClsVentas objVentas = new ClsVentas(); + if (!objVentas.UpdateVentaLineaAdicional(CveLineaAdicional, CveVenta, "", 2, UsuarioActual.CveEmpresa)) + { + errorCambioEstatus = true; + } + if (!errorCambioEstatus) + { + CargaDatos(); + } + objVentas.Dispose(); + } + + protected void LnkDescargaExcel_Click(object sender, EventArgs e) + { + if(TipoLinea == 1) + { + GridView gvTemp = GvLineasAdicionales; + //gvTemp.ExportToExcelX("RepLineasAdicionales" + NowADS().ToShortDateString()); + gvTemp.ExportToExcelGembox("RepLineasAdicionales", UsuarioActual, "Rep Lineas Adicionales", AnchoImagen: 150); + } + else if(TipoLinea == 2) + { + GridView gvTemp = GvLAPO; + gvTemp.Columns[12].Visible = false; + //gvTemp.ExportToExcelX("ReportePO" + NowADS().ToShortDateString()); + gvTemp.ExportToExcelGembox( "ReportePO", UsuarioActual, "Reporte PO ", AnchoImagen:150); + } + } + + protected void GvLAPO_RowDataBound(object sender, GridViewRowEventArgs e) + { + if (e.Row.RowType == DataControlRowType.DataRow) + { + + LinkButton LnkCambiarEstatus = e.Row.FCLinkButton("LnkCambiarEstatus"); + LinkButton LnkCargarComprobante = e.Row.FCLinkButton("LnkCargarComprobante"); + LinkButton LnkDescargaComprobante = e.Row.FCLinkButton("LnkDescargaComprobante"); + + if (e.Row.DataKey("CveLineaAdicional")=="") + { + if (e.Row.DataKey("CveLineaAdicional") == "" && e.Row.DataKey("CveCliente") == "") + { + e.Row.CssClass = "SubTotales2"; + if (e.Row.DataKey("CveLineaAdicional") == "" && e.Row.DataKey("CveCliente") == "" && e.Row.DataKey("CveProveedor") != "") + { + e.Row.Cells[0].Text = ""+ e.Row.DBCampo("Proveedor") +""; + } + } + else + { + e.Row.CssClass = "SubTotales"; + } + LnkCambiarEstatus.Visible = false; + LnkCargarComprobante.Visible = false; + LnkDescargaComprobante.Visible = false; + } + else + { + if (e.Row.DataKey("CveVenta").ToEntero() > 0 && e.Row.DataKey("CveLineaAdicionalEstatus").ToEntero() == 1) + { + + if (UsuarioActual.TienePermisoProceso(356)) LnkCambiarEstatus.Visible = true; + LnkCargarComprobante.Visible = true; + } + + if (e.Row.DataKey("LineaAdicionalComprobante").Length > 0 && e.Row.DataKey("CveVenta").ToEntero() > 0) + { + FileInfo fi = new FileInfo($@"{UsuarioActual.Empresa.Ruta}\LineasAdicionales\{e.Row.DataKey("LineaAdicionalComprobante")}"); + + if (fi.Exists) + { + LnkDescargaComprobante.Visible = true; + ScriptManager.GetCurrent(this).RegisterPostBackControl(LnkDescargaComprobante); + } + } + } + } + } + + protected void LnkDescargaComprobante_Click(object sender, EventArgs e) + { + GridViewRow GvRow = (GridViewRow)((LinkButton)sender).NamingContainer; + string Comprobante = GvRow.DataKey("LineaAdicionalComprobante"); + FileInfo fi = new FileInfo($@"{UsuarioActual.Empresa.Ruta}\LineasAdicionales\{Comprobante}"); + + if (fi.Exists) + { + Response.Clear(); + Response.AddHeader("Content-Disposition", "attachment; filename=" + fi.Name); + Response.AddHeader("Content-Length", fi.Length.ToString()); + Response.ContentType = "text/octet-stream"; + Response.Flush(); + Response.TransmitFile(fi.FullName); + Response.End(); + } + } + + protected void GvLAPO_RowCommand(object sender, GridViewCommandEventArgs e) + { + if (e.CommandName == "Estatus") + { + GridViewRow GvRow = (GridViewRow)((LinkButton)e.CommandSource).NamingContainer; + int CveLineaAdicionalActualizarEstatus = GvRow.DataKey("CveLineaAdicional").ToString().ToEntero(); + int CveVenta = GvRow.DataKey("CveVenta").ToString().ToEntero(); + + bool errorCambioEstatus = false; + //int cveestatus = e.CommandArgument.ToEntero() + 2; //pasar al siguiente estatus + + ClsVentas objVentas = new ClsVentas(); + if (!objVentas.UpdateVentaLineaAdicional(CveLineaAdicionalActualizarEstatus, CveVenta,"", 2, UsuarioActual.CveEmpresa)) + { + errorCambioEstatus = true; + } + objVentas.Dispose(); + if (!errorCambioEstatus) + { + CargaDatos(); + } + } + } + +} \ No newline at end of file