531 lines
25 KiB
C#
531 lines
25 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Web;
|
||
using System.Web.UI.WebControls;
|
||
using Extensiones;
|
||
using System.Data;
|
||
using static Extensiones.ModExtensiones;
|
||
using Microsoft.Reporting.WebForms;
|
||
using System.Web.UI.HtmlControls;
|
||
using System.Text;
|
||
|
||
public partial class Ventas_RepProductosServiciosPeriodo : ClsPaginas
|
||
{
|
||
|
||
#region PROPIEDADES
|
||
|
||
private string Opcion
|
||
{
|
||
get { return (ViewState["Opcion"] == null) ? "-1" : ViewState["Opcion"].ToString(); }
|
||
set { ViewState["Opcion"] = value; }
|
||
}
|
||
private int CveProyecto
|
||
{
|
||
get { return (ViewState["CveProyecto"] == null) ? -1 : Convert.ToInt32(ViewState["CveProyecto"]); }
|
||
set { ViewState["CveProyecto"] = value; }
|
||
}
|
||
private int TipoCambio
|
||
{
|
||
get { return (ViewState["TipoCambio"] == null) ? -1 : Convert.ToInt32(ViewState["TipoCambio"]); }
|
||
set { ViewState["TipoCambio"] = value; }
|
||
}
|
||
private decimal TCEspecifico
|
||
{
|
||
get { return (ViewState["TCEspecifico"] == null) ? 0 : Convert.ToDecimal(ViewState["TCEspecifico"]); }
|
||
set { ViewState["TCEspecifico"] = value; }
|
||
}
|
||
private DataTable DtVentas
|
||
{
|
||
get { return DtVentas = (DataTable)ViewState["DtVentas"]; }
|
||
set { ViewState["DtVentas"] = value; }
|
||
}
|
||
|
||
#endregion
|
||
|
||
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
InicializaValores();
|
||
}
|
||
}
|
||
|
||
#region CARGAS
|
||
|
||
private void InicializaValores()
|
||
{
|
||
TipoCambio = 1;
|
||
TCEspecifico = -1;
|
||
CargaCombos();
|
||
Opcion = Request["Opcion"] == null ? "-1" : Request["Opcion"].ToString();
|
||
if (UsuarioActual.CveEmpresa == 72 && UsuarioActual.CveUsuario.Contiene(100, 1614, 1517))
|
||
{
|
||
liRepHP.Visible = true;
|
||
}
|
||
|
||
//Modalidad Cotizacion
|
||
if (Opcion == "Cot")
|
||
{
|
||
DdlTipoComprobante.SelectedValueExist(Opcion);
|
||
DdlGrupo.SelectedValueExist("7");
|
||
DdlTipoComprobante_SelectedIndexChanged(DdlTipoComprobante, EventArgs.Empty);
|
||
DdlEstatus.SelectedValue = "-1";
|
||
}
|
||
}
|
||
|
||
private void CargaCombos()
|
||
{
|
||
////CargaClientes
|
||
//ClsClientes ObjClientes = new ClsClientes();
|
||
//if (ObjClientes.GetClientes(-1, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa))
|
||
//{
|
||
// DdlClientes.DataSource = ObjClientes.DtResultados;
|
||
//}
|
||
//ObjClientes.Dispose();
|
||
//DdlClientes.DataBind();
|
||
DdlClientes.setEsWebService(true);
|
||
DdlClientes.Attributes.Add("data-metodo", "getcliente");
|
||
DdlClientes.SelectedText = "Todos";
|
||
DdlClientes.SelectedValue = "-1";
|
||
|
||
//CargaSucursales
|
||
DdlSubProyectoEjecucion.DataSource = get_GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1);
|
||
DdlSubProyectoEjecucion.DataBind();
|
||
|
||
//Vendedor
|
||
DdlVendedor.DataSource = get_GlobalDTVendedores(UsuarioActual.CveEmpresa);
|
||
DdlVendedor.DataBind();
|
||
DdlVendedor.Items.Insert(0, new ListItem("Todos", "-1"));
|
||
|
||
//CargaUsuarios
|
||
DdlUsuario.DataSource = get_GlobalDTUsuarios().FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa}");
|
||
DdlUsuario.DataBind();
|
||
|
||
//CargaEstatus
|
||
DdlEstatus.DataSource = GlobalDTEstatusFactura.FiltraParametros(" CveEstatusFactura NOT IN (1, 4, 5) ");
|
||
DdlEstatus.DataBind();
|
||
DdlEstatus.Items.Add(new ListItem("Canceladas", "4"));
|
||
if (UsuarioActual.Empresa.TipoFacturacion == "CFDi")
|
||
{
|
||
DdlEstatus.SelectedIndex = 2;
|
||
}
|
||
else
|
||
{
|
||
DdlEstatus.SelectedIndex = 1;
|
||
}
|
||
|
||
//CargaProyectos
|
||
DdlProyecto.DataSource = get_GlobalDTProyectos(UsuarioActual.Empresa.CveEmpresa);
|
||
DdlProyecto.DataBind();
|
||
DdlProyecto.Items.Insert(0, new ListItem("Todos", "-1"));
|
||
|
||
//Cargo Categorias
|
||
DdlCategoria.DataSource = get_GlobalDTGralCategorias(UsuarioActual.CveEmpresa);
|
||
DdlCategoria.DataBind();
|
||
|
||
//Cargo Clasificaciones
|
||
DdlClasificacion.DataSource = get_GlobalDTClasificaciones(UsuarioActual.CveEmpresa);
|
||
DdlClasificacion.DataBind();
|
||
|
||
//Carga Productos
|
||
DdlPS.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) == "1");
|
||
|
||
if (UsuarioActual.Empresa.Funcionalidad(105) == "1")
|
||
{
|
||
DdlPS.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacion.SelectedValue);
|
||
DdlPS.SelectedText = "";
|
||
DdlPS.SelectedValue = "-1";
|
||
}
|
||
else
|
||
{
|
||
DdlPS.ddl.Items.Clear();
|
||
DdlPS.ddl.DataSource = get_GlobalDTPSSimplificado(UsuarioActual.CveEmpresa);
|
||
DdlPS.ddl.DataBind();
|
||
DdlPS.ddl.Items.Insert(0, new ListItem("Todos", "-1"));
|
||
}
|
||
|
||
DdlClienteClasificacion.DataSource = get_GlobalDTClienteClasificaciones(UsuarioActual.CveEmpresa);
|
||
DdlClienteClasificacion.DataBind();
|
||
DdlClienteClasificacion.Items.Insert(0, new ListItem("Todos", "-1"));
|
||
|
||
//Carga Grupos
|
||
CargaGrupo();
|
||
|
||
//Carga Tipo Centro de Costo
|
||
CargaTipoCentroCosto();
|
||
|
||
}
|
||
|
||
private void CargaSubProyectos()
|
||
{
|
||
DdlSubProyecto.Items.Clear();
|
||
DdlSubProyecto.DataSource = get_GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1);
|
||
DdlSubProyecto.DataBind();
|
||
DdlSubProyecto.Items.Insert(0, new ListItem("Todos", "-1"));
|
||
}
|
||
|
||
private void CargaTipoCentroCosto()
|
||
{
|
||
if (UsuarioActual.Empresa.Tipo_CentroCosto == 1)
|
||
{
|
||
|
||
DdlSubProyecto.Items.Clear();
|
||
DivProyecto.Visible = false;
|
||
LblProyecto.Visible = false;
|
||
LblSubProyecto.InnerText = "Sucursal:";
|
||
DdlSubProyecto.DataSource = get_GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1);
|
||
DdlSubProyecto.Items.Insert(0, new ListItem("Todos", "-1"));
|
||
DdlSubProyecto.DataBind();
|
||
|
||
DdlSubProyectoEjecucion.Items.Clear();
|
||
LblSubProyectoEjecucion.InnerText = "Sucursal Ejecución:";
|
||
DdlSubProyectoEjecucion.DataSource = get_GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1);
|
||
DdlSubProyectoEjecucion.Items.Insert(0, new ListItem("Todos", "-1"));
|
||
DdlSubProyectoEjecucion.DataBind();
|
||
|
||
DdlGrupo.Items.Insert(0, new ListItem("Sucursal", "2"));
|
||
DdlGrupo.Items.Insert(16, new ListItem("Sucursal Ejec.", "19"));
|
||
DdlGrupo.DataBind();
|
||
|
||
}
|
||
else if (UsuarioActual.Empresa.Tipo_CentroCosto == 2)
|
||
{
|
||
DdlSubProyecto.Items.Clear();
|
||
DivProyecto.Visible = false;
|
||
LblProyecto.Visible = false;
|
||
LblSubProyecto.InnerText = "Proyecto:";
|
||
DdlSubProyecto.DataSource = get_GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1);
|
||
DdlSubProyecto.Items.Insert(0, new ListItem("Todos", "-1"));
|
||
DdlSubProyecto.DataBind();
|
||
|
||
DdlSubProyectoEjecucion.Items.Clear();
|
||
LblSubProyectoEjecucion.InnerText = "Proyecto Ejecución:";
|
||
DdlSubProyectoEjecucion.DataSource = get_GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1);
|
||
DdlSubProyectoEjecucion.Items.Insert(0, new ListItem("Todos", "-1"));
|
||
DdlSubProyectoEjecucion.DataBind();
|
||
|
||
DdlGrupo.Items.Insert(0, new ListItem("Proyecto", "2"));
|
||
DdlGrupo.Items.Insert(16, new ListItem("Proyecto Ejec.", "19"));
|
||
DdlGrupo.DataBind();
|
||
}
|
||
else if (UsuarioActual.Empresa.Tipo_CentroCosto == 3)
|
||
{
|
||
DdlGrupo.Items.Insert(0, new ListItem("Proyecto", "1"));
|
||
DdlGrupo.Items.Insert(1, new ListItem("SubProyecto", "2"));
|
||
DdlGrupo.Items.Insert(17, new ListItem("SubProyecto Ejec.", "19"));
|
||
DdlGrupo.DataBind();
|
||
}
|
||
else if (UsuarioActual.Empresa.Tipo_CentroCosto == 4)
|
||
{
|
||
LblProyecto.InnerText = "Sucursal:";
|
||
LblSubProyecto.InnerText = "Proyecto:";
|
||
|
||
LblSubProyectoEjecucion.InnerText = "Proyecto Ejecución:";
|
||
|
||
DdlGrupo.Items.Insert(0, new ListItem("Proyecto", "1"));
|
||
DdlGrupo.Items.Insert(1, new ListItem("SubProyecto", "2"));
|
||
DdlGrupo.Items.Insert(17, new ListItem("SubProyecto Ejec.", "19"));
|
||
DdlGrupo.DataBind();
|
||
}
|
||
else if (UsuarioActual.Empresa.Tipo_CentroCosto == 5)
|
||
{
|
||
LblProyecto.InnerText = "Proyecto:";
|
||
LblSubProyecto.InnerText = "Sucursal:";
|
||
LblSubProyectoEjecucion.InnerText = "Sucursal Ejecución:";
|
||
|
||
DdlGrupo.Items.Insert(0, new ListItem("Proyecto", "1"));
|
||
DdlGrupo.Items.Insert(1, new ListItem("SubProyecto", "2"));
|
||
DdlGrupo.Items.Insert(17, new ListItem("SubProyecto Ejec.", "19"));
|
||
DdlGrupo.DataBind();
|
||
}
|
||
}
|
||
|
||
private void CargaGrupo()
|
||
{
|
||
DdlGrupo.Items.Insert(0, new ListItem("Categoria", "3"));
|
||
DdlGrupo.Items.Insert(1, new ListItem("Clasificacion", "4"));
|
||
DdlGrupo.Items.Insert(2, new ListItem("Productos-Servicios", "5"));
|
||
DdlGrupo.Items.Insert(3, new ListItem("Año", "6"));
|
||
DdlGrupo.Items.Insert(4, new ListItem("Mes", "7"));
|
||
DdlGrupo.Items.Insert(5, new ListItem("Año/Mes", "8"));
|
||
DdlGrupo.Items.Insert(6, new ListItem("Fecha", "9"));
|
||
DdlGrupo.Items.Insert(7, new ListItem("Cliente", "10"));
|
||
DdlGrupo.Items.Insert(8, new ListItem("Vendedor", "12"));
|
||
DdlGrupo.Items.Insert(9, new ListItem("Usuario", "13"));
|
||
DdlGrupo.Items.Insert(10, new ListItem("Estatus Fact.", "14"));
|
||
DdlGrupo.Items.Insert(11, new ListItem("Año Ejec.", "15"));
|
||
DdlGrupo.Items.Insert(12, new ListItem("Mes Ejec.", "16"));
|
||
DdlGrupo.Items.Insert(13, new ListItem("Año/Mes Ejec.", "17"));
|
||
DdlGrupo.Items.Insert(14, new ListItem("Fecha Ejec.", "18"));
|
||
DdlGrupo.Items.Insert(15, new ListItem("Cliente - PS", "20"));
|
||
DdlGrupo.DataBind();
|
||
DdlGrupo.SelectedValueExist("8");
|
||
}
|
||
|
||
|
||
#endregion
|
||
|
||
#region SELECTED INDEX CHANGE
|
||
|
||
protected void DdlClienteClasificacion_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
DdlClientes.ddl.Items.Clear();
|
||
DdlClientes.DataSource = get_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"));
|
||
}
|
||
|
||
protected void DdlTipoComprobante_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
DdlEstatus.Items.Clear();
|
||
if (DdlTipoComprobante.SelectedValue != "-1")
|
||
{
|
||
DdlEstatus.DataSource = GlobalDTEstatusFactura.FiltraParametros(String.Format("TipoDocto = '{0}'", DdlTipoComprobante.SelectedValue));
|
||
}
|
||
else
|
||
{
|
||
DdlEstatus.DataSource = GlobalDTEstatusFactura;
|
||
}
|
||
DdlEstatus.Items.Add(new ListItem("Todos", "-1"));
|
||
DdlEstatus.DataBind();
|
||
}
|
||
|
||
protected void DdlProyecto_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
CargaSubProyectos();
|
||
}
|
||
|
||
protected void RblTipoCambio_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
TipoCambio = RblTipoCambio.SelectedValue.ToEntero();
|
||
if (TipoCambio == 3)
|
||
{
|
||
LiEspecifico.Visible = true;
|
||
TCEspecifico = get_GlobalTipoCambio(DateTime.Now).ToDecimal();
|
||
TxtEspecifico.Text = TCEspecifico.ToString();
|
||
}
|
||
else
|
||
{
|
||
LiEspecifico.Visible = false;
|
||
}
|
||
UpBodyTipoCambio.Update();
|
||
}
|
||
|
||
protected void BtnTipoCambio_Click(object sender, EventArgs e)
|
||
{
|
||
Consulta();
|
||
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivTipoCambio"));
|
||
UPDatos.Update();
|
||
}
|
||
|
||
|
||
protected void BtnPersonalizar_Click(object sender, EventArgs e)
|
||
{
|
||
Consulta();
|
||
UPDatos.Update();
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region CONSULTA
|
||
|
||
|
||
protected void BtnConsultar_Click(object sender, EventArgs e)
|
||
{
|
||
Consulta();
|
||
}
|
||
|
||
private void Consulta()
|
||
{
|
||
ClsVentas ObjVentas = new ClsVentas();
|
||
if (RblTipoCambio.SelectedValue.ToEntero() == 3 && TxtEspecifico.Text != "")
|
||
{
|
||
TCEspecifico = TxtEspecifico.Text.ToDecimal();
|
||
}
|
||
else
|
||
{
|
||
TCEspecifico = -1;
|
||
}
|
||
|
||
int VerEn = -1;
|
||
if (RbSubTotal.Checked) { VerEn = 1; }
|
||
if (RbTotal.Checked) { VerEn = 2; }
|
||
if (RbIVA.Checked) { VerEn = 3; }
|
||
|
||
DateTime FechaI, FechaF, FechaIEjec, FechaFEjec;
|
||
if (txtFechaI.Text.Trim() != "") { FechaI = txtFechaI.Text.ToDate(); } else { FechaI = MinFecha; }
|
||
if (txtFechaF.Text.Trim() != "") { FechaF = txtFechaF.Text.ToDate(); } else { FechaF = MaxFecha; }
|
||
if (TxtFechaIEjec.Text.Trim() != "") { FechaIEjec = TxtFechaIEjec.Text.ToDate(); } else { FechaIEjec = MinFecha; }
|
||
if (TxtFechaFEjec.Text.Trim() != "") { FechaFEjec = TxtFechaFEjec.Text.ToDate(); } else { FechaFEjec = MaxFecha; }
|
||
|
||
if (ObjVentas.GetRepPSPeriodo(FechaI, FechaF, FechaIEjec, FechaFEjec, DdlClientes.SelectedValue.ToEntero(), DdlSubProyectoEjecucion.SelectedValue.ToEntero(),
|
||
DdlVendedor.SelectedValue.ToEntero(), DdlUsuario.SelectedValue.ToEntero(), DdlEstatus.SelectedValue.ToEntero(), "-1", UsuarioActual.CveEmpresa,
|
||
DdlGrupo.SelectedValue.ToEntero(), DdlTipoComprobante.SelectedValue, DdlProyecto.SelectedValue.ToEntero(), DdlSubProyecto.SelectedValue.ToEntero(),
|
||
RblTipoCambio.SelectedValue.ToEntero(), TCEspecifico, CveUsuarioConsulta: UsuarioActual.CveUsuario, VerEn: VerEn, CvePS: DdlPS.SelectedValue.ToEntero(),
|
||
CveClasificacion: DdlClasificacion.SelectedValue.ToEntero(), CveCategoria: DdlCategoria.SelectedValue.ToEntero(), TipoFecha: DdlTipoFecha.SelectedValue.ToEntero(),
|
||
CveClienteClasificacion: DdlClienteClasificacion.SelectedValue.ToEntero(), ModalidadContable: !ChkLecturaAdmin.Checked))
|
||
{
|
||
GvDatos.DataSource = ObjVentas.DtResultados;
|
||
DtVentas = ObjVentas.DtResultados;
|
||
}
|
||
CveProyecto = DdlProyecto.SelectedValue.ToEntero();
|
||
ObjVentas.Dispose();
|
||
GvDatos.DataBind();
|
||
if (GvDatos.Rows.Count > 0)
|
||
{
|
||
CargaGraficas(DtVentas);
|
||
this.DvGraficas.Visible = true;
|
||
}
|
||
else
|
||
{
|
||
this.DvGraficas.Visible = false;
|
||
}
|
||
UPDatos.Update();
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region GRAFICA
|
||
|
||
private void CargaGraficas(DataTable DtVentas)
|
||
{
|
||
MuestraGrafica(div_ventas, DtVentas, "GPO", "Total", "", "", "gh2", "");
|
||
}
|
||
|
||
private void MuestraGrafica(HtmlGenericControl divcontainer, DataTable DTDatos, string ColTitle, string ColValue, string Titulo, string SubTitulo, string Indicador = "gh", string XReferencia = "", string YReferencia = "")
|
||
{
|
||
string Info = "";
|
||
StringBuilder SBJSScript = new StringBuilder();
|
||
|
||
if (DTDatos.Rows.Count > 0)
|
||
{
|
||
foreach (DataRow DbRow in DTDatos.Rows)
|
||
{
|
||
string moneda = DbRow["Moneda"].ToString();
|
||
string total = DbRow["GPO"].ToString();
|
||
if (total != "Total Peso Mexicano")
|
||
{
|
||
if (moneda == "Peso Mexicano")
|
||
{
|
||
Info = String.Format("{2}['{1}',{0}],", DbRow[ColValue], DbRow[ColTitle], Info);
|
||
}
|
||
}
|
||
}
|
||
Info = Info.Remove(Info.Length - 1, 1);
|
||
SBJSScript.AppendFormat("graficahighcharts('{0}','{1}','{2}','{3}',[{4}],1,'{5}');", divcontainer.ClientID, Titulo, SubTitulo, YReferencia, Info, XReferencia);
|
||
}
|
||
else
|
||
{
|
||
SBJSScript.AppendFormat("graficahighcharts('{0}','{1}','{2}','{3}',[{4}],1,'{5}');", divcontainer.ClientID, Titulo, SubTitulo, YReferencia, " ", XReferencia);
|
||
}
|
||
RegistraScript(SBJSScript.ToString(), Indicador);
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region REP HP
|
||
|
||
protected void LnkRepHP_Click(object sender, EventArgs e)
|
||
{
|
||
ClsVentas Rep = new ClsVentas();
|
||
StringBuilder Str = new StringBuilder();
|
||
Str.AppendLine("Header Section,,,,,,,,,,,End Customer Identification ,,,,,,,,,,,,, Ship To Identification,,,,,,,,,,,,, Sold To Identification,,,,,,,,,,,,, Bill To Identification,,,,,,,,,,,,, Salesperson Detail,,,,,, Line Item Detail,,,,,,,,,,,,,,,,,,,,,,,,,,,, New FIELDS,,,,,,,,,,,,,,,,,,,,,,,,,, ");
|
||
Str.AppendLine("Partner Purchase Price Currency Code, Exchange Rate, Reporter_id, Reported Partner Type, Reporter Company Name , Sell From Address line 1, Sell From Address line 2, Sell From City, Reported Partner State/Province, Sell from postal code, Sell from Country code,End User Customer Name,End User Company Tax ID,End User Address Line 1,End User Address Line 2,End User City,End User State/Province Code,End User Postal Code,End User Country Code,End User ID,End Customer Department,End Customer Contact Name,End Customer Contact Phone,End Customer County, Ship To Customer Name, Ship To Company Tax ID, Ship To Address Line 1, Ship To Address Line 2, Ship To City, Ship To State/Province Code, Ship To Postal Code, Ship To Country Code, Ship To Customer ID, Ship To Department, Ship To Contact Name, Ship To Contact Phone, Ship To County, Sold To Customer Name, Sold To Company Tax ID, Sold To Address Line 1, Sold To Address Line 2, Sold To City, Sold To State/Province Code, Sold To Postal Code, Sold To Country Code, Sold To Customer ID, Sold To Department, Sold To Contact Name, Sold To Contact Phone, Sold To County, Bill To Customer Name, Bill To Company Tax ID, Bill To Address Line 1 , Bill To Address Line 2, Bill To City, Bill To State/Province Code, Bill To Postal Code, Bill To Country Code, Bill To Customer ID, Bill To Agreement Number, Bill To Contact Name, Bill To Contact Phone, Bill To County, HP Representative Name, HP Sales Rep Email, Salesperson2 Name, Salesperson2 Unique Employee ID, Salesperson's Manager's Name,Salesperson's Manager Unique Employee ID,Quantity Qualifier,Product Quantity Shipped/Sold,Line Item ID,Partner Reported Product ID,Product Description,Date Type Qualifier,Channel Partner to Customer Transaction Date,Reseller’’s Product Number,Partner Purchase Price,Extended Price,Partner Sell Price,Extended Resale Price,Transaction Type,Rebate Tracking #,Partner Requested Rebate Amount,Extended Rebate Amount,Debit Number,Channel Partner to Customer Invoice ID,Reference Number,Customer to Channel Partner Purchase Order ID,Deal ID #1,Deal ID #2,Deal ID #3,Deal ID #4,Deal ID #5,Deal ID #6,Marketing Subprogram Code,Product Serial ID assigned by HP,Purchasing Source wholesaler indicator,Drop Ship Flag,Distributor's Invoice Number,Partner Internal transaction ID,Partner Comment,Deal Bundle ID #1,Deal Bundle ID #2,Deal Bundle ID #3,Deal Bundle ID #4,Deal Bundle ID #5,Deal Bundle ID #6,NMSO NAME,Sales Type,Purchase Agreement,Product Origin,Partner Reported CBN#,Partner Reference,Supplies Tracking ID (QR Code),Sell From Location ID (assigned by HP or Partner-assigned),Sell from name,Comment Deal ID #1,Comment Deal ID #2,Comment Deal ID #3,Comment Deal ID #4,Comment Deal ID #5,Comment Deal ID #6,Partner Sell Price Currency Code");
|
||
if (Rep.GetReporteHP(72, DateTime.Now.AddMonths(-1).FirstDayOfMonth(), DateTime.Now.AddMonths(-1).LastDayOfMonth()))
|
||
{
|
||
foreach (DataRow dr in Rep.DtResultados.Rows)
|
||
{
|
||
Str.AppendLine($"MXN,,AM30089,,COMPUPROVEEDORES, S.A.DE C.V.,,,,,,,,,,,,,,,,,,,,{dr["Nombre"]},{dr["RFC"]},{dr["Direccion"]},,{dr["Ciudad"]},{dr["Estado"]},{dr["CP"]},MX,{dr["RFC"]},,,,,{dr["Nombre"]},{dr["RFC"]},{dr["Direccion"]},,{dr["Ciudad"]},{dr["Estado"]},{dr["CP"]},MX,{dr["RFC"]},,,,,,,,,,,,,,,,,,,,,,,,,{dr["Cantidad"]},,{dr["Codigo"]},,,{dr["Fecha"]},,,,{dr["PU"]},,,,,,,{dr["SerieFolio"]},,,,,,,,,,,,,,,,,,,,,,,,,{dr["Proveedor"]},,,,,,,,,,,,MXN");
|
||
}
|
||
}
|
||
|
||
Rep.Dispose();
|
||
//GenerarPDF una salida
|
||
Response.Clear();
|
||
Response.ContentType = "text/csv";
|
||
Response.AppendHeader("Content-Disposition", "attachment; filename=ReporteHP.csv");
|
||
Response.Write(Str.ToString());
|
||
Context.Response.End();
|
||
}
|
||
|
||
|
||
#endregion
|
||
|
||
#region GRIDVIEW
|
||
|
||
protected void GvDatos_RowDataBound(object sender, GridViewRowEventArgs e)
|
||
{
|
||
if (e.Row.RowType == DataControlRowType.DataRow)
|
||
{
|
||
if (e.Row.RowIndex == 0 || e.Row.DBCampo("GPO") == "Total Dólares")
|
||
{
|
||
e.Row.CssClass = "Totales";
|
||
}
|
||
|
||
if (e.Row.Cells[2].Text.ToDouble() == 0) { e.Row.Cells[2].Text = ""; }
|
||
if (e.Row.Cells[3].Text.ToDouble() == 0) { e.Row.Cells[3].Text = ""; }
|
||
if (e.Row.Cells[4].Text.ToDouble() == 0) { e.Row.Cells[4].Text = ""; }
|
||
if (e.Row.Cells[5].Text.ToDouble() == 0) { e.Row.Cells[5].Text = ""; }
|
||
if (e.Row.Cells[6].Text.ToDouble() == 0) { e.Row.Cells[6].Text = ""; }
|
||
if (e.Row.Cells[7].Text.ToDouble() == 0) { e.Row.Cells[7].Text = ""; }
|
||
if (e.Row.Cells[8].Text.ToDouble() == 0) { e.Row.Cells[8].Text = ""; }
|
||
if (e.Row.Cells[9].Text.ToDouble() == 0) { e.Row.Cells[9].Text = ""; }
|
||
if (e.Row.Cells[10].Text.ToDouble() == 0) { e.Row.Cells[10].Text = ""; }
|
||
if (e.Row.Cells[11].Text.ToDouble() == 0) { e.Row.Cells[11].Text = ""; }
|
||
if (e.Row.Cells[12].Text.ToDouble() == 0) { e.Row.Cells[12].Text = ""; }
|
||
if (e.Row.Cells[13].Text.ToDouble() == 0) { e.Row.Cells[13].Text = ""; }
|
||
if (e.Row.Cells[14].Text.ToDouble() == 0) { e.Row.Cells[14].Text = ""; }
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region PDF
|
||
|
||
protected void ImgImprimir_Click(object sender, EventArgs e)
|
||
{
|
||
GeneraPDF("PDF");
|
||
}
|
||
|
||
protected void ImgExcel_Click(object sender, EventArgs e)
|
||
{
|
||
GeneraPDF("EXCEL");
|
||
}
|
||
|
||
private void GeneraPDF(string Formato)
|
||
{
|
||
if (DtVentas.Rows.Count > 0)
|
||
{
|
||
StringBuilder StrFiltro = new StringBuilder();
|
||
StrFiltro.AppendFormat("<b>Agrupado por</b>: {0}", DdlGrupo.SelectedItem.Text);
|
||
if (DdlTipoComprobante.SelectedValue != "-1") { StrFiltro.AppendFormat(" <b>Tipo Documento</b>: {0}", DdlTipoComprobante.SelectedItem.Text); }
|
||
if (txtFechaI.Text != "") { StrFiltro.AppendFormat(" <b>Fecha Inicio </b>: {0}", txtFechaI.Text.ToDate().ToShortDateString()); }
|
||
if (txtFechaF.Text != "") { StrFiltro.AppendFormat(" <b>Fecha Fin </b>: {0}", txtFechaF.Text.ToDate().ToShortDateString()); }
|
||
System.IO.FileInfo Imagen = new System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta));
|
||
string logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa);
|
||
DataTable dt = DtVentas.FiltraParametros("", "Orden");
|
||
string FechaI, FechaF;
|
||
if (txtFechaI.Text == "" || txtFechaI.Text == "__/__/____") { FechaI = "-1"; } else { FechaI = txtFechaI.Text; }
|
||
if (txtFechaF.Text == "" || txtFechaF.Text == "__/__/____") { FechaF = "-1"; } else { FechaF = txtFechaF.Text; }
|
||
List<ReportParameter> para = new List<ReportParameter>();
|
||
para.Add(new ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa));
|
||
para.Add(new ReportParameter("FechaInicio", FechaI));
|
||
para.Add(new ReportParameter("FechaFin", FechaF));
|
||
para.Add(new ReportParameter("UsuarioImprimio", UsuarioActual.Nombre));
|
||
para.Add(new ReportParameter("FechaImpresion", DateTime.Now.ToShortDateString()));
|
||
para.Add(new ReportParameter("Filtros", StrFiltro.ToString()));
|
||
if (Imagen.Exists)
|
||
{
|
||
para.Add(new ReportParameter("LogoPath", logouri));
|
||
}
|
||
else
|
||
{
|
||
para.Add(new ReportParameter("LogoPath", ""));
|
||
}
|
||
ImprimirPDF("Empresas/Grales/Formatos/RepVentasPeriodo.rdlc", dt, para, String.Format("ReporteVentas-{0}", DateTime.Now.ToShortDateString()), Formato: Formato);
|
||
}
|
||
else
|
||
{
|
||
Alert("No hay datos consultados", TipoMensaje.MsgAdvertencia);
|
||
}
|
||
|
||
}
|
||
|
||
#endregion
|
||
|
||
} |