1386 lines
57 KiB
C#
1386 lines
57 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;
|
|
|
|
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 dtempleados
|
|
{
|
|
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; }
|
|
}
|
|
#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;
|
|
DdlEjercicios.DataBind();
|
|
if ((dtejercicio != null) && dtejercicio.Rows.Count > 0)
|
|
{
|
|
if (dtejercicio.COUNT("Ejercicio", string.Format("Ejercicio={0}", EjercicioActual)) == 0)
|
|
{
|
|
DdlEjercicios.Items.Insert(0, new ListItem(EjercicioActual.ToString(), EjercicioActual.ToString()));
|
|
}
|
|
if (dtejercicio.COUNT("Ejercicio", string.Format("Ejercicio={0}", (EjercicioActual - 1))) == 0)
|
|
{
|
|
DdlEjercicios.Items.Insert(1, new ListItem((EjercicioActual - 1).ToString(), (EjercicioActual - 1).ToString()));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
DdlEjercicios.Items.Add(new ListItem(EjercicioActual.ToString(), EjercicioActual.ToString()));
|
|
DdlEjercicios.Items.Add(new ListItem((EjercicioActual - 1).ToString(), (EjercicioActual - 1).ToString()));
|
|
|
|
}
|
|
if (DdlEjercicios.Items.Count > 0)
|
|
{
|
|
DdlEjercicios.SelectedIndex = 0;
|
|
}
|
|
}
|
|
private void CargaTiposPeriodo()
|
|
{
|
|
DdlTipoPeriodo.DataSource = GlobalDTTipoPeriodo.FiltraParametros("Estatus = 'Activo'");
|
|
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)
|
|
{
|
|
bool continuar = false;
|
|
int CveProyecto = DdlProyecto.SelectedValue.ToEntero();
|
|
int CveSubProyecto = DdlSubProyecto.SelectedValue.ToEntero();
|
|
int CveTurno = DdlTurno.SelectedValue.ToEntero();
|
|
int CvePeriodo = DdlPeriodo.SelectedValue.ToEntero();
|
|
int CveEmpresa = UsuarioActual.CveEmpresa;
|
|
int Agrupador = DdlAgrupador.SelectedValue.ToEntero();
|
|
|
|
CvePeriodoSeleccionado = 0;
|
|
dtempleados = null;
|
|
dtConceptos = null;
|
|
DataTable dtPeriodo = new DataTable();
|
|
DataTable dtasistencia = new DataTable();
|
|
using (ClsNominas objnom = new ClsNominas())
|
|
{
|
|
if (objnom.GetNominaEmpleado(CveProyecto, CveSubProyecto, CveTurno, CvePeriodo, CveEmpresa, Agrupador) && objnom.DTSetResultados.Tables.Count > 1)
|
|
{
|
|
dtempleados = objnom.DTSetResultados.Tables[3];
|
|
dtConceptos = objnom.DTSetResultados.Tables[0];
|
|
dtPeriodo = objnom.DTSetResultados.Tables[1];
|
|
dtasistencia = objnom.DTSetResultados.Tables[2];
|
|
CvePeriodoSeleccionado = CvePeriodo;
|
|
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();
|
|
string Concepto = row["Concepto"].ToString();
|
|
GvNominas.Columns[CurrentColumn].ItemStyle.BackColor = System.Drawing.Color.Transparent;
|
|
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();
|
|
string Concepto = row["Concepto"].ToString();
|
|
GvNominas.Columns[CurrentColumn].ItemStyle.BackColor = System.Drawing.Color.Transparent;
|
|
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].Visible = true;
|
|
CurrentColumn++;
|
|
|
|
field = (BoundField)GvNominas.Columns[CurrentColumn];
|
|
field.HeaderText = "Total";
|
|
field.DataField = "Total";
|
|
field.ItemStyle.BackColor = System.Drawing.Color.LightGray;
|
|
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();
|
|
string Concepto = row["Concepto"].ToString();
|
|
GvNominas.Columns[CurrentColumn].ItemStyle.BackColor = System.Drawing.Color.Transparent;
|
|
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].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[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;
|
|
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;
|
|
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;
|
|
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;
|
|
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;
|
|
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;
|
|
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;
|
|
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;
|
|
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;
|
|
GvNominas.Columns.Insert(CurrentColumn++, field);
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
GvNominas.DataSource = dtempleados;
|
|
GvNominas.DataBind();
|
|
}
|
|
else
|
|
{
|
|
|
|
GvNominas.DataSource = null;
|
|
GvNominas.DataBind();
|
|
}
|
|
|
|
try
|
|
{
|
|
|
|
DateTime FechaInicio = (DateTime)dtPeriodo.Rows[0]["FechaInicio"];
|
|
DateTime FechaFin = (DateTime)dtPeriodo.Rows[0]["FechaFin"];
|
|
StringBuilder gvasistencia = new StringBuilder();
|
|
gvasistencia.Append("<table class=\"table table-striped table-hover mysmallbtn Widthall ScrollAD\">");
|
|
if (true)
|
|
{
|
|
DateTime fecha = FechaInicio;
|
|
|
|
gvasistencia.Append("<tr class=\"Titulos\">");
|
|
gvasistencia.Append("<td>Nombre</td>");
|
|
while (fecha <= FechaFin)
|
|
{
|
|
gvasistencia.AppendFormat("<td>{0:dd/MM/yyyy}</td>", fecha);
|
|
fecha = fecha.AddDays(1);
|
|
}
|
|
gvasistencia.Append("</tr>");
|
|
}
|
|
string tipo = "";
|
|
foreach (DataRow rempl in dtempleados.Rows)
|
|
{
|
|
int CvePersonal = rempl["CvePersonal"].ToString().ToEntero();
|
|
string nombre = rempl["Nombre"].ToString();
|
|
DateTime fecha = FechaInicio;
|
|
gvasistencia.Append("<tr>");
|
|
gvasistencia.AppendFormat("<td>{0}</td>", nombre);
|
|
while (fecha <= FechaFin)
|
|
{
|
|
DataRow drow = dtasistencia.FiltroPrimero(string.Format("Fecha='{0:yyyy/MM/dd}' AND CvePersonal={1}", fecha, CvePersonal));
|
|
fecha = fecha.AddDays(1);
|
|
tipo = "-";
|
|
if (drow != null)
|
|
{
|
|
tipo = string.Format("{0} ({1}%)", drow["Tipo"], drow["PorcentajePago"]);
|
|
drow.Delete();
|
|
}
|
|
gvasistencia.AppendFormat("<td>{0}</td>", tipo);
|
|
}
|
|
gvasistencia.Append("</tr>");
|
|
}
|
|
gvasistencia.Append("</table>");
|
|
ltlGvAsistencia.Text = gvasistencia.ToString();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
throw;
|
|
}
|
|
|
|
#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 Nombre = e.Row.DataKey("Nombre").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\" href=\"/RH/Personal.aspx?CvePersonal={0}\">{1}</a>", cvePersonal, Nombre);
|
|
if (CveNomina > 0)
|
|
{
|
|
if (SeTimbro == "False")
|
|
{
|
|
LnkTimbrar.Visible = true;
|
|
e.Row.CssClass = "info";
|
|
|
|
}
|
|
else
|
|
{
|
|
e.Row.CssClass = "success";
|
|
}
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
LtlNombre.Text = "Total General";
|
|
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)
|
|
{
|
|
|
|
}
|
|
|
|
protected void ImgDelete_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
protected void LnkCancelar_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
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
|
|
{
|
|
using (System.Data.Odbc.OdbcConnection conn = new System.Data.Odbc.OdbcConnection("Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" + fileItem.FileUrl))
|
|
{
|
|
conn.Open();
|
|
string exceltableName = "Nomina";
|
|
DataTable tables = conn.GetSchema("Tables");
|
|
if (tables.FiltraParametros(string.Format("TABLE_NAME LIKE'%{0}%'", exceltableName)).Rows.Count == 0)
|
|
{
|
|
continuar = false;
|
|
stringError = "El documento no contiene la hoja nomina";
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
exceltableName = tables.FiltroPrimero(string.Format("TABLE_NAME LIKE'%{0}%'", exceltableName))["TABLE_NAME"].ToString();
|
|
}
|
|
if (continuar)
|
|
{
|
|
using (System.Data.Odbc.OdbcCommand cmd = conn.CreateCommand())
|
|
{
|
|
|
|
cmd.CommandType = CommandType.Text;
|
|
cmd.CommandText = $"SELECT * FROM [{exceltableName}] WHERE LEN(Codigo)>0 AND Codigo <> 'Codigo'";
|
|
using (System.Data.Odbc.OdbcDataAdapter da = new System.Data.Odbc.OdbcDataAdapter(cmd))
|
|
{
|
|
da.Fill(DTEXcel);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
continuar = false;
|
|
stringError = "Ocurrio un Error al procesar el excel ";
|
|
string.Format(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.Rows)
|
|
{
|
|
string Codigo = row["Codigo"].ToString();
|
|
int CvePersonal = 0;
|
|
int CveNomina = 0;
|
|
double SubTotal = 0;
|
|
double Total = 0;
|
|
int CveMetodoPago = 0;
|
|
if (Codigo != "-1" && objpersonal.GetPersonal(-1, Codigo, "-1", "-1", "-1", -1, -1, -1, -1, -1, -1, -1, 2, -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
|
|
{
|
|
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))
|
|
{
|
|
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);
|
|
|
|
}
|
|
}
|
|
}
|
|
if (rollback)
|
|
{
|
|
objpersonal.RollBack();
|
|
}
|
|
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();
|
|
RegistraScript("$('#ModalConceptos').modal();");
|
|
}
|
|
private void mostrarConceptos()
|
|
{
|
|
#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));
|
|
}
|
|
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);
|
|
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");
|
|
}
|
|
|
|
}
|
|
}
|
|
#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 = "";
|
|
|
|
{
|
|
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());
|
|
}
|
|
}
|
|
//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("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("D:/ADSistemas/Proyectos/SIG/WEB/Empresas/Grales/Formatos/SobreRecibo.rdlc", lrds, parametros, "SobreRecibo.pdf", "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");
|
|
}
|
|
}
|
|
protected void LnkFormato_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.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(2, 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(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.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));
|
|
int Fila = 2;
|
|
foreach (DataRow erow in dtempleados.FiltraParametros("CvePersonal>0").Rows)
|
|
{
|
|
Fila++;
|
|
column = 1;
|
|
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 = row["CveConcepto"].ToString();
|
|
libro.Cell(Fila, column).Value = erow[Concepto];
|
|
column++;
|
|
Concepto = string.Format("{0}-E", row["CveConcepto"]);
|
|
libro.Cell(Fila, column).Value = erow[Concepto];
|
|
|
|
}
|
|
}
|
|
//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();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Alert("Ocurrio un error al generar el Formato de nominas" + ex.ToString());
|
|
}
|
|
}
|
|
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 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; }
|
|
}
|
|
|
|
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();
|
|
|
|
// 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");
|
|
|
|
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 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();");
|
|
}
|
|
} |