This commit is contained in:
JORGE LUIS CAUDILLO ESPARZA
2021-05-19 10:42:08 -07:00
parent a92f48dc3b
commit 2b1cf3ccae
21 changed files with 3119 additions and 1065 deletions

View File

@@ -87,8 +87,10 @@ public partial class Nomina_Finiquito : ClsPaginas
if (Request["CvePersonal"] != null && Request["CvePersonal"].ToString().ToEntero() > 0)
{
ViewState["CvePersonal"] = Request["CvePersonal"].ToString().ToEntero();
CargaPersonal();
HypCodigo.NavigateUrl = $"/RH/Personal.aspx?CvePersonal={CvePersonal}";
HypEmpleado.NavigateUrl = $"/RH/Personal.aspx?CvePersonal={CvePersonal}";
CargaMotivoBaja();
CargaPersonal();
}
else
{
@@ -97,9 +99,14 @@ public partial class Nomina_Finiquito : ClsPaginas
LtlEmpleadoCancelar.Visible = false;
RegistraScript("$('#ModalEmpleados').modal();");
}
gconceptos.Visible = ChkesLiquidacion.Checked;
}
}
protected void ChkesLiquidacion_CheckedChanged(object sender, EventArgs e)
{
gconceptos.Visible = ChkesLiquidacion.Checked;
}
private void CargaMotivoBaja()
{
DdlMotivoBaja.DataSource = GlobalDTMotivoBaja.FiltraParametros("CveEmpresa = " + UsuarioActual.CveEmpresa);
@@ -126,8 +133,11 @@ public partial class Nomina_Finiquito : ClsPaginas
DataRow drow = ObjPersonal.DtResultados.Rows[0];
HypCodigo.Text = drow["Codigo"].ToString();
HypEmpleado.Text = drow["NombreCompleto"].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");
@@ -136,7 +146,24 @@ public partial class Nomina_Finiquito : ClsPaginas
LblFechaAlta.Text = string.Format("{0:dd/MM/yyyy}", da["FechaInicio"]);
FechaInicio = LblFechaAlta.Text.ToDateTime();
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" });
}
}
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();
@@ -161,7 +188,7 @@ public partial class Nomina_Finiquito : ClsPaginas
private void CamposCalculados()
{
TxtSalarioMinimo.Text = "123.22";
//TxtSalarioMinimo.Text = "123.22";
if (TxtFechaBaja.Text.Length > 9)
{
DateTime fechafin = TxtFechaBaja.Text.ToDateTime();
@@ -179,15 +206,19 @@ public partial class Nomina_Finiquito : ClsPaginas
private decimal getyearsresult(DateTime fechafin, DateTime fechainicio)
{
decimal retorno = 0;
DateTime zeroTime = new DateTime(1, 1, 1);
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;
}
@@ -257,11 +288,36 @@ public partial class Nomina_Finiquito : ClsPaginas
}
//PnlConceptoPersonal.Visible = false;
//DdlmcConceptos_SelectedIndexChanged(DdlmcConceptos, null);
DdlmcConceptos_SelectedIndexChanged(DdlmcConceptos, null);
RegistraScript(string.Format("$('#ModalUpConcepto').on('shown.bs.modal', function () {{$('#{0}').trigger('focus')}});$('#ModalUpConcepto').modal();", TxtmcImporte.ClientID));
UPpanelModalUpConcepto.Update();
}
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 CveConceptoPolgvc, CveConceptoDolgvc;
protected void GvConceptos_RowDataBound(object sender, GridViewRowEventArgs e)
{
@@ -745,8 +801,30 @@ public partial class Nomina_Finiquito : ClsPaginas
private List<NConcepto> cargasobrericiboconceptos(DataTable dtConceptos, DataTable dtempleadosConceptos, DataTable dtempleados)
{
int SRCvePersonal = this.CvePersonal;
DataTable dtper = dtConceptos.FiltraParametros("Tipo IN ('P') AND EsPadre = 1 ");
DataTable dtded = dtConceptos.FiltraParametros("Tipo IN ('D') AND EsPadre = 1 ");
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 <> 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));
@@ -824,19 +902,145 @@ public partial class Nomina_Finiquito : ClsPaginas
SubTotales.CveConceptoP = 0;
SubTotales.ConceptoP = "Total Percepciones";
SubTotales.EstatusP = -2;
SubTotales.ImporteP = dtempleados.SUM("SumaPercepciones", string.Format("CvePersonal = {0}", SRCvePersonal));
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));
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 = dtempleados.SUM("Total", string.Format("CvePersonal = {0}", SRCvePersonal));
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))
{
BorradoLogico = 1;
}
row["BorradoLogico"] = BorradoLogico;
}
dtper.AcceptChanges();
foreach (DataRow row in dtded.Rows)
{
int BorradoLogico = 0;
int CveConcepto = row["CveConcepto"].ToString().ToEntero();
if (!(dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) != 0))
{
BorradoLogico = 1;
}
row["BorradoLogico"] = BorradoLogico;
}
dtded.AcceptChanges();
dtper = dtper.FiltraParametros("BorradoLogico=0");
dtded = dtded.FiltraParametros("BorradoLogico=0");
int maxper = dtper.Rows.Count;
int maxded = dtded.Rows.Count;
int i = 0;
List<NConcepto> lconc = new List<NConcepto>();
for (i = 0; i < maxper || i < maxded; i++)
{
NConcepto nConcepto = new NConcepto();
DataRow row;
if (maxper > i)
{
row = dtper.Rows[i];
int CveConcepto = row["CveConcepto"].ToString().ToEntero();
string Concepto = row["Concepto"].ToString();
string Codigo = row["Codigo"].ToString();
//bool visible = (dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) > 0);
double Importe = dtempleados.SUM(string.Format("[V_{0}]", CveConcepto), string.Format("CvePersonal = {0}", SRCvePersonal));
nConcepto.CveConceptoP = CveConcepto;
nConcepto.ConceptoP = Concepto;
nConcepto.NoConceptoP = Codigo;
nConcepto.ImporteP = Importe;
nConcepto.ValorP = dtempleados.SUM(string.Format("[VAL_{0}]", CveConcepto), string.Format("CvePersonal = {0}", SRCvePersonal));
nConcepto.isOnlyBisibleP = row["SoloVisible"].ToString().ToEntero();
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.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);
@@ -858,7 +1062,7 @@ public partial class Nomina_Finiquito : ClsPaginas
using (ClsRH ObjPersonal = new ClsRH())
using (ClsNominas onom = new ClsNominas(ObjPersonal.IniciaTransacSQL()))
{
if (ObjPersonal.UpPersonalAltas(CvePersonal, "", TxtFechaBaja.Text.ToDateTime().ToString("yyyy/MM/dd"), -1, DdlMotivoBaja.SelectedValue.ToEntero(), ChkesLiquidacion.Checked) && ObjPersonal.GetPersonalAltas(CvePersonal) && ObjPersonal.DtResultados.Rows.Count > 0)
if (ObjPersonal.UpPersonalAltas(CvePersonal, "", TxtFechaBaja.Text.ToDateTime().ToString("yyyy/MM/dd"), -1, 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();
@@ -894,6 +1098,7 @@ public partial class Nomina_Finiquito : ClsPaginas
DataTable dtempleados = null;
*/
/*
if (objnom.GetNominaEmpleado(-1, -1, -1, CvePeriodoIndemnizacion, UsuarioActual.CveEmpresa, 1, 3, CvePersonal) && objnom.DTSetResultados.Tables.Count > 1)
{
dtempleados = objnom.DTSetResultados.Tables[3];
@@ -903,7 +1108,7 @@ public partial class Nomina_Finiquito : ClsPaginas
if (dtConceptos != null && dtempleadosConceptos != null && dtempleados != null)
{
finindem = cargasobrericiboconceptos(dtConceptos, dtempleadosConceptos, dtempleados);
}
}*/
dtempleadosConceptos = null;
dtempleados = null;
if (objnom.GetNominaEmpleado(-1, -1, -1, CvePeriodoFiniquito, UsuarioActual.CveEmpresa, 1, 3, CvePersonal) && objnom.DTSetResultados.Tables.Count > 1)
@@ -919,6 +1124,7 @@ public partial class Nomina_Finiquito : ClsPaginas
if (dtConceptos != null && dtempleadosConceptos != null && dtempleados != null)
{
finordin = cargasobrericiboconceptos(dtConceptos, dtempleadosConceptos, dtempleados);
finindem = cargasobrericiboconceptosIndemnizacion(dtConceptos, dtempleadosConceptos, dtempleados);
}
GvFinOrdinario.DataSource = finordin;
@@ -1105,7 +1311,7 @@ public partial class Nomina_Finiquito : ClsPaginas
using (ClsRH ObjPersonal = new ClsRH())
using (ClsNominas onom = new ClsNominas(ObjPersonal.IniciaTransacSQL()))
{
if (ObjPersonal.UpPersonalAltas(CvePersonal, "", TxtFechaBaja.Text.ToDateTime().ToString("yyyy/MM/dd"), -1, DdlMotivoBaja.SelectedValue.ToEntero(), ChkesLiquidacion.Checked) && ObjPersonal.GetPersonalAltas(CvePersonal) && ObjPersonal.DtResultados.Rows.Count > 0)
if (ObjPersonal.UpPersonalAltas(CvePersonal, "", TxtFechaBaja.Text.ToDateTime().ToString("yyyy/MM/dd"), -1, 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();
@@ -1131,12 +1337,7 @@ public partial class Nomina_Finiquito : ClsPaginas
}
UPDatos.Update();
}
protected void DdlmcConceptos_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void BtnAceptarMC_Click(object sender, EventArgs e)
{
@@ -1211,7 +1412,7 @@ public partial class Nomina_Finiquito : ClsPaginas
loadsobrerecibo(objNomina);
}
Alert("El cambio se ha guardado correctamente.");
}
}
}
else
@@ -1227,4 +1428,5 @@ public partial class Nomina_Finiquito : ClsPaginas
}
}
}