Files
SIG/Nomina/Nomina2.aspx.cs
JORGE LUIS CAUDILLO ESPARZA c8c12f862e
2020-10-15 07:13:28 -07:00

4193 lines
218 KiB
C#

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 System.Text;
using static Extensiones.ModExtensiones;
using System.Drawing;
public partial class Nomina_Nomina2 : ClsPaginas
{
#region Propiedades
private DataTable dtPeriodos
{
get
{
if (ViewState["dtPeriodos"] == null) { return null; }
else { return (DataTable)ViewState["dtPeriodos"]; }
}
set { ViewState["dtPeriodos"] = value; }
}
private DataTable dtConceptos
{
get
{
if (ViewState["dtConceptos"] == null) { return null; }
else { return (DataTable)ViewState["dtConceptos"]; }
}
set { ViewState["dtConceptos"] = value; }
}
private DataTable dtempleadosConceptos
{
get
{
if (ViewState["dtempleadosConceptos"] == null) { return null; }
else { return (DataTable)ViewState["dtempleadosConceptos"]; }
}
set { ViewState["dtempleadosConceptos"] = value; }
}
private DataTable dtempleados
{
get
{
if (ViewState["dtempleados"] == null) { return null; }
else { return (DataTable)ViewState["dtempleados"]; }
}
set { ViewState["dtempleados"] = value; }
}
private DataTable DtSuaProcesado
{
get
{
if (ViewState["dtempleados"] == null) { return null; }
else { return (DataTable)ViewState["dtempleados"]; }
}
set { ViewState["dtempleados"] = value; }
}
protected bool PermisoCancelarEmitido
{
get
{
if (ViewState["PermisoCancelarEmitido"] == null) { return false; }
else { return (bool)ViewState["PermisoCancelarEmitido"]; }
}
set { ViewState["PermisoCancelarEmitido"] = value; }
}
protected bool PermisoAutorizar
{
get
{
if (ViewState["PermisoAutorizar"] == null) { return false; }
else { return (bool)ViewState["PermisoAutorizar"]; }
}
set { ViewState["PermisoAutorizar"] = value; }
}
protected bool PermisoEmitir
{
get
{
if (ViewState["PermisoEmitir"] == null) { return false; }
else { return (bool)ViewState["PermisoEmitir"]; }
}
set { ViewState["PermisoEmitir"] = value; }
}
protected int CvePeriodoSeleccionado
{
get
{
if (ViewState["CvePeriodoSeleccionado"] == null) { return 0; }
else { return ViewState["CvePeriodoSeleccionado"].ToString().ToEntero(); }
}
set { ViewState["CvePeriodoSeleccionado"] = value; }
}
protected int CcveMovtoPermanente
{
get
{
if (ViewState["CcveMovtoPermanente"] == null) { return 0; }
else { return ViewState["CcveMovtoPermanente"].ToString().ToEntero(); }
}
set { ViewState["CcveMovtoPermanente"] = value; }
}
protected int FiltCveProyecto
{
get
{
if (ViewState["FiltCveProyecto"] == null) { return 0; }
else { return ViewState["FiltCveProyecto"].ToString().ToEntero(); }
}
set { ViewState["FiltCveProyecto"] = value; }
}
protected int FiltCveSubProyecto
{
get
{
if (ViewState["FiltCveSubProyecto"] == null) { return 0; }
else { return ViewState["FiltCveSubProyecto"].ToString().ToEntero(); }
}
set { ViewState["FiltCveSubProyecto"] = value; }
}
protected int FiltCveTurno
{
get
{
if (ViewState["FiltCveTurno"] == null) { return 0; }
else { return ViewState["FiltCveTurno"].ToString().ToEntero(); }
}
set { ViewState["FiltCveTurno"] = value; }
}
protected int FiltCvePeriodo
{
get
{
if (ViewState["FiltCvePeriodo"] == null) { return 0; }
else { return ViewState["FiltCvePeriodo"].ToString().ToEntero(); }
}
set { ViewState["FiltCvePeriodo"] = value; }
}
protected int FiltAgrupador
{
get
{
if (ViewState["FiltAgrupador"] == null) { return 0; }
else { return ViewState["FiltAgrupador"].ToString().ToEntero(); }
}
set { ViewState["FiltAgrupador"] = value; }
}
#endregion
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
cargaEjercicios();
CargaTiposPeriodo();
cargaPeriodos();
//Permisos
if (UsuarioActual.TienePermisoProceso(82))
{
PermisoAutorizar = true;
}
else
{
PermisoAutorizar = false;
}
if (UsuarioActual.TienePermisoProceso(83))
{
PermisoEmitir = true;
PermisoCancelarEmitido = true;
}
else
{
PermisoEmitir = false;
PermisoCancelarEmitido = false;
}
}
}
#region Filtros
private void cargaEjercicios()
{
int EjercicioActual = UsuarioActual.Empresa.EjercicioActual;
if (EjercicioActual == 0)
{
EjercicioActual = DateTime.Now.Year;
}
DataTable dtejercicio = null;
using (ClsNominas objnom = new ClsNominas())
{
if (objnom.GetEjercicios(UsuarioActual.CveEmpresa))
{
dtejercicio = objnom.DtResultados;
}
}
DdlEjercicios.DataSource = dtejercicio;
DdlEjerciciosCM.DataSource = dtejercicio;
DdlEjercicios.DataBind();
DdlEjerciciosCM.DataBind();
ListItem litem = null;
if ((dtejercicio != null) && dtejercicio.Rows.Count > 0)
{
if (dtejercicio.COUNT("Ejercicio", string.Format("Ejercicio={0}", EjercicioActual)) == 0)
{
litem = new ListItem(EjercicioActual.ToString(), EjercicioActual.ToString());
DdlEjercicios.Items.Insert(0, litem);
DdlEjerciciosCM.Items.Insert(0, litem);
}
if (dtejercicio.COUNT("Ejercicio", string.Format("Ejercicio={0}", (EjercicioActual - 1))) == 0)
{
litem = new ListItem((EjercicioActual - 1).ToString(), (EjercicioActual - 1).ToString());
DdlEjercicios.Items.Insert(1, litem);
DdlEjerciciosCM.Items.Insert(1, litem);
}
}
else
{
litem = new ListItem(EjercicioActual.ToString(), EjercicioActual.ToString());
DdlEjercicios.Items.Insert(0, litem);
DdlEjerciciosCM.Items.Insert(0, litem);
litem = new ListItem((EjercicioActual - 1).ToString(), (EjercicioActual - 1).ToString());
DdlEjercicios.Items.Insert(0, litem);
DdlEjerciciosCM.Items.Insert(0, litem);
}
if (DdlEjercicios.Items.Count > 0)
{
DdlEjercicios.SelectedIndex = 0;
}
}
private void CargaTiposPeriodo()
{
DdlTipoPeriodo.DataSource = GlobalDTTipoPeriodo.FiltraParametros("Estatus = 'Activo'");
DdlTipoPeriodoCM.DataSource = DdlTipoPeriodo.DataSource;
DdlTipoPeriodoSim.DataSource = DdlTipoPeriodo.DataSource;
DdlTipoPeriodoSim.DataBind();
DdlTipoPeriodoCM.DataBind();
DdlTipoPeriodo.DataBind();
DdlTipoPeriodo.Items.Insert(0, new ListItem("Seleccione", "-1"));
if (DdlTipoPeriodo.Items.Count > 0)
{
DdlTipoPeriodo.SelectedIndex = 0;
}
}
private void cargaPeriodos()
{
int tipoPeriodo = DdlTipoPeriodo.SelectedValue.ToEntero();
int ejercicio = DdlEjercicios.SelectedValue.ToEntero();
dtPeriodos = null;
if (DdlTipoPeriodo.SelectedValue.ToEntero() > 0)
{
using (ClsNominas objperiodos = new ClsNominas())
{
if (objperiodos.GetPeriodos(tipoPeriodo, UsuarioActual.CveEmpresa, ejercicio, -1, -1))
{
dtPeriodos = objperiodos.DtResultados.FiltraParametros("Estatus IN (1,2,3,4,5)");
}
}
}
DdlPeriodo.DataSource = dtPeriodos;
DdlPeriodo.DataBind();
DdlPeriodo.Items.Insert(0, new ListItem("Seleccione", "-1"));
muestraPeriodo();
}
protected void DdlEjercicios_SelectedIndexChanged(object sender, EventArgs e)
{
cargaPeriodos();
}
protected void DdlTipoPeriodo_SelectedIndexChanged(object sender, EventArgs e)
{
cargaPeriodos();
}
protected void DdlPeriodo_SelectedIndexChanged(object sender, EventArgs e)
{
muestraPeriodo();
}
private void muestraPeriodo()
{
int CvePeriodo = DdlPeriodo.SelectedValue.ToEntero();
LnkConsultar.Visible = (CvePeriodo > 0);
UPFiltros.Update();
UpDatos.Update();
}
#endregion
#region Datos
protected void LnkConsultar_Click(object sender, EventArgs e)
{
FiltCveProyecto = DdlProyecto.SelectedValue.ToEntero();
FiltCveSubProyecto = DdlSubProyecto.SelectedValue.ToEntero();
FiltCveTurno = DdlTurno.SelectedValue.ToEntero();
FiltCvePeriodo = DdlPeriodo.SelectedValue.ToEntero();
FiltAgrupador = DdlAgrupador.SelectedValue.ToEntero();
cargaDatos();
}
public void cargaDatos()
{
int CveEmpresa = UsuarioActual.CveEmpresa;
bool continuar = false;
CvePeriodoSeleccionado = 0;
dtempleados = null;
dtConceptos = null;
DataTable dtPeriodo = new DataTable();
DataTable dtasistencia = new DataTable();
if (FiltCvePeriodo > 0)
{
using (ClsNominas objnom = new ClsNominas())
{
if (objnom.GetNominaEmpleado(FiltCveProyecto, FiltCveSubProyecto, FiltCveTurno, FiltCvePeriodo, CveEmpresa, FiltAgrupador) && objnom.DTSetResultados.Tables.Count > 1)
{
dtempleados = objnom.DTSetResultados.Tables[3];
dtempleadosConceptos = objnom.DTSetResultados.Tables[4];
dtConceptos = objnom.DTSetResultados.Tables[0];
dtPeriodo = objnom.DTSetResultados.Tables[1];
dtasistencia = objnom.DTSetResultados.Tables[2];
CvePeriodoSeleccionado = FiltCvePeriodo;
continuar = true;
}
}
}
#region CargaGrid
if (continuar)
{
string ctipo = "P";
/*
while (GvNominas.Columns.Count > 3)
{
GvNominas.Columns.RemoveAt(2);
//GvNominas.Columns.sa();
}*/
int CurrentColumn = 2;
BoundField bf;
foreach (DataRow row in dtConceptos.FiltraParametros("Tipo IN ('P') AND EsPadre = 1 ").Rows)
{
int CveConcepto = row["CveConcepto"].ToString().ToEntero();
int SoloVisible = row["SoloVisible"].ToString().ToEntero();
string Concepto = row["Concepto"].ToString();
GvNominas.Columns[CurrentColumn].ItemStyle.BackColor = System.Drawing.Color.Transparent;
GvNominas.Columns[CurrentColumn].ItemStyle.CssClass = " ";
GvNominas.Columns[CurrentColumn].HeaderStyle.CssClass = " ";
if (SoloVisible == 1)
{
GvNominas.Columns[CurrentColumn].HeaderStyle.CssClass = "isOnlyVisible ";
}
GvNominas.Columns[CurrentColumn].Visible = (dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) != 0);
bf = (BoundField)GvNominas.Columns[CurrentColumn];
bf.DataField = string.Format("V_{0}", CveConcepto);
bf.HeaderText = Concepto;
if (GvNominas.Columns[CurrentColumn].Visible)
{
CurrentColumn++;
}
}
if (true)
{
BoundField field = (BoundField)GvNominas.Columns[CurrentColumn];
field.HeaderText = "Percepciones";
field.DataField = "SumaPercepciones";
field.ItemStyle.BackColor = System.Drawing.Color.LightGray;
GvNominas.Columns[CurrentColumn].Visible = true;
CurrentColumn++;
}
foreach (DataRow row in dtConceptos.FiltraParametros("Tipo IN ('D') AND EsPadre = 1 ").Rows)
{
int CveConcepto = row["CveConcepto"].ToString().ToEntero();
int SoloVisible = row["SoloVisible"].ToString().ToEntero();
string Concepto = row["Concepto"].ToString();
GvNominas.Columns[CurrentColumn].ItemStyle.BackColor = System.Drawing.Color.Transparent;
GvNominas.Columns[CurrentColumn].ItemStyle.CssClass = " ";
GvNominas.Columns[CurrentColumn].HeaderStyle.CssClass = " ";
if (SoloVisible == 1)
{
GvNominas.Columns[CurrentColumn].HeaderStyle.CssClass = "isOnlyVisible ";
}
GvNominas.Columns[CurrentColumn].Visible = (dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) != 0);
bf = (BoundField)GvNominas.Columns[CurrentColumn];
bf.DataField = string.Format("V_{0}", CveConcepto);
bf.HeaderText = Concepto;
if (GvNominas.Columns[CurrentColumn].Visible)
{
CurrentColumn++;
}
}
if (true)
{
BoundField field = (BoundField)GvNominas.Columns[CurrentColumn];
field.HeaderText = "Deducciones";
field.DataField = "SumaDeducciones";
field.ItemStyle.BackColor = System.Drawing.Color.LightGray;
GvNominas.Columns[CurrentColumn].ItemStyle.CssClass = " ";
GvNominas.Columns[CurrentColumn].HeaderStyle.CssClass = " ";
GvNominas.Columns[CurrentColumn].Visible = true;
CurrentColumn++;
field = (BoundField)GvNominas.Columns[CurrentColumn];
field.HeaderText = "Total";
field.DataField = "Total";
field.ItemStyle.BackColor = System.Drawing.Color.DarkGray;
field.ItemStyle.CssClass = "TotalWhite";
field.HeaderStyle.CssClass = "TotalWhite";
GvNominas.Columns[CurrentColumn].Visible = true;
CurrentColumn++;
}
foreach (DataRow row in dtConceptos.FiltraParametros("Tipo IN ('O') AND EsPadre = 1 ").Rows)
{
int CveConcepto = row["CveConcepto"].ToString().ToEntero();
int SoloVisible = row["SoloVisible"].ToString().ToEntero();
string Concepto = row["Concepto"].ToString();
GvNominas.Columns[CurrentColumn].ItemStyle.BackColor = System.Drawing.Color.Transparent;
GvNominas.Columns[CurrentColumn].ItemStyle.CssClass = " ";
GvNominas.Columns[CurrentColumn].HeaderStyle.CssClass = " ";
if (SoloVisible == 1)
{
GvNominas.Columns[CurrentColumn].HeaderStyle.CssClass = "isOnlyVisible ";
}
GvNominas.Columns[CurrentColumn].Visible = (dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) != 0);
bf = (BoundField)GvNominas.Columns[CurrentColumn];
bf.DataField = string.Format("V_{0}", CveConcepto);
bf.HeaderText = Concepto;
if (GvNominas.Columns[CurrentColumn].Visible)
{
CurrentColumn++;
}
}
if (true)
{
BoundField field = (BoundField)GvNominas.Columns[CurrentColumn];
field.HeaderText = "Obligaciones";
field.DataField = "SumaObligaciones";
field.ItemStyle.BackColor = System.Drawing.Color.LightGray;
GvNominas.Columns[CurrentColumn].ItemStyle.CssClass = " ";
GvNominas.Columns[CurrentColumn].HeaderStyle.CssClass = " ";
GvNominas.Columns[CurrentColumn].Visible = true;
CurrentColumn++;
}
for (int i = CurrentColumn; i < 102; i++)
{
bf = (BoundField)GvNominas.Columns[i];
bf.DataField = "";
bf.HeaderText = "";
GvNominas.Columns[i].ItemStyle.BackColor = System.Drawing.Color.Transparent;
GvNominas.Columns[CurrentColumn].ItemStyle.CssClass = " ";
GvNominas.Columns[CurrentColumn].HeaderStyle.CssClass = " ";
GvNominas.Columns[i].Visible = false;
}
bool tr = false;
if (tr)
{
bool sumaPercepciones = false;
bool sumaDeducciones = false;
if (GvNominas.Columns.Count > 3)
{
foreach (DataRow row in dtConceptos.FiltraParametros("Tipo IN ('P','D','O') AND EsPadre = 1 ").Rows)
{
int CveConcepto = row["CveConcepto"].ToString().ToEntero();
string Concepto = row["Concepto"].ToString();
string Tipo = row["Tipo"].ToString();
if (Tipo != ctipo)
{
if (ctipo == "P")
{
CurrentColumn++;
if (Tipo != "D")
{
CurrentColumn++;
CurrentColumn++;
}
}
else if (ctipo == "D")
{
CurrentColumn++;
CurrentColumn++;
}
ctipo = Tipo;
}
CurrentColumn++;
}
}
else
{
foreach (DataRow row in dtConceptos.FiltraParametros("Tipo IN ('P','D','O') AND EsPadre = 1 ").Rows)
{
int CveConcepto = row["CveConcepto"].ToString().ToEntero();
string Concepto = row["Concepto"].ToString();
string Tipo = row["Tipo"].ToString();
if (Tipo != ctipo)
{
if (ctipo == "P")
{
BoundField field = new BoundField();
field.HeaderText = "Percepciones";
field.DataField = "SumaPercepciones";
field.DataFormatString = "{0:N2}";
field.ItemStyle.Width = Unit.Pixel(120);
field.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
field.ItemStyle.BackColor = System.Drawing.Color.LightGray;
GvNominas.Columns.Insert(CurrentColumn++, field);
sumaPercepciones = true;
if (Tipo != "D")
{
field = new BoundField();
field.HeaderText = "Deducciones";
field.DataField = "SumaDeducciones";
field.DataFormatString = "{0:N2}";
field.ItemStyle.Width = Unit.Pixel(120);
field.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
field.ItemStyle.BackColor = System.Drawing.Color.LightGray;
field.ItemStyle.CssClass = " ";
field.HeaderStyle.CssClass = " ";
GvNominas.Columns.Insert(CurrentColumn++, field);
field = new BoundField();
field.HeaderText = "Total";
field.DataField = "Total";
field.DataFormatString = "{0:N2}";
field.ItemStyle.Width = Unit.Pixel(120);
field.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
field.ItemStyle.BackColor = System.Drawing.Color.LightGray;
field.ItemStyle.CssClass = " ";
field.HeaderStyle.CssClass = " ";
GvNominas.Columns.Insert(CurrentColumn++, field);
sumaDeducciones = true;
}
}
else if (ctipo == "D")
{
BoundField field = new BoundField();
if (!sumaPercepciones)
{
field.HeaderText = "Percepciones";
field.DataField = "SumaPercepciones";
field.DataFormatString = "{0:N2}";
field.ItemStyle.Width = Unit.Pixel(120);
field.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
field.ItemStyle.BackColor = System.Drawing.Color.LightGray;
field.ItemStyle.CssClass = " ";
field.HeaderStyle.CssClass = " ";
GvNominas.Columns.Insert(CurrentColumn++, field);
field = new BoundField();
sumaPercepciones = true;
}
field.HeaderText = "Deducciones";
field.DataField = "SumaDeducciones";
field.DataFormatString = "{0:N2}";
field.ItemStyle.Width = Unit.Pixel(120);
field.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
field.ItemStyle.BackColor = System.Drawing.Color.LightGray;
field.ItemStyle.CssClass = " ";
field.HeaderStyle.CssClass = " ";
GvNominas.Columns.Insert(CurrentColumn++, field);
field = new BoundField();
field.HeaderText = "Total";
field.DataField = "Total";
field.DataFormatString = "{0:N2}";
field.ItemStyle.Width = Unit.Pixel(120);
field.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
field.ItemStyle.BackColor = System.Drawing.Color.LightGray;
field.ItemStyle.CssClass = "TotalWhite ";
field.HeaderStyle.CssClass = "TotalWhite ";
GvNominas.Columns.Insert(CurrentColumn++, field);
sumaDeducciones = true;
}
ctipo = Tipo;
}
if (true)
{
BoundField field = new BoundField();
field.Visible = (dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) > 0);
field.HeaderText = Concepto;
field.DataField = string.Format("V_{0}", CveConcepto);
field.DataFormatString = "{0:N2}";
field.ItemStyle.Width = Unit.Pixel(80);
GvNominas.Columns.Insert(CurrentColumn++, field);
}
}
if (true)
{
BoundField field = new BoundField();
if (!sumaPercepciones)
{
field.HeaderText = "Percepciones";
field.DataField = "SumaPercepciones";
field.DataFormatString = "{0:N2}";
field.ItemStyle.Width = Unit.Pixel(120);
field.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
field.ItemStyle.BackColor = System.Drawing.Color.LightGray;
field.ItemStyle.CssClass = " ";
field.HeaderStyle.CssClass = " ";
GvNominas.Columns.Insert(CurrentColumn++, field);
field = new BoundField();
sumaPercepciones = true;
}
if (!sumaDeducciones)
{
field.HeaderText = "Deducciones";
field.DataField = "SumaDeducciones";
field.DataFormatString = "{0:N2}";
field.ItemStyle.Width = Unit.Pixel(120);
field.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
field.ItemStyle.BackColor = System.Drawing.Color.LightGray;
field.ItemStyle.CssClass = " ";
field.HeaderStyle.CssClass = " ";
GvNominas.Columns.Insert(CurrentColumn++, field);
field = new BoundField();
field.HeaderText = "Total";
field.DataField = "Total";
field.DataFormatString = "{0:N2}";
field.ItemStyle.Width = Unit.Pixel(120);
field.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
field.ItemStyle.BackColor = System.Drawing.Color.LightGray;
field.ItemStyle.CssClass = " ";
field.HeaderStyle.CssClass = " ";
GvNominas.Columns.Insert(CurrentColumn++, field);
sumaDeducciones = true;
field = new BoundField();
}
field.HeaderText = "Obligaciones";
field.DataField = "SumaObligaciones";
field.DataFormatString = "{0:N2}";
field.ItemStyle.Width = Unit.Pixel(120);
field.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
field.ItemStyle.BackColor = System.Drawing.Color.LightGray;
field.ItemStyle.CssClass = " ";
field.HeaderStyle.CssClass = " ";
GvNominas.Columns.Insert(CurrentColumn++, field);
}
}
}
GvNominas.DataSource = dtempleados;
GvNominas.DataBind();
}
else
{
GvNominas.DataSource = null;
GvNominas.DataBind();
}
if (dtPeriodo != null && dtPeriodo.Rows.Count > 0)
{
DateTime FechaInicio = (DateTime)dtPeriodo.Rows[0]["FechaInicio"];
DateTime FechaFin = (DateTime)dtPeriodo.Rows[0]["FechaFin"];
StringBuilder gvasistencia = new StringBuilder();
gvasistencia.Append("<div><table class=\"table table-striped table-hover mysmallbtn Widthall ScrollAD gvasistencia \" data-rows=\"1\" data-heighterror=\"360\"><tbody>");
if (true)
{
DateTime fecha = FechaInicio;
gvasistencia.Append("<tr class=\"Titulos ADtr\">");
gvasistencia.Append("<th>Nombre</th>");
while (fecha <= FechaFin)
{
gvasistencia.AppendFormat("<th>{0:dd/MM/yyyy}</th>", fecha);
fecha = fecha.AddDays(1);
}
gvasistencia.Append("</tr>");
}
string tipo = "";
foreach (DataRow rempl in dtempleados.FiltraParametros("CvePersonal>0").Rows)
{
int CvePersonal = rempl["CvePersonal"].ToString().ToEntero();
string nombre = rempl["Nombre"].ToString();
string Codigo = rempl["Codigo"].ToString();
DateTime fecha = FechaInicio; int HorasDobles, HorasTriples;
gvasistencia.Append("<tr>");
gvasistencia.AppendFormat("<td><a class=\"Texto sline\" href=\"/RH/Personal.aspx?CvePersonal={0}\">{2}<br/>{1}</a></td>", CvePersonal, nombre, Codigo);
while (fecha <= FechaFin)
{
DataRow drow = dtasistencia.FiltroPrimero(string.Format("Fecha='{0:yyyy/MM/dd}' AND CvePersonal={1}", fecha, CvePersonal));
tipo = "-";
if (drow != null)
{
tipo = string.Format("{0} ({1}%)", drow["Tipo"], drow["PorcentajePago"]);
HorasDobles = drow["HorasDobles"].ToString().ToEntero();
HorasTriples = drow["HorasTriples"].ToString().ToEntero();
if (HorasDobles > 0)
{
tipo = string.Format("{0}<br/>{1} horas dobles", tipo, HorasDobles);
}
if (HorasTriples > 0)
{
tipo = string.Format("{0}<br/>{1} horas triple", tipo, HorasTriples);
}
drow.Delete();
}
gvasistencia.AppendFormat("<td> <a onclick=\"openasis({1},'{2}')\"> {0} </a></td>", tipo, CvePersonal, fecha);
fecha = fecha.AddDays(1);
}
gvasistencia.Append("</tr>");
}
gvasistencia.Append("</tbody></table></div>");
ltlGvAsistencia.Text = gvasistencia.ToString();
}
#endregion
UpDatos.Update();
}
protected void GvNominas_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Literal LtlNombre = e.Row.FCLiteral("LtlNombre");
LinkButton LnkTimbrar = (LinkButton)e.Row.FindControl("LnkTimbrar");
int cvePersonal = e.Row.DataKey("CvePersonal").ToEntero();
int CvePeriodo = e.Row.DataKey("CvePeriodo").ToEntero();
int CveNomina = e.Row.DataKey("CveNomina").ToEntero();
string SeTimbro = e.Row.DataKey("SeTimbro").ToString();
string NomAutorizado = e.Row.DataKey("NomAutorizado").ToString();
string Nombre = e.Row.DataKey("Nombre").ToString();
string Codigo = e.Row.DataKey("Codigo").ToString();
string Turno = e.Row.DataKey("Turno").ToString();
string SubProyecto = e.Row.DataKey("SubProyecto").ToString();
LnkTimbrar.Visible = false;
if (cvePersonal > 0)
{
LtlNombre.Text = String.Format("<a class=\"Texto sline\" href=\"/RH/Personal.aspx?CvePersonal={0}\">{2}<br/>{1}</a>", cvePersonal, Nombre, Codigo);
if (CveNomina > 0)
{
if (NomAutorizado == "False")
{
}
else
{
if (SeTimbro == "False")
{
LnkTimbrar.Visible = true;
e.Row.CssClass = "info";
}
else
{
e.Row.CssClass = "success";
}
}
}
}
else
{
LtlNombre.Text = "Total General";
e.Row.FindControl("LnkTimbrar").Visible = false;
if (Turno.Length == 0 && SubProyecto.Length > 0)
{
LtlNombre.Text = String.Format("<b>Sub Proyecto: {0}<b>", SubProyecto);
}
else if (Turno.Length > 0)
{
LtlNombre.Text = String.Format("<b>Turno: {0}<b>", SubProyecto);
}
else
{
e.Row.CssClass = "SubTotales";
}
//e.Row.FindControl("LnkSobreRecibo").Visible = false;
}
}
}
#endregion
protected void LnkTimbrar_Click(object sender, EventArgs e)
{
LinkButton lnk = (LinkButton)sender;
GridViewRow gvRow = (GridViewRow)lnk.NamingContainer;
int CvePeriodo = gvRow.DataKey("CvePeriodo").ToEntero();
int CvePersonal = gvRow.DataKey("CvePersonal").ToEntero();
int CveNomina = gvRow.DataKey("CveNomina").ToEntero();
LogicNominas lognom = new LogicNominas();
string Msg = lognom.TimbrarNomina(CveNomina, CvePersonal, CvePeriodo, UsuarioActual);
if (Msg != null && Msg.Length > 0)
{ Alert(Msg, TipoMensaje.MsgAdvertencia); }
else
{
ClsNominas ObjPeriodo = new ClsNominas();
ObjPeriodo.CambiaEstatusPeriodo(CvePeriodo, (int)enumNominasEstatus.Timbrada, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa);
ObjPeriodo.Dispose();
Alert("Se ha timbrado correctamente");
gvRow.FindControl("ImgDelete").Visible = false;
gvRow.FindControl("LnkCancelar").Visible = false;
//gvRow.FCImage("ImgBandera").ImageUrl = "/Imagenes/flag_green.png";
gvRow.ForeColor = Color.Green;
lnk.Visible = false; UpDatos.Update();
}
}
protected void ImgDelete_Click(object sender, EventArgs e)
{
int Cve = ((LinkButton)sender).CommandArgument.ToEntero();
ClsNominas Nom = new ClsNominas();
if (Nom.RemoveNom_Nominas(Cve))
{
Alert("Los movimientos de la nómina fueron eliminados", TipoMensaje.MsgInformacion); cargaDatos();
}
Nom.Dispose();
}
protected void LnkCancelar_Click(object sender, EventArgs e)
{
int CveNomina = ((LinkButton)sender).CommandArgument.ToEntero();
if (CveNomina > 0)
{
ClsNominas Nom = new ClsNominas();
if (Nom.GetNom_Nominas(CveNomina, -1, -1, -1, UsuarioActual.CveEmpresa))
{
Timbrado ObjTimbrado = new Timbrado();
string FolioFiscal = Nom.FolioFiscal;
decimal Total = Nom.Total.ToString().ToDecimal();
string RFCReceptor = Nom.RFC;
string RFCEmisor = UsuarioActual.Empresa.RFC;
if (ObjTimbrado.CFDICancelar(UsuarioActual.Empresa, FolioFiscal, Total, RFCReceptor, RFCEmisor))
{
Nom.UpdateEstatusNomNominas(2, UsuarioActual.Empresa.CvePAC, "", "", ("01/01/2000").ToDate(), CveNomina, 0, 0, 0, 0, 0);
Alert("La nómina con folio fiscal fue cancelada ante el SAT", TipoMensaje.MsgInformacion);
}
}
Nom.Dispose();
cargaDatos();
}
}
protected void LnkModalPlantillaNomina_Click(object sender, EventArgs e)
{
RegistraScript("$('#DModalNominas').modal();");
using (ClsNominas ObjNomina = new ClsNominas())
{
if (ObjNomina.GetConceptos(UsuarioActual.CveEmpresa))
{
GVConceptosPlantilla.DataSource = ObjNomina.DtResultados.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa}");
GVConceptosPlantilla.DataBind();
}
}
UpCargarNomina.Update();
}
protected void LnkFormato_Click(object sender, EventArgs e)
{
try
{
StringBuilder str = new StringBuilder("0");
bool continuar = false;
foreach (GridViewRow gvrow in GVConceptosPlantilla.Rows)
{
if (gvrow.DataKey("CveConcepto").ToEntero() > 0 && gvrow.FCCheckBox("chkCon").Checked)
{
str.AppendFormat(",{0}",gvrow.DataKey("CveConcepto"));
continuar = true;
}
}
if (continuar)
{
ClosedXML.Excel.XLWorkbook wb = new ClosedXML.Excel.XLWorkbook();
DataTable dtc = dtConceptos.FiltraParametros(string.Format("Tipo IN ('P','D','O') AND EsPadre = 1 AND CveConcepto in({0})", str));
var libro = wb.AddWorksheet("Nomina");
int column = 1;
libro.Row(1).Hide();
libro.Cell(1, column).Value = "Codigo";
libro.Cell(2, column).Value = "Codigo";
column++;
libro.Cell(1, column).Value = "Empleado";
libro.Cell(2, column).Value = "Empleado";
libro.Column(column).Width = 35;
foreach (DataRow row in dtc.Rows)
{
column++;
string CveConcepto = row["CveConcepto"].ToString();
string Concepto = row["Concepto"].ToString();
libro.Cell(1, column).Value = CveConcepto;
libro.Cell(2, column).Value = Concepto;
libro.Column(column).Width = 15;
}
libro.Row(1).CellsUsed().Style.Font.FontColor = ClosedXML.Excel.XLColor.White;
libro.Row(2).CellsUsed().Style.Font.FontColor = ClosedXML.Excel.XLColor.White;
libro.Row(1).CellsUsed().Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189));
libro.Row(2).CellsUsed().Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189));
libro.Cell(3, 1).Value = 0;
libro.Range(3, 2, 3, 3).Merge().Value = "¿Modificar SI(S)/NO(N)?";
column = 2;
foreach (DataRow row in dtc.Rows)
{
column++;
string Concepto = string.Format("V_{0}", row["CveConcepto"]);
libro.Cell(3, column).Value = "N";
}
libro.Row(3).CellsUsed().Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(177, 160, 199));
int Fila = 3;
foreach (DataRow erow in dtempleados.FiltraParametros("CvePersonal>0 AND NomAutorizado=0").Rows)
{
Fila++;
column = 1;
libro.Cell(Fila, column).Value = erow["Codigo"];
column++;
libro.Cell(Fila, column).Value = erow["Nombre"];
foreach (DataRow row in dtc.Rows)
{
column++;
string Concepto = string.Format("V_{0}", row["CveConcepto"]);
libro.Cell(Fila, column).Value = erow[Concepto];
}
}
System.IO.Stream fs = new System.IO.MemoryStream();
wb.SaveAs(fs);
fs.Position = 0;
System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();
using (System.IO.Stream input = fs)
{
input.CopyTo(memoryStream);
}
memoryStream.Position = 0;
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.xlsx", "Plantilla conceptos nómina "));
Response.BinaryWrite(memoryStream.ToArray());
Response.End();
}
else
{
Alert("Debe seleccionar los conceptos a cargar.", TipoMensaje.MsgAdvertencia);
}
}
catch (Exception ex)
{
Alert("Ocurrio un error al generar el Formato de nominas" + ex.ToString());
}
}
protected void LnkCargarNomina_Click(object sender, EventArgs e)
{
List<Archivo> Filesgral = TxtArchivoNomina.getfiles().Archivos;
bool continuar = Filesgral.Count > 0;
string stringError = "";
Archivo fileItem = continuar ? Filesgral[0] : null;
if (continuar)
{
string FileExtension = fileItem.Extencion.ToUpper();
if (FileExtension == "XLS" | FileExtension == "XLSX" | FileExtension == "CSV")
{
}
else
{
continuar = false;
stringError = "No se inserto un archivo de tipo Excel";
}
}
DataTable DTEXcel = new DataTable();
if (continuar)
{
try
{
DTEXcel = Extensiones.ModExtensiones.ReadExcelFile(fileItem.FileUrl, true).FiltraParametros(" LEN(Codigo)>0 AND Codigo <> 'Codigo'");
}
catch (Exception ex)
{
continuar = false;
stringError = "Ocurrio un Error al procesar el excel ";
string.Format("{0} \r\n{0}", stringError, ex.ToString()).GuardaLog();
}
}
if (continuar && DTEXcel.Rows.Count == 0)
{
continuar = false;
stringError = "No se encontraron cambios";
}
StringBuilder str = new StringBuilder();
bool rollback = false;
if (continuar)
{
int CveMoneda = 1;
//List<int> lConceptos = new List<int>();
//foreach (DataColumn item in DTEXcel.Columns)
//{
// if (item.ColumnName.ToEntero() > 0)
// {
// lConceptos.Add(item.ColumnName.ToEntero());
// }
//}
using (ClsRH objpersonal = new ClsRH())
{
using (ClsNominas objNomina = new ClsNominas(objpersonal.IniciaTransacSQL()))
{
foreach (DataRow row in DTEXcel.FiltraParametros("LEN(Codigo)>0 ").Rows)
{
string Codigo = row["Codigo"].ToString();
int CvePersonal = -1; // row["CvePersonal"].ToString().ToEntero();
int CveNomina = 0;
double SubTotal = 0;
double Total = 0;
int CveMetodoPago = 0;
if (Codigo != "-1" && objpersonal.GetPersonal(CvePersonal, Codigo, "-1", "-1", "-1", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "-1", -1, -1, -1, -1, -1, -1, "-1", "-1", "-1", "-1", UsuarioActual.CveEmpresa) &&
objpersonal.DtResultados.Rows.Count == 1)
{
CvePersonal = objpersonal.CvePersonal;
CveMetodoPago = objpersonal.CveMetodoPago;
}
else
{
CvePersonal = 0;
str.AppendLine(string.Format("No se encontro el codigo {0}<br>", Codigo));
}
if (CvePersonal > 0)
{
if (objNomina.GetNom_Nominas(-1, CvePersonal, CvePeriodoSeleccionado, -1, UsuarioActual.CveEmpresa))
{
if (objNomina.DtResultados.Rows.Count > 0)
{
CveNomina = objNomina.CveNomina;
}
else
{
if (objNomina.AddNom_Nominas(-1, 1, CvePersonal, CvePeriodoSeleccionado, SubTotal, 0, 0, Total, CveMoneda, 1, CveMetodoPago, DateTime.Now, "Deducciones nómina",
"", "", "", "", 0, 0, 0, new DateTime(), new DateTime(), new DateTime(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, false))
{
CveNomina = objNomina.CveNomina;
}
else
{
rollback = true;
}
}
}
else
{
rollback = true;
}
}
if (CveNomina > 0)
{
//foreach (int CveConcepto in lConceptos)
//{
// decimal Importe = 0;
// decimal ImporteGravado = 0;
// decimal ImporteExento = 0;
// Importe = row[CveConcepto.ToString()].ToString().ToDecimal();
// //try
// //{
// // ImporteExento = row[string.Format("E{0}", CveConcepto)].ToString().ToDecimal();
// //}
// //catch (Exception) { }
// ImporteGravado = Importe - ImporteExento;
// objNomina.AddUPNom_NominasDetalles(objNomina.CveNomina, CvePeriodoSeleccionado, CvePersonal, CveConcepto, Importe, ImporteGravado, ImporteExento, UsuarioActual.CveUsuario);
//}
for (int i = 2; i < DTEXcel.Columns.Count; i++)
{
int CveConcepto = DTEXcel.Columns[i].ColumnName.ToEntero();
decimal Importe = 0;
decimal ImporteGravado = 0;
decimal ImporteExento = 0;
bool dontsaveconcepto = ((row[i].ToString().ToUpper() == "N") || (DTEXcel.Rows[0][i].ToString().ToUpper() == "N"));
Importe = row[i].ToString().ToDecimal();
ImporteGravado = Importe - ImporteExento;
if (CveConcepto > 0)
{
if (!dontsaveconcepto)//el usuario definira si desea actualizar o no el concepto en el periodo
{
if (!objNomina.AddUPNom_NominasDetalles(objNomina.CveNomina, CvePeriodoSeleccionado, CvePersonal, CveConcepto, Importe, ImporteGravado, ImporteExento, UsuarioActual.CveUsuario, true))
{
rollback = true;
}
}
}
else
{
rollback = false;
stringError = "ocurrio un error al procesar el archivo favor de intentar de nuevo volviendo a descargar la plantilla.<br/>si el problema Persiste Contacte a soporte.";
}
}
}
}
if (rollback)
{
objpersonal.RollBack();
continuar = false;
}
else
{
objpersonal.Commit();
}
}
}
}
if (!continuar)
{
Alert(stringError, ModExtensiones.TipoMensaje.MsgAdvertencia);
}
else
{
Alert("La información se a actualizado satisfactoriamente");
}
}
protected void LnkFormatoEmpleados_Click(object sender, EventArgs e)
{
}
#region SobreRecibo
protected int SRCvePersonal
{
get
{
if (ViewState["SRCvePersonal"] == null) { return 0; }
else { return ViewState["SRCvePersonal"].ToString().ToEntero(); }
}
set { ViewState["SRCvePersonal"] = value; }
}
protected int SRCvePeriodo
{
get
{
if (ViewState["SRCvePeriodo"] == null) { return 0; }
else { return ViewState["SRCvePeriodo"].ToString().ToEntero(); }
}
set { ViewState["SRCvePeriodo"] = value; }
}
protected void LnkSobreRecibo_Click(object sender, EventArgs e)
{
GridViewRow gvrow = (GridViewRow)(((LinkButton)sender).NamingContainer);
string Nombre = gvrow.DataKey("Nombre").ToString();
SRCvePersonal = gvrow.DataKey("CvePersonal").ToEntero();
SRCvePeriodo = gvrow.DataKey("CvePeriodo").ToEntero();
int CveNomina = gvrow.DataKey("CveNomina").ToEntero();
LblEmpleado.Text = Nombre;
TabPersonal.ActiveTabIndex = 0;
mostrarConceptos();
pnlAddupMovto.Visible = false;
CargaMovtoPermanente();
RegistraScript("$('#ModalConceptos').modal();");
}
private void mostrarConceptos()
{
#region "Llenado de datos empleado"
string CodigoEmpleado = "";
string NombreCompleto = "";
string RFC = "";
string CURP = "";
string TipoPeriodo = "";
string NSS = "";
string DiasLaborados = "";
string DiasFaltados = "";
string DiasVacaciones = "";
string FechaInicio = "";
string FechaFin = "";
string DiasRetardos = "";
string DiasIncapacidad = "";
string Puesto = "";
string Departamento = "";
string SD = "";
string SDI = "";
string SalarioDiarioIMSS = "";
DataRow drow = dtempleados.FiltroPrimero(string.Format("CvePersonal = {0}", SRCvePersonal));
if (drow != null)
{
DiasLaborados = string.Format("{0}", drow["DiasLaborados"].ToString().ToEntero());
DiasFaltados = string.Format("{0}", drow["DiasFaltados"].ToString().ToEntero());
DiasVacaciones = string.Format("{0}", drow["DiasVacaciones"].ToString().ToEntero());
FechaInicio = string.Format("{0:dd/MM/yyyy}", drow["FechaInicio"]);
FechaFin = string.Format("{0:dd/MM/yyyy}", drow["FechaFin"]);
DiasRetardos = string.Format("{0}", drow["DiasRetardos"].ToString().ToEntero());
DiasIncapacidad = string.Format("{0}", drow["DiasIncapacidad"].ToString().ToEntero());
SD = string.Format("{0:####.####}", drow["SalarioDiario"]);
SDI = string.Format("{0:####.####}", drow["SalarioDiarioIntegrado"]);
SalarioDiarioIMSS = string.Format("{0:####.####}", drow["SalarioDiarioIMSS"]);
}
using (ClsRH objrh = new ClsRH())
{
if (objrh.GetPersonal(SRCvePersonal, UsuarioActual.CveEmpresa) && objrh.DtResultados.Rows.Count > 0)
{
DataRow erow = objrh.DtResultados.Rows[0];
CodigoEmpleado = erow["Codigo"].ToString();
NombreCompleto = erow["NombreCompleto"].ToString();
RFC = erow["RFC"].ToString();
CURP = erow["CURP"].ToString();
TipoPeriodo = erow["TipoPeriodo"].ToString();
NSS = erow["NSS"].ToString();
Puesto = erow["Puesto"].ToString();
Departamento = erow["Departamento"].ToString();
}
}
LblCodigoEmpleado.Text = CodigoEmpleado;
//LblNombreCompleto.Text = NombreCompleto;
LblRFC.Text = RFC;
LblCURP.Text = CURP;
LblTipoPeriodo.Text = TipoPeriodo;
LblNSS.Text = NSS;
LblDiasLaborados.Text = DiasLaborados;
LblDiasFaltados.Text = DiasFaltados;
LblDiasVacaciones.Text = DiasVacaciones;
LblFecha.Text = string.Format("{0} al {1}", FechaInicio, FechaFin);
LblDiasRetardos.Text = DiasRetardos;
LblDiasIncapacidad.Text = DiasIncapacidad;
LblSRPuesto.Text = Puesto;
LblSRDepartamento.Text = Departamento;
LblSRSalarioDiario.Text = SD;
LblSRSalarioDiarioIntegrado.Text = SDI;
LblSRSbc.Text = SalarioDiarioIMSS;
#endregion
#region "Sobre Recibo"
{
DataTable dtper = dtConceptos.FiltraParametros("Tipo IN ('P') AND EsPadre = 1 ");
DataTable dtded = dtConceptos.FiltraParametros("Tipo IN ('D') AND EsPadre = 1 ");
dtper.Columns.Add("BorradoLogico", typeof(int));
dtded.Columns.Add("BorradoLogico", typeof(int));
foreach (DataRow row in dtper.Rows)
{
int BorradoLogico = 0;
int CveConcepto = row["CveConcepto"].ToString().ToEntero();
if (!(dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) != 0))
{
BorradoLogico = 1;
}
row["BorradoLogico"] = BorradoLogico;
}
dtper.AcceptChanges();
foreach (DataRow row in dtded.Rows)
{
int BorradoLogico = 0;
int CveConcepto = row["CveConcepto"].ToString().ToEntero();
if (!(dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) != 0))
{
BorradoLogico = 1;
}
row["BorradoLogico"] = BorradoLogico;
}
dtded.AcceptChanges();
dtper = dtper.FiltraParametros("BorradoLogico=0");
dtded = dtded.FiltraParametros("BorradoLogico=0");
int maxper = dtper.Rows.Count;
int maxded = dtded.Rows.Count;
int i = 0;
List<NConcepto> lconc = new List<NConcepto>();
for (i = 0; i < maxper || i < maxded; i++)
{
NConcepto nConcepto = new NConcepto();
DataRow row;
if (maxper > i)
{
row = dtper.Rows[i];
int CveConcepto = row["CveConcepto"].ToString().ToEntero();
string Concepto = row["Concepto"].ToString();
string Codigo = row["Codigo"].ToString();
//bool visible = (dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) > 0);
double Importe = dtempleados.SUM(string.Format("[V_{0}]", CveConcepto), string.Format("CvePersonal = {0}", SRCvePersonal));
nConcepto.CveConceptoP = CveConcepto;
nConcepto.ConceptoP = Concepto;
nConcepto.NoConceptoP = Codigo;
nConcepto.ImporteP = Importe;
nConcepto.ValorP = dtempleados.SUM(string.Format("[VAL_{0}]", CveConcepto), string.Format("CvePersonal = {0}", SRCvePersonal));
nConcepto.isOnlyBisibleP = row["SoloVisible"].ToString().ToEntero();
}
if (maxded > i)
{
row = dtded.Rows[i];
int CveConcepto = row["CveConcepto"].ToString().ToEntero();
string Concepto = row["Concepto"].ToString();
string Codigo = row["Codigo"].ToString();
//bool visible = (dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) > 0);
double Importe = dtempleados.SUM(string.Format("[V_{0}]", CveConcepto), string.Format("CvePersonal = {0}", SRCvePersonal));
nConcepto.CveConceptoD = CveConcepto;
nConcepto.ConceptoD = Concepto;
nConcepto.NoConceptoD = Codigo;
nConcepto.ImporteD = Importe;
nConcepto.ValorD = dtempleados.SUM(string.Format("[VAL_{0}]", CveConcepto), string.Format("CvePersonal = {0}", SRCvePersonal));
nConcepto.isOnlyBisibleD = row["SoloVisible"].ToString().ToEntero();
}
lconc.Add(nConcepto);
}
lconc.Add(new NConcepto());
NConcepto SubTotales = new NConcepto();
SubTotales.CveConceptoP = 0;
SubTotales.ConceptoP = "Total Percepciones";
SubTotales.EstatusP = -2;
SubTotales.ImporteP = dtempleados.SUM("SumaPercepciones", string.Format("CvePersonal = {0}", SRCvePersonal));
///Alert(SubTotales.ImporteP.ToString());
SubTotales.CveConceptoD = 0;
SubTotales.ConceptoD = "Total Deducciones";
SubTotales.EstatusD = -2;
SubTotales.ImporteD = dtempleados.SUM("SumaDeducciones", string.Format("CvePersonal = {0}", SRCvePersonal));
NConcepto Totales = new NConcepto();
Totales.CveConceptoD = 0;
Totales.ConceptoD = "Total";
Totales.EstatusD = -3;
Totales.ImporteD = dtempleados.SUM("Total", string.Format("CvePersonal = {0}", SRCvePersonal));
lconc.Add(SubTotales);
lconc.Add(Totales);
GvConceptos.DataSource = lconc;
GvConceptos.DataBind();
}
#endregion
#region "Infonavit"
{
using (ClsRH objper = new ClsRH())
{
objper.GetPersonalConceptos(SRCvePersonal, UsuarioActual.CveEmpresa);
DataRow frow = objper.DtResultados.FiltroPrimero("CveSistema =3");
TxtInfoValor.Text = "";
DdlInfoTipoAplicacion.SelectedValueExist("-1");
TxtInfoDescripcion.Text = "";
TxtInfoNumCredito.Text = "";
TxtInfoFechaInicio.Text = "";
ChkInfo.Checked = false;
if (frow != null)
{
TxtInfoValor.Text = String.Format("{0:###,###.##}", frow["Importe"]);
DdlInfoTipoAplicacion.SelectedValueExist(frow["TipoAplicacion"].ToString());
TxtInfoDescripcion.Text = String.Format("{0}", frow["Descripcion02"]);
TxtInfoNumCredito.Text = String.Format("{0}", frow["Descripcion01"]);
TxtInfoFechaInicio.Text = String.Format("{0:dd/MM/yyyy}", frow["FInicioAplicacion"]);
ChkInfo.Checked = frow["estatus"].ToString().ToUpper().Contiene("1", "TRUE");
}
frow = objper.DtResultados.FiltroPrimero("CveSistema =4");
TxtFonValor.Text = "";
DdlFonTipoAplicacion.SelectedValueExist("-1");
TxtFonDescripcion.Text = "";
TxtFonNumCredito.Text = "";
TxtFonFechaInicio.Text = "";
ChkFonacot.Checked = false;
if (frow != null)
{
TxtFonValor.Text = String.Format("{0:###,###.##}", frow["Importe"]);
DdlFonTipoAplicacion.SelectedValueExist(frow["TipoAplicacion"].ToString());
TxtFonDescripcion.Text = String.Format("{0}", frow["Descripcion02"]);
TxtFonNumCredito.Text = String.Format("{0}", frow["Descripcion01"]);
TxtFonFechaInicio.Text = String.Format("{0:dd/MM/yyyy}", frow["FInicioAplicacion"]);
ChkFonacot.Checked = frow["estatus"].ToString().ToUpper().Contiene("1", "TRUE");
}
}
}
#endregion
UpModalConceptos.Update();
}
protected void BtnImprimirsobrerecibo_Click(object sender, EventArgs e)
{
DataTable dtper = dtConceptos.FiltraParametros("Tipo IN ('P') AND EsPadre = 1 ");
DataTable dtded = dtConceptos.FiltraParametros("Tipo IN ('D') AND EsPadre = 1 ");
dtper.Columns.Add("BorradoLogico", typeof(int));
dtded.Columns.Add("BorradoLogico", typeof(int));
foreach (DataRow row in dtper.Rows)
{
int BorradoLogico = 0;
int CveConcepto = row["CveConcepto"].ToString().ToEntero();
if (!(dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) != 0))
{
BorradoLogico = 1;
}
row["BorradoLogico"] = BorradoLogico;
}
dtper.AcceptChanges();
foreach (DataRow row in dtded.Rows)
{
int BorradoLogico = 0;
int CveConcepto = row["CveConcepto"].ToString().ToEntero();
if (!(dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) != 0))
{
BorradoLogico = 1;
}
row["BorradoLogico"] = BorradoLogico;
}
dtded.AcceptChanges();
dtper = dtper.FiltraParametros("BorradoLogico=0");
dtded = dtded.FiltraParametros("BorradoLogico=0");
int maxper = dtper.Rows.Count;
int maxded = dtded.Rows.Count;
int i = 0;
List<NConcepto> lconc = new List<NConcepto>();
for (i = 0; i < maxper || i < maxded; i++)
{
NConcepto nConcepto = new NConcepto();
DataRow row;
if (maxper > i)
{
row = dtper.Rows[i];
int CveConcepto = row["CveConcepto"].ToString().ToEntero();
string Concepto = row["Concepto"].ToString();
string Codigo = row["Codigo"].ToString();
//bool visible = (dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) > 0);
double Importe = dtempleados.SUM(string.Format("[V_{0}]", CveConcepto), string.Format("CvePersonal = {0}", SRCvePersonal));
nConcepto.CveConceptoP = CveConcepto;
nConcepto.ConceptoP = Concepto;
nConcepto.NoConceptoP = Codigo;
nConcepto.ImporteP = Importe;
nConcepto.ValorP = dtempleados.SUM(string.Format("[VAL_{0}]", CveConcepto), string.Format("CvePersonal = {0}", SRCvePersonal));
}
if (maxded > i)
{
row = dtded.Rows[i];
int CveConcepto = row["CveConcepto"].ToString().ToEntero();
string Concepto = row["Concepto"].ToString();
string Codigo = row["Codigo"].ToString();
//bool visible = (dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) > 0);
double Importe = dtempleados.SUM(string.Format("[V_{0}]", CveConcepto), string.Format("CvePersonal = {0}", SRCvePersonal));
nConcepto.CveConceptoD = CveConcepto;
nConcepto.ConceptoD = Concepto;
nConcepto.NoConceptoD = Codigo;
nConcepto.ImporteD = Importe;
nConcepto.ValorD = dtempleados.SUM(string.Format("[VAL_{0}]", CveConcepto), string.Format("CvePersonal = {0}", SRCvePersonal));
}
lconc.Add(nConcepto);
}
lconc.Add(new NConcepto());
NConcepto SubTotales = new NConcepto();
SubTotales.CveConceptoP = 0;
SubTotales.ConceptoP = "Total Percepciones";
SubTotales.EstatusP = -2;
SubTotales.ImporteP = dtempleados.SUM("SumaPercepciones", string.Format("CvePersonal = {0}", SRCvePersonal));
///Alert(SubTotales.ImporteP.ToString());
SubTotales.CveConceptoD = 0;
SubTotales.ConceptoD = "Total Deducciones";
SubTotales.EstatusD = -2;
SubTotales.ImporteD = dtempleados.SUM("SumaDeducciones", string.Format("CvePersonal = {0}", SRCvePersonal));
NConcepto Totales = new NConcepto();
Totales.CveConceptoD = 0;
Totales.ConceptoD = "Total";
Totales.EstatusD = -3;
Totales.ImporteD = dtempleados.SUM("Total", string.Format("CvePersonal = {0}", SRCvePersonal));
lconc.Add(SubTotales);
lconc.Add(Totales);
List<Microsoft.Reporting.WebForms.ReportDataSource> lrds = new List<Microsoft.Reporting.WebForms.ReportDataSource>();
Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource();
rds.Name = "DataSet1";
rds.Value = lconc;
lrds.Add(rds);
List<Microsoft.Reporting.WebForms.ReportParameter> parametros = new List<Microsoft.Reporting.WebForms.ReportParameter>();
string CodigoEmpleado = "";
string NombreCompleto = "";
string RFC = "";
string CURP = "";
string TipoPeriodo = "";
string NSS = "";
string DiasLaborados = "";
string DiasFaltados = "";
string DiasVacaciones = "";
string FechaInicio = "";
string FechaFin = "";
string DiasRetardos = "";
string DiasIncapacidad = "";
{
DataRow drow = dtempleados.FiltroPrimero(string.Format("CvePersonal = {0}", SRCvePersonal));
if (drow != null)
{
DiasLaborados = string.Format("{0}", drow["DiasLaborados"].ToString().ToEntero());
DiasFaltados = string.Format("{0}", drow["DiasFaltados"].ToString().ToEntero());
DiasVacaciones = string.Format("{0}", drow["DiasVacaciones"].ToString().ToEntero());
FechaInicio = string.Format("{0:dd/MM/yyyy}", drow["FechaInicio"]);
FechaFin = string.Format("{0:dd/MM/yyyy}", drow["FechaFin"]);
DiasRetardos = string.Format("{0}", drow["DiasRetardos"].ToString().ToEntero());
DiasIncapacidad = string.Format("{0}", drow["DiasIncapacidad"].ToString().ToEntero());
}
}
//string Codigo = "";
using (ClsRH objrh = new ClsRH())
{
if (objrh.GetPersonal(SRCvePersonal, UsuarioActual.CveEmpresa) && objrh.DtResultados.Rows.Count > 0)
{
DataRow drow = objrh.DtResultados.Rows[0];
CodigoEmpleado = drow["Codigo"].ToString();
NombreCompleto = drow["NombreCompleto"].ToString();
RFC = drow["RFC"].ToString();
CURP = drow["CURP"].ToString();
TipoPeriodo = drow["TipoPeriodo"].ToString();
NSS = drow["NSS"].ToString();
}
}
parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("DiasIncapacidad", DiasIncapacidad));
parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("Codigo", CodigoEmpleado));
parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("NombreCompleto", NombreCompleto));
parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("RFC", RFC));
parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("CURP", ""));
parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("TipoPeriodo", TipoPeriodo));
parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("NSS", NSS));
parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("DiasLaborados", DiasLaborados));
parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("DiasFaltados", DiasFaltados));
parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("DiasVacaciones", DiasVacaciones));
parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("FechaInicio", FechaInicio));
parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("FechaFin", FechaFin));
parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("DiasRetardos", DiasRetardos));
parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("FechaPago", ""));
//parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("", ""));
//parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("", ""));
//parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("", ""));
//parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("", ""));
//parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("", ""));
;
ImprimirPDF(System.IO.Path.Combine(ModExtensiones.DirectorioBaseEmpresas, "Empresas/Grales/Formatos/SobreRecibo.rdlc"), lrds, parametros, "SobreRecibo", "PDF", null);
}
protected void BtnGuardarInfornavit_Click(object sender, EventArgs e)
{
double importe = TxtInfoValor.Text.ToDouble();
int TipoAplicacion = DdlInfoTipoAplicacion.SelectedValue.ToEntero();
int NoPagos = 0;
double SaldoIni = 0;
string descripcion02 = TxtInfoDescripcion.Text;
string descripcion01 = TxtInfoNumCredito.Text;
string fecha = TxtInfoFechaInicio.Text.Replace("_", "");
int estatus = ChkInfo.Checked ? 1 : 0;
if (fecha.Length > 8)
fecha = fecha.ToDateTime().ToString("yyyy/MM/dd");
else
fecha = "";
bool continuar = true;
using (ClsRH ObjPersonal = new ClsRH())
{
if (!ObjPersonal.AddConcepto(SRCvePersonal, -1, importe, TipoAplicacion, NoPagos, SaldoIni, UsuarioActual.CveUsuario, 3, descripcion01, descripcion02, fecha, "", estatus, UsuarioActual.CveEmpresa))
continuar = false;
}
if (continuar)
{
LnkConsultar_Click(null, null);
mostrarConceptos();
Alert("Se actualizo el calculo de infonavit");
}
}
private class NConcepto
{
public string NoConceptoP { get; set; }
public string ConceptoP { get; set; }
public string LabelValorP { get; set; }
public int CveConceptoP { get; set; }
public double ImporteP { get; set; }
public double ValorP { get; set; }
public int EstatusP { get; set; }
public bool isEditedP { get; set; }
public int isOnlyBisibleP { get; set; }
public string NoConceptoD { get; set; }
public string ConceptoD { get; set; }
public string LabelValorD { get; set; }
public int CveConceptoD { get; set; }
public double ImporteD { get; set; }
public double ValorD { get; set; }
public int EstatusD { get; set; }
public bool isEditedD { get; set; }
public int isOnlyBisibleD { get; set; }
}
protected void GvConceptos_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// Datakeys
// Concepto,CveConcepto,Importe,Estatus,ConceptoD,CveConceptoD,ImporteD,EstatusD
int CveConcepto = e.Row.DataKey("CveConceptoP").ToEntero();
int CveConceptoD = e.Row.DataKey("CveConceptoD").ToEntero();
// Dim Importe As Decimal = e.Row.DataKey("Importe").ToDecimal()
// Dim ImporteD As Decimal = e.Row.DataKey("ImporteD").ToDecimal()
int Estatus = e.Row.DataKey("EstatusP").ToEntero();
int EstatusD = e.Row.DataKey("EstatusD").ToEntero();
int isOnlyBisibleP = e.Row.DataKey("isOnlyBisibleP").ToEntero();
int isOnlyBisibleD = e.Row.DataKey("isOnlyBisibleD").ToEntero();
// Controles
Label LtlConcepto = e.Row.FCLabel("LtlConcepto");
LinkButton LnkConcepto = e.Row.FCLinkButton("LnkConcepto");
Label LtlConceptoD = e.Row.FCLabel("LtlConceptoD");
LinkButton LnkConceptoD = e.Row.FCLinkButton("LnkConceptod");
Label LtlImporte = e.Row.FCLabel("LtlImporte");
LinkButton LnkImporte = e.Row.FCLinkButton("LnkImporte");
Label LtlImporteD = e.Row.FCLabel("LtlImporteD");
LinkButton LnkImporteD = e.Row.FCLinkButton("LnkImporteD");
//isEditedD
if (isOnlyBisibleP == 1)
{
e.Row.CssClass = string.Format("{0} isOnlyBisibleP", e.Row.CssClass);
}
if (isOnlyBisibleD == 1)
{
e.Row.CssClass = string.Format("{0} isOnlyBisibleD", e.Row.CssClass);
}
if (Estatus < -1 | EstatusD < -1)
e.Row.CssClass = "ConceptosTotales";
if (CveConcepto == 0 && (Estatus == 0 || Estatus == -1 || Estatus == -3))
LtlImporte.Text = "";
if (CveConceptoD == 0 && (EstatusD == 0 || EstatusD == -1))
LtlImporteD.Text = "";
if (Estatus == -1)
LtlConcepto.Visible = false;
else if (Estatus > 0)
LtlImporte.Visible = false;
if (EstatusD == -1)
LtlConceptoD.Visible = false;
else if (EstatusD > 0)
LtlImporteD.Visible = false;
LnkConcepto.Visible = !LtlConcepto.Visible;
LnkConceptoD.Visible = !LtlConceptoD.Visible;
LnkImporte.Visible = !LtlImporte.Visible;
LnkImporteD.Visible = !LtlImporteD.Visible;
}
}
#endregion
protected void LnkFormatoTabular_Click(object sender, EventArgs e)
{
try
{
ClosedXML.Excel.XLWorkbook wb = new ClosedXML.Excel.XLWorkbook();
var libro = wb.AddWorksheet("Nomina");
int column = 1;
//libro.Row(1).Hide();
//libro.Column(1).Hide();
//libro.Cell(1, column).Value = "CvePersonal";
//libro.Cell(2, column).Value = "CvePersonal";
//column++;
libro.Cell(1, column).Value = "Codigo";
//libro.Cell(2, column).Value = "Codigo";
column++;
libro.Cell(1, column).Value = "Empleado";
//libro.Cell(2, column).Value = "Empleado";
libro.Column(column).Width = 35;
foreach (DataRow row in dtConceptos.FiltraParametros("Tipo IN ('P','D','O') AND EsPadre = 1 ").Rows)
{
column++;
string CveConcepto = row["CveConcepto"].ToString();
string Concepto = row["Concepto"].ToString();
//libro.Cell(1, column).Value = CveConcepto;
libro.Cell(1, column).Value = Concepto;
libro.Column(column).Width = 15;
//column++;
//CveConcepto = string.Format("E{0}", row["CveConcepto"]);
//Concepto = string.Format("Exento {0}", row["Concepto"]);
//libro.Cell(1, column).Value = CveConcepto;
//libro.Cell(2, column).Value = Concepto;
//libro.Column(column).Width = 15;
}
libro.Row(1).CellsUsed().Style.Font.FontColor = ClosedXML.Excel.XLColor.White;
libro.Row(1).CellsUsed().Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189));
//libro.Row(1).Cell(13).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(247, 150, 70));
//libro.Row(1).Cell(14).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(0, 176, 240));
//libro.Row(1).Cell(15).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(177, 160, 199));
//libro.Cell(3, 1).Value = 0;
//libro.Range(3, 2, 3, 3).Merge().Value = "¿Modificar SI(S)/NO(N)?";
//column = 3;
//foreach (DataRow row in dtConceptos.FiltraParametros("Tipo IN ('P','D','O') AND EsPadre = 1 ").Rows)
//{
// column++;
// string Concepto = string.Format("V_{0}", row["CveConcepto"]);
// libro.Cell(3, column).Value = "N";
// //column++;
// //string ConceptoG = string.Format("VG_{0}", row["CveConcepto"]);
// //libro.Cell(3, column).Value = "N";
//}
//libro.Row(3).CellsUsed().Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(177, 160, 199));
int Fila = 1;
foreach (DataRow erow in dtempleados.Rows)
{
Fila++;
column = 1;
//libro.Cell(Fila, column).Value = erow["CvePersonal"];
//column++;
libro.Cell(Fila, column).Value = erow["Codigo"];
column++;
libro.Cell(Fila, column).Value = erow["Nombre"];
foreach (DataRow row in dtConceptos.FiltraParametros("Tipo IN ('P','D','O') AND EsPadre = 1 ").Rows)
{
column++;
string Concepto = string.Format("V_{0}", row["CveConcepto"]);
libro.Cell(Fila, column).Value = erow[Concepto];
//libro.Cell(Fila, column).Style.NumberFormat
//column++;
//string ConceptoG = string.Format("VG_{0}", row["CveConcepto"]);
//libro.Cell(Fila, column).Value = erow[Concepto].ToString().ToDecimal() - erow[ConceptoG].ToString().ToDecimal();
}
}
//libro.Row(2).SetAutoFilter();
libro.Row(2).CellsUsed().Style.Font.FontColor = ClosedXML.Excel.XLColor.White;
libro.Row(2).Cell(1).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189));
libro.Row(2).CellsUsed().Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189));
System.IO.Stream fs = new System.IO.MemoryStream();
wb.SaveAs(fs);
fs.Position = 0;
System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();
using (System.IO.Stream input = fs)
{
input.CopyTo(memoryStream);
}
memoryStream.Position = 0;
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.xlsx", "FormatoCargaNominas"));
Response.BinaryWrite(memoryStream.ToArray());
Response.End();
}
catch (Exception ex)
{
Alert("Ocurrio un error al generar el Formato de nominas" + ex.ToString());
}
}
protected void LnkConcepto_Click(object sender, EventArgs e)
{
}
protected void LnkConceptoD_Click(object sender, EventArgs e)
{
}
protected void LnkVerTablas_Click(object sender, EventArgs e)
{
using (ClsNominas objnom = new ClsNominas())
{
if (objnom.GetTablasNomina(UsuarioActual.CveEmpresa) && objnom.DTSetResultados.Tables.Count > 1)
{
GVFactorDesctInfonavit.DataSource = objnom.DTSetResultados.Tables[0];
GVSalariosMinimos.DataSource = objnom.DTSetResultados.Tables[1];
GVIMMSRiesgot.DataSource = objnom.DTSetResultados.Tables[2];
GVInfonavitSegViv.DataSource = objnom.DTSetResultados.Tables[3];
GVVigISRMensual.DataSource = objnom.DTSetResultados.Tables[4];
GVVigSubEmpMensual.DataSource = objnom.DTSetResultados.Tables[5];
GVUma.DataSource = objnom.DTSetResultados.Tables[6];
}
}
GVFactorDesctInfonavit.DataBind();
GVSalariosMinimos.DataBind();
GVIMMSRiesgot.DataBind();
GVInfonavitSegViv.DataBind();
GVVigISRMensual.DataBind();
GVVigSubEmpMensual.DataBind();
GVVigSubEmpMensual.DataBind();
GVUma.DataBind();
UpModalTablas.Update();
RegistraScript("$('#ModalTablas').modal();");
}
private void ImprimirReporte()
{
string RutaDocumento = System.IO.Path.Combine(ModExtensiones.DirectorioBaseEmpresas, "Empresas/Grales/Lista de Raya.docx");
if (dtempleados != null && dtempleados.Rows.Count > 0)
{
if (System.IO.File.Exists(RutaDocumento))
{
try
{
clsGemBoxDocument GemDocumen = new clsGemBoxDocument(RutaDocumento);
List<TagsDocumentos> listaTags = new List<TagsDocumentos>();
string strEmpresa = UsuarioActual.Empresa.Empresa;
string strFechaInicio = "";
string strFechaFin = "";
string strTipo = "";
string strPeriodoNum = "";
string strUbicacion = string.Format("{0}, {1}, {2}, {3}", UsuarioActual.Empresa.Direccion, UsuarioActual.Empresa.Colonia, UsuarioActual.Empresa.Ciudad, UsuarioActual.Empresa.Estado);
string strRegPatImss = "";
string strRFC = UsuarioActual.Empresa.RFC;
string strfecha = DateTime.Now.ToString("dd/MMM/yyyy", System.Globalization.CultureInfo.CreateSpecificCulture("es-MX"));
string strhora = DateTime.Now.ToString("HH:mm:ss", System.Globalization.CultureInfo.CreateSpecificCulture("es-MX"));
int CvePeriodo = DdlPeriodo.SelectedValue.ToEntero();
DataRow rperiodo = dtPeriodos.FiltroPrimero(string.Format("CvePeriodo = {0}", CvePeriodo));
if (rperiodo != null)
{
strFechaInicio = string.Format("{0:dd/MM/yyyy}", rperiodo["FechaInicio"]);
strFechaFin = string.Format("{0:dd/MM/yyyy}", rperiodo["FechaFin"]);
strPeriodoNum = rperiodo["Numero"].ToString();
strTipo = DdlTipoPeriodo.SelectedItem.Text;
}
listaTags.Add(new TagsDocumentos("[Empresa]", strEmpresa));
listaTags.Add(new TagsDocumentos("[FechaInicio]", strFechaInicio));
listaTags.Add(new TagsDocumentos("[FechaFin]", strFechaFin));
listaTags.Add(new TagsDocumentos("[Tipo]", strTipo));
listaTags.Add(new TagsDocumentos("[PeriodoNum]", strPeriodoNum));
listaTags.Add(new TagsDocumentos("[Ubicacion]", strUbicacion));
listaTags.Add(new TagsDocumentos("[RegPatImss]", strRegPatImss));
listaTags.Add(new TagsDocumentos("[RFC]", strRFC));
listaTags.Add(new TagsDocumentos("[fecha]", strfecha));
listaTags.Add(new TagsDocumentos("[hora]", strhora));
GemBox.Document.DocumentModel document = GemDocumen.documento;
var section = document.Sections[0];
GemBox.Document.Tables.TableRow row;
GemBox.Document.Tables.Table sobrereciboTable;
GemBox.Document.Tables.Table tconeptos;
GemBox.Document.Paragraph paragraphh;
int CveDepartamento = 0;
string Departamento = "";
GemBox.Document.ParagraphStyle styilo = (GemBox.Document.ParagraphStyle)document.Styles.GetOrAdd(GemBox.Document.StyleTemplateType.Normal);
GemBox.Document.ParagraphStyle styilostrong = (GemBox.Document.ParagraphStyle)document.Styles.GetOrAdd(GemBox.Document.StyleTemplateType.NoSpacing);
//GemBox.Document.Style styilonegrita = GemBox.Document.Style.CreateStyle(GemBox.Document.StyleTemplateType.Strong, document);
//document.Styles.Add(styilonegrita);
foreach (DataRow drow in dtempleados.FiltraParametros("", "", new string[] { "CveDepartamento", "Departamento" }).Rows)
{
CveDepartamento = drow["CveDepartamento"].ToString().ToEntero();
Departamento = drow["Departamento"].ToString();
paragraphh = new GemBox.Document.Paragraph(document, Departamento);
paragraphh.ParagraphFormat.Style = styilostrong;
section.Blocks.Add(paragraphh);
paragraphh = new GemBox.Document.Paragraph(document, "........................................................................................................................................................................");
section.Blocks.Add(paragraphh);
foreach (DataRow drow2 in dtempleados.FiltraParametros(string.Format("CveDepartamento={0}", CveDepartamento)).Rows)
{
sobrereciboTable = new GemBox.Document.Tables.Table(document);
sobrereciboTable.TableFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(100, GemBox.Document.Tables.TableWidthUnit.Percentage);
section.Blocks.Add(sobrereciboTable);
row = new GemBox.Document.Tables.TableRow(document);
sobrereciboTable.Rows.Add(row);
var cell = new GemBox.Document.Tables.TableCell(document);
row.Cells.Add(cell);
/*
string SalarioDiariop = "";
string FechaIngreso = "", Nombre = "", DiasLaborados = "";*/
paragraphh = new GemBox.Document.Paragraph(document, string.Format("{1} : {0}", drow2["Nombre"].ToString(), drow2["Codigo"].ToString())); cell.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilostrong;
paragraphh = new GemBox.Document.Paragraph(document, string.Format("Fecha Ingr:{0:dd/MM/yyyy}, S.D.:{1:N2} ", drow2["FechaIngreso"], drow2["SalarioDiario"])); cell.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
paragraphh = new GemBox.Document.Paragraph(document, string.Format("Días pagados:{0}, Retardos: {1}, Ausencias:{2} ", drow2["DiasPago"], drow2["DiasRetardos"], drow2["DiasFaltados"])); cell.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
row = new GemBox.Document.Tables.TableRow(document);
sobrereciboTable.Rows.Add(row);
cell = new GemBox.Document.Tables.TableCell(document);
row.Cells.Add(cell);
tconeptos = new GemBox.Document.Tables.Table(document);
tconeptos.TableFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(100, GemBox.Document.Tables.TableWidthUnit.Percentage);
cell.Blocks.Add(tconeptos);
GemBox.Document.Tables.TableRow rowx; GemBox.Document.Tables.TableCell cellx;
{
rowx = new GemBox.Document.Tables.TableRow(document);
tconeptos.Rows.Add(rowx);
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Percepción"); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilostrong;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Valor"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Importe"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
}
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilostrong;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Deducción"); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilostrong;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Valor"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Importe"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
}
}
//Percepción Valor Importe Deducción Valor Importe
bool gonext = true;
int cindex = 0;
int CvePersonal = 1;
while (gonext)
{
cindex = cindex + 1;
CvePersonal = drow2["CvePersonal"].ToString().ToEntero();
int CveConcepto; string Concepto = ""; string Codigo = ""; string importe = ""; string valor = "";
rowx = new GemBox.Document.Tables.TableRow(document);
tconeptos.Rows.Add(rowx);
DataRow rowconcept = dtempleadosConceptos.FiltroPrimero(string.Format("CvePersonal={0} AND Tipo =1 AND Fila ={1}", CvePersonal, cindex));
if (rowconcept != null)
{
CveConcepto = rowconcept["CveConcepto"].ToString().ToEntero();
importe = string.Format("${0:N2}", rowconcept["Importe"]);
valor = string.Format("{0:#,###.##}", rowconcept["Valor"]);
Concepto = "";
rowconcept = dtConceptos.FiltroPrimero(string.Format("CveConcepto={0}", CveConcepto));
if (rowconcept != null)
{
Concepto = rowconcept["Concepto"].ToString();
Codigo = rowconcept["Codigo"].ToString();
}
}
else
{
gonext = false;
}
//percepciones
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, Codigo); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, Concepto); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, valor); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, importe); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
}
CveConcepto = 0; Concepto = ""; importe = ""; Codigo = ""; valor = "";
rowconcept = dtempleadosConceptos.FiltroPrimero(string.Format("CvePersonal={0} AND Tipo =2 AND Fila ={1}", CvePersonal, cindex));
if (rowconcept != null)
{
CveConcepto = rowconcept["CveConcepto"].ToString().ToEntero();
importe = string.Format("${0:N2}", rowconcept["Importe"]);
valor = string.Format("{0:#,###.##}", rowconcept["Valor"]);
//string valor = "";
Concepto = "";
rowconcept = dtConceptos.FiltroPrimero(string.Format("CveConcepto={0}", CveConcepto));
if (rowconcept != null)
{
Concepto = rowconcept["Concepto"].ToString();
Codigo = rowconcept["Codigo"].ToString();
}
gonext = true;
}
//deducciones
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, Codigo); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, Concepto); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, valor); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, importe); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
}
}
{
rowx = new GemBox.Document.Tables.TableRow(document);
tconeptos.Rows.Add(rowx);
}
//Total Percepciones y deducciones
{
rowx = new GemBox.Document.Tables.TableRow(document);
tconeptos.Rows.Add(rowx);
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Total Percepciones"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, string.Format("${0:N2}", drow2["SumaPercepciones"])); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
}
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Total Deducciones"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, string.Format("${0:N2}", drow2["SumaDeducciones"])); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
}
}
//Neto a Pagar
{
rowx = new GemBox.Document.Tables.TableRow(document);
tconeptos.Rows.Add(rowx);
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
}
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Neto a Pagar"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, string.Format("${0:N2}", drow2["Total"])); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
}
}
setborderclear(tconeptos);
keeptablesamepage(sobrereciboTable);
}
paragraphh = new GemBox.Document.Paragraph(document, "........................................................................................................................................................................");
section.Blocks.Add(paragraphh);
paragraphh = new GemBox.Document.Paragraph(document, string.Format("Total Departamento {0}", Departamento.ToUpper()));
paragraphh.ParagraphFormat.Style = styilostrong;
section.Blocks.Add(paragraphh);
#region "totaldepto"
{
sobrereciboTable = new GemBox.Document.Tables.Table(document);
sobrereciboTable.TableFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(100, GemBox.Document.Tables.TableWidthUnit.Percentage);
section.Blocks.Add(sobrereciboTable);
row = new GemBox.Document.Tables.TableRow(document);
sobrereciboTable.Rows.Add(row);
var cell = new GemBox.Document.Tables.TableCell(document);
row.Cells.Add(cell);
tconeptos = new GemBox.Document.Tables.Table(document);
tconeptos.TableFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(100, GemBox.Document.Tables.TableWidthUnit.Percentage);
cell.Blocks.Add(tconeptos);
GemBox.Document.Tables.TableRow rowx; GemBox.Document.Tables.TableCell cellx;
//Percepción Valor Importe Deducción Valor Importe
bool gonext = true;
int cindex = 0;
int OrdenP = -999;
int ordenD = -999;
#region "Titulos"
{
rowx = new GemBox.Document.Tables.TableRow(document);
tconeptos.Rows.Add(rowx);
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Percepción"); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilostrong;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Valor"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Importe"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
}
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Deducción"); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilostrong;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Valor"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Importe"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
}
}
#endregion
#region "Titulos"
while (gonext)
{
cindex = cindex + 1;
int CveConcepto; string Concepto = ""; string Codigo = ""; string importe = "";
rowx = new GemBox.Document.Tables.TableRow(document);
tconeptos.Rows.Add(rowx);
DataRow rowconcept;
while ((rowconcept = dtConceptos.FiltroPrimero(string.Format("Orden>{0} AND Tipo ='P'", OrdenP))) != null && importe == "")
{
double sumaimporte = dtempleadosConceptos.SUM("Importe", string.Format("CveDepartamento={0} AND CveConcepto={1}", CveDepartamento, rowconcept["CveConcepto"]));
OrdenP = rowconcept["Orden"].ToString().ToEntero();
if (sumaimporte > 0)
{
CveConcepto = rowconcept["CveConcepto"].ToString().ToEntero();
importe = string.Format("${0:N2}", sumaimporte);
Concepto = rowconcept["Concepto"].ToString();
Codigo = rowconcept["Codigo"].ToString();
}
}
if (importe == "")
{
gonext = false;
}
//percepciones
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, Codigo); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, Concepto); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, importe); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
}
CveConcepto = 0; Concepto = ""; importe = ""; Codigo = "";
while ((rowconcept = dtConceptos.FiltroPrimero(string.Format("Orden>{0} AND Tipo ='D'", ordenD))) != null && importe == "")
{
double sumaimporte = dtempleadosConceptos.SUM("Importe", string.Format("CveDepartamento={0} AND CveConcepto={1}", CveDepartamento, rowconcept["CveConcepto"]));
ordenD = rowconcept["Orden"].ToString().ToEntero();
if (sumaimporte > 0)
{
CveConcepto = rowconcept["CveConcepto"].ToString().ToEntero();
importe = string.Format("${0:N2}", sumaimporte);
Concepto = rowconcept["Concepto"].ToString();
Codigo = rowconcept["Codigo"].ToString();
}
}
if (importe != "")
{
gonext = true;
}
//deducciones
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, Codigo); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, Concepto); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, importe); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
}
}
#endregion
{
rowx = new GemBox.Document.Tables.TableRow(document);
tconeptos.Rows.Add(rowx);
}
{
rowx = new GemBox.Document.Tables.TableRow(document);
tconeptos.Rows.Add(rowx);
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Total Percepciones"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, string.Format("${0:N2}", dtempleados.SUM("SumaPercepciones", string.Format("CveDepartamento={0}", CveDepartamento)))); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
}
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilostrong;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Total Deducciones"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, string.Format("${0:N2}", dtempleados.SUM("SumaDeducciones", string.Format("CveDepartamento={0}", CveDepartamento)))); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
}
}
//no empleados
{
rowx = new GemBox.Document.Tables.TableRow(document);
tconeptos.Rows.Add(rowx);
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Total de empleados"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, string.Format("{0:N0}", dtempleados.COUNT("CvePersonal", string.Format("CveDepartamento={0}", CveDepartamento)))); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
}
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
}
}
//Neto depto
{
rowx = new GemBox.Document.Tables.TableRow(document);
tconeptos.Rows.Add(rowx);
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
}
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Neto del departamento"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, string.Format("${0:N2}", dtempleados.SUM("Total", string.Format("CveDepartamento={0}", CveDepartamento)))); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
}
}
setborderclear(tconeptos);
keeptablesamepage(sobrereciboTable);
}
#endregion
}
paragraphh = new GemBox.Document.Paragraph(document, "TOTAL ");
paragraphh.ParagraphFormat.Style = styilostrong;
section.Blocks.Add(paragraphh);
#region "total"
{
sobrereciboTable = new GemBox.Document.Tables.Table(document);
sobrereciboTable.TableFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(100, GemBox.Document.Tables.TableWidthUnit.Percentage);
section.Blocks.Add(sobrereciboTable);
row = new GemBox.Document.Tables.TableRow(document);
sobrereciboTable.Rows.Add(row);
var cell = new GemBox.Document.Tables.TableCell(document);
row.Cells.Add(cell);
tconeptos = new GemBox.Document.Tables.Table(document);
tconeptos.TableFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(100, GemBox.Document.Tables.TableWidthUnit.Percentage);
cell.Blocks.Add(tconeptos);
GemBox.Document.Tables.TableRow rowx; GemBox.Document.Tables.TableCell cellx;
//Percepción Valor Importe Deducción Valor Importe
bool gonext = true;
int cindex = 0;
int OrdenP = -999;
int ordenD = -999;
//Titulos
{
rowx = new GemBox.Document.Tables.TableRow(document);
tconeptos.Rows.Add(rowx);
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Percepción"); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilostrong;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Valor"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Importe"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
}
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Deducción"); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilostrong;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Valor"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Importe"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
}
}
//conceptos percep,deduc
while (gonext)
{
cindex = cindex + 1;
int CveConcepto; string Concepto = ""; string Codigo = ""; string importe = "";
rowx = new GemBox.Document.Tables.TableRow(document);
tconeptos.Rows.Add(rowx);
DataRow rowconcept;
while ((rowconcept = dtConceptos.FiltroPrimero(string.Format("Orden>{0} AND Tipo ='P'", OrdenP))) != null && importe == "")
{
double sumaimporte = dtempleadosConceptos.SUM("Importe", string.Format(" CveConcepto={0}", rowconcept["CveConcepto"]));
OrdenP = rowconcept["Orden"].ToString().ToEntero();
if (sumaimporte > 0)
{
CveConcepto = rowconcept["CveConcepto"].ToString().ToEntero();
importe = string.Format("${0:N2}", sumaimporte);
Concepto = rowconcept["Concepto"].ToString();
Codigo = rowconcept["Codigo"].ToString();
}
}
if (importe == "")
{
gonext = false;
}
//percepciones
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, Codigo); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, Concepto); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, importe); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
}
CveConcepto = 0; Concepto = ""; importe = ""; Codigo = "";
while ((rowconcept = dtConceptos.FiltroPrimero(string.Format("Orden>{0} AND Tipo ='D'", ordenD))) != null && importe == "")
{
double sumaimporte = dtempleadosConceptos.SUM("Importe", string.Format(" CveConcepto={0}", rowconcept["CveConcepto"]));
ordenD = rowconcept["Orden"].ToString().ToEntero();
if (sumaimporte > 0)
{
CveConcepto = rowconcept["CveConcepto"].ToString().ToEntero();
importe = string.Format("${0:N2}", sumaimporte);
Concepto = rowconcept["Concepto"].ToString();
Codigo = rowconcept["Codigo"].ToString();
}
}
if (importe != "")
{
gonext = true;
}
//deducciones
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, Codigo); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, Concepto); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, importe); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
}
}
{
rowx = new GemBox.Document.Tables.TableRow(document);
tconeptos.Rows.Add(rowx);
}
//Totales perceciones deducciones
{
rowx = new GemBox.Document.Tables.TableRow(document);
tconeptos.Rows.Add(rowx);
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Total Percepciones"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, string.Format("${0:N2}", dtempleados.SUM("SumaPercepciones"))); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
}
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Total Deducciones"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, string.Format("${0:N2}", dtempleados.SUM("SumaDeducciones"))); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
}
}
{
rowx = new GemBox.Document.Tables.TableRow(document);
tconeptos.Rows.Add(rowx);
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Total de empleados general"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, string.Format("{0:N0}", dtempleados.COUNT("CvePersonal"))); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
}
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
}
}
//neto empresa
{
rowx = new GemBox.Document.Tables.TableRow(document);
tconeptos.Rows.Add(rowx);
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
}
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Neto general"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, string.Format("${0:N2}", dtempleados.SUM("Total"))); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
}
}
gonext = true;
int OrdenO = -999;
//basura para espacio
{
rowx = new GemBox.Document.Tables.TableRow(document);
tconeptos.Rows.Add(rowx);
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, " "); cellx.Blocks.Add(paragraphh);
}
rowx = new GemBox.Document.Tables.TableRow(document);
tconeptos.Rows.Add(rowx);
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, " "); cellx.Blocks.Add(paragraphh);
}
}
rowx = new GemBox.Document.Tables.TableRow(document);
tconeptos.Rows.Add(rowx);
{
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
}
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Obligación"); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilostrong;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Importe"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
}
}
while (gonext)
{
cindex = cindex + 1;
int CveConcepto; string Concepto = ""; string Codigo = ""; string importe = "";
rowx = new GemBox.Document.Tables.TableRow(document);
tconeptos.Rows.Add(rowx);
{
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, Codigo); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.ColumnSpan = 2;
paragraphh = new GemBox.Document.Paragraph(document, Concepto); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
//cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
//cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
//paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
//paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, importe); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
}
}
DataRow rowconcept;
while ((rowconcept = dtConceptos.FiltroPrimero(string.Format("Orden>{0} AND Tipo ='O'", OrdenO))) != null && importe == "")
{
double sumaimporte = dtempleadosConceptos.SUM("Valor", string.Format(" CveConcepto={0}", rowconcept["CveConcepto"]));
OrdenO = rowconcept["Orden"].ToString().ToEntero();
if (sumaimporte > 0)
{
CveConcepto = rowconcept["CveConcepto"].ToString().ToEntero();
importe = string.Format("${0:N2}", sumaimporte);
Concepto = rowconcept["Concepto"].ToString();
Codigo = rowconcept["Codigo"].ToString();
}
}
if (importe == "")
{
gonext = false;
}
//Obligaciones
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, Codigo); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, Concepto); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, importe); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
}
}
{
rowx = new GemBox.Document.Tables.TableRow(document);
tconeptos.Rows.Add(rowx);
}
{
rowx = new GemBox.Document.Tables.TableRow(document);
tconeptos.Rows.Add(rowx);
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, " "); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
}
{
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(3, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh);
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(30, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, "Total Obligaciones"); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(6, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, ""); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilo;
cellx = new GemBox.Document.Tables.TableCell(document); rowx.Cells.Add(cellx);
cellx.CellFormat.PreferredWidth = new GemBox.Document.Tables.TableWidth(11, GemBox.Document.Tables.TableWidthUnit.Percentage);
paragraphh = new GemBox.Document.Paragraph(document, string.Format("${0:N2}", dtempleados.SUM("SumaObligaciones"))); cellx.Blocks.Add(paragraphh); paragraphh.ParagraphFormat.Alignment = GemBox.Document.HorizontalAlignment.Right;
paragraphh.ParagraphFormat.Style = styilostrong;
}
}
setborderclear(tconeptos);
keeptablesamepage(tconeptos);
keeptablesamepage(sobrereciboTable);
}
#endregion
GemDocumen.SustituirTags(listaTags);
GemDocumen.GuardarStreamPDF();
//GemDocumen.GuardarStream();
System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(GemDocumen.GetBytesDocumento());
GemDocumen.Dispose();
Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", $"attachment;filename=Lista de Raya.pdf");
//Response.AddHeader("content-disposition", $"attachment;filename=Lista de Raya.docx");
Response.Buffer = true;
memoryStream.WriteTo(Response.OutputStream);
Response.End();
}
catch (Exception e)
{
Extensiones.ModExtensiones.GuardaLog(string.Format("Nomina2(errorLayout):{0} ", e.ToString()));
Alert("No se pudo generar la lista de raya favor de contactar a soporte tecnico.", Extensiones.ModExtensiones.TipoMensaje.ToastError);
}
}
else
{
Alert("No se encontro la plantilla.", Extensiones.ModExtensiones.TipoMensaje.ToastAdventencia);
}
}
else
{
Alert("es necesario calcular el periodo primero.", Extensiones.ModExtensiones.TipoMensaje.ToastAdventencia);
}
}
#region "Gembox"
private void keeptablesamepage(GemBox.Document.Tables.Table table)
{
//Mantener tabla unida
{
// Get all Paragraph formats in a Table element.
IEnumerable<GemBox.Document.ParagraphFormat> formats = table.GetChildElements(true, GemBox.Document.ElementType.TableCell)
.Cast<GemBox.Document.Tables.TableCell>()
.SelectMany(cell =>
{
if (cell.Blocks.Count == 0)
cell.Blocks.Add(new GemBox.Document.Paragraph(cell.Document));
return cell.GetChildElements(true, GemBox.Document.ElementType.Paragraph);
})
.Cast<GemBox.Document.Paragraph>()
.Select(p => p.ParagraphFormat);
// Set KeepLinesTogether and KeepWithNext properties.
foreach (GemBox.Document.ParagraphFormat format in formats)
{
format.KeepLinesTogether = true;
format.KeepWithNext = true;
}
}
}
private void setborderclear(GemBox.Document.Tables.Table table)
{
table.TableFormat.Borders.SetBorders(GemBox.Document.MultipleBorderTypes.All, GemBox.Document.BorderStyle.None, GemBox.Document.Color.Empty, 0);
foreach (var row in table.Rows)
{
foreach (var cell in row.Cells)
{
cell.CellFormat.Borders.ClearBorders();
}
}
}
#endregion
protected void LnkListaRaya_Click(object sender, EventArgs e)
{
ImprimirReporte();
}
#region Movtos Permanentes
protected void CargaTipoConcepto()
{
//DdlTipo.Items.Insert(0, new ListItem("Percepciones", "P"));
//DdlTipo.Items.Insert(1, new ListItem("Deducciones", "D"));
//DdlTipo.Items.Insert(2, new ListItem("Obligaciones", "O"));
//DdlTipo.SelectedValueExist("-1");
CargaConcepto();
}
protected void CargaConcepto()
{
DdlConcepto.Items.Clear();
if (DdlTipo.SelectedValue == "-1")
{
DdlConcepto.DataSource = get_GlobalDTNomConceptos(UsuarioActual.CveEmpresa);
}
else
{
DdlConcepto.DataSource = get_GlobalDTNomConceptos(UsuarioActual.CveEmpresa).FiltraParametros(string.Format("Tipo ='{0}'", DdlTipo.SelectedValue));
}
DdlConcepto.DataBind();
DdlConcepto.Items.Insert(0, new ListItem("Seleccione", "-1"));
DdlConcepto.SelectedValueExist("-1");
}
private void CargaMovtoPermanente()
{
using (ClsNominas ObjMovt = new ClsNominas())
{
ObjMovt.GetMovtoPermanente(UsuarioActual.CveEmpresa, SRCvePersonal);
GVMovtoPermanente.DataSource = ObjMovt.DtResultados;
}
GVMovtoPermanente.DataBind();
UpMovtosPermanentes.Update();
}
protected void DdlTipo_SelectedIndexChanged(object sender, EventArgs e)
{
CargaConcepto();
}
protected void LnkAddMovtoPermanente_Click(object sender, EventArgs e)
{
CargaConcepto();
DdlTipoDescto_SelectedIndexChanged(null, null);
pnlAddupMovto.Visible = true;
LnkAddMovto.Visible = true;
LnkUpMovto.Visible = false;
LtlMovtoPermanenteaddup.Text = "Agregar Movimiento";
TxtDescripcion.Text = "";
TxtValor.Text = "";
TxtVecesAplicar.Text = "";
TxtMontoLimite.Text = "";
TxtFechaAplicacion.Text = "";
ChkEstatus.Visible = true;
}
protected void LnkAddMovto_Click(object sender, EventArgs e)
{
int cveConcepto = DdlConcepto.SelectedValue.ToEntero();
string descripcion = TxtDescripcion.Text;
int tipoDescuento = DdlTipoDescto.SelectedValue.ToEntero();
double valor = TxtValor.Text.ToDouble();
int vecesAplicar = TxtVecesAplicar.Text.ToEntero();
decimal montoLimite = TxtMontoLimite.Text.ToDecimal();
string fechaInicioAplicacion = TxtFechaAplicacion.Text.ToDate().ToString("yyyy/MM/dd");
bool estatus = ChkEstatus.Checked;
bool Continuar;
using (ClsNominas ObjMovt = new ClsNominas())
{
Continuar = ObjMovt.AddMovtoPermanente(cveConcepto, SRCvePersonal, descripcion, tipoDescuento, valor, vecesAplicar, montoLimite, fechaInicioAplicacion, estatus);
}
if (Continuar)
{
this.RegistraScript("$('#DModalMovtoPermanente').modal('hide');");
CargaMovtoPermanente();
UpMovtosPermanentes.Update();
this.Alert("El Movto_Permanente Se ha agregado");
}
}
protected void LnkUpMovto_Click(object sender, EventArgs e)
{
int cveConcepto = DdlConcepto.SelectedValue.ToEntero();
string descripcion = TxtDescripcion.Text;
int tipoDescuento = DdlTipoDescto.SelectedValue.ToEntero();
double valor = TxtValor.Text.ToDouble();
int vecesAplicar = TxtVecesAplicar.Text.ToEntero();
decimal montoLimite = TxtMontoLimite.Text.ToDecimal();
string fechaInicioAplicacion = TxtFechaAplicacion.Text.ToDate().ToString("yyyy/MM/dd");
bool estatus = ChkEstatus.Checked;
bool Continuar;
using (ClsNominas ObjMovt = new ClsNominas())
{
Continuar = ObjMovt.UpMovtoPermanente(CcveMovtoPermanente, cveConcepto, SRCvePersonal, descripcion, tipoDescuento, valor, vecesAplicar, montoLimite, fechaInicioAplicacion, estatus);
}
if (Continuar)
{
this.RegistraScript("$('#DModalMovtoPermanente').modal('hide');");
CargaMovtoPermanente();
UpMovtosPermanentes.Update();
this.Alert("El Movto_Permanente Se ha agregado");
}
}
protected void DdlTipoDescto_SelectedIndexChanged(object sender, EventArgs e)
{
pnlMonto.Visible = DdlTipoDescto.SelectedValue.ToEntero() > 2;
pnlVecesAplicar.Visible = DdlTipoDescto.SelectedValue.ToEntero() < 3;
}
protected void LnkEditarMovtoPermanente_Click(object sender, EventArgs e)
{
GridViewRow gvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
CcveMovtoPermanente = gvRow.DataKey("CveMovtoPermanente").ToEntero();
int cveConcepto = gvRow.DataKey("CveConcepto").ToEntero();
int cvePersonal = gvRow.DataKey("CvePersonal").ToEntero();
string descripcion = gvRow.DataKey("Descripcion");
int tipoDescuento = gvRow.DataKey("TipoDescuento").ToEntero();
double valor = gvRow.DataKey("Valor").ToDouble();
int vecesAplicar = gvRow.DataKey("VecesAplicar").ToEntero();
decimal montoLimite = gvRow.DataKey("MontoLimite").ToDecimal();
DateTime fechaInicioAplicacion = gvRow.DataKey("FechaInicioAplicacion").ToDate();
bool estatus = gvRow.DataKey("Estatus") == "1" || gvRow.DataKey("Estatus").ToUpper() == "TRUE";
DateTime fechaRegistro = gvRow.DataKey("FechaRegistro").ToDateTime();
string tipo = "P";
DataRow drow = get_GlobalDTNomConceptos(UsuarioActual.CveEmpresa).FiltroPrimero(string.Format("Tipo ='{0}'", cveConcepto));
if (drow != null)
{
tipo = drow["Tipo"].ToString();
DdlTipo.SelectedValueExist(tipo);
DdlTipo_SelectedIndexChanged(null, null);
}
DdlConcepto.SelectedValueExist(cveConcepto);
TxtDescripcion.Text = descripcion.ToString();
DdlTipoDescto.SelectedValueExist(tipoDescuento.ToString());
DdlTipoDescto_SelectedIndexChanged(null, null);
TxtValor.Text = valor.ToString();
TxtVecesAplicar.Text = vecesAplicar.ToString();
TxtMontoLimite.Text = montoLimite.ToString();
TxtFechaAplicacion.Text = $"{fechaInicioAplicacion:dd/MM/yyyy}";
ChkEstatus.Checked = estatus;
this.RegistraScript("$('#DModalMovtoPermanente').modal();");
pnlAddupMovto.Visible = true;
LnkAddMovto.Visible = false;
LnkUpMovto.Visible = true;
UpMovtosPermanentes.Update();
}
#endregion
protected void LnkGuardarFonacot_Click(object sender, EventArgs e)
{
double importe = TxtFonValor.Text.ToDouble();
int TipoAplicacion = DdlFonTipoAplicacion.SelectedValue.ToEntero();
int NoPagos = 0;
double SaldoIni = 0;
string descripcion02 = TxtFonDescripcion.Text;
string descripcion01 = TxtFonNumCredito.Text;
string fecha = TxtFonFechaInicio.Text.Replace("_", "");
int estatus = ChkFonacot.Checked ? 1 : 0;
if (fecha.Length > 8)
fecha = fecha.ToDateTime().ToString("yyyy/MM/dd");
else
fecha = "";
bool continuar = true;
using (ClsRH ObjPersonal = new ClsRH())
{
if (!ObjPersonal.AddConcepto(SRCvePersonal, -1, importe, TipoAplicacion, NoPagos, SaldoIni, UsuarioActual.CveUsuario, 4, descripcion01, descripcion02, fecha, "", estatus, UsuarioActual.CveEmpresa))
continuar = false;
}
if (continuar)
{
LnkConsultar_Click(null, null);
mostrarConceptos();
Alert("Se actualizo el calculo de fonacot");
}
}
protected void LnkAutorizar_Click(object sender, EventArgs e)
{
autorizarNomina(-1);
}
private void autorizarNomina(int FiltroCvePersonal)
{
bool continuar = true;
DataTable dtr = dtempleados.FiltraParametros(string.Format("(CvePersonal={0} OR {0}=-1) AND CvePersonal > 0 AND NomAutorizado =0", FiltroCvePersonal), "", new string[] { "CvePersonal", "CveMetodoPago" });
DataTable dtconp = null;
int CvePeriodoSeleccionado = DdlPeriodo.SelectedValue.ToEntero();//cambiar reparar
#region PropNomina
int CvePersonal = 0;
int CveNomina = 0;
int CveMetodoPago = 0;
double Total = 0;
int CveMoneda = 1;
#endregion
#region PropNominaDetalle
int CveConcepto = 0;
decimal ImporteConcepto = 0, ImporteGravadoConcepto = 0, ImporteExentoConcepto = 0;
#endregion
using (ClsNominas objNomina = new ClsNominas())
{
objNomina.IniciaTransacSQL();
foreach (DataRow rtemp in dtr.Rows)
{
CveNomina = 0;
CvePersonal = rtemp["CvePersonal"].ToString().ToEntero();
CveMetodoPago = rtemp["CveMetodoPago"].ToString().ToEntero();
Total = 0;//cambiar reparar
if (CvePersonal > 0)
{
if (continuar)
{
if (objNomina.GetNom_Nominas(-1, CvePersonal, CvePeriodoSeleccionado, -1, UsuarioActual.CveEmpresa))
{
if (objNomina.DtResultados.Rows.Count > 0)
{
CveNomina = objNomina.CveNomina;
}
else
{
if (objNomina.AddNom_Nominas(-1, 1, CvePersonal, CvePeriodoSeleccionado, Total, 0, 0, Total, CveMoneda, 1, CveMetodoPago, DateTime.Now, "Deducciones nómina",
"", "", "", "", 0, 0, 0, new DateTime(), new DateTime(), new DateTime(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa))
{
CveNomina = objNomina.CveNomina;
}
else
{
continuar = false;
}
}
}
}
if (CveNomina == 0)
{
continuar = false;
}
if (continuar)
{
dtconp = dtempleadosConceptos.FiltraParametros(string.Format("CvePersonal={0} AND Importe<>0", CvePersonal));
foreach (DataRow rcon in dtconp.Rows)
{
CveConcepto = rcon["CveConcepto"].ToString().ToEntero();
ImporteConcepto = rcon["Importe"].ToString().ToDecimal();
ImporteGravadoConcepto = rcon["ImporteGravado"].ToString().ToDecimal();
ImporteExentoConcepto = ImporteConcepto - ImporteGravadoConcepto;
if (continuar)
{
if (!objNomina.AddUPNom_NominasDetalles(CveNomina, CvePeriodoSeleccionado, CvePersonal, CveConcepto, ImporteConcepto, ImporteGravadoConcepto, ImporteExentoConcepto, UsuarioActual.CveUsuario))
{
continuar = false;
}
}
}
}
}
}
if (continuar)
{
continuar = objNomina.AutorizaNom_Nominas(-1, CvePeriodoSeleccionado, true);
}
if (continuar)
{
objNomina.Commit();
Alert("La nomina se autorizó correctamente.");
cargaDatos();
}
else
{
objNomina.RollBack();
}
}
if (dtr != null)
{
dtr.Dispose();
}
if (dtconp != null)
{
dtconp.Dispose();
}
}
protected void LnkCargaAsistenciaMasiva_Click(object sender, EventArgs e)
{
RegistraScript("$('#DModalCargaASistenciaMasiva').modal();");
}
protected void LnkCargarAsistenciaMasiva_Click(object sender, EventArgs e)
{
using (ClsRH ObjPersonal = new ClsRH())
{
ObjPersonal.IniciaTransacSQL();
bool OcurrioError = false;
if (!ObjPersonal.AddAsistenciaMasiva2(DdlPeriodoCM.SelectedValue.ToEntero(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa))
OcurrioError = true;
if (OcurrioError)
{
ObjPersonal.RollBack();
Alert("Ocurrió un error al guardar las Asistencias.", ModExtensiones.TipoMensaje.MsgError);
}
else
{
ObjPersonal.Commit();
Alert("Las Asistencias se guardaron correctamente.", ModExtensiones.TipoMensaje.ToastInformacion);
}
}
}
private void cargaPeriodosCM()
{
int tipoPeriodo = DdlTipoPeriodoCM.SelectedValue.ToEntero();
int ejercicio = DdlEjerciciosCM.SelectedValue.ToEntero();
DataTable dtPeriodos = null;
if (tipoPeriodo > 0)
{
using (ClsNominas objperiodos = new ClsNominas())
{
if (objperiodos.GetPeriodos(tipoPeriodo, UsuarioActual.CveEmpresa, ejercicio, -1, -1))
{
dtPeriodos = objperiodos.DtResultados;
}
}
}
DdlPeriodoCM.DataSource = dtPeriodos;
DdlPeriodoCM.DataBind();
DdlPeriodoCM.Items.Insert(0, new ListItem("Seleccione", "-1"));
UpModalAsistenciaMasiva.Update();
}
protected void DdlEjerciciosCM_SelectedIndexChanged(object sender, EventArgs e)
{
cargaPeriodosCM();
}
protected void DdlTipoPeriodoCM_SelectedIndexChanged(object sender, EventArgs e)
{
cargaPeriodosCM();
}
protected void LnkGuardarASistencia_Click(object sender, EventArgs e)
{
int CvePersonal = TxtasiscvePersonal.Text.ToEntero();
DateTime fecha = TxtasisFecha.Text.ToDate();
using (ClsRH objpersonal = new ClsRH())
{
if (objpersonal.AddAsistencia(CvePersonal, -1, -1, fecha, DdlTipoAsistencias.SelectedValue.ToEntero(), TxtPorPago.Text.Trim().ToDouble(), TxtHorasDobles.Text.Trim().ToDouble(),
TxtHorasTriples.Text.Trim().ToDouble(), DdlMotivoHoraExtra.SelectedValue.ToEntero(), TxtObservaciones.Text.Trim(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa))
{
}
Alert("se ha guardado la asistencia satisfactoriamente");
}
}
protected void btnasis_Click(object sender, EventArgs e)
{
int CvePersonal = TxtasiscvePersonal.Text.ToEntero();
DateTime fecha = TxtasisFecha.Text.ToDate();
DataRow drow = dtempleados.FiltroPrimero(string.Format("CvePersonal={0}", CvePersonal));
TxtPersonal.Text = drow["nombre"].ToString();
if (DdlTipoAsistencias.Items.Count == 1)
{
DdlTipoAsistencias.DataSource = GlobalDTAsistenciasInasistencias.FiltraParametros(string.Format("CveEmpresa = {0}", UsuarioActual.CveEmpresa));
DdlTipoAsistencias.DataBind();
}
if (DdlMotivoHoraExtra.Items.Count == 1)
{
DdlMotivoHoraExtra.DataSource = GlobalDTMotivosHorasExtras.FiltraParametros(string.Format("CveEmpresa = {0}", UsuarioActual.CveEmpresa));
DdlMotivoHoraExtra.DataBind();
}
using (ClsRH objpersonal = new ClsRH())
{
if (objpersonal.GetAsistencias(CvePersonal, -1, -1, -1, -1, -1, fecha, fecha, UsuarioActual.CveEmpresa))
{
if (objpersonal.DtResultados.Rows.Count > 0)
{
DataRow dr = objpersonal.DtResultados.Rows[0];
DdlTipoAsistencias.SelectedValueExist(dr["CveAsistenciasInasistencias"].ToString());
TxtPorPago.Text = dr["PorcentajePago"].ToString();
TxtHorasDobles.Text = dr["HorasDobles"].ToString();
TxtHorasTriples.Text = dr["HorasTriples"].ToString();
DdlMotivoHoraExtra.SelectedValueExist(dr["CveMotivoHoraExtra"].ToString());
TxtPorPago.Text = dr["Observacion"].ToString();
// CveAsistenciasInasistencias
// PorcentajePago
// HorasDobles
// HorasTriples
//CveMotivoHoraExtra
//Observacion
//
}
}
}
RegistraScript("$('#DModalModAsistencia').modal();");
}
protected void LnkSimulador_Click(object sender, EventArgs e)
{
GvConceptossimulador.DataSource = new DataTable();
GvConceptossimulador.DataBind();
RegistraScript("$('#DSimulador').modal()");
UpSimulador.Update();
}
protected void LnkSimularXNeto_Click(object sender, EventArgs e)
{
int CveProyecto = -1;
int CveSubProyecto = 1;
int CveTurno = -1;
int CvePeriodo = 12551;
int CveEmpresa = UsuarioActual.CveEmpresa;
int Agrupador = -1;
decimal Neto = TxtNetoaPagar.Text.ToDecimal();
decimal NetoSimulado = 0;
decimal SDI = (Neto * 1.25M) / 15;
decimal SDIOLD = 0;
decimal sumador = 100;
decimal multiplicador = 1;
bool ismayor = false;
bool isfirst = true;
bool continuarV = true;
DataTable dtPeriodo = new DataTable();
DataTable dtasistencia = new DataTable();
DataTable dtConceptos = new DataTable();
DataTable dtempleados = new DataTable();
DataTable dtempleadosConceptos = new DataTable();
bool continuar = false;
using (ClsNominas objnom = new ClsNominas())
{
while (Neto != NetoSimulado && continuarV)
{
if (objnom.GetNominaEmpleadoSimulador(CveProyecto, CveSubProyecto, CveTurno, CvePeriodo, CveEmpresa, Agrupador, SDI) && objnom.DTSetResultados.Tables.Count > 1)
{
dtempleados = objnom.DTSetResultados.Tables[3];
dtempleadosConceptos = objnom.DTSetResultados.Tables[4];
dtConceptos = objnom.DTSetResultados.Tables[0];
dtPeriodo = objnom.DTSetResultados.Tables[1];
dtasistencia = objnom.DTSetResultados.Tables[2];
continuar = true;
NetoSimulado = dtempleados.SUM("Total", string.Format("CvePersonal = {0}", 1)).ToString().ToDecimal();
}
if (continuar)
{
if (isfirst)
{
if (Neto > NetoSimulado)
{
ismayor = true;
}
else
{
ismayor = false;
}
isfirst = false;
}
else
{
if (!((Neto > NetoSimulado) == ismayor))
{
SDI = SDIOLD;
sumador = sumador * 0.1M;
if (sumador < .00000001M)
{
continuarV = false;
}
}
}
multiplicador = (Neto > NetoSimulado) ? 1 : -1;
SDIOLD = SDI;
SDI = SDI + (multiplicador * sumador);
}
else
{
continuarV = false;
}
}
}
if (continuar)
{
{
DataTable dtper = dtConceptos.FiltraParametros("Tipo IN ('P') AND EsPadre = 1 ");
DataTable dtded = dtConceptos.FiltraParametros("Tipo IN ('D') AND EsPadre = 1 ");
dtper.Columns.Add("BorradoLogico", typeof(int));
dtded.Columns.Add("BorradoLogico", typeof(int));
foreach (DataRow row in dtper.Rows)
{
int BorradoLogico = 0;
int CveConcepto = row["CveConcepto"].ToString().ToEntero();
if (!(dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) > 0))
{
BorradoLogico = 1;
}
row["BorradoLogico"] = BorradoLogico;
}
dtper.AcceptChanges();
foreach (DataRow row in dtded.Rows)
{
int BorradoLogico = 0;
int CveConcepto = row["CveConcepto"].ToString().ToEntero();
if (!(dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) > 0))
{
BorradoLogico = 1;
}
row["BorradoLogico"] = BorradoLogico;
}
dtded.AcceptChanges();
dtper = dtper.FiltraParametros("BorradoLogico=0");
dtded = dtded.FiltraParametros("BorradoLogico=0");
int maxper = dtper.Rows.Count;
int maxded = dtded.Rows.Count;
int i = 0;
List<NConcepto> lconc = new List<NConcepto>();
for (i = 0; i < maxper || i < maxded; i++)
{
NConcepto nConcepto = new NConcepto();
DataRow row;
if (maxper > i)
{
row = dtper.Rows[i];
int CveConcepto = row["CveConcepto"].ToString().ToEntero();
string Concepto = row["Concepto"].ToString();
string Codigo = row["Codigo"].ToString();
//bool visible = (dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) > 0);
double Importe = dtempleados.SUM(string.Format("[V_{0}]", CveConcepto), string.Format("CvePersonal = {0}", 1));
nConcepto.CveConceptoP = CveConcepto;
nConcepto.ConceptoP = Concepto;
nConcepto.NoConceptoP = Codigo;
nConcepto.ImporteP = Importe;
nConcepto.ValorP = dtempleados.SUM(string.Format("[VAL_{0}]", CveConcepto), string.Format("CvePersonal = {0}", 1));
}
if (maxded > i)
{
row = dtded.Rows[i];
int CveConcepto = row["CveConcepto"].ToString().ToEntero();
string Concepto = row["Concepto"].ToString();
string Codigo = row["Codigo"].ToString();
//bool visible = (dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) > 0);
double Importe = dtempleados.SUM(string.Format("[V_{0}]", CveConcepto), string.Format("CvePersonal = {0}", 1));
nConcepto.CveConceptoD = CveConcepto;
nConcepto.ConceptoD = Concepto;
nConcepto.NoConceptoD = Codigo;
nConcepto.ImporteD = Importe;
nConcepto.ValorD = dtempleados.SUM(string.Format("[VAL_{0}]", CveConcepto), string.Format("CvePersonal = {0}", 1));
}
lconc.Add(nConcepto);
}
lconc.Add(new NConcepto());
NConcepto SubTotales = new NConcepto();
SubTotales.CveConceptoP = 0;
SubTotales.ConceptoP = "Total Percepciones";
SubTotales.EstatusP = -2;
SubTotales.ImporteP = dtempleados.SUM("SumaPercepciones", string.Format("CvePersonal = {0}", 1));
///Alert(SubTotales.ImporteP.ToString());
SubTotales.CveConceptoD = 0;
SubTotales.ConceptoD = "Total Deducciones";
SubTotales.EstatusD = -2;
SubTotales.ImporteD = dtempleados.SUM("SumaDeducciones", string.Format("CvePersonal = {0}", 1));
//NConcepto Totales = new NConcepto();
//Totales.CveConceptoD = 0;
//Totales.ConceptoD = "Total";
//Totales.EstatusD = -3;
//Totales.ImporteD = dtempleados.SUM("Total", string.Format("CvePersonal = {0}", 1));
lconc.Add(SubTotales);
//lconc.Add(Totales);
GvConceptossimulador.DataSource = lconc;
GvConceptossimulador.DataBind();
}
}
UpSimulador.Update();
}
protected void DdlTipoPeriodoSim_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void LnkDownArchivosSua_Click(object sender, EventArgs e)
{
TxtFechaInicio.Text = DateTime.Now.AddDays(DateTime.Now.Day - 1).ToString("dd/MM/yyy");
TXTFechaFin.Text = DateTime.Now.AddDays(DateTime.Now.Day - 1).AddMonths(1).AddDays(-1).ToString("dd/MM/yyy");
RegistraScript("$('#DmodalGetSua').modal();");
UpModalGetSUA.Update();
}
protected void LnkGetTxtsSUA_Click(object sender, EventArgs e)
{
string concater = "";
string MovtosAfil = "";
string MovtosmodSalario = "";
string movtosBajas = "";
using (ClsRH ObjPersonal = new ClsRH())
{
if (ObjPersonal.GetMovimientosToSUA(UsuarioActual.CveEmpresa, TxtFechaInicio.Text.ToDate().ToString("yyyy/MM/dd"), TXTFechaFin.Text.ToDate().ToString("yyyy/MM/dd")))
{
//01: MovtosAfil
concater = "";
foreach (var item in ObjPersonal.DtResultados.Select("Tipo=1"))
{
MovtosAfil = string.Format("{0}{1}{2}", MovtosAfil, concater, item["Movtotxt"]);
concater = "\\r\\n";
}
//02: MovtosmodSalario
concater = "";
foreach (var item in ObjPersonal.DtResultados.Select("Tipo=2"))
{
MovtosmodSalario = string.Format("{0}{1}{2}", MovtosmodSalario, concater, item["Movtotxt"]);
concater = "\\r\\n";
}
//03: movtosBajas
concater = "";
foreach (var item in ObjPersonal.DtResultados.Select("Tipo=3"))
{
movtosBajas = string.Format("{0}{1}{2}", movtosBajas, concater, item["Movtotxt"]);
concater = "\\r\\n";
}
}
RegistraScript(string.Format("SaveCsv(\"MovtosAfil.txt\", '{0}');SaveCsv(\"MovtosmodSalario.txt\", '{1}');SaveCsv(\"movtosBajas.txt\", '{2}');", MovtosAfil.Replace("'", "\\'"), MovtosmodSalario.Replace("'", "\\'"), movtosBajas.Replace("'", "\\'")));
RegistraScript("$('#DmodalGetSua').modal('hide');");
}
}
protected void LnkUpSuamodal_Click(object sender, EventArgs e)
{
TxtArchivoSua.Text = "";
GVProcesarSUA.DataSource = null;
GVProcesarSUA.DataBind();
RegistraScript("$('#DmodalCompareSua').modal();shownew();");
UpArchivoSua.Update();
}
protected void LnkUpSuaFile_Click(object sender, EventArgs e)
{
string fileurl = "";
GVProcesarSUA.DataSource = null;
Files archivos = TxtArchivoSua.getfiles();
if (archivos.Archivos.Count > 0)
{
fileurl = archivos.Archivos[0].FileUrl;
string SuaFiletext = System.IO.File.ReadAllText(fileurl, Encoding.GetEncoding("iso-8859-1"));
using (ClsNominas ObjPersonal = new ClsNominas())
{
if (ObjPersonal.ProcesarSUA(SuaFiletext, UsuarioActual.CveEmpresa))
{
if (ObjPersonal.DTSetResultados.Tables.Count > 4)
{
DateTime dateperiodo;
DateTime.TryParseExact(string.Format("{0}01", ObjPersonal.DTSetResultados.Tables[1].Rows[0]["Periodo"]), "yyyyMMdd", new System.Globalization.CultureInfo("es-MX"), System.Globalization.DateTimeStyles.None, out dateperiodo);
LtlPeriodo.Text = dateperiodo.Date.ToString("MMMM yyyy", new System.Globalization.CultureInfo("es-MX"));
DtSuaProcesado = ObjPersonal.DTSetResultados.Tables[3];
GVProcesarSUA.DataSource = ObjPersonal.DTSetResultados.Tables[3];
}
}
}
}
GVProcesarSUA.DataBind();
TxtArchivoSua.Text = "";
RegistraScript("showResult();");
UpArchivoSua.Update();
}
protected void GVProcesarSUA_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string SalarioSUA = string.Format("{0:N2}", e.Row.DataKey("SalarioSUA").ToDecimal());
string SalarioSIG = string.Format("{0:N2}", e.Row.DataKey("SalarioSIG").ToDecimal());
int celda = 1;
if (SalarioSUA != SalarioSIG)
{
e.Row.Cells[celda].CssClass = "cellFail";
e.Row.Cells[celda + 1].CssClass = "cellFail";
}
celda = celda + 2;
string CuotaFijaSUA = string.Format("{0:N2}", e.Row.DataKey("CuotaFijaSUA").ToDecimal());
string CuotaFijaSIG = string.Format("{0:N2}", e.Row.DataKey("CuotaFijaSIG").ToDecimal());
if (CuotaFijaSUA != CuotaFijaSIG)
{
e.Row.Cells[celda].CssClass = "cellFail";
e.Row.Cells[celda + 1].CssClass = "cellFail";
}
celda = celda + 2;
string CuotaExcedenteSUA = string.Format("{0:N2}", e.Row.DataKey("CuotaExcedenteSUA").ToDecimal());
string CuotaExcedenteSIG = string.Format("{0:N2}", e.Row.DataKey("CuotaExcedenteSIG").ToDecimal());
if (CuotaExcedenteSUA != CuotaExcedenteSIG)
{
e.Row.Cells[celda].CssClass = "cellFail";
e.Row.Cells[celda + 1].CssClass = "cellFail";
}
celda = celda + 2;
string PrestacionesDineroSUA = string.Format("{0:N2}", e.Row.DataKey("PrestacionesDineroSUA").ToDecimal());
string PrestacionesSIG = string.Format("{0:N2}", e.Row.DataKey("PrestacionesSIG").ToDecimal());
if (PrestacionesDineroSUA != PrestacionesSIG)
{
e.Row.Cells[celda].CssClass = "cellFail";
e.Row.Cells[celda + 1].CssClass = "cellFail";
}
celda = celda + 2;
string GastosMedPenSUA = string.Format("{0:N2}", e.Row.DataKey("GastosMedPenSUA").ToDecimal());
string GastosMedicosSIG = string.Format("{0:N2}", e.Row.DataKey("GastosMedicosSIG").ToDecimal());
if (GastosMedPenSUA != GastosMedicosSIG)
{
e.Row.Cells[celda].CssClass = "cellFail";
e.Row.Cells[celda + 1].CssClass = "cellFail";
}
celda = celda + 2;
string RiesgosdeTrabajoSUA = string.Format("{0:N2}", e.Row.DataKey("RiesgosdeTrabajoSUA").ToDecimal());
string RiesgoTrabajoSIG = string.Format("{0:N2}", e.Row.DataKey("RiesgoTrabajoSIG").ToDecimal());
if (RiesgosdeTrabajoSUA != RiesgoTrabajoSIG)
{
e.Row.Cells[celda].CssClass = "cellFail";
e.Row.Cells[celda + 1].CssClass = "cellFail";
}
celda = celda + 2;
string InvalidezyVidaSUA = string.Format("{0:N2}", e.Row.DataKey("InvalidezyVidaSUA").ToDecimal());
string InvalidezyVidaSIG = string.Format("{0:N2}", e.Row.DataKey("InvalidezyVidaSIG").ToDecimal());
if (InvalidezyVidaSUA != InvalidezyVidaSIG)
{
e.Row.Cells[celda].CssClass = "cellFail";
e.Row.Cells[celda + 1].CssClass = "cellFail";
}
celda = celda + 2;
string GuarderiaSUA = string.Format("{0:N2}", e.Row.DataKey("GuarderiaSUA").ToDecimal());
string GuarderiaSIG = string.Format("{0:N2}", e.Row.DataKey("GuarderiaSIG").ToDecimal());
if (GuarderiaSUA != GuarderiaSIG)
{
e.Row.Cells[celda].CssClass = "cellFail";
e.Row.Cells[celda + 1].CssClass = "cellFail";
}
celda = celda + 2;
string RetiroSUA = string.Format("{0:N2}", e.Row.DataKey("RetiroSUA").ToDecimal());
string RetiroSIG = string.Format("{0:N2}", e.Row.DataKey("RetiroSIG").ToDecimal());
if (RetiroSUA != RetiroSIG)
{
e.Row.Cells[celda].CssClass = "cellFail";
e.Row.Cells[celda + 1].CssClass = "cellFail";
}
}
}
protected void LnkDownExcelSua_Click(object sender, EventArgs e)
{
ClosedXML.Excel.XLWorkbook wb = new ClosedXML.Excel.XLWorkbook();
var libro = wb.AddWorksheet("SUA");
int Fila = 1;
libro.Column(1).Width = 50;
ClosedXML.Excel.IXLRange range = libro.Range(Fila, 2, Fila, 3);
range.Merge();
range.Value = "Salario";
range = libro.Range(Fila, 4, Fila, 5);
range.Merge();
range.Value = "Cuota Fija";
range = libro.Range(Fila, 6, Fila, 7);
range.Merge();
range.Value = "Cuota Excedente";
range = libro.Range(Fila, 8, Fila, 9);
range.Merge();
range.Value = "Prestaciones en Dinero";
range = libro.Range(Fila, 10, Fila, 11);
range.Merge();
range.Value = "Gastos Medicos";
range = libro.Range(Fila, 12, Fila, 13);
range.Merge();
range.Value = "Riesgos de Trabajo";
range = libro.Range(Fila, 14, Fila, 15);
range.Merge();
range.Value = "Invalidez y Vida";
range = libro.Range(Fila, 16, Fila, 17);
range.Merge();
range.Value = "Guarderia";
range = libro.Range(Fila, 18, Fila, 19);
range.Merge();
range.Value = "Retiro";
Fila = Fila + 1;
libro.Cell(Fila, 1).Value = "Empleado";
libro.Cell(Fila, 2).Value = "SUA"; //SalarioSUA
libro.Cell(Fila, 3).Value = "SIG";//SalarioSIG
libro.Cell(Fila, 4).Value = "SUA";//CuotaFijaSUA
libro.Cell(Fila, 5).Value = "SIG";//CuotaFijaSIG
libro.Cell(Fila, 6).Value = "SUA";//CuotaExcedenteSUA
libro.Cell(Fila, 7).Value = "SIG";//CuotaExcedenteSIG
libro.Cell(Fila, 8).Value = "SUA";//PrestacionesDineroSUA
libro.Cell(Fila, 9).Value = "SIG";//PrestacionesSIG
libro.Cell(Fila, 10).Value = "SUA";//GastosMedPenSUA
libro.Cell(Fila, 11).Value = "SIG";//GastosMedicosSIG
libro.Cell(Fila, 12).Value = "SUA";//RiesgosdeTrabajoSUA
libro.Cell(Fila, 13).Value = "SIG";//RiesgoTrabajoSIG
libro.Cell(Fila, 14).Value = "SUA";//InvalidezyVidaSUA
libro.Cell(Fila, 15).Value = "SIG";//InvalidezyVidaSIG
libro.Cell(Fila, 16).Value = "SUA";//GuarderiaSUA
libro.Cell(Fila, 17).Value = "SIG";//GuarderiaSIG
libro.Cell(Fila, 18).Value = "SUA";//RetiroSUA
libro.Cell(Fila, 19).Value = "SIG";//RetiroSIG
libro.Cell(1, 1).Style.Font.FontColor = ClosedXML.Excel.XLColor.White;
libro.Cell(1, 1).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189));
libro.Row(1).CellsUsed().Style.Font.FontColor = ClosedXML.Excel.XLColor.White;
libro.Row(1).CellsUsed().Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189));
libro.Row(2).CellsUsed().Style.Font.FontColor = ClosedXML.Excel.XLColor.White;
libro.Row(2).CellsUsed().Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189));
foreach (DataRow erow in DtSuaProcesado.Rows)
{
Fila++;
libro.Cell(Fila, 1).Value = erow["CodigoNombreCompleto"];
libro.Cell(Fila, 2).Value = string.Format("{0:N2}", erow["SalarioSUA"]);
libro.Cell(Fila, 3).Value = string.Format("{0:N2}", erow["SalarioSIG"]);
libro.Cell(Fila, 4).Value = string.Format("{0:N2}", erow["CuotaFijaSUA"]);
libro.Cell(Fila, 5).Value = string.Format("{0:N2}", erow["CuotaFijaSIG"]);
libro.Cell(Fila, 6).Value = string.Format("{0:N2}", erow["CuotaExcedenteSUA"]);
libro.Cell(Fila, 7).Value = string.Format("{0:N2}", erow["CuotaExcedenteSIG"]);
libro.Cell(Fila, 8).Value = string.Format("{0:N2}", erow["PrestacionesDineroSUA"]);
libro.Cell(Fila, 9).Value = string.Format("{0:N2}", erow["PrestacionesSIG"]);
libro.Cell(Fila, 10).Value = string.Format("{0:N2}", erow["GastosMedPenSUA"]);
libro.Cell(Fila, 11).Value = string.Format("{0:N2}", erow["GastosMedicosSIG"]);
libro.Cell(Fila, 12).Value = string.Format("{0:N2}", erow["RiesgosdeTrabajoSUA"]);
libro.Cell(Fila, 13).Value = string.Format("{0:N2}", erow["RiesgoTrabajoSIG"]);
libro.Cell(Fila, 14).Value = string.Format("{0:N2}", erow["InvalidezyVidaSUA"]);
libro.Cell(Fila, 15).Value = string.Format("{0:N2}", erow["InvalidezyVidaSIG"]);
libro.Cell(Fila, 16).Value = string.Format("{0:N2}", erow["GuarderiaSUA"]);
libro.Cell(Fila, 17).Value = string.Format("{0:N2}", erow["GuarderiaSIG"]);
libro.Cell(Fila, 18).Value = string.Format("{0:N2}", erow["RetiroSUA"]);
libro.Cell(Fila, 19).Value = string.Format("{0:N2}", erow["RetiroSIG"]);
}
//libro.Row(2).SetAutoFilter();
System.IO.Stream fs = new System.IO.MemoryStream();
wb.SaveAs(fs);
fs.Position = 0;
System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();
using (System.IO.Stream input = fs)
{
input.CopyTo(memoryStream);
}
memoryStream.Position = 0;
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.xlsx", "FormatoCargaNominas"));
Response.BinaryWrite(memoryStream.ToArray());
Response.End();
}
}