Commit inicial Ventas Productivo
This commit is contained in:
233
Inventarios/RepConsumoInterno.aspx.cs
Normal file
233
Inventarios/RepConsumoInterno.aspx.cs
Normal file
@@ -0,0 +1,233 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
using Extensiones;
|
||||
using System.Data;
|
||||
using Microsoft.Reporting.WebForms;
|
||||
using System.IO;
|
||||
|
||||
public partial class Inventarios_RepConsumoInterno : ClsPaginas
|
||||
{
|
||||
#region PROPIEDADES
|
||||
private DataTable DTDatos
|
||||
{
|
||||
get
|
||||
{
|
||||
return (DataTable)ViewState["DTDatos"];
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
ViewState["DTDatos"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
CargaFiltros();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#region CARGA DATOS
|
||||
protected void BtnConsultar_Click(object sender, EventArgs e)
|
||||
{
|
||||
CargaDatos();
|
||||
}
|
||||
|
||||
protected void CargaDatos()
|
||||
{
|
||||
ClsInventarios ObjGeneral = new ClsInventarios();
|
||||
|
||||
int CveEmpresa = UsuarioActual.CveEmpresa;
|
||||
int CveAlmacen = DdlAlmacen.SelectedValue.ToEntero();
|
||||
int CvePersonal = DdlPersonal.SelectedValue.ToEntero();
|
||||
int CveAF = DdlAF.SelectedValue.ToEntero();
|
||||
int CvePS = DdlPS.SelectedValue.ToEntero();
|
||||
|
||||
String FechaInicio = TxtFechaI.Text == "" ? "-1" : TxtFechaI.Text;
|
||||
String FechaFin = TxtFechaF.Text == "" ? "-1" : TxtFechaF.Text;
|
||||
|
||||
if (ObjGeneral.GetConsumoInterno(CveEmpresa, CveAlmacen, CvePersonal, CveAF, CvePS, FechaInicio, FechaFin))
|
||||
{
|
||||
DTDatos = ObjGeneral.DtResultados;
|
||||
GVDatos.DataSource = DTDatos;
|
||||
}
|
||||
ObjGeneral.Dispose();
|
||||
bool TienePermisoImportes = UsuarioActual.TienePermisoProceso(201);
|
||||
GVDatos.Columns[8].Visible = TienePermisoImportes; // costo
|
||||
|
||||
GVDatos.DataBind();
|
||||
|
||||
UPDatos.Update();
|
||||
}
|
||||
|
||||
protected void DdlClasificacion_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
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, DdlClasificacion.SelectedValue.ToEntero());
|
||||
DdlPS.ddl.DataBind();
|
||||
DdlPS.ddl.Items.Insert(0, new ListItem("Seleccione el Producto", "-1"));
|
||||
}
|
||||
}
|
||||
|
||||
protected void GVDatos_RowDataBound(object sender, GridViewRowEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region INICIALIZA FILTROS
|
||||
|
||||
protected void CargaFiltros()
|
||||
{
|
||||
CargaAlmacen();
|
||||
CargaFechas();
|
||||
CargaPersonal();
|
||||
CargaProductos();
|
||||
CargaAF();
|
||||
}
|
||||
|
||||
protected void CargaAlmacen()
|
||||
{
|
||||
//Carga Almacen
|
||||
DdlAlmacen.DataSource = get_GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1);//.FiltraParametros("CveTipoAlmacen NOT IN (9,11)");
|
||||
DdlAlmacen.Items.Insert(0, new ListItem("Todos", "-1"));
|
||||
DdlAlmacen.SelectedValue = "-1";
|
||||
DdlAlmacen.DataBind();
|
||||
}
|
||||
|
||||
protected void CargaPersonal()
|
||||
{
|
||||
//Carga Personal
|
||||
|
||||
DdlPersonal.DataSource = get_GlobalDTRHPersonal(UsuarioActual.CveEmpresa);
|
||||
DdlPersonal.Items.Insert(0, new ListItem("Todos", "-1"));
|
||||
DdlPersonal.SelectedValue = "-1";
|
||||
DdlPersonal.DataBind();
|
||||
}
|
||||
|
||||
protected void CargaProductos()
|
||||
{
|
||||
//Carga Clasificaciones PS
|
||||
DdlClasificacion.DataSource = get_GlobalDTClasificaciones(UsuarioActual.CveEmpresa);
|
||||
DdlClasificacion.DataBind();
|
||||
|
||||
// Carga PS
|
||||
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"));
|
||||
}
|
||||
}
|
||||
|
||||
protected void CargaAF()
|
||||
{
|
||||
// Carga AF
|
||||
DdlAF.DataSource = get_GlobalDTActivoFijos(UsuarioActual.CveEmpresa);
|
||||
DdlAF.Items.Insert(0, new ListItem("Todos", "-1"));
|
||||
DdlAF.SelectedValue = "-1";
|
||||
DdlAF.DataBind();
|
||||
}
|
||||
|
||||
protected void CargaFechas()
|
||||
{
|
||||
TxtFechaI.Text = DateTime.Now.AddDays(-30).ToShortDateString();
|
||||
TxtFechaF.Text = DateTime.Now.ToShortDateString();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IMPRESION REPORTE
|
||||
|
||||
protected void ImprimiReporte(string Formato = "PDF")
|
||||
{
|
||||
string Almacen = DdlAlmacen.SelectedItem.Text;
|
||||
string Clasificacion = DdlClasificacion.SelectedItem.Text;
|
||||
string PS = DdlPS.SelectedText == "" ? "Todos" : DdlPS.SelectedText;
|
||||
|
||||
string Personal = DdlPersonal.SelectedItem.Text;
|
||||
string AF = DdlAF.SelectedItem.Text;
|
||||
|
||||
string FechaInicio = DateTime.Parse(TxtFechaI.Text).ToShortDateString();
|
||||
string FechaFin = DateTime.Parse(TxtFechaF.Text).ToShortDateString();
|
||||
|
||||
|
||||
string Ruta = string.Format("{0}Empresas/{1}/", AppDomain.CurrentDomain.BaseDirectory, UsuarioActual.CveEmpresa);
|
||||
string RutaPDF = string.Format("{0}/Formatos/RepConsumoInterno.rdlc", Ruta);
|
||||
|
||||
if (!File.Exists(RutaPDF))
|
||||
{
|
||||
RutaPDF = "Empresas/Grales/Formatos/RepConsumoInterno.rdlc";
|
||||
}
|
||||
|
||||
var logouri = string.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa);
|
||||
System.IO.FileInfo Imagen = new System.IO.FileInfo(string.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta));
|
||||
|
||||
List<ReportParameter> @params = new List<ReportParameter>();
|
||||
|
||||
@params.Add(new ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa));
|
||||
|
||||
@params.Add(new ReportParameter("FechaInicio", FechaInicio));
|
||||
@params.Add(new ReportParameter("FechaFin", FechaFin));
|
||||
|
||||
@params.Add(new ReportParameter("UsuarioImprimio", UsuarioActual.Nombre));
|
||||
|
||||
@params.Add(new ReportParameter("Almacen", Almacen));
|
||||
@params.Add(new ReportParameter("Clasificacion", Clasificacion));
|
||||
@params.Add(new ReportParameter("PS", PS));
|
||||
@params.Add(new ReportParameter("Personal", Personal));
|
||||
@params.Add(new ReportParameter("AF", AF));
|
||||
|
||||
@params.Add(new ReportParameter("FechaImpresion", DateTime.Now.ToShortDateString()));
|
||||
|
||||
if (Imagen.Exists)
|
||||
{
|
||||
@params.Add(new ReportParameter("LogoPath", logouri));
|
||||
}
|
||||
else
|
||||
{
|
||||
@params.Add(new ReportParameter("LogoPath", ""));
|
||||
}
|
||||
|
||||
ImprimirPDF(RutaPDF, DTDatos, @params, "RepConsumoInterno " + DateTime.Now.ToString("yyyyMMddhhmmss"), Formato);
|
||||
}
|
||||
|
||||
protected void LnkImprimirPDF_Click(object sender, EventArgs e)
|
||||
{
|
||||
ImprimiReporte();
|
||||
}
|
||||
|
||||
protected void LnkImprimirExcel_Click(object sender, EventArgs e)
|
||||
{
|
||||
ImprimiReporte("Excel");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user