135 lines
6.2 KiB
C#
135 lines
6.2 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;
|
|
|
|
public partial class CGame_RepOrdenCorte : 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)
|
|
{
|
|
txtFechaI.Text = DateTime.Now.ToString();
|
|
txtFechaF.Text = DateTime.Now.ToString();
|
|
CargaHuerta();
|
|
DdlHuerta.SelectedValueExist(Request["CveHuerta"] == null ? "-1" : Request["CveHuerta"].ToString());
|
|
txtFechaI.Text = Request["FechaI"] == null ? DateTime.Now.ToString() : Request["FechaI"].ToString();
|
|
txtFechaF.Text = Request["FechaF"] == null ? DateTime.Now.ToString() : Request["FechaF"].ToString();
|
|
if (DdlHuerta.SelectedValue.ToEntero() > 0) { Consultar(); }
|
|
}
|
|
}
|
|
|
|
protected void CargaHuerta()
|
|
{
|
|
ClsCGame ObjCort = new ClsCGame();
|
|
if (ObjCort.GetHuerta(UsuarioActual.CveEmpresa))
|
|
{
|
|
DdlHuerta.DataSource = ObjCort.DtResultados;
|
|
DdlHuerta.Items.Insert(0, new ListItem("Todos", "-1"));
|
|
DdlHuerta.DataBind();
|
|
}
|
|
ObjCort.Dispose();
|
|
UPDatos.Update();
|
|
}
|
|
|
|
protected void Consultar_Click(object sender, EventArgs e)
|
|
{
|
|
Consultar();
|
|
}
|
|
|
|
private void Consultar()
|
|
{
|
|
String FolioOC, FechaI, FechaF;
|
|
if (TxtFolioOC.Text != "") { FolioOC = TxtFolioOC.Text; } else { FolioOC = "-1"; }
|
|
if (TxtFolioOC.Text != "") { FechaI = MinFecha.ToShortDateString(); FechaF = MaxFecha.ToShortDateString(); } else { FechaI = txtFechaI.Text; FechaF = txtFechaF.Text; }
|
|
ClsCGame ObjCGame = new ClsCGame();
|
|
if (ObjCGame.GetOrdenCorte(UsuarioActual.CveEmpresa, -1, DdlHuerta.SelectedValue.ToEntero(), FolioOC, FechaI.ToDate(), FechaF.ToDate(), Opcion: 3))
|
|
{
|
|
GvDatos.DataSource = ObjCGame.DtResultados;
|
|
GvDatos.DataBind();
|
|
DtDatos = ObjCGame.DtResultados;
|
|
}
|
|
ObjCGame.Dispose();
|
|
UPDatos.Update();
|
|
}
|
|
|
|
protected void GenerarPDF(String Opcion)
|
|
{
|
|
String FechaF;
|
|
if (txtFechaF.Text == "" || txtFechaF.Text == "__/__/____") { FechaF = "-1"; } else { FechaF = $" <b>Fecha Entrega Final:</b> {txtFechaF.Text}"; }
|
|
String FechaI;
|
|
if (txtFechaI.Text == "" || txtFechaI.Text == "__/__/____") { FechaI = "-1"; } else { FechaI = $" <b>Fecha Entrega Inicial:</b> {txtFechaI.Text}"; }
|
|
String Huerta;
|
|
if (DdlHuerta.SelectedValue != "-1") { Huerta = $" <b>Huerta:</b> {DdlHuerta.SelectedItem.Text}"; } else { Huerta = ""; }
|
|
String Folio;
|
|
if (TxtFolioOC.Text != "") { Folio = $" <b>Folio:</b> {TxtFolioOC.Text}"; } else { Folio = ""; }
|
|
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> {Folio}{Huerta}{FechaI}{FechaF}"));
|
|
if (Imagen.Exists)
|
|
{
|
|
para.Add(new ReportParameter("LogoPath", logouri));
|
|
}
|
|
else
|
|
{
|
|
para.Add(new ReportParameter("LogoPath", ""));
|
|
}
|
|
ImprimirPDF("Empresas/Grales/Formatos/RepEmpaque.rdlc", DtDatos, para, "Reporte de Empaque", Opcion);
|
|
}
|
|
else
|
|
{
|
|
Alert("No hay datos consultados", TipoMensaje.MsgAdvertencia);
|
|
}
|
|
}
|
|
|
|
|
|
protected void LnkPdf_Click(object sender, EventArgs e)
|
|
{
|
|
GenerarPDF("PDF");
|
|
}
|
|
|
|
protected void ImgExcel_Click(object sender, EventArgs e)
|
|
{
|
|
GenerarPDF("EXCEL");
|
|
}
|
|
|
|
protected void GvDatos_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
|
|
if (e.Row.RowIndex == 0)
|
|
{
|
|
e.Row.Cells[0].Text = "Total";
|
|
e.Row.CssClass = "Totales";
|
|
e.Row.Cells[3].Text = ((e.Row.Cells[2].Text.ToDouble() * 100)/ e.Row.DBCampo("PesoCompleto").ToDouble()).FormatoNumero();
|
|
e.Row.Cells[5].Text = ((e.Row.Cells[4].Text.ToDouble() * 100) / e.Row.DBCampo("PesoCompleto").ToDouble()).FormatoNumero();
|
|
e.Row.Cells[7].Text = ((e.Row.Cells[6].Text.ToDouble() * 100) / e.Row.DBCampo("PesoCompleto").ToDouble()).FormatoNumero();
|
|
e.Row.Cells[9].Text = (( e.Row.DBCampo("PesoCompleto").ToDouble() - e.Row.Cells[2].Text.ToDouble()- e.Row.Cells[4].Text.ToDouble() - e.Row.Cells[6].Text.ToDouble()) * 100/ e.Row.DBCampo("PesoCompleto").ToDouble()).FormatoNumero();
|
|
}
|
|
else
|
|
{
|
|
String Css = "Texto";
|
|
String Liga = $"/CGame/RepOrdenCorteDetalle.aspx?&CveOrdenCorte={e.Row.DataKey("CveOrdenCorte")}";
|
|
e.Row.FCLabel("LblFolioOC").Text = "<a class=" + "" + Css + "" + " href=" + "" + Liga + "" + ">" + e.Row.FCLabel("LblFolioOC").Text + "</a>";
|
|
|
|
//String Css2 = "Texto";
|
|
//String Liga2 = $"/CGame/OrdenProduccion.aspx?&CveOrdenProduccion={e.Row.DataKey("CveOrdenProduccion")}";
|
|
//e.Row.FCLabel("LblFolioOP").Text = "<a class=" + "" + Css2 + "" + " href=" + "" + Liga2 + "" + ">" + e.Row.FCLabel("LblFolioOP").Text + "</a>";
|
|
}
|
|
}
|
|
}
|
|
} |