208 lines
9.5 KiB
C#
208 lines
9.5 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_RepEmpaque : ClsPaginas
|
|
{
|
|
|
|
#region PROPIEDADES
|
|
private DataTable DtDatos
|
|
{
|
|
get { return DtDatos = (DataTable)ViewState["DtDatos"]; }
|
|
set { ViewState["DtDatos"] = value; }
|
|
}
|
|
private int CveHuerta
|
|
{
|
|
get { return (ViewState["CveHuerta"] == null) ? 0 : Convert.ToInt32(ViewState["CveHuerta"]); }
|
|
set { ViewState["CveHuerta"] = value; }
|
|
}
|
|
private int Modalidad
|
|
{
|
|
get { return (ViewState["Modalidad"] == null) ? 0 : Convert.ToInt32(ViewState["Modalidad"]); }
|
|
set { ViewState["Modalidad"] = value; }
|
|
}
|
|
|
|
#endregion
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
txtFechaI.Text = DateTime.Now.ToString();
|
|
txtFechaF.Text = DateTime.Now.ToString();
|
|
CveHuerta = Request["CveHuerta"] == null ? 0 : Request["CveHuerta"].ToString().ToEntero();
|
|
Modalidad = Request["Modalidad"] == null ? 0 : Request["Modalidad"].ToString().ToEntero();
|
|
txtFechaI.Text = Request["FechaI"] == null ? DateTime.Now.ToString() : Request["FechaI"].ToString();
|
|
txtFechaF.Text = Request["FechaF"] == null ? DateTime.Now.ToString() : Request["FechaF"].ToString();
|
|
CargaHuerta();
|
|
if (CveHuerta > 0) { DdlHuerta.SelectedValueExist(CveHuerta); }
|
|
if (Modalidad > 0) { DdlModalidad.SelectedValueExist(Modalidad); }
|
|
CambioModalidad();
|
|
Consulta();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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)
|
|
{
|
|
Consulta();
|
|
}
|
|
|
|
private void Consulta()
|
|
{
|
|
String Folio;
|
|
if (TxtFolio.Text != "") { Folio = TxtFolio.Text; } else { Folio = "-1"; }
|
|
ClsCGame ObjCGame = new ClsCGame();
|
|
if (ObjCGame.GetProduccion(UsuarioActual.CveEmpresa, Folio, -1, DdlHuerta.SelectedValue.ToEntero(), txtFechaI.Text.ToDate(), txtFechaF.Text.ToDate(), Opcion: 1, Modalidad: DdlModalidad.SelectedValue.ToEntero()))
|
|
{
|
|
if (DdlModalidad.SelectedValue.ToEntero() == 2) { GvPreEnfriado.DataSource = ObjCGame.DtResultados; } else { GvDatos.DataSource = ObjCGame.DtResultados; }
|
|
DtDatos = ObjCGame.DtResultados;
|
|
ObjCGame.Dispose();
|
|
}
|
|
if (DdlModalidad.SelectedValue.ToEntero() == 2) { GvPreEnfriado.DataBind(); } else { GvDatos.DataBind(); }
|
|
UPDatos.Update();
|
|
UpPreEnfriado.Update();
|
|
}
|
|
|
|
#region GridView
|
|
protected void GvDatos_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
e.Row.Cells[13].Text = (e.Row.DBCampo("Corte").ToDouble() - e.Row.DBCampo("Unidades").ToDouble() - e.Row.DBCampo("Merma").ToDouble()).FormatoNumero();
|
|
e.Row.Cells[14].Text = ((e.Row.Cells[13].Text.ToDouble() * 100) / e.Row.DBCampo("Corte").ToDouble()).FormatoNumero();
|
|
if (e.Row.RowIndex == 0)
|
|
{
|
|
e.Row.Cells[0].Text = "Total";
|
|
e.Row.CssClass = "Totales";
|
|
e.Row.Cells[6].Text = ((e.Row.DBCampo("Primera").ToDouble()*100)/ (e.Row.DBCampo("Unidades").ToDouble() + e.Row.DBCampo("Merma").ToDouble())).FormatoNumero();
|
|
e.Row.Cells[8].Text = ((e.Row.DBCampo("Segunda").ToDouble() * 100) / (e.Row.DBCampo("Unidades").ToDouble() + e.Row.DBCampo("Merma").ToDouble())).FormatoNumero();
|
|
e.Row.Cells[10].Text = ((e.Row.DBCampo("Jugo").ToDouble() * 100) / (e.Row.DBCampo("Unidades").ToDouble() + e.Row.DBCampo("Merma").ToDouble())).FormatoNumero();
|
|
e.Row.Cells[12].Text = ((e.Row.DBCampo("Merma").ToDouble() * 100) / (e.Row.DBCampo("Unidades").ToDouble() + e.Row.DBCampo("Merma").ToDouble())).FormatoNumero();
|
|
}
|
|
else
|
|
{
|
|
String Css = "Texto";
|
|
String Liga = $"/CGame/Empaque.aspx?&CveProduccion={e.Row.DataKey("CveProduccion")}";
|
|
e.Row.FCLabel("LblFolio").Text = "<a class=" + "" + Css + "" + " href=" + "" + Liga + "" + ">" + e.Row.FCLabel("LblFolio").Text + "</a>";
|
|
e.Row.Cells[16].Text = "Ver Resultados";
|
|
String Liga2 = String.Format("/CGame/RepEmpaqueDetalle.aspx?&CveHuerta={0}&Folio={1}&FechaInicial={2}&FechaFinal={3}&CveProduccion={4}", e.Row.DBCampo("CveHuerta"), e.Row.DBCampo("Folio"), e.Row.DBCampo("FechaInicio").ToDate().ToShortDateString(), e.Row.DBCampo("FechaFin").ToDate().ToShortDateString(), e.Row.DBCampo("CveProduccion"));
|
|
e.Row.Cells[16].Text = "<a class=" + "" + Css + "" + " href=" + "" + Liga2 + "" + ">" + e.Row.Cells[16].Text + "</a>";
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
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 (TxtFolio.Text != "") { Folio = $" <b>Folio:</b> {TxtFolio.Text}"; } else { Folio = ""; }
|
|
if (DtDatos.Rows.Count > 0)
|
|
{
|
|
DtDatos.Columns.Add("EnPiso");
|
|
foreach (DataRow Dt in DtDatos.Rows)
|
|
{
|
|
Dt["EnPiso"] = (Dt["Corte"].ToString().ToDouble() - Dt["Unidades"].ToString().ToDouble() - Dt["Merma"].ToString().ToDouble()).FormatoNumero();
|
|
}
|
|
|
|
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 DdlModalidad_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
CambioModalidad();
|
|
}
|
|
|
|
private void CambioModalidad()
|
|
{
|
|
if (DdlModalidad.SelectedValue.ToEntero() == 1)
|
|
{
|
|
DivGvDatos.Visible = true;
|
|
DivGvPreEnfriado.Visible = false;
|
|
LnkPdf.Visible = true;
|
|
}
|
|
else
|
|
{
|
|
DivGvDatos.Visible = false;
|
|
DivGvPreEnfriado.Visible = true;
|
|
LnkPdf.Visible = false;
|
|
}
|
|
UPDatos.Update();
|
|
UpPreEnfriado.Update();
|
|
}
|
|
|
|
protected void GvPreEnfriado_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";
|
|
}
|
|
else
|
|
{
|
|
if (e.Row.DBCampo("CveTipoEtiqueta").ToEntero() == 1)
|
|
{
|
|
e.Row.FCLabel("LblTipoEtiqueta").Text = "Si";
|
|
}
|
|
else
|
|
{
|
|
e.Row.FCLabel("LblTipoEtiqueta").Text = "No";
|
|
}
|
|
|
|
String Css = "Texto";
|
|
e.Row.Cells[12].Text = "Ver Resultados";
|
|
String Liga2 = String.Format("/CGame/RepEmpaqueDetalle.aspx?&CveHuerta={0}&Folio={1}&FechaInicial={2}&FechaFinal={3}", e.Row.DBCampo("CveHuerta"), e.Row.DBCampo("Folio"), e.Row.DBCampo("FechaInicio"), e.Row.DBCampo("FechaFin"));
|
|
e.Row.Cells[12].Text = "<a class=" + "" + Css + "" + " href=" + "" + Liga2 + "" + ">" + e.Row.Cells[12].Text + "</a>";
|
|
}
|
|
|
|
}
|
|
}
|
|
} |