Commit inicial Ventas Productivo
This commit is contained in:
306
Ventas/RepRecuperacionPeriodo.aspx.cs
Normal file
306
Ventas/RepRecuperacionPeriodo.aspx.cs
Normal file
@@ -0,0 +1,306 @@
|
||||
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_RepRecuperacionPeriodo : ClsPaginas
|
||||
{
|
||||
#region PROPIEDADES
|
||||
|
||||
private DataTable DtDatos
|
||||
{
|
||||
get { return DtDatos = (DataTable)ViewState["DtDatos"]; }
|
||||
set { ViewState["DtDatos"] = value; }
|
||||
}
|
||||
private int TipoCambio
|
||||
{
|
||||
get { return (ViewState["TipoCambio"] == null) ? -1 : Convert.ToInt32(ViewState["TipoCambio"]); }
|
||||
set { ViewState["TipoCambio"] = value; }
|
||||
}
|
||||
private double TCEspecifico
|
||||
{
|
||||
get { return (ViewState["TCEspecifico"] == null) ? 0 : Convert.ToDouble(ViewState["TCEspecifico"]); }
|
||||
set { ViewState["TCEspecifico"] = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
InicializaValores();
|
||||
}
|
||||
}
|
||||
|
||||
private void InicializaValores()
|
||||
{
|
||||
TipoCambio = 1;
|
||||
TCEspecifico = -1;
|
||||
|
||||
//Carga Clientes
|
||||
DdlClientes.DataSource = get_GlobalDTCliente(UsuarioActual.CveEmpresa, -1);
|
||||
DdlClientes.DataBind();
|
||||
|
||||
//Carga SubProyectos
|
||||
DdlSubProyecto.DataSource = get_GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1);
|
||||
DdlSubProyecto.DataBind();
|
||||
|
||||
//Carga Vendedor
|
||||
DdlVendedor.DataSource = get_GlobalDTVendedores(UsuarioActual.CveEmpresa);
|
||||
DdlVendedor.DataBind();
|
||||
DdlVendedor.SelectedValueExist(UsuarioActual.CveVendedor);
|
||||
if (UsuarioActual.CveVendedor > 0 && UsuarioActual.TienePermisoProceso(263))
|
||||
{
|
||||
DdlVendedor.SelectedValueExist(UsuarioActual.CveVendedor.ToString());
|
||||
DdlVendedor.Attributes.Add("disabled", "disabled");
|
||||
DdlVendedor.Enabled = false;
|
||||
}
|
||||
|
||||
//Carga Usuarios
|
||||
DdlUsuario.DataSource = get_GlobalDTUsuarios().FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa}");
|
||||
DdlUsuario.DataBind();
|
||||
|
||||
//Carga Responsable
|
||||
DdlResponsable.DataSource = get_GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa);
|
||||
DdlResponsable.DataBind();
|
||||
|
||||
//Carga Bancos
|
||||
DdlBanco.DataSource = GlobalDTBancos.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa}");
|
||||
DdlBanco.Items.Insert(0, new ListItem("Todos", "-1"));
|
||||
DdlBanco.DataBind();
|
||||
|
||||
//Carga Clasificacion Cliente
|
||||
ClsClientes ObjCliente = new ClsClientes();
|
||||
if (ObjCliente.GetClienteClasificacion(UsuarioActual.CveEmpresa))
|
||||
{
|
||||
DdlClienteClasificacion.DataSource = ObjCliente.DtResultados;
|
||||
}
|
||||
ObjCliente.Dispose();
|
||||
DdlClienteClasificacion.Items.Insert(0, new ListItem("Todos", "-1"));
|
||||
DdlClienteClasificacion.DataBind();
|
||||
|
||||
txtFechaI.Text = DateTime.Now.FirstDayOfMonth().ToShortDateString();
|
||||
txtFechaF.Text = DateTime.Now.ToShortDateString();
|
||||
|
||||
}
|
||||
|
||||
private void GenerarPDF(string Opcion)
|
||||
{
|
||||
string FechaInicio, FechaFin, Sucursal, Grupo, Vendedor,Cliente, ClasificacionCliente,Banco,CuentaBancaria,TipoDocto,EstatusCliente,Registro,Responsable;
|
||||
if (txtFechaI.Text == "") { FechaInicio = ""; } else { FechaInicio = $" <b>Fecha Inicio:</b> {txtFechaI.Text}"; }
|
||||
if (txtFechaF.Text == "") { FechaFin = ""; } else { FechaFin = $" <b>Fecha Fin:</b> {txtFechaF.Text}"; }
|
||||
if (DdlSubProyecto.SelectedValue == "-1") { Sucursal = ""; } else { Sucursal = $" <b>Sucursal:</b> {DdlSubProyecto.SelectedItem.Text}"; }
|
||||
if (DdlGrupo.SelectedValue == "-1") { Grupo = ""; } else { Grupo = $" <b>Grupo:</b> {DdlGrupo.SelectedItem.Text}"; }
|
||||
if (DdlVendedor.SelectedValue == "-1") { Vendedor = ""; } else { Vendedor = $" <b>Vendedor:</b> {DdlVendedor.SelectedItem.Text}"; }
|
||||
if (DdlClientes.SelectedValue == "-1") { Cliente = ""; } else { Cliente = $" <b>Cliente:</b> {DdlClientes.SelectedItem.Text}"; }
|
||||
if (DdlClienteClasificacion.SelectedValue == "-1") { ClasificacionCliente = ""; } else { ClasificacionCliente = $" <b>Clasificación Cliente:</b> {DdlClienteClasificacion.SelectedItem.Text}"; }
|
||||
if (DdlBanco.SelectedValue == "-1") { Banco = ""; } else { Banco = $" <b>Banco:</b> {DdlBanco.SelectedItem.Text}"; }
|
||||
if (DdlCuentaBancaria.SelectedValue == "-1") { CuentaBancaria = ""; } else { CuentaBancaria = $" <b>Cuenta Bancaria:</b> {DdlCuentaBancaria.SelectedItem.Text}"; }
|
||||
if (DdlTipoDocto.SelectedValue == "-1") { TipoDocto = ""; } else { TipoDocto = $" <b>Tipo Documento:</b> {DdlTipoDocto.SelectedItem.Text}"; }
|
||||
if (DdlEstatusCliente.SelectedValue == "-1") { EstatusCliente = ""; } else { EstatusCliente = $" <b>Estatus Cliente:</b> {DdlEstatusCliente.SelectedItem.Text}"; }
|
||||
if (DdlUsuario.SelectedValue == "-1") { Registro = ""; } else { Registro = $" <b>Registro:</b> {DdlUsuario.SelectedItem.Text}"; }
|
||||
if (DdlResponsable.SelectedValue == "-1") { Responsable = ""; } else { Responsable = $" <b>Responsable:</b> {DdlResponsable.SelectedItem.Text}"; }
|
||||
|
||||
if (DtDatos.Rows.Count > 0)
|
||||
{
|
||||
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);
|
||||
List<ReportParameter> para = new List<ReportParameter>();
|
||||
para.Add(new ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa));
|
||||
para.Add(new ReportParameter("UsuarioImprimio", UsuarioActual.Nombre));
|
||||
para.Add(new ReportParameter("FechaImpresion", DateTime.Now.ToString()));
|
||||
para.Add(new ReportParameter("Filtros", $"<b>Filtros:</b> {FechaInicio}{FechaFin}{Sucursal}{Grupo}{Vendedor}{Cliente}{ClasificacionCliente}{Banco}{CuentaBancaria}{TipoDocto}{EstatusCliente}{Registro}{Responsable}"));
|
||||
if (Imagen.Exists)
|
||||
{
|
||||
para.Add(new ReportParameter("LogoPath", logouri));
|
||||
}
|
||||
else
|
||||
{
|
||||
para.Add(new ReportParameter("LogoPath", ""));
|
||||
}
|
||||
ImprimirPDF("Empresas/Grales/Formatos/RepRecuperacionPeriodo.rdlc", DtDatos, para, "RepRecuperacionPeriodo", Opcion);
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert("No hay datos consultados", TipoMensaje.MsgAdvertencia);
|
||||
}
|
||||
}
|
||||
|
||||
protected void LnkPdf_Click(object sender, EventArgs e)
|
||||
{
|
||||
GenerarPDF("PDF");
|
||||
}
|
||||
|
||||
protected void LnkExcel_Click(object sender, EventArgs e)
|
||||
{
|
||||
GenerarPDF("EXCEL");
|
||||
}
|
||||
|
||||
protected void GvDatos_RowDataBound(object sender, GridViewRowEventArgs e)
|
||||
{
|
||||
if (e.Row.RowType == DataControlRowType.DataRow)
|
||||
{
|
||||
if (e.Row.DBCampo("Orden").ToString() == "")
|
||||
{
|
||||
e.Row.CssClass = "Totales";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void BtnConsultar_Click(object sender, EventArgs e)
|
||||
{
|
||||
Consulta();
|
||||
}
|
||||
|
||||
private void Consulta()
|
||||
{
|
||||
if (RblTipoCambio.SelectedValue.ToEntero() == 3 && TxtEspecifico.Text != "") { TCEspecifico = TxtEspecifico.Text.ToDouble(); } else { TCEspecifico = -1; }
|
||||
ClsMovimientos ObjMov = new ClsMovimientos();
|
||||
if (ObjMov.GetRepRecuperacionPerido(txtFechaI.Text.ToDate(),txtFechaF.Text.ToDate(),DdlClientes.SelectedValue.ToEntero(),DdlSubProyecto.SelectedValue.ToEntero(),
|
||||
DdlVendedor.SelectedValue.ToEntero(),DdlUsuario.SelectedValue.ToEntero(),-1,"-1",UsuarioActual.CveEmpresa,DdlGrupo.SelectedValue.ToEntero(),
|
||||
DdlResponsable.SelectedValue.ToEntero(),DdlTipoDocto.SelectedValue, DdlEstatusCliente.SelectedValue.ToEntero(),UsuarioActual.CveUsuario,
|
||||
DdlBanco.SelectedValue.ToEntero(), DdlCuentaBancaria.SelectedValue.ToEntero(), TipoCambio, TCEspecifico, DdlClienteClasificacion.SelectedValue.ToEntero()))
|
||||
{
|
||||
GvDatos.DataSource = ObjMov.DtResultados;
|
||||
DtDatos = ObjMov.DtResultados;
|
||||
}
|
||||
ObjMov.Dispose();
|
||||
GvDatos.DataBind();
|
||||
UpDatos.Update();
|
||||
}
|
||||
|
||||
protected void RblTipoCambio_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
TipoCambio = RblTipoCambio.SelectedValue.ToEntero();
|
||||
if (TipoCambio == 3)
|
||||
{
|
||||
LiEspecifico.Visible = true;
|
||||
TCEspecifico = get_GlobalTipoCambio(DateTime.Now);
|
||||
TxtEspecifico.Text = TCEspecifico.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
LiEspecifico.Visible = false;
|
||||
}
|
||||
UpBodyTipoCambio.Update();
|
||||
}
|
||||
|
||||
protected void LnkVerGrafica_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (DtDatos != null)
|
||||
{
|
||||
if (DtDatos.Rows.Count > 0)
|
||||
{
|
||||
DataTable Dt = new DataTable();
|
||||
Dt.Columns.Add("mes");
|
||||
|
||||
DataTable Dt2 = new DataTable();
|
||||
Dt2.Columns.Add("balloonText");
|
||||
Dt2.Columns.Add("bullet");
|
||||
Dt2.Columns.Add("title");
|
||||
Dt2.Columns.Add("valueField");
|
||||
Dt2.Columns.Add("fillAlphas");
|
||||
|
||||
foreach (DataRow Row in DtDatos.Rows)
|
||||
{
|
||||
if (Row["Orden"].ToString() !="")
|
||||
{
|
||||
Dt.Columns.Add($"{Row["GPO"].ToString()} {Row["Abreviatura"].ToString()}");
|
||||
DataRow Row2 = Dt2.NewRow();
|
||||
Row2["balloonText"] = "Pagado [[category]]: [[value]]";
|
||||
Row2["bullet"] = "round";
|
||||
Row2["title"] = $"{Row["GPO"].ToString()} {Row["Abreviatura"].ToString()}";
|
||||
Row2["valueField"] = $"{Row["GPO"].ToString()} {Row["Abreviatura"].ToString()}";
|
||||
Row2["fillAlphas"] = 0;
|
||||
Dt2.Rows.Add(Row2);
|
||||
}
|
||||
}
|
||||
|
||||
DataRow RowEnero = Dt.NewRow();
|
||||
DataRow RowFebrero = Dt.NewRow();
|
||||
DataRow RowMarzo = Dt.NewRow();
|
||||
DataRow RowAbril = Dt.NewRow();
|
||||
DataRow RowMayo = Dt.NewRow();
|
||||
DataRow RowJunio = Dt.NewRow();
|
||||
DataRow RowJulio = Dt.NewRow();
|
||||
DataRow RowAgosto = Dt.NewRow();
|
||||
DataRow RowSeptiembre = Dt.NewRow();
|
||||
DataRow RowOctubre = Dt.NewRow();
|
||||
DataRow RowNoviembre = Dt.NewRow();
|
||||
DataRow RowDiciembre = Dt.NewRow();
|
||||
|
||||
foreach (DataRow Row in DtDatos.Rows)
|
||||
{
|
||||
if (Row["Orden"].ToString() !="")
|
||||
{
|
||||
RowEnero[$"{Row["GPO"].ToString()} {Row["Abreviatura"].ToString()}"] = Row["Enero"].ToString();
|
||||
RowEnero["mes"] = "Enero";
|
||||
RowFebrero[$"{Row["GPO"].ToString()} {Row["Abreviatura"].ToString()}"] = Row["Febrero"].ToString();
|
||||
RowFebrero["mes"] = "Febrero";
|
||||
RowMarzo[$"{Row["GPO"].ToString()} {Row["Abreviatura"].ToString()}"] = Row["Marzo"].ToString();
|
||||
RowMarzo["mes"] = "Marzo";
|
||||
RowAbril[$"{Row["GPO"].ToString()} {Row["Abreviatura"].ToString()}"] = Row["Abril"].ToString();
|
||||
RowAbril["mes"] = "Abril";
|
||||
RowMayo[$"{Row["GPO"].ToString()} {Row["Abreviatura"].ToString()}"] = Row["Mayo"].ToString();
|
||||
RowMayo["mes"] = "Mayo";
|
||||
RowJunio[$"{Row["GPO"].ToString()} {Row["Abreviatura"].ToString()}"] = Row["Junio"].ToString();
|
||||
RowJunio["mes"] = "Junio";
|
||||
RowJulio[$"{Row["GPO"].ToString()} {Row["Abreviatura"].ToString()}"] = Row["Julio"].ToString();
|
||||
RowJulio["mes"] = "Julio";
|
||||
RowAgosto[$"{Row["GPO"].ToString()} {Row["Abreviatura"].ToString()}"] = Row["Agosto"].ToString();
|
||||
RowAgosto["mes"] = "Agosto";
|
||||
RowSeptiembre[$"{Row["GPO"].ToString()} {Row["Abreviatura"].ToString()}"] = Row["Septiembre"].ToString();
|
||||
RowSeptiembre["mes"] = "Septiembre";
|
||||
RowOctubre[$"{Row["GPO"].ToString()} {Row["Abreviatura"].ToString()}"] = Row["Octubre"].ToString();
|
||||
RowOctubre["mes"] = "Octubre";
|
||||
RowNoviembre[$"{Row["GPO"].ToString()} {Row["Abreviatura"].ToString()}"] = Row["Noviembre"].ToString();
|
||||
RowNoviembre["mes"] = "Noviembre";
|
||||
RowDiciembre[$"{Row["GPO"].ToString()} {Row["Abreviatura"].ToString()}"] = Row["Diciembre"].ToString();
|
||||
RowDiciembre["mes"] = "Diciembre";
|
||||
}
|
||||
}
|
||||
|
||||
Dt.Rows.Add(RowEnero);
|
||||
Dt.Rows.Add(RowFebrero);
|
||||
Dt.Rows.Add(RowMarzo);
|
||||
Dt.Rows.Add(RowAbril);
|
||||
Dt.Rows.Add(RowMayo);
|
||||
Dt.Rows.Add(RowJunio);
|
||||
Dt.Rows.Add(RowJulio);
|
||||
Dt.Rows.Add(RowAgosto);
|
||||
Dt.Rows.Add(RowSeptiembre);
|
||||
Dt.Rows.Add(RowOctubre);
|
||||
Dt.Rows.Add(RowNoviembre);
|
||||
Dt.Rows.Add(RowDiciembre);
|
||||
|
||||
RegistraScript($"CargaGraficaLineas({Dt.ToJson()},{Dt2.ToJson()})", "11");
|
||||
RegistraScript(String.Format("$('#{0}').modal();", "DivModalGrafica"), "22");
|
||||
UpGrafica.Update();
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert("No hay datos consultados", TipoMensaje.MsgAdvertencia);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert("No hay datos consultados", TipoMensaje.MsgAdvertencia);
|
||||
}
|
||||
}
|
||||
|
||||
protected void BtnTipoCambio_Click(object sender, EventArgs e)
|
||||
{
|
||||
Consulta();
|
||||
}
|
||||
|
||||
protected void DdlBanco_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
DdlCuentaBancaria.Items.Clear();
|
||||
if (DdlBanco.SelectedValue.ToEntero() > 0)
|
||||
Reference in New Issue
Block a user