202 lines
7.1 KiB
C#
202 lines
7.1 KiB
C#
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 DTDatosGvD
|
|
{
|
|
get
|
|
{
|
|
if (ViewState["DTDatosGvD"] == null)
|
|
{
|
|
ViewState["DTDatosGvD"] = new DataTable();
|
|
}
|
|
return (DataTable)ViewState["DTDatosGvD"];
|
|
}
|
|
set { ViewState["DTDatosGvD"] = (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()
|
|
{
|
|
txtFechaI.Text = NowADS().FirstDayOfMonth().ToShortDateString();
|
|
txtFechaF.Text = NowADS().ToShortDateString();
|
|
|
|
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()
|
|
{
|
|
DTDatosGvD = new DataTable();
|
|
LnkDescargaExcel.Visible = false;
|
|
|
|
ClsVentas objVentas = new ClsVentas();
|
|
|
|
if (objVentas.GetLineasAdicionalesVencimientos( DdlClientes.SelectedValue.ToEntero(), -1, txtFechaI.Text.ToDate(), txtFechaF.Text.ToDate(), 1, UsuarioActual.CveEmpresa))
|
|
{
|
|
GvD.DataSource = objVentas.DtResultados;
|
|
|
|
if (objVentas.DtResultados.Rows.Count > 0)
|
|
{
|
|
DTDatosGvD = objVentas.DtResultados;
|
|
LnkDescargaExcel.Visible = true;
|
|
UpAcciones.Update();
|
|
}
|
|
}
|
|
objVentas.Dispose();
|
|
GvD.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 LnkDescargaExcel_Click(object sender, EventArgs e)
|
|
{
|
|
if(TipoLinea == 1)
|
|
{
|
|
GridView gvTemp = GvD;
|
|
//gvTemp.ExportToExcelX("RepLineasAdicionales" + NowADS().ToShortDateString());
|
|
gvTemp.ExportToExcelGembox("RepLineasAdicionales", UsuarioActual, "Rep Lineas Adicionales", 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 = "<a href='/Compras/Proveedores.aspx?CveProveedor="+ e.Row.DBCampo("CveProveedor") + "' >"+ e.Row.DBCampo("Proveedor") +"</a>";
|
|
}
|
|
}
|
|
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();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} |