Commit inicial Ventas Productivo
This commit is contained in:
292
CRM/RepAcercamientosProcesos.aspx.cs
Normal file
292
CRM/RepAcercamientosProcesos.aspx.cs
Normal file
@@ -0,0 +1,292 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Data;
|
||||
using Extensiones;
|
||||
|
||||
public partial class CRM_RepAcercamientosProcesos : ClsPaginas
|
||||
{
|
||||
#region "PROPIEDADES"
|
||||
private string Agrupador
|
||||
{
|
||||
get { return (ViewState["Agrupador"] == null) ? "" : (ViewState["Agrupador"]).ToString(); }
|
||||
set { ViewState["Agrupador"] = value; }
|
||||
}
|
||||
|
||||
private DataTable DtColor
|
||||
{
|
||||
get { return DtColor = (DataTable)ViewState["DtColor"]; }
|
||||
set { ViewState["DtColor"] = value; }
|
||||
}
|
||||
|
||||
private DataTable DtDatos
|
||||
{
|
||||
get { return DtDatos = (DataTable)ViewState["DtDatos"]; }
|
||||
set { ViewState["DtDatos"] = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
DateTime startOfWeek = DateTime.Today.AddDays(-1 * (int)(DateTime.Today.DayOfWeek));
|
||||
TxtFechaInicio.Text = startOfWeek.ToString("dd/MM/yyyy");
|
||||
TxtFechaFin.Text = startOfWeek.AddDays(7).ToString("dd/MM/yyyy");
|
||||
CargaDdl();
|
||||
cargarDatos();
|
||||
CreaDtColor();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void CargaDdl()
|
||||
{
|
||||
ClsCRM ObjCRM = new ClsCRM();
|
||||
DdlTipoProceso.DataSource = null;
|
||||
DdlVendedor.DataSource = null;
|
||||
DdlMedioCaptacion.DataSource = null;
|
||||
DdlProbabilidad.DataSource = null;
|
||||
|
||||
if (ObjCRM.GetTipoProceso(UsuarioActual.CveEmpresa, 1))
|
||||
{
|
||||
DdlTipoProceso.DataSource = ObjCRM.DtResultados;
|
||||
}
|
||||
DdlVendedor.DataSource = get_GlobalDTVendedores(UsuarioActual.CveEmpresa);
|
||||
if (ObjCRM.GetMedioCaptacion(UsuarioActual.CveEmpresa))
|
||||
{
|
||||
DdlMedioCaptacion.DataSource = ObjCRM.DtResultados;
|
||||
}
|
||||
if (ObjCRM.GetProbabilidadAcercamiento(UsuarioActual.CveEmpresa, -1))
|
||||
{
|
||||
DdlProbabilidad.DataSource = ObjCRM.DtResultados;
|
||||
}
|
||||
ObjCRM.Dispose();
|
||||
|
||||
DdlTipoProceso.DataBind();
|
||||
DdlVendedor.DataBind();
|
||||
DdlMedioCaptacion.DataBind();
|
||||
DdlProbabilidad.DataBind();
|
||||
DdlVendedor.Items.Insert(0, new ListItem("Seleccione ", "-1"));
|
||||
DdlMedioCaptacion.Items.Insert(0, new ListItem("Seleccione ", "-1"));
|
||||
DdlProbabilidad.Items.Insert(0, new ListItem("Seleccione ", "-1"));
|
||||
DdlVendedor.SelectedValue = "-1";
|
||||
DdlMedioCaptacion.SelectedValue = "-1";
|
||||
DdlProbabilidad.SelectedValue = "-1";
|
||||
DdlTipoProceso.SelectedIndex = 0;
|
||||
upDatosRepA.Update();
|
||||
}
|
||||
protected void cargarDatos()
|
||||
{
|
||||
int cveTipoProceso = DdlTipoProceso.SelectedValue.ToEntero();
|
||||
int idgrupo1 = DdlGrupo1.SelectedValue.ToEntero();
|
||||
int idgrupo2 = DdlGrupo2.SelectedValue.ToEntero();
|
||||
string fechaIni = TxtFechaInicio.Text.Length > 0 ? TxtFechaInicio.Text.ToDateTime().ToString("yyyy/MM/dd") : "";
|
||||
string fechaFin = TxtFechaFin.Text.Length > 0 ? TxtFechaFin.Text.ToDateTime().ToString("yyyy/MM/dd") : "";
|
||||
int cveVendedor = DdlVendedor.SelectedValue.ToEntero();
|
||||
int cveMedioCaptacion = DdlMedioCaptacion.SelectedValue.ToEntero();
|
||||
int cveProbabilidadAcercamiento = DdlProbabilidad.SelectedValue.ToEntero();
|
||||
ClsCRM ObjCRM = new ClsCRM();
|
||||
GVRepAcercamientosEtapas.Columns.Clear();
|
||||
|
||||
if (ObjCRM.RepAcercamientosEtapas(UsuarioActual.CveEmpresa, cveTipoProceso, idgrupo1, idgrupo2, fechaIni, fechaFin, cveVendedor, cveMedioCaptacion, cveProbabilidadAcercamiento))
|
||||
{
|
||||
DataTable dte = ObjCRM.DSResultados.Tables[1];
|
||||
GVRepAcercamientosEtapas.DataSource = ObjCRM.DSResultados.Tables[0];
|
||||
DtDatos= ObjCRM.DSResultados.Tables[0];
|
||||
BoundField test = new BoundField();
|
||||
test.DataField = "Grupo1";
|
||||
test.HeaderText = "";
|
||||
switch (idgrupo1)
|
||||
{
|
||||
case 1:
|
||||
test.HeaderText = "Vendedor";
|
||||
Agrupador = "Vendedor";
|
||||
break;
|
||||
case 2:
|
||||
test.HeaderText = "Medio de Captación";
|
||||
Agrupador = "Medio de Captación";
|
||||
break;
|
||||
case 3:
|
||||
test.HeaderText = "Probabilidad de Acercamiento";
|
||||
Agrupador = "Probabilidad de Acercamiento";
|
||||
break;
|
||||
case 4:
|
||||
test.HeaderText = "Fecha";
|
||||
Agrupador = "Fecha";
|
||||
break;
|
||||
}
|
||||
GVRepAcercamientosEtapas.Columns.Add(test);
|
||||
|
||||
HyperLinkField hypt = new HyperLinkField();
|
||||
hypt.DataTextField = $"Total";
|
||||
hypt.HeaderText = $"Total";
|
||||
hypt.DataNavigateUrlFields = new string[] { "CveGrupo1", "CveGrupo2" };
|
||||
hypt.DataNavigateUrlFormatString = $"/CRM/RepAcercamientosProcesosDetalle.ASPX?CveTipoProceso={cveTipoProceso}&CveGrupo1={{0}}&CveGrupo2={{1}}&FechaInicio={TxtFechaInicio.Text}&FechaFin={TxtFechaFin.Text}";
|
||||
GVRepAcercamientosEtapas.Columns.Add(hypt);
|
||||
foreach (DataRow row in dte.Rows)
|
||||
{
|
||||
HyperLinkField hyp = new HyperLinkField();
|
||||
hyp.DataTextField = $"C_{row["CveEtapaProceso"]}";
|
||||
hyp.HeaderText = $"{row["EtapaProceso"]}";
|
||||
hyp.DataNavigateUrlFields = new string[]{ "CveGrupo1","CveGrupo2"};
|
||||
hyp.DataNavigateUrlFormatString = $"/CRM/RepAcercamientosProcesosDetalle.ASPX?CveTipoProceso={cveTipoProceso}&CveGrupo1={{0}}&CveGrupo2={{1}}&FechaInicio={TxtFechaInicio.Text}&FechaFin={TxtFechaFin.Text}&cveEtapaProceso={row["CveEtapaProceso"]}";
|
||||
GVRepAcercamientosEtapas.Columns.Add(hyp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GVRepAcercamientosEtapas.DataSource = null;
|
||||
|
||||
}
|
||||
ObjCRM.Dispose();
|
||||
GVRepAcercamientosEtapas.DataBind();
|
||||
upDatosRepA.Update();
|
||||
}
|
||||
|
||||
|
||||
protected void LnkConsultar_Click(object sender, EventArgs e)
|
||||
{
|
||||
cargarDatos();
|
||||
}
|
||||
|
||||
private void CreaDtColor()
|
||||
{
|
||||
DtColor = new DataTable();
|
||||
DtColor.Columns.Add("Color");
|
||||
DataRow RowColor = null;
|
||||
RowColor = DtColor.NewRow();
|
||||
RowColor["Color"] = "#FF0F00";
|
||||
DtColor.Rows.Add(RowColor);
|
||||
RowColor = null;
|
||||
RowColor = DtColor.NewRow();
|
||||
RowColor["Color"] = "#FF6600";
|
||||
DtColor.Rows.Add(RowColor);
|
||||
RowColor = null;
|
||||
RowColor = DtColor.NewRow();
|
||||
RowColor["Color"] = "#FF9E01";
|
||||
DtColor.Rows.Add(RowColor);
|
||||
RowColor = null;
|
||||
RowColor = DtColor.NewRow();
|
||||
RowColor["Color"] = "#FCD202";
|
||||
DtColor.Rows.Add(RowColor);
|
||||
RowColor = null;
|
||||
RowColor = DtColor.NewRow();
|
||||
RowColor["Color"] = "#F8FF01";
|
||||
DtColor.Rows.Add(RowColor);
|
||||
RowColor = null;
|
||||
RowColor = DtColor.NewRow();
|
||||
RowColor["Color"] = "#B0DE09";
|
||||
DtColor.Rows.Add(RowColor);
|
||||
RowColor = null;
|
||||
RowColor = DtColor.NewRow();
|
||||
RowColor["Color"] = "#04D215";
|
||||
DtColor.Rows.Add(RowColor);
|
||||
RowColor = null;
|
||||
RowColor = DtColor.NewRow();
|
||||
RowColor["Color"] = "#0D8ECF";
|
||||
DtColor.Rows.Add(RowColor);
|
||||
RowColor = null;
|
||||
RowColor = DtColor.NewRow();
|
||||
RowColor["Color"] = "#0D52D1";
|
||||
DtColor.Rows.Add(RowColor);
|
||||
RowColor = null;
|
||||
RowColor = DtColor.NewRow();
|
||||
RowColor["Color"] = "#2A0CD0";
|
||||
DtColor.Rows.Add(RowColor);
|
||||
RowColor = null;
|
||||
RowColor = DtColor.NewRow();
|
||||
RowColor["Color"] = "#8A0CCF";
|
||||
DtColor.Rows.Add(RowColor);
|
||||
RowColor = null;
|
||||
RowColor = DtColor.NewRow();
|
||||
RowColor["Color"] = "#CD0D74";
|
||||
DtColor.Rows.Add(RowColor);
|
||||
RowColor = null;
|
||||
RowColor = DtColor.NewRow();
|
||||
RowColor["Color"] = "#754DEB";
|
||||
DtColor.Rows.Add(RowColor);
|
||||
RowColor = null;
|
||||
RowColor = DtColor.NewRow();
|
||||
RowColor["Color"] = "#DDDDDD";
|
||||
DtColor.Rows.Add(RowColor);
|
||||
RowColor = null;
|
||||
RowColor = DtColor.NewRow();
|
||||
RowColor["Color"] = "#999999";
|
||||
DtColor.Rows.Add(RowColor);
|
||||
RowColor = null;
|
||||
RowColor = DtColor.NewRow();
|
||||
RowColor["Color"] = "#333333";
|
||||
DtColor.Rows.Add(RowColor);
|
||||
RowColor = null;
|
||||
RowColor = DtColor.NewRow();
|
||||
RowColor["Color"] = "#000000";
|
||||
DtColor.Rows.Add(RowColor);
|
||||
}
|
||||
|
||||
protected void LnkVerGrafica_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (DtDatos != null)
|
||||
{
|
||||
if (DtDatos.Rows.Count < 1)
|
||||
{
|
||||
Alert("No hay datos disponibles", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
||||
return;
|
||||
}
|
||||
LblTituloGrafica.Text = $"Agrupado por: {Agrupador}";
|
||||
RegistraScript("$('#DivModalGrafica').modal('show')");
|
||||
CambioGrafica();
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert("No hay datos disponibles", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
||||
}
|
||||
}
|
||||
|
||||
protected void DdlGrafica_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
CambioGrafica();
|
||||
}
|
||||
|
||||
private void CambioGrafica()
|
||||
{
|
||||
DataTable Dt = new DataTable();
|
||||
Dt.Columns.Add("Texto");
|
||||
Dt.Columns.Add("Valor");
|
||||
Dt.Columns.Add("Color");
|
||||
|
||||
int RowColorIndex = 0;
|
||||
foreach (DataRow Dr in DtDatos.Rows)
|
||||
{
|
||||
DataRow Row = Dt.NewRow();
|
||||
Row["Texto"] = $"{Dr["Grupo1"].ToString()}";
|
||||
Row["Valor"] = Dr["TOTAL"].ToString().FormatoNumero();
|
||||
Row["Color"] = DtColor.Rows[RowColorIndex]["Color"].ToString();
|
||||
Dt.Rows.Add(Row);
|
||||
RowColorIndex++;
|
||||
if (RowColorIndex == 17) { RowColorIndex = 0; }
|
||||
}
|
||||
|
||||
var query = from s in Dt.AsEnumerable()
|
||||
select new
|
||||
{
|
||||
Texto = s["Texto"].ToString(),
|
||||
Valor = s["Valor"].ToString().ToDouble(),
|
||||
Color = s["Color"].ToString()
|
||||
};
|
||||
var json = Newtonsoft.Json.JsonConvert.SerializeObject(query);
|
||||
switch (DdlGrafica.SelectedValue.ToEntero())
|
||||
{
|
||||
case 1:
|
||||
RegistraScript($"CargaGraficaBarras({json})", "22");
|
||||
break;
|
||||
case 2:
|
||||
RegistraScript($"CargaGraficaPastel({json})", "22");
|
||||
break;
|
||||
}
|
||||
UPModalProd.Update();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user