1691 lines
76 KiB
C#
1691 lines
76 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Specialized;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using Extensiones;
|
|
using Modelos;
|
|
using static Extensiones.ModExtensiones;
|
|
|
|
public partial class Nomina_Finiquito : ClsPaginas
|
|
{
|
|
#region Propiedades
|
|
private int CvePersonal
|
|
{
|
|
get { return ViewState["CvePersonal"] != null ? ViewState["CvePersonal"].ToString().ToEntero() : 0; }
|
|
//set { ViewState["CvePersonal"] = value; }
|
|
}
|
|
private bool esSimulacion
|
|
{
|
|
get { return ViewState["esSimulacion"] != null ? (bool)ViewState["esSimulacion"] : false; }
|
|
set { ViewState["esSimulacion"] = value; }
|
|
}
|
|
private bool NominaAutorizada
|
|
{
|
|
get { return ViewState["NominaAutorizada"] != null ? (bool)ViewState["NominaAutorizada"] : false; }
|
|
set { ViewState["NominaAutorizada"] = value; }
|
|
}
|
|
|
|
|
|
private int CvePersonalAltas
|
|
{
|
|
get { return ViewState["CvePersonalAltas"] != null ? ViewState["CvePersonalAltas"].ToString().ToEntero() : 0; }
|
|
set { ViewState["CvePersonalAltas"] = value; }
|
|
}
|
|
/*private int CvePeriodoIndemnizacion
|
|
{
|
|
get { return ViewState["CvePeriodoIndemnizacion"] != null ? ViewState["CvePeriodoIndemnizacion"].ToString().ToEntero() : 0; }
|
|
set { ViewState["CvePeriodoIndemnizacion"] = value; }
|
|
}*/
|
|
private int CvePeriodoFiniquito
|
|
{
|
|
get { return ViewState["CvePeriodoFiniquito"] != null ? ViewState["CvePeriodoFiniquito"].ToString().ToEntero() : 0; }
|
|
set { ViewState["CvePeriodoFiniquito"] = value; }
|
|
}
|
|
private DateTime FechaInicio
|
|
{
|
|
get { return ViewState["FechaInicio"] != null ? (DateTime)ViewState["FechaInicio"] : DateTime.Now; }
|
|
set { ViewState["FechaInicio"] = value; }
|
|
}
|
|
private DataTable DtAltas
|
|
{
|
|
get { return ViewState["DtAltas"] != null ? (DataTable)ViewState["DtAltas"] : null; }
|
|
set { ViewState["DtAltas"] = 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; }
|
|
}
|
|
#endregion
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
GvFinOrdinario.DataSource = new DataTable();
|
|
GVFinIndemnizacion.DataSource = new DataTable();
|
|
GvFinOrdinario.DataBind();
|
|
GVFinIndemnizacion.DataBind();
|
|
if (Request["CvePersonal"] != null && Request["CvePersonal"].ToString().ToEntero() > 0)
|
|
{
|
|
ViewState["CvePersonal"] = Request["CvePersonal"].ToString().ToEntero();
|
|
HypCodigo.NavigateUrl = $"/RH/Personal.aspx?CvePersonal={CvePersonal}";
|
|
HypEmpleado.NavigateUrl = $"/RH/Personal.aspx?CvePersonal={CvePersonal}";
|
|
CargaMotivoBaja();
|
|
CargaPersonal();
|
|
LnkFormatoRenuncia.Visible = true;
|
|
}
|
|
else
|
|
{
|
|
CargaDdlPersonal();
|
|
ViewState["CvePersonal"] = -1;
|
|
LtlEmpleadoCancelar.Visible = false;
|
|
RegistraScript("$('#ModalEmpleados').modal();");
|
|
LnkFormatoRenuncia.Visible = false;
|
|
LnkSimular.Visible = false;
|
|
LnkCancelar.Visible = false;
|
|
LnkGuardarDatos.Visible = false;
|
|
}
|
|
gconceptos.Visible = ChkesLiquidacion.Checked;
|
|
}
|
|
}
|
|
|
|
protected void ChkesLiquidacion_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
gconceptos.Visible = ChkesLiquidacion.Checked;
|
|
}
|
|
private void CargaMotivoBaja()
|
|
{
|
|
DdlMotivoBaja.DataSource = get_GlobalDTMotivoBaja(UsuarioActual.CveEmpresa);
|
|
DdlMotivoBaja.DataBind();
|
|
}
|
|
private void CargaDdlPersonal()
|
|
{
|
|
using (ClsRH ObjPersonal = new ClsRH())
|
|
{
|
|
if (ObjPersonal.GetPersonal(-1, UsuarioActual.CveEmpresa))
|
|
{
|
|
DdlPersonal.DataSource = ObjPersonal.DtResultados;
|
|
DdlPersonal.DataBind();
|
|
}
|
|
}
|
|
}
|
|
private void CargaPersonal()
|
|
{
|
|
LnkFormatoRenuncia.Visible = false;
|
|
LnkCancelar.Visible = false;
|
|
using (ClsRH ObjPersonal = new ClsRH())
|
|
{
|
|
if (ObjPersonal.GetPersonal(CvePersonal, UsuarioActual.CveEmpresa) && ObjPersonal.DtResultados.Rows.Count > 0)
|
|
{
|
|
DataRow drow = ObjPersonal.DtResultados.Rows[0];
|
|
HypCodigo.Text = drow["Codigo"].ToString();
|
|
HypEmpleado.Text = drow["NombreCompleto"].ToString();
|
|
LtlSFTipoSalario.Text = drow["TipodeSalario"].ToString();
|
|
HypCodigo.NavigateUrl = $"/RH/Personal.aspx?CvePersonal={drow["CvePersonal"]}";
|
|
LblPuesto.Text = drow["Puesto"].ToString();
|
|
LblSalario.Text = drow["SalarioDiario"].ToString();
|
|
LtlAreaGeografica.Text = drow["AreaGeografica"].ToString();
|
|
if (ObjPersonal.GetPersonalAltas(CvePersonal) && ObjPersonal.DtResultados.Rows.Count > 0)
|
|
{
|
|
DtAltas = ObjPersonal.DtResultados.FiltraParametros("", "FechaInicio");
|
|
DataRow da = ObjPersonal.DtResultados.Rows[0];
|
|
CvePersonalAltas = da["CvePersonalAltas"].ToString().ToEntero();
|
|
LblFechaAlta.Text = string.Format("{0:dd/MM/yyyy}", da["FechaInicio"]);
|
|
FechaInicio = LblFechaAlta.Text.ToDateTime();
|
|
TxtObservaciones.Text = da["Observaciones"].ToString();
|
|
TxtFechaBaja.Text = string.Format("{0:dd/MM/yyyy}", da["FechaFin"]);
|
|
if (da["CveMotivoBaja"].ToString() == "")
|
|
{
|
|
chkIndemnizacion.Checked = true;
|
|
chkSeparacionUnica.Checked = true;
|
|
chkPrimaantiguedad.Checked = true;
|
|
}
|
|
else
|
|
{
|
|
chkIndemnizacion.Checked = da["ValIndemnizacion"].ToString().ToUpper().Contiene(new string[] { "1", "TRUE" });
|
|
chkSeparacionUnica.Checked = da["ValSeparacionunica"].ToString().ToUpper().Contiene(new string[] { "1", "TRUE" });
|
|
chkPrimaantiguedad.Checked = da["ValPrimadeantiguedad"].ToString().ToUpper().Contiene(new string[] { "1", "TRUE" });
|
|
}
|
|
|
|
DdlTipoPeriodo.SelectedValueExist(((da["CveTipoPeriodo"]).ToString() == "6" ? "-2" : "-1"));
|
|
DdlMotivoBaja.SelectedValueExist(da["CveMotivoBaja"]);
|
|
TxtSalarioMinimo.Text = $"{da["SalarioMinimo"]:N2}";
|
|
ChkesLiquidacion.Checked = (da["esLiquidacion"].ToString() == "1" || da["esLiquidacion"].ToString().ToUpper() == "TRUE");
|
|
//CvePeriodoIndemnizacion = da["CvePeriodoIndemnizacion"].ToString().ToEntero();
|
|
CvePeriodoFiniquito = da["CvePeriodoFiniquito"].ToString().ToEntero();
|
|
if (CvePeriodoFiniquito > 0)
|
|
{
|
|
LnkCancelar.Visible = true;
|
|
LnkSimular.Visible = false;
|
|
using (ClsNominas onom = new ClsNominas())
|
|
{
|
|
loadsobrerecibo(onom);
|
|
}
|
|
|
|
if (da["Autorizado"].ToString().ToEntero() == 1)
|
|
{
|
|
|
|
LnkAutorizar.Visible = false;
|
|
LnkTimbrar.Visible = true;
|
|
|
|
LnkGuardarDatos.Enabled = false;
|
|
|
|
LnkGuardarDatos.CssClass = "btn btn-default";
|
|
LnkGuardarDatos.ToolTip = "el finiquito ha sido capturado.";
|
|
}
|
|
|
|
if (da["SeTimbro"].ToString().ToEntero() == 1)
|
|
{
|
|
LnkAutorizar.Visible = false;
|
|
LnkTimbrar.Visible = false;
|
|
|
|
LnkGuardarDatos.Enabled = false;
|
|
|
|
LnkGuardarDatos.CssClass = "btn btn-default";
|
|
LnkGuardarDatos.ToolTip = "el finiquito ha sido capturado.";
|
|
}
|
|
UpAcciones.Update();
|
|
}
|
|
}
|
|
CamposCalculados();
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void LnkCampiarEmpleado_Click(object sender, EventArgs e)
|
|
{
|
|
Response.Redirect($"/Nomina/Finiquito.aspx?CvePersonal={DdlPersonal.SelectedValue}");
|
|
}
|
|
|
|
private void CamposCalculados()
|
|
{
|
|
//TxtSalarioMinimo.Text = "123.22";
|
|
if (TxtFechaBaja.Text.Length > 9)
|
|
{
|
|
DateTime fechafin = TxtFechaBaja.Text.ToDateTime();
|
|
DateTime fechaalta = LblFechaAlta.Text.ToDateTime();
|
|
int diasanio = fechafin.DayOfYear;
|
|
if (fechafin.Year == fechaalta.Year)
|
|
{
|
|
diasanio = diasanio - fechaalta.DayOfYear;
|
|
|
|
}
|
|
|
|
decimal antiguedad = getyearsresult(fechafin, FechaInicio);
|
|
TxtAntiguedad.Text = string.Format("{0:##0.00###}", antiguedad);
|
|
TxtDiasTransAnio.Text = string.Format("{0}", diasanio);
|
|
}
|
|
else
|
|
{
|
|
|
|
TxtAntiguedad.Text = "--";
|
|
TxtDiasTransAnio.Text = "--";
|
|
}
|
|
}
|
|
|
|
private decimal getyearsresult(DateTime fechafin, DateTime fechainicio)
|
|
{
|
|
|
|
decimal retorno = 0;
|
|
decimal mes = 12;
|
|
retorno = (fechafin.Year - fechainicio.Year) - (fechafin.Month > fechainicio.Month ? 0 : (fechafin.Month == fechainicio.Month && fechafin.Day > fechainicio.Day ? 0 : 1));
|
|
retorno += (((fechafin.Month == fechainicio.Month && fechafin.Day > fechainicio.Day ? fechainicio.Month : fechafin.Month + (fechafin.Month > fechainicio.Month ? 0 : 12)) - fechainicio.Month) / mes);
|
|
/* DateTime zeroTime = new DateTime(1, 1, 1);
|
|
TimeSpan span;
|
|
if (fechainicio < fechafin)
|
|
{
|
|
span = fechafin - fechainicio;
|
|
decimal years = (zeroTime + span).Year - 1;
|
|
retorno = Math.Round(years + (span.TotalDays.ToString().ToDecimal() / 365), 4);
|
|
}*/
|
|
return retorno;
|
|
}
|
|
|
|
protected void LnkImportexCalculo_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
if (!esSimulacion && !NominaAutorizada)
|
|
{
|
|
|
|
int SRCveConcepto = ((LinkButton)sender).CommandArgument.ToEntero();
|
|
//CvePeriodoSeleccionado
|
|
//SRCvePersonal
|
|
if (SRCveConcepto > 0)
|
|
{
|
|
using (ClsNominas onom = new ClsNominas())
|
|
{
|
|
if (onom.DeleteNom_NominasDetalles(SRCveConcepto, CvePersonal, CvePeriodoFiniquito))
|
|
{
|
|
Alert("el importe sera tomado del calculo y no del valor fijo");
|
|
loadsobrerecibo(onom);
|
|
UPDatos.Update();
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (esSimulacion)
|
|
{
|
|
Alert("No se puede eliminar una nomina en modo Simulación", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
}
|
|
else
|
|
{
|
|
Alert("No se puede eliminar una nomina autorizada", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
}
|
|
}
|
|
}
|
|
protected void LnkConcepto_Click(object sender, EventArgs e)
|
|
{
|
|
if (!esSimulacion && !NominaAutorizada)
|
|
{
|
|
|
|
int SRCveConcepto = ((LinkButton)sender).CommandArgument.ToEntero();
|
|
string SRTipoConcepto = ((LinkButton)sender).CommandArgument;
|
|
#region carga conceptos
|
|
DataTable dtCon;
|
|
if (SRCveConcepto > 0)
|
|
{
|
|
DataRow drow = dtConceptos.FiltroPrimero(string.Format("CveConcepto={0}", SRCveConcepto));
|
|
if (drow != null)
|
|
{
|
|
SRTipoConcepto = drow["Tipo"].ToString();
|
|
}
|
|
else
|
|
{
|
|
SRCveConcepto = 0;
|
|
SRTipoConcepto = "D";
|
|
}
|
|
}
|
|
|
|
|
|
if (SRTipoConcepto == "P")
|
|
{
|
|
dtCon = dtConceptos.FiltraParametros("Tipo ='P' AND EsPadre = 1 ").Copy(); //AND CveSistema <>12'
|
|
}
|
|
else
|
|
{
|
|
dtCon = dtConceptos.FiltraParametros("Tipo ='D' AND EsPadre = 1 ").Copy();
|
|
SRTipoConcepto = "D";
|
|
}
|
|
dtCon.Columns.Add(new DataColumn("CodigoConcepto"));
|
|
foreach (DataRow trow in dtCon.Rows)
|
|
{
|
|
trow["CodigoConcepto"] = string.Format("{0} - {1}", trow["Codigo"], trow["Concepto"]);
|
|
}
|
|
dtCon.AcceptChanges();
|
|
DataRow row = dtCon.NewRow();
|
|
row["CveConcepto"] = "-1";
|
|
row["CodigoConcepto"] = "Seleccione";
|
|
dtCon.Rows.InsertAt(row, 0);
|
|
#endregion
|
|
DdlmcConceptos.DataSource = dtCon;
|
|
DdlmcConceptos.DataBind();
|
|
if (SRCveConcepto > 0)
|
|
{
|
|
DdlmcConceptos.SelectedValueExist(SRCveConcepto);
|
|
}
|
|
|
|
//PnlConceptoPersonal.Visible = false;
|
|
DdlmcConceptos_SelectedIndexChanged(DdlmcConceptos, null);
|
|
RegistraScript(string.Format("$('#ModalUpConcepto').on('shown.bs.modal', function () {{$('#{0}').trigger('focus')}});$('#ModalUpConcepto').modal();", TxtmcImporte.ClientID));
|
|
UPpanelModalUpConcepto.Update();
|
|
}
|
|
else
|
|
{
|
|
if (esSimulacion)
|
|
{
|
|
Alert("No se puede editar una nomina en modo Simulación", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
}
|
|
else
|
|
{
|
|
Alert("No se puede editar una nomina autorizada", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
protected void DdlmcConceptos_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
/*
|
|
int CveConcepto = DdlmcConceptos.SelectedValue.ToEntero();
|
|
TxtmcImporte.Text = "";
|
|
TxtmcImporteGrabado.Text = "";
|
|
Txtmcvalor.Text = "";
|
|
if (CveConcepto > 0)
|
|
{
|
|
DataRow drow = dtempleadosConceptos.FiltroPrimero(string.Format("CveConcepto={0} AND CvePersonal ={1}", CveConcepto, CvePersonal));
|
|
if (drow != null)
|
|
{
|
|
TxtmcImporte.Text = string.Format("{0:N2}", drow["Importe"]);
|
|
TxtmcImporteGrabado.Text = string.Format("{0:N2}", drow["ImporteGravado"]);
|
|
Txtmcvalor.Text = string.Format("{0:N2}", drow["Valor"]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (e != null)
|
|
{
|
|
Alert("Seleccione un concepto.", TipoMensaje.MsgAdvertencia);
|
|
}
|
|
}
|
|
UPpanelModalUpConcepto.Update();
|
|
*/
|
|
int CveConcepto = DdlmcConceptos.SelectedValue.ToEntero();
|
|
TxtmcImporte.Text = "";
|
|
TxtmcImporteGrabado.Text = "";
|
|
Txtmcvalor.Text = "";
|
|
ChkCalAutomaticoG.Checked = false;
|
|
ChkCalAutomatico.Checked = false;
|
|
ChkCalAutomaticoV.Checked = false;
|
|
if (CveConcepto > 0)
|
|
{
|
|
DataRow drow = dtempleadosConceptos.FiltroPrimero(string.Format("CveConcepto={0} AND CvePersonal ={1}", CveConcepto, CvePersonal));
|
|
if (drow != null)
|
|
{
|
|
int TipoCalculo = drow["Estatus"].ToString().ToEntero();
|
|
ChkCalAutomaticoG.Checked = true;
|
|
ChkCalAutomatico.Checked = true;
|
|
ChkCalAutomaticoV.Checked = true;
|
|
if (TipoCalculo >= 5)
|
|
{
|
|
TipoCalculo -= 5;
|
|
ChkCalAutomaticoG.Checked = false;
|
|
}
|
|
if (TipoCalculo >= 3)
|
|
{
|
|
TipoCalculo -= 3;
|
|
ChkCalAutomatico.Checked = false;
|
|
}
|
|
if (TipoCalculo >= 1)
|
|
{
|
|
ChkCalAutomaticoV.Checked = false;
|
|
|
|
}
|
|
TxtmcImporte.Text = string.Format("{0:N2}", drow["Importe"]);
|
|
TxtmcImporteGrabado.Text = string.Format("{0:N2}", drow["ImporteGravado"]);
|
|
Txtmcvalor.Text = string.Format("{0:N2}", drow["Valor"]);
|
|
}
|
|
else
|
|
{
|
|
ChkCalAutomaticoV.Checked = true;
|
|
ChkCalAutomaticoG.Checked = true;
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (e != null)
|
|
{
|
|
Alert("Seleccione un concepto.", TipoMensaje.MsgAdvertencia);
|
|
}
|
|
}
|
|
UPpanelModalUpConcepto.Update();
|
|
ChkCalAutomaticoV_CheckedChanged(ChkCalAutomaticoV, null);
|
|
ChkCalAutomatico_CheckedChanged(ChkCalAutomatico, null);
|
|
ChkCalAutomaticoG_CheckedChanged(ChkCalAutomaticoG, null);
|
|
}
|
|
protected void ChkCalAutomaticoV_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
Txtmcvalor.Enabled = !ChkCalAutomaticoV.Checked;
|
|
}
|
|
protected void ChkCalAutomatico_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
TxtmcImporte.Enabled = !ChkCalAutomatico.Checked;
|
|
}
|
|
protected void ChkCalAutomaticoG_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
TxtmcImporteGrabado.Enabled = !ChkCalAutomaticoG.Checked;
|
|
|
|
}
|
|
|
|
protected void BtnAceptarMC_Click(object sender, EventArgs e)
|
|
{
|
|
int chkImporte = ChkCalAutomatico.Checked ? 0 : 1;
|
|
int chkImporteGravado = ChkCalAutomaticoG.Checked ? 0 : 1;
|
|
int chkImporteValor = ChkCalAutomaticoV.Checked ? 0 : 1;
|
|
bool continuar = true;
|
|
int CveNomina = 0;
|
|
double Total = 0;
|
|
int CveMoneda = 1;
|
|
int CveMetodoPago = 0;
|
|
int CveConcepto = DdlmcConceptos.SelectedValue.ToEntero();
|
|
if (CveConcepto > 0 && CvePersonal > 0)
|
|
{
|
|
decimal ImporteConcepto = chkImporte == 1 ? TxtmcImporte.Text.Replace("$", "").Replace(",", "").ToDecimal() : 0;
|
|
decimal ImporteGravadoConcepto = ChkCalAutomaticoG.Checked ? 0.0m : TxtmcImporteGrabado.Text.Replace("$", "").Replace(",", "").ToDecimal();
|
|
decimal ImporteExentoConcepto = ImporteConcepto - ImporteGravadoConcepto;
|
|
decimal ImporteValor = Txtmcvalor.Text.Replace("$", "").Replace(",", "").ToDecimal();
|
|
using (ClsNominas objNomina = new ClsNominas())
|
|
{
|
|
objNomina.IniciaTransacSQL();
|
|
if (continuar)
|
|
{
|
|
if (objNomina.GetNom_Nominas(-1, CvePersonal, CvePeriodoFiniquito, -1, UsuarioActual.CveEmpresa))
|
|
{
|
|
if (objNomina.DtResultados.Rows.Count > 0)
|
|
{
|
|
CveNomina = objNomina.CveNomina;
|
|
}
|
|
else
|
|
{
|
|
if (objNomina.AddNom_Nominas(-1, 1, CvePersonal, CvePeriodoFiniquito, 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, false))
|
|
{
|
|
CveNomina = objNomina.CveNomina;
|
|
}
|
|
else
|
|
{
|
|
continuar = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (CveNomina == 0)
|
|
{
|
|
continuar = false;
|
|
}
|
|
|
|
|
|
|
|
if (continuar)
|
|
{
|
|
|
|
if (continuar)
|
|
{
|
|
|
|
if (!objNomina.AddUPNom_NominasDetalles(CveNomina, CvePeriodoFiniquito, CvePersonal, CveConcepto, ImporteConcepto, ImporteGravadoConcepto, ImporteExentoConcepto, ImporteValor, UsuarioActual.CveUsuario, true, chkImporte, chkImporteGravado, chkImporteValor))
|
|
{
|
|
continuar = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (continuar)
|
|
{ objNomina.Commit(); }
|
|
else
|
|
{
|
|
objNomina.RollBack();
|
|
}
|
|
}
|
|
if (continuar)
|
|
{
|
|
using (ClsNominas objNomina = new ClsNominas())
|
|
{
|
|
loadsobrerecibo(objNomina);
|
|
}
|
|
Alert("El cambio se ha guardado correctamente.");
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
if (CveConcepto > 0)
|
|
{
|
|
Alert("Debe seleccionar un empleado.", TipoMensaje.MsgAdvertencia);
|
|
}
|
|
else
|
|
{
|
|
Alert("Debe seleccionar un concepto.", TipoMensaje.MsgAdvertencia);
|
|
}
|
|
}
|
|
UPDatos.Update();
|
|
|
|
}
|
|
|
|
|
|
//int CveConceptoPolgvc, CveConceptoDolgvc;
|
|
//protected void GvConceptos_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
//{
|
|
// if (e.Row.RowType == DataControlRowType.DataRow)
|
|
// {
|
|
// if (e.Row.RowIndex == 0)
|
|
// {
|
|
// CveConceptoPolgvc = 1;
|
|
// CveConceptoDolgvc = 1;
|
|
// }
|
|
// // 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();
|
|
// bool isEditedP = e.Row.DataKey("isEditedP").ToEntero() > 0;
|
|
// bool isEditedD = e.Row.DataKey("isEditedD").ToEntero() > 0;
|
|
// //isEditedD
|
|
// // 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 (isEditedP)
|
|
// {
|
|
// e.Row.CssClass = string.Format("{0} isEditedP", e.Row.CssClass);
|
|
// }
|
|
// if (isEditedD)
|
|
// {
|
|
// e.Row.CssClass = string.Format("{0} isEditedD", e.Row.CssClass);
|
|
// }
|
|
|
|
// 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; }
|
|
|
|
// LtlImporte.Visible = false;
|
|
// LtlImporteD.Visible = false;
|
|
// if (Estatus < -1 | EstatusD < -1)
|
|
// {
|
|
// e.Row.CssClass = "ConceptosTotales";
|
|
// LtlImporte.Visible = true;
|
|
// LtlImporteD.Visible = true;
|
|
// }
|
|
// LnkImporte.CommandArgument = (CveConcepto > 0 ? CveConcepto.ToString() : "P");
|
|
// LnkImporteD.CommandArgument = (CveConceptoD > 0 ? CveConceptoD.ToString() : "D");
|
|
|
|
// LnkImporte.Text = (CveConcepto > 0 ? string.Format("${0:N2}", e.Row.DataKey("ImporteP").ToDecimal()) : (CveConceptoPolgvc > 0 ? "<i class=\"fa fa-plus\"></i>" : ""));
|
|
// LnkImporteD.Text = (CveConceptoD > 0 ? string.Format("${0:N2}", e.Row.DataKey("ImporteD").ToDecimal()) : (CveConceptoDolgvc > 0 ? "<i class=\"fa fa-plus\"></i>" : ""));
|
|
|
|
|
|
|
|
// if (CveConcepto == 0 && (Estatus == 0 || Estatus == -1 || Estatus == -3)) { LtlImporte.Text = ""; }
|
|
|
|
// if (CveConceptoD == 0 && (EstatusD == 0 || EstatusD == -1)) { LtlImporteD.Text = ""; }
|
|
|
|
|
|
|
|
// LnkConcepto.Visible = !LtlConcepto.Visible;
|
|
// LnkConceptoD.Visible = !LtlConceptoD.Visible;
|
|
// LnkImporte.Visible = !LtlImporte.Visible;
|
|
// LnkImporteD.Visible = !LtlImporteD.Visible;
|
|
|
|
|
|
// CveConceptoPolgvc = CveConcepto;
|
|
// CveConceptoDolgvc = CveConceptoD;
|
|
// }
|
|
//}
|
|
|
|
|
|
protected void LnkCambiarEmpleado_Click(object sender, EventArgs e)
|
|
{
|
|
CargaDdlPersonal();
|
|
RegistraScript("$('#ModalEmpleados').modal();");
|
|
UpModalEmpleados.Update();
|
|
}
|
|
|
|
/*
|
|
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 int 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 int isEditedD { get; set; }
|
|
public int isOnlyBisibleD { get; set; }
|
|
}*/
|
|
|
|
protected void LnkGuardarDatos_Click(object sender, EventArgs e)
|
|
{
|
|
if (LblFechaAlta.Text.ToDate() > TxtFechaBaja.Text.ToDate())
|
|
{
|
|
Alert("la fecha de baja no puede ser menor a la fecha alta", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
}
|
|
else
|
|
{
|
|
bool continuar = true;
|
|
esSimulacion = false;
|
|
using (ClsRH ObjPersonal = new ClsRH())
|
|
using (ClsNominas onom = new ClsNominas(ObjPersonal.IniciaTransacSQL()))
|
|
{
|
|
onom.ValidaFechaFinPersonal(CvePersonal, UsuarioActual.CveEmpresa, TxtFechaBaja.Text.ToDateTime().ToString("yyyy/MM/dd"));
|
|
if (onom.DtResultados.Rows.Count > 0)
|
|
{
|
|
continuar = false;
|
|
StringBuilder strbuild = new StringBuilder();
|
|
strbuild.Append("No es posible guardar el finiquito ya que existen asistencias posteriores a la fecha fin con nominas autorizadas, es necesario desautorizar la siguientes nominas para reintentar el proceso.");
|
|
foreach (DataRow drow in onom.DtResultados.Rows)
|
|
{
|
|
strbuild.AppendFormat("<br/> {0}", drow["PeriodoTexto"]);
|
|
}
|
|
Alert(strbuild.ToString(), TipoMensaje.MsgAdvertencia);
|
|
}
|
|
|
|
if (continuar && ObjPersonal.UpPersonalAltas(CvePersonal, UsuarioActual.CveUsuario, "", TxtFechaBaja.Text.ToDateTime().ToString("yyyy/MM/dd"), DdlTipoPeriodo.SelectedValue.ToEntero(), DdlMotivoBaja.SelectedValue.ToEntero(), ChkesLiquidacion.Checked, chkIndemnizacion.Checked, chkSeparacionUnica.Checked, chkPrimaantiguedad.Checked, TxtObservaciones.Text) && ObjPersonal.GetPersonalAltas(CvePersonal) && ObjPersonal.DtResultados.Rows.Count > 0)
|
|
{
|
|
DataRow da = ObjPersonal.DtResultados.Rows[0];
|
|
//CvePeriodoIndemnizacion = da["CvePeriodoIndemnizacion"].ToString().ToEntero();
|
|
CvePeriodoFiniquito = da["CvePeriodoFiniquito"].ToString().ToEntero();
|
|
// Alert(string.Format("{0}: {1}", CvePeriodoIndemnizacion, CvePeriodoFiniquito));
|
|
}
|
|
else { continuar = false; }
|
|
if (continuar) { continuar = validaAutorizado(onom); }
|
|
if (continuar)
|
|
{
|
|
continuar = onom.GetFiniquitosPersonal(CvePersonal, UsuarioActual.CveEmpresa, diasindemnizacion: Txtdiasindemnizacion.Text.ToEntero());
|
|
}
|
|
if (continuar)
|
|
{
|
|
ObjPersonal.Commit();
|
|
}
|
|
else
|
|
{
|
|
ObjPersonal.RollBack();
|
|
}
|
|
if (continuar)
|
|
{ loadsobrerecibo(onom); LnkCancelar.Visible =!LnkAutorizar.Visible?false: true; LnkSimular.Visible = false; }
|
|
}
|
|
|
|
}
|
|
UPDatos.Update();
|
|
}
|
|
|
|
protected void LnkSimular_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
if (LblFechaAlta.Text.ToDate() > TxtFechaBaja.Text.ToDate())
|
|
{
|
|
Alert("la fecha de baja no puede ser menor a la fecha alta", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
}
|
|
else
|
|
{
|
|
bool continuar = false;
|
|
esSimulacion = true;
|
|
using (ClsRH ObjPersonal = new ClsRH())
|
|
using (ClsNominas onom = new ClsNominas(ObjPersonal.IniciaTransacSQL()))
|
|
{
|
|
if (continuar = ObjPersonal.UpPersonalAltas(CvePersonal, UsuarioActual.CveUsuario, "", TxtFechaBaja.Text.ToDateTime().ToString("yyyy/MM/dd"), DdlTipoPeriodo.SelectedValue.ToEntero(), DdlMotivoBaja.SelectedValue.ToEntero(), ChkesLiquidacion.Checked, chkIndemnizacion.Checked, chkSeparacionUnica.Checked, chkPrimaantiguedad.Checked) && ObjPersonal.GetPersonalAltas(CvePersonal) && ObjPersonal.DtResultados.Rows.Count > 0)
|
|
{
|
|
DataRow da = ObjPersonal.DtResultados.Rows[0];
|
|
//CvePeriodoIndemnizacion = da["CvePeriodoIndemnizacion"].ToString().ToEntero();
|
|
CvePeriodoFiniquito = da["CvePeriodoFiniquito"].ToString().ToEntero();
|
|
// Alert(string.Format("{0}: {1}", CvePeriodoIndemnizacion, CvePeriodoFiniquito));
|
|
}
|
|
else { continuar = false; }
|
|
if (continuar) { continuar = validaAutorizado(onom); }
|
|
if (continuar)
|
|
{
|
|
continuar = onom.GetFiniquitosPersonal(CvePersonal, UsuarioActual.CveEmpresa, diasindemnizacion: Txtdiasindemnizacion.Text.ToEntero());
|
|
if (onom.DtResultados.Rows.Count > 0)
|
|
{
|
|
DataRow drow = onom.DtResultados.Rows[0];
|
|
|
|
LnkShowFfiniquito.Text = string.Format("{0:##,###,###.00##}", drow["SalarioBC"]);
|
|
LtlSFSDI.Text = string.Format("<pre>{0:##,###,###.00##}</pre>", drow["SDI"]);
|
|
LtlSFDias.Text = string.Format("<pre>{0:##,###,###}</pre>", drow["diasMesAnterior"]);
|
|
LtlSFPercepciones.Text = string.Format("<pre>{0:##,###,###.00##}</pre>", drow["TotalPercepciones"]);
|
|
LtlSFVar.Text = string.Format("<pre>(Percepciones /días)\r\n{0:##,###,###.00##}</pre>", drow["TotalPercepciones"].ToString().ToDecimal() / drow["diasMesAnterior"].ToString().ToDecimal());
|
|
LtlSF.Text = string.Format("<pre>Si((Tipo de salario ='Fijo'),SDI,(Salario Variable + SDI))\r\n{0:##,###,###.00##}</pre>", drow["SalarioBC"]);
|
|
}
|
|
GVSDF.DataSource = onom.DTSetResultados.Tables[1];
|
|
GVSDF.DataBind();
|
|
}
|
|
if (continuar)
|
|
{ loadsobrerecibo(onom); }
|
|
if (continuar)
|
|
{
|
|
ObjPersonal.RollBack();
|
|
}
|
|
else
|
|
{
|
|
ObjPersonal.RollBack();
|
|
}
|
|
}
|
|
|
|
}
|
|
UPDatos.Update();
|
|
}
|
|
|
|
public bool validaAutorizado(ClsNominas objnom)
|
|
{
|
|
bool validaAutorizado = false;
|
|
if (objnom.GetNominaEmpleado(-1, -1, -1, CvePeriodoFiniquito, UsuarioActual.CveEmpresa, 1, 3, CvePersonal, Neto: 1) && objnom.DTSetResultados.Tables.Count > 1)
|
|
{
|
|
validaAutorizado = (objnom.DTSetResultados.Tables[3].COUNT("CvePersonal", "NomAutorizado =1") > 0);
|
|
}
|
|
if (validaAutorizado)
|
|
{
|
|
Alert("No se puede calcular el finiquito en un periodo autorizado", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
}
|
|
return !validaAutorizado;
|
|
}
|
|
|
|
public void loadsobrerecibo(ClsNominas objnom)
|
|
{
|
|
List<NConcepto> finordin = null;
|
|
List<NConcepto> finindem = null;
|
|
dtempleadosConceptos = null;
|
|
dtempleados = null;
|
|
LnkAutorizar.Visible = true;
|
|
if (objnom.GetNominaEmpleado(-1, -1, -1, CvePeriodoFiniquito, UsuarioActual.CveEmpresa, 1, 3, CvePersonal, Neto: 1) && objnom.DTSetResultados.Tables.Count > 1)
|
|
{
|
|
dtempleados = objnom.DTSetResultados.Tables[3];
|
|
LnkAutorizar.Visible = (dtempleados.COUNT("CvePersonal", string.Format("NomAutorizado =0 AND CvePersonal ={0}", CvePersonal)) > 0);
|
|
NominaAutorizada = !LnkAutorizar.Visible;
|
|
LnkFormatoRenuncia.Visible = true;
|
|
LnkGuardarDatos.Enabled = LnkAutorizar.Visible;
|
|
LnkTimbrar.Visible = !(LnkAutorizar.Visible) && (dtempleados.COUNT("CvePersonal", string.Format("SeTimbro=0 AND CvePersonal ={0}", CvePersonal)) > 0);
|
|
LnkCancelarNomina.Visible = !LnkAutorizar.Visible && LnkTimbrar.Visible;
|
|
UpAcciones.Update();
|
|
dtempleadosConceptos = objnom.DTSetResultados.Tables[4];
|
|
dtConceptos = objnom.DTSetResultados.Tables[0];
|
|
LnkCancelar.Visible = !LnkAutorizar.Visible? false: LnkCancelar.Visible;
|
|
LnkGuardarDatos.Visible = !LnkAutorizar.Visible?false: LnkGuardarDatos.Visible;
|
|
}
|
|
if (dtConceptos != null && dtempleadosConceptos != null && dtempleados != null)
|
|
{
|
|
finordin = cargasobrericiboconceptos(dtConceptos, dtempleadosConceptos, dtempleados);
|
|
finindem = cargasobrericiboconceptosIndemnizacion(dtConceptos, dtempleadosConceptos, dtempleados);
|
|
}
|
|
|
|
GvFinOrdinario.DataSource = finordin;
|
|
GVFinIndemnizacion.DataSource = finindem;
|
|
GvFinOrdinario.DataBind();
|
|
GVFinIndemnizacion.DataBind();
|
|
//LnkGuardarDatos.Enabled = false;
|
|
if (!(LnkGuardarDatos.Enabled))
|
|
{
|
|
|
|
LnkGuardarDatos.CssClass = "btn btn-default";
|
|
LnkGuardarDatos.ToolTip = "el finiquito ha sido capturado.";
|
|
}
|
|
}
|
|
|
|
private List<NConcepto> cargasobrericiboconceptos(DataTable dtConceptos, DataTable dtempleadosConceptos, DataTable dtempleados)
|
|
{
|
|
int SRCvePersonal = this.CvePersonal;
|
|
DataTable dtper = dtConceptos.FiltraParametros("Tipo IN ('P') AND EsPadre = 1 And CveSistema NOT IN(10,11,32) ");
|
|
DataTable dtded = dtConceptos.FiltraParametros("Tipo IN ('D') AND EsPadre = 1 AND CveSistema NOT IN( 47,101)");
|
|
double percepcionesindem = 0;
|
|
double deduccionesindem = 0;
|
|
foreach (DataRow row in dtConceptos.FiltraParametros("Tipo IN ('P') AND EsPadre = 1 And CveSistema IN(10,11,32) ").Rows)
|
|
{
|
|
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));
|
|
percepcionesindem += Importe;
|
|
}
|
|
foreach (DataRow row in dtConceptos.FiltraParametros("Tipo IN ('D') AND EsPadre = 1 AND CveSistema =47").Rows)
|
|
{
|
|
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));
|
|
deduccionesindem += Importe;
|
|
}
|
|
|
|
|
|
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) && (dtempleadosConceptos.COUNT("CveConcepto", string.Format("CveConcepto={0} AND CvePersonal ={1} AND Estatus >0", CveConcepto, SRCvePersonal)) == 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) && (dtempleadosConceptos.COUNT("CveConcepto", string.Format("CveConcepto={0} AND CvePersonal ={1} AND Estatus >0", CveConcepto, SRCvePersonal)) == 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();
|
|
|
|
|
|
nConcepto.isSavedP = dtempleadosConceptos.COUNT("CveConcepto", string.Format("CveConcepto={0} AND CvePersonal ={1} AND Estatus >0", CveConcepto, SRCvePersonal));
|
|
nConcepto.isEditedP = dtempleadosConceptos.COUNT("CveConcepto", string.Format("CveConcepto={0} AND CvePersonal ={1} AND Estatus =2", CveConcepto, 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));
|
|
nConcepto.isOnlyBisibleD = row["SoloVisible"].ToString().ToEntero();
|
|
|
|
|
|
nConcepto.isSavedD = dtempleadosConceptos.COUNT("CveConcepto", string.Format("CveConcepto={0} AND CvePersonal ={1} AND Estatus >0", CveConcepto, SRCvePersonal));
|
|
nConcepto.isEditedD = dtempleadosConceptos.COUNT("CveConcepto", string.Format("CveConcepto={0} AND CvePersonal ={1} AND Estatus =2", CveConcepto, 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)) - percepcionesindem;
|
|
///Alert(SubTotales.ImporteP.ToString());
|
|
|
|
|
|
SubTotales.CveConceptoD = 0;
|
|
SubTotales.ConceptoD = "Total Deducciones";
|
|
SubTotales.EstatusD = -2;
|
|
SubTotales.ImporteD = dtempleados.SUM("SumaDeducciones", string.Format("CvePersonal = {0}", SRCvePersonal)) - deduccionesindem;
|
|
|
|
double neto = SubTotales.ImporteP - SubTotales.ImporteD;
|
|
NConcepto Totales = new NConcepto();
|
|
Totales.CveConceptoD = 0;
|
|
Totales.ConceptoD = "Total";
|
|
Totales.EstatusD = -3;
|
|
Totales.ImporteD = neto;
|
|
|
|
lconc.Add(SubTotales);
|
|
lconc.Add(Totales);
|
|
return lconc;
|
|
|
|
}
|
|
|
|
private List<NConcepto> cargasobrericiboconceptosIndemnizacion(DataTable dtConceptos, DataTable dtempleadosConceptos, DataTable dtempleados)
|
|
{
|
|
int SRCvePersonal = this.CvePersonal;
|
|
DataTable dtper = dtConceptos.FiltraParametros("Tipo IN ('P') AND EsPadre = 1 AND CveSistema IN(10,11,32) ");
|
|
DataTable dtded = dtConceptos.FiltraParametros("Tipo IN ('D') AND EsPadre = 1 AND CveSistema = 47");
|
|
double percepcionesindem = 0;
|
|
double deduccionesindem = 0;
|
|
foreach (DataRow row in dtConceptos.FiltraParametros("Tipo IN ('P') AND EsPadre = 1 And CveSistema IN(10,11,32) ").Rows)
|
|
{
|
|
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));
|
|
percepcionesindem += Importe;
|
|
}
|
|
foreach (DataRow row in dtConceptos.FiltraParametros("Tipo IN ('D') AND EsPadre = 1 AND CveSistema =47").Rows)
|
|
{
|
|
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));
|
|
deduccionesindem += Importe;
|
|
}
|
|
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) && (dtempleadosConceptos.COUNT("CveConcepto", string.Format("CveConcepto={0} AND CvePersonal ={1} AND Estatus >0", CveConcepto, SRCvePersonal)) == 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) && (dtempleadosConceptos.COUNT("CveConcepto", string.Format("CveConcepto={0} AND CvePersonal ={1} AND Estatus >0", CveConcepto, SRCvePersonal)) == 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();
|
|
|
|
|
|
nConcepto.isSavedP = dtempleadosConceptos.COUNT("CveConcepto", string.Format("CveConcepto={0} AND CvePersonal ={1} AND Estatus >0", CveConcepto, SRCvePersonal));
|
|
nConcepto.isEditedP = dtempleadosConceptos.COUNT("CveConcepto", string.Format("CveConcepto={0} AND CvePersonal ={1} AND Estatus =2", CveConcepto, 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));
|
|
nConcepto.isOnlyBisibleD = row["SoloVisible"].ToString().ToEntero();
|
|
|
|
|
|
nConcepto.isSavedD = dtempleadosConceptos.COUNT("CveConcepto", string.Format("CveConcepto={0} AND CvePersonal ={1} AND Estatus >0", CveConcepto, SRCvePersonal));
|
|
nConcepto.isEditedD = dtempleadosConceptos.COUNT("CveConcepto", string.Format("CveConcepto={0} AND CvePersonal ={1} AND Estatus =2", CveConcepto, SRCvePersonal));
|
|
}
|
|
lconc.Add(nConcepto);
|
|
}
|
|
|
|
lconc.Add(new NConcepto());
|
|
|
|
NConcepto SubTotales = new NConcepto();
|
|
SubTotales.CveConceptoP = 0;
|
|
SubTotales.ConceptoP = "Total Percepciones";
|
|
SubTotales.EstatusP = -2;
|
|
SubTotales.ImporteP = percepcionesindem;
|
|
///Alert(SubTotales.ImporteP.ToString());
|
|
|
|
|
|
SubTotales.CveConceptoD = 0;
|
|
SubTotales.ConceptoD = "Total Deducciones";
|
|
SubTotales.EstatusD = -2;
|
|
SubTotales.ImporteD = deduccionesindem;
|
|
|
|
double neto = SubTotales.ImporteP - SubTotales.ImporteD;
|
|
NConcepto Totales = new NConcepto();
|
|
Totales.CveConceptoD = 0;
|
|
Totales.ConceptoD = "Total";
|
|
Totales.EstatusD = -3;
|
|
Totales.ImporteD = neto;
|
|
|
|
lconc.Add(SubTotales);
|
|
lconc.Add(Totales);
|
|
return lconc;
|
|
|
|
}
|
|
|
|
int CveConceptoPolgvc, CveConceptoDolgvc;
|
|
protected void GvConceptos_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
if (e.Row.RowIndex == 0)
|
|
{
|
|
CveConceptoPolgvc = 1;
|
|
CveConceptoDolgvc = 1;
|
|
}
|
|
// 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();
|
|
bool isEditedP = e.Row.DataKey("isEditedP").ToEntero() > 0;
|
|
bool isEditedD = e.Row.DataKey("isEditedD").ToEntero() > 0;
|
|
//isEditedD
|
|
// 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");
|
|
|
|
LinkButton LnkImportexCalculo = e.Row.FCLinkButton("LnkImportexCalculo");
|
|
LinkButton LnkImporteDxCalculo = e.Row.FCLinkButton("LnkImporteDxCalculo");
|
|
bool isSavedP = e.Row.DataKey("isSavedP").ToEntero() > 0;
|
|
bool isSavedD = e.Row.DataKey("isSavedD").ToEntero() > 0;
|
|
|
|
//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 (isEditedP)
|
|
{
|
|
e.Row.CssClass = string.Format("{0} isEditedP", e.Row.CssClass);
|
|
}
|
|
if (isEditedD)
|
|
{
|
|
e.Row.CssClass = string.Format("{0} isEditedD", e.Row.CssClass);
|
|
}
|
|
|
|
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; }
|
|
|
|
LtlImporte.Visible = false;
|
|
LtlImporteD.Visible = false;
|
|
if (Estatus < -1 | EstatusD < -1)
|
|
{
|
|
e.Row.CssClass = "ConceptosTotales";
|
|
LtlImporte.Visible = true;
|
|
LtlImporteD.Visible = true;
|
|
}
|
|
LnkImporte.CommandArgument = (CveConcepto > 0 ? CveConcepto.ToString() : "P");
|
|
LnkImporteD.CommandArgument = (CveConceptoD > 0 ? CveConceptoD.ToString() : "D");
|
|
LnkImportexCalculo.CommandArgument = LnkImporte.CommandArgument;
|
|
LnkImporteDxCalculo.CommandArgument = LnkImporteD.CommandArgument;
|
|
LnkImportexCalculo.Visible = isSavedP && !esSimulacion && !NominaAutorizada;
|
|
LnkImporteDxCalculo.Visible = isSavedD && !esSimulacion && !NominaAutorizada;
|
|
|
|
LnkImporte.Text = (CveConcepto > 0 ? string.Format("${0:N2}", e.Row.DataKey("ImporteP").ToDecimal()) : (CveConceptoPolgvc > 0 ? "<i class=\"fa fa-plus\"></i>" : ""));
|
|
LnkImporteD.Text = (CveConceptoD > 0 ? string.Format("${0:N2}", e.Row.DataKey("ImporteD").ToDecimal()) : (CveConceptoDolgvc > 0 ? "<i class=\"fa fa-plus\"></i>" : ""));
|
|
|
|
|
|
|
|
if (CveConcepto == 0 && (Estatus == 0 || Estatus == -1 || Estatus == -3)) { LtlImporte.Text = ""; }
|
|
|
|
if (CveConceptoD == 0 && (EstatusD == 0 || EstatusD == -1)) { LtlImporteD.Text = ""; }
|
|
|
|
|
|
|
|
LnkConcepto.Visible = !LtlConcepto.Visible;
|
|
LnkConceptoD.Visible = !LtlConceptoD.Visible;
|
|
LnkImporte.Visible = !LtlImporte.Visible;
|
|
LnkImporteD.Visible = !LtlImporteD.Visible;
|
|
|
|
LinkButton LnkConceptoO = e.Row.FCLinkButton("LnkConceptoO");
|
|
LinkButton LnkImporteO = e.Row.FCLinkButton("LnkImporteO");
|
|
if (LnkConceptoO != null)
|
|
{
|
|
LnkConceptoO.Visible = false;
|
|
LnkImporteO.Visible = false;
|
|
if (e.Row.DBCampo("ImporteO").ToDecimal() == 0)
|
|
{
|
|
e.Row.FCLabel("LtlConceptoO").Visible = false;
|
|
e.Row.FCLabel("LtlImporteO").Visible = false;
|
|
if (e.Row.DataKey("isOnlyBisibleO").ToEntero() == 1)
|
|
{
|
|
e.Row.CssClass = string.Format("{0} isOnlyBisibleO", e.Row.CssClass);
|
|
}
|
|
}
|
|
}
|
|
|
|
CveConceptoPolgvc = CveConcepto;
|
|
CveConceptoDolgvc = CveConceptoD;
|
|
}
|
|
}
|
|
|
|
protected void LnkCancelar_Click(object sender, EventArgs e)
|
|
{
|
|
LnkFormatoRenuncia.Visible = false;
|
|
using (ClsNominas onom = new ClsNominas())
|
|
{
|
|
if (onom.RemoveFiniquito(CvePersonal, UsuarioActual.CveEmpresa, CvePersonalAltas))
|
|
{
|
|
loadsobrerecibo(onom);
|
|
Alert("se ha eliminado el proceso de finiquito");
|
|
UPDatos.Update();
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void LnkCancelarNomina_Click(object sender, EventArgs e)
|
|
{
|
|
DataTable dtr = dtempleados.FiltraParametros("CvePersonal > 0 AND NomAutorizado =1 AND SeTimbro=0", "", new string[] { "CveNomina" });
|
|
bool continuar = true;
|
|
|
|
using (ClsNominas Nom = new ClsNominas())
|
|
{
|
|
Nom.IniciaTransacSQL();
|
|
//AutorizaNom_Nominas
|
|
foreach (DataRow drow in dtr.Rows)
|
|
{
|
|
if (continuar && (continuar = Nom.RemoveNom_Nominas(drow["CveNomina"].ToString().ToEntero(), false, UsuarioActual.CveUsuario)))
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
if (continuar)
|
|
{
|
|
|
|
Nom.Commit();
|
|
}
|
|
if (continuar)
|
|
{
|
|
Alert("Los movimientos de la nómina fueron eliminados", TipoMensaje.MsgInformacion);
|
|
loadsobrerecibo(Nom);
|
|
|
|
}
|
|
}
|
|
}
|
|
protected void LnkShowFfiniquito_Click(object sender, EventArgs e)
|
|
{
|
|
RegistraScript("$('#ModalSueldoFiniquito').modal('show');");
|
|
}
|
|
|
|
protected void LnkAutorizar_Click(object sender, EventArgs e)
|
|
{
|
|
autorizarNomina(CvePersonal);
|
|
UPDatos.Update();
|
|
//Alert("El finiquito se ha autorizado satisfactoriamente.");
|
|
//LnkAutorizar.Visible = false;
|
|
//LnkTimbrar.Visible = true;
|
|
}
|
|
|
|
|
|
private void autorizarNomina(int FiltroCvePersonal)
|
|
{
|
|
|
|
bool continuar = true;
|
|
string[] getcolumnas = new string[] { "CvePersonal", "CveMetodoPago", "SumaPercepciones", "Total", "SalarioDiario", "SalarioDiarioIMSS", "SalarioDiarioIntegrado", "DiasLaborados", "DiasFaltados", "DiasVacaciones", "DiasIncapacidad" };
|
|
|
|
DataTable dtr = dtempleados.FiltraParametros(string.Format("(CvePersonal={0} OR {0}=-1) AND CvePersonal > 0 AND NomAutorizado =0", FiltroCvePersonal), "", getcolumnas);
|
|
DataTable dtconp = null;
|
|
int CvePeriodoSeleccionado = CvePeriodoFiniquito;//cambiar reparar
|
|
#region PropNomina
|
|
int CvePersonal = 0;
|
|
int CveNomina = 0;
|
|
int CveMetodoPago = 0;
|
|
double SubTotal = 0;
|
|
double Total = 0;
|
|
int CveMoneda = 1;
|
|
#endregion
|
|
#region PropNominaDetalle
|
|
int CveConcepto = 0;
|
|
decimal ImporteConcepto = 0, ImporteGravadoConcepto = 0, ImporteExentoConcepto = 0, ImporteValor = 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();
|
|
SubTotal = rtemp["SumaPercepciones"].ToString().ToDouble();
|
|
Total = rtemp["Total"].ToString().ToDouble();
|
|
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, 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
|
|
{
|
|
continuar = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (CveNomina == 0)
|
|
{
|
|
continuar = false;
|
|
}
|
|
|
|
|
|
if (continuar)
|
|
{
|
|
dtconp = dtempleadosConceptos.FiltraParametros(string.Format("CvePersonal={0} AND (Importe<>0 OR Valor <>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;
|
|
ImporteValor = rcon["Valor"].ToString().ToDecimal();
|
|
if (continuar)
|
|
{
|
|
|
|
if (!objNomina.AddUPNom_NominasDetalles(CveNomina, CvePeriodoSeleccionado, CvePersonal, CveConcepto, ImporteConcepto, ImporteGravadoConcepto, ImporteExentoConcepto, ImporteValor, UsuarioActual.CveUsuario, false, 1, 1, 1))
|
|
{
|
|
continuar = false;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
if (continuar)
|
|
{
|
|
decimal SalarioDiario = rtemp["SalarioDiario"].ToString().ToEntero();
|
|
decimal SalarioDiarioIMSS = rtemp["SalarioDiarioIMSS"].ToString().ToEntero();
|
|
decimal SalarioDiarioIntegrado = rtemp["SalarioDiarioIntegrado"].ToString().ToEntero();
|
|
int DiasLaborados = rtemp["DiasLaborados"].ToString().ToEntero();
|
|
int DiasFaltados = rtemp["DiasFaltados"].ToString().ToEntero();
|
|
int DiasVacaciones = rtemp["DiasVacaciones"].ToString().ToEntero();
|
|
int DiasIncapacidad = rtemp["DiasIncapacidad"].ToString().ToEntero();
|
|
continuar = objNomina.PA_Nom_NominasAutorizarUP(CvePersonal, CvePeriodoSeleccionado, SalarioDiario, SalarioDiarioIMSS, SalarioDiarioIntegrado, 0, 0, Total, SubTotal, DiasLaborados, DiasFaltados, DiasVacaciones, DiasIncapacidad);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (continuar)
|
|
{
|
|
objNomina.Commit();
|
|
LnkAutorizar.Visible = false;
|
|
LnkTimbrar.Visible = true;
|
|
|
|
LnkGuardarDatos.Enabled = false;
|
|
|
|
LnkGuardarDatos.CssClass = "btn btn-default";
|
|
LnkGuardarDatos.ToolTip = "el finiquito ha sido capturado.";
|
|
Alert("La nomina se autorizó correctamente.");
|
|
}
|
|
else
|
|
{
|
|
objNomina.RollBack();
|
|
|
|
}
|
|
}
|
|
if (dtr != null)
|
|
{
|
|
dtr.Dispose();
|
|
|
|
}
|
|
if (dtconp != null)
|
|
{
|
|
dtconp.Dispose();
|
|
|
|
}
|
|
}
|
|
|
|
protected void LnkTimbrar_Click(object sender, EventArgs e)
|
|
{
|
|
int CvePeriodo = CvePeriodoFiniquito;
|
|
|
|
string[] getcolumnas = new string[] { "CvePersonal", "CveMetodoPago", "CveNomina", "Total", "SalarioDiario", "SalarioDiarioIMSS", "SalarioDiarioIntegrado", "DiasLaborados", "DiasFaltados", "DiasVacaciones", "DiasIncapacidad" };
|
|
|
|
DataTable dtr = dtempleados.FiltraParametros(string.Format(" CvePersonal={0} ", CvePersonal), "", getcolumnas);
|
|
int CveNomina = dtr.Rows[0]["CveNomina"].ToString().ToEntero();
|
|
LogicNominas lognom = new LogicNominas();
|
|
|
|
|
|
string Msg = "";
|
|
Msg = lognom.TimbrarNomina(CveNomina, CvePersonal, CvePeriodo, UsuarioActual, versionTimbre: VersionTimbradoEnum.Version4_0);
|
|
|
|
if (Msg != null && Msg.Length > 0)
|
|
{ Alert(Msg, TipoMensaje.MsgAdvertencia); }
|
|
else
|
|
{
|
|
using (ClsNominas ObjPeriodo = new ClsNominas())
|
|
{
|
|
|
|
//ObjPeriodo.CambiaEstatusPeriodo(CvePeriodo, (int)enumNominasEstatus.Timbrada, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa);
|
|
loadsobrerecibo(ObjPeriodo);
|
|
}
|
|
//ObjPeriodo.Dispose();
|
|
//Alert("Se ha timbrado correctamente");
|
|
|
|
Alert("El finiquito se ha timbrado satisfactoriamente");
|
|
LnkTimbrar.Visible = false; UPDatos.Update();
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
protected void LnkFormatoRenuncia_Click(object sender, EventArgs e)
|
|
{
|
|
if (dtConceptos != null)
|
|
{
|
|
|
|
DataTable dtper = dtConceptos.FiltraParametros("Tipo IN ('P') AND EsPadre = 1 AND SoloVisible =0");
|
|
DataTable dtded = dtConceptos.FiltraParametros("Tipo IN ('D') AND EsPadre = 1 AND SoloVisible =0");
|
|
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), string.Format("CvePersonal = {0}", CvePersonal)) != 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), string.Format("CvePersonal = {0}", CvePersonal)) != 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}", CvePersonal));
|
|
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}", CvePersonal));
|
|
}
|
|
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}", CvePersonal));
|
|
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}", CvePersonal));
|
|
}
|
|
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}", CvePersonal));
|
|
///Alert(SubTotales.ImporteP.ToString());
|
|
|
|
SubTotales.CveConceptoD = 0;
|
|
SubTotales.ConceptoD = "Total Deducciones";
|
|
SubTotales.EstatusD = -2;
|
|
SubTotales.ImporteD = dtempleados.SUM("SumaDeducciones", string.Format("CvePersonal = {0}", CvePersonal));
|
|
|
|
NConcepto Totales = new NConcepto();
|
|
Totales.CveConceptoD = 0;
|
|
Totales.ConceptoD = "Total";
|
|
Totales.EstatusD = -3;
|
|
Totales.ImporteD = dtempleados.SUM("Total", string.Format("CvePersonal = {0}", CvePersonal));
|
|
|
|
lconc.Add(SubTotales);
|
|
lconc.Add(Totales);
|
|
|
|
DataTable dtCon = new DataTable();
|
|
dtCon.Columns.Add(new DataColumn("NoConceptoP", typeof(string)));
|
|
dtCon.Columns.Add(new DataColumn("ConceptoP", typeof(string)));
|
|
dtCon.Columns.Add(new DataColumn("LabelValorP", typeof(string)));
|
|
dtCon.Columns.Add(new DataColumn("CveConceptoP", typeof(int)));
|
|
dtCon.Columns.Add(new DataColumn("ImporteP", typeof(double)));
|
|
dtCon.Columns.Add(new DataColumn("ValorP", typeof(double)));
|
|
dtCon.Columns.Add(new DataColumn("EstatusP", typeof(int)));
|
|
dtCon.Columns.Add(new DataColumn("isEditedP", typeof(int)));
|
|
dtCon.Columns.Add(new DataColumn("isOnlyBisibleP", typeof(int)));
|
|
dtCon.Columns.Add(new DataColumn("NoConceptoD", typeof(string)));
|
|
dtCon.Columns.Add(new DataColumn("ConceptoD", typeof(string)));
|
|
dtCon.Columns.Add(new DataColumn("LabelValorD", typeof(string)));
|
|
dtCon.Columns.Add(new DataColumn("CveConceptoD", typeof(int)));
|
|
dtCon.Columns.Add(new DataColumn("ImporteD", typeof(double)));
|
|
dtCon.Columns.Add(new DataColumn("ValorD", typeof(double)));
|
|
dtCon.Columns.Add(new DataColumn("EstatusD", typeof(int)));
|
|
dtCon.Columns.Add(new DataColumn("isEditedD", typeof(int)));
|
|
dtCon.Columns.Add(new DataColumn("isOnlyBisibleD", typeof(int)));
|
|
foreach (NConcepto itc in lconc)
|
|
{
|
|
DataRow dr = dtCon.NewRow();
|
|
dr["NoConceptoP"] = itc.NoConceptoP;
|
|
dr["ConceptoP"] = itc.ConceptoP;
|
|
dr["LabelValorP"] = itc.LabelValorP;
|
|
dr["CveConceptoP"] = itc.CveConceptoP;
|
|
dr["ImporteP"] = itc.ImporteP;
|
|
dr["ValorP"] = itc.ValorP;
|
|
dr["EstatusP"] = itc.EstatusP;
|
|
dr["isEditedP"] = itc.isEditedP;
|
|
dr["isOnlyBisibleP"] = itc.isOnlyBisibleP;
|
|
dr["NoConceptoD"] = itc.NoConceptoD;
|
|
dr["ConceptoD"] = itc.ConceptoD;
|
|
dr["LabelValorD"] = itc.LabelValorD;
|
|
dr["CveConceptoD"] = itc.CveConceptoD;
|
|
dr["ImporteD"] = itc.ImporteD;
|
|
dr["ValorD"] = itc.ValorD;
|
|
dr["EstatusD"] = itc.EstatusD;
|
|
dr["isEditedD"] = itc.isEditedD;
|
|
dr["isOnlyBisibleD"] = itc.isOnlyBisibleD;
|
|
dtCon.Rows.Add(dr);
|
|
}
|
|
dtCon.AcceptChanges();
|
|
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 = dtCon;// 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 = "";
|
|
string SubProyecto = "";
|
|
string Usuario = UsuarioActual.Nombre;
|
|
string FolioFiscal = "";
|
|
{
|
|
DataRow drow = dtempleados.FiltroPrimero(string.Format("CvePersonal = {0}", CvePersonal));
|
|
if (drow != null)
|
|
{
|
|
SubProyecto = drow["SubProyecto"].ToString();
|
|
FolioFiscal = string.Format("{0}", drow["FolioFiscal"]);
|
|
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(CvePersonal, 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();
|
|
FechaFin = TxtFechaBaja.Text;//string.Format("{0:dd/MM/yyyy}", drow["FechaFin"]);
|
|
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("Empresa", UsuarioActual.Empresa.Empresa));
|
|
parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("SubProyecto", SubProyecto));
|
|
parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("FechaPago", ""));
|
|
parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("FolioFiscal", FolioFiscal));
|
|
parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("Usuario", Usuario));
|
|
//parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("", ""));
|
|
//parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("", ""));
|
|
//parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("", ""));
|
|
string urlfile = System.IO.Path.Combine(string.Format("{0}Formatos/SobreReciboFiniquito.rdlc", UsuarioActual.Empresa.Ruta));
|
|
if (!System.IO.File.Exists(urlfile))
|
|
{
|
|
urlfile = System.IO.Path.Combine(ModExtensiones.DirectorioBaseEmpresas, "Empresas/Grales/Formatos/SobreReciboFiniquito.rdlc");
|
|
}
|
|
|
|
ImprimirPDF(urlfile, lrds, parametros, "SobreRecibo", "PDF", null);
|
|
}
|
|
else
|
|
{
|
|
Alert("sin información disponible.");
|
|
}
|
|
}
|
|
} |