217 lines
9.1 KiB
C#
217 lines
9.1 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 Microsoft.Reporting.WebForms;
|
|
|
|
public partial class Inventarios_RepEntradasSaliidasContrato : ClsPaginas
|
|
{
|
|
#region PROPIEDADES
|
|
private DataTable DtDatos
|
|
{
|
|
get { return DtDatos = (DataTable)ViewState["DtDatos"]; }
|
|
set { ViewState["DtDatos"] = value; }
|
|
}
|
|
|
|
#endregion
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
InicializaValores();
|
|
}
|
|
}
|
|
|
|
private void InicializaValores()
|
|
{
|
|
TxtFechaI.Text = DateTime.Now.AddMonths(-1).ToShortDateString();
|
|
TxtFechaF.Text = DateTime.Now.ToShortDateString();
|
|
|
|
ClsContratos ObjContrato = new ClsContratos();
|
|
if (ObjContrato.GetContratos(-1, UsuarioActual.CveEmpresa))
|
|
{
|
|
DdlContrato.DataSource = ObjContrato.DtResultados;
|
|
}
|
|
ObjContrato.Dispose();
|
|
DdlContrato.DataBind();
|
|
DdlContrato.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
|
|
DdlAlmacen.DataSource = get_GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa,-1);
|
|
DdlAlmacen.DataBind();
|
|
DdlAlmacen.Items.Insert(0, new ListItem("Todos", "-1"));
|
|
|
|
DdlTipoMovimiento.DataSource = GlobalDTInvConceptos;
|
|
DdlTipoMovimiento.DataBind();
|
|
DdlTipoMovimiento.Items.Insert(0, new ListItem("Todos", "-1"));
|
|
|
|
DdlMoneda.DataSource = GlobalDTMonedas;
|
|
DdlMoneda.DataBind();
|
|
DdlMoneda.Items.Insert(0, new ListItem("Todos", "-1"));
|
|
|
|
DdlProveedor.DataSource = get_GlobalDTCompProveedores(UsuarioActual.CveEmpresa);
|
|
DdlProveedor.DataBind();
|
|
DdlProveedor.Items.Insert(0, new ListItem("Todos", "-1"));
|
|
|
|
DdlClasificacion.DataSource = get_GlobalDTClasificaciones(UsuarioActual.CveEmpresa);
|
|
DdlClasificacion.DataBind();
|
|
DdlClasificacion.Items.Insert(0, new ListItem("Todos", "-1"));
|
|
|
|
ClsClasificaciones ObjClasificaciones = new ClsClasificaciones();
|
|
if (ObjClasificaciones.GetClasificacionesExistencias(UsuarioActual.CveEmpresa))
|
|
{
|
|
DdlClasificacion.DataSource = ObjClasificaciones.DtResultados;
|
|
}
|
|
ObjClasificaciones.Dispose();
|
|
DdlClasificacion.DataBind();
|
|
DdlClasificacion.Items.Insert(0, new ListItem("Todos", "-1"));
|
|
|
|
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, CveClasificacion: DdlClasificacion.SelectedValue.ToEntero());
|
|
DdlPS.ddl.DataBind();
|
|
DdlPS.ddl.Items.Insert(0, new ListItem("Seleccione el Producto", "-1"));
|
|
}
|
|
|
|
if (UsuarioActual.Empresa.Funcionalidad(130) == "1")
|
|
{
|
|
DivMarca.Visible = true;
|
|
ClsProductosServicios ObjMarcas = new ClsProductosServicios();
|
|
if (ObjMarcas.GetMarcas(UsuarioActual.CveEmpresa))
|
|
{
|
|
DdlMarca.DataSource = ObjMarcas.DtResultados;
|
|
}
|
|
ObjMarcas.Dispose();
|
|
DdlMarca.DataBind();
|
|
}
|
|
DdlMarca.Items.Insert(0, new ListItem(" Todas ", "-1"));
|
|
}
|
|
|
|
private void CargaDatos()
|
|
{
|
|
DateTime FechaInicial = DateTime.MinValue;
|
|
DateTime FechaFinal = DateTime.MaxValue;
|
|
if (TxtFechaI.Text.Trim() != "" && TxtFechaI.Text != "__/__/____")
|
|
{
|
|
FechaInicial = TxtFechaI.Text.ToDate();
|
|
}
|
|
if (TxtFechaF.Text.Trim() != "" && TxtFechaF.Text != "__/__/____")
|
|
{
|
|
FechaFinal = TxtFechaF.Text.ToDate();
|
|
}
|
|
|
|
ClsInventarios ObjInv = new ClsInventarios();
|
|
if (ObjInv.GetRepEntradasSalidasXContrato(UsuarioActual.CveEmpresa,DdlMoneda.SelectedValue.ToEntero(), FechaInicial,
|
|
FechaFinal, DdlTipoMovimiento.SelectedValue.ToEntero(),DdlProveedor.SelectedValue.ToEntero(),DdlAlmacen.SelectedValue.ToEntero(),
|
|
DdlPS.SelectedValue.ToEntero(),DdlClasificacion.SelectedValue.ToEntero(), DdlMovs.SelectedValue.ToEntero(),DdlMarca.SelectedValue.ToEntero(),
|
|
DdlContrato.SelectedValue.ToEntero()))
|
|
{
|
|
GvM.DataSource = ObjInv.DtResultados;
|
|
DtDatos= ObjInv.DtResultados;
|
|
}
|
|
ObjInv.Dispose();
|
|
GvM.DataBind();
|
|
UpMov.Update();
|
|
}
|
|
|
|
protected void btConsultar_Click(object sender, EventArgs e)
|
|
{
|
|
CargaDatos();
|
|
}
|
|
|
|
protected void GvM_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
if (e.Row.DBCampo("CvePS").ToEntero() <= 0)
|
|
{
|
|
e.Row.CssClass = "Totales";
|
|
}
|
|
else
|
|
{
|
|
e.Row.Cells[5].BackColor = System.Drawing.Color.LightGray;
|
|
e.Row.Cells[9].BackColor = System.Drawing.Color.LightGray;
|
|
if (e.Row.DBCampo("SaldoIniCant").ToDouble() <= 0) { e.Row.Cells[2].Text = "-"; }
|
|
if (e.Row.DBCampo("EntradaCant").ToDouble() <= 0) { e.Row.Cells[3].Text = "-"; }
|
|
if (e.Row.DBCampo("SalidaCant").ToDouble() <= 0) { e.Row.Cells[4].Text = "-"; }
|
|
if (e.Row.DBCampo("SaldoFCant").ToDouble() <= 0) { e.Row.Cells[5].Text = "-"; }
|
|
if (e.Row.DBCampo("SaldoIniImp").ToDouble() <= 0) { e.Row.Cells[6].Text = "-"; }
|
|
if (e.Row.DBCampo("EntradaImp").ToDouble() <= 0) { e.Row.Cells[7].Text = "-"; }
|
|
if (e.Row.DBCampo("SalidaImp").ToDouble() <= 0) { e.Row.Cells[8].Text = "-"; }
|
|
if (e.Row.DBCampo("SaldoFImp").ToDouble() <= 0) { e.Row.Cells[9].Text = "-"; }
|
|
if (e.Row.DBCampo("PrecioVenta").ToDouble() <= 0) { e.Row.Cells[10].Text = "-"; }
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
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, CveClasificacion: DdlClasificacion.SelectedValue.ToEntero());
|
|
DdlPS.ddl.DataBind();
|
|
DdlPS.ddl.Items.Insert(0, new ListItem("Seleccione el Producto", "-1"));
|
|
}
|
|
}
|
|
|
|
protected void LnkExcel_Click(object sender, EventArgs e)
|
|
{
|
|
GenerarPDF("EXCEL");
|
|
}
|
|
|
|
protected void LnkPdf_Click(object sender, EventArgs e)
|
|
{
|
|
GenerarPDF("PDF");
|
|
}
|
|
|
|
protected void GenerarPDF(String Opcion)
|
|
{
|
|
String FechaI;
|
|
if (TxtFechaI.Text == "" || TxtFechaI.Text == "__/__/____") { FechaI = ""; } else { FechaI = $" <b>Fecha Inicial:</b> {TxtFechaI.Text}"; }
|
|
String FechaF;
|
|
if (TxtFechaF.Text == "" || TxtFechaF.Text == "__/__/____") { FechaF = ""; } else { FechaF = $" <b>Fecha Final:</b> {TxtFechaF.Text}"; }
|
|
String Contrato;
|
|
if (DdlContrato.SelectedValue != "-1") { Contrato = $" <b>Contrato:</b> {DdlContrato.SelectedItem.Text}"; } else { Contrato = ""; }
|
|
String Almacen;
|
|
if (DdlAlmacen.SelectedValue != "-1") { Almacen = $" <b>Cliente:</b> {DdlAlmacen.SelectedItem.Text}"; } else { Almacen = ""; }
|
|
if (DtDatos.Rows.Count > 0)
|
|
{
|
|
System.IO.FileInfo Imagen = new System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png");
|
|
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("AgrupadoPor", $"<b>Agrupado Por:</b> {Contrato}{Almacen}{FechaI}{FechaF}"));
|
|
if (Imagen.Exists)
|
|
{
|
|
para.Add(new ReportParameter("LogoPath", logouri));
|
|
}
|
|
else
|
|
{
|
|
para.Add(new ReportParameter("LogoPath", ""));
|
|
}
|
|
ImprimirPDF("Empresas/Grales/Formatos/RepEntradasSalidasXContrato.rdlc", DtDatos, para, "Reporte de Entradas y Salidas X Contrato", Opcion);
|
|
}
|
|
else
|
|
{
|
|
Alert("No hay datos consultados", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
}
|
|
}
|
|
} |