This commit is contained in:
440
Nomina/Finiquito.aspx.cs
Normal file
440
Nomina/Finiquito.aspx.cs
Normal file
@@ -0,0 +1,440 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
using System.Data;
|
||||
using Extensiones;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
partial class Nomina_Finiquito : ClsPaginas
|
||||
{
|
||||
private class ConceptosPersonal
|
||||
{
|
||||
public ConceptosPersonal()
|
||||
{
|
||||
Concepto = "";
|
||||
ConceptoD = "";
|
||||
CveConcepto = 0;
|
||||
CveConceptoD = 0;
|
||||
Estatus = 0;
|
||||
Estatus = 0;
|
||||
}
|
||||
public string Concepto { get; set; }
|
||||
public int CveConcepto { get; set; }
|
||||
public decimal Importe { get; set; }
|
||||
public int Estatus { get; set; }
|
||||
|
||||
public string ConceptoD { get; set; }
|
||||
public int CveConceptoD { get; set; }
|
||||
public decimal ImporteD { get; set; }
|
||||
public int EstatusD { get; set; }
|
||||
}
|
||||
#region Propiedades
|
||||
private int CvePersonal
|
||||
{
|
||||
get { return ViewState["CvePersonal"] != null ? ViewState["CvePersonal"].ToString().ToEntero() : 0; }
|
||||
set { ViewState["CvePersonal"] = value; }
|
||||
}
|
||||
private int CveTipoPeriodo
|
||||
{
|
||||
get { return ViewState["CveTipoPeriodo"] != null ? ViewState["CveTipoPeriodo"].ToString().ToEntero() : 0; }
|
||||
set
|
||||
{
|
||||
ViewState["CveTipoPeriodo"] = value;
|
||||
}
|
||||
}
|
||||
private int CvePeriodoFiniquito
|
||||
{
|
||||
get { return ViewState["CvePeriodoFiniquito"] != null ? ViewState["CvePeriodoFiniquito"].ToString().ToEntero() : 0; }
|
||||
set { ViewState["CvePeriodoFiniquito"] = value; }
|
||||
}
|
||||
|
||||
private int GCEstatus
|
||||
{
|
||||
get { return ViewState["GCEstatus"] != null ? ViewState["GCEstatus"].ToString().ToEntero() : 0; }
|
||||
set { ViewState["GCEstatus"] = value; }
|
||||
}
|
||||
private int GCCveConcepto
|
||||
{
|
||||
get { return ViewState["GCCveConcepto"] != null ? ViewState["GCCveConcepto"].ToString().ToEntero() : 0; }
|
||||
set { ViewState["GCCveConcepto"] = value; }
|
||||
}
|
||||
private decimal GCImporte
|
||||
{
|
||||
get { return ViewState["GCImporte"] != null ? ViewState["GCImporte"].ToString().ToDecimal() : 0; }
|
||||
set { ViewState["GCImporte"] = value; }
|
||||
}
|
||||
|
||||
|
||||
private DataTable DTConceptosPersonal
|
||||
{
|
||||
get { return ViewState["DTConceptosPersonal"] != null ? (DataTable)ViewState["DTConceptosPersonal"] : null; }
|
||||
set { ViewState["DTConceptosPersonal"] = value; }
|
||||
}
|
||||
private DataTable DTConceptos
|
||||
{
|
||||
get { return ViewState["DTConceptos"] != null ? (DataTable)ViewState["DTConceptos"] : null; }
|
||||
set { ViewState["DTConceptos"] = value; }
|
||||
}
|
||||
private bool esLiquidacion
|
||||
{
|
||||
get { return ViewState["esLiquidacion"] != null ? System.Convert.ToBoolean(ViewState["esLiquidacion"]) : false; }
|
||||
set { ViewState["esLiquidacion"] = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
private List<ConceptosPersonal> ConceptsPersonas
|
||||
{
|
||||
get
|
||||
{
|
||||
List<ConceptosPersonal> listaconceptos = new List<ConceptosPersonal>();
|
||||
decimal TotalP = 0;
|
||||
decimal TotalD = 0;
|
||||
if ((!Information.IsNothing(DTConceptosPersonal) && DTConceptosPersonal.Rows.Count > 0))
|
||||
{
|
||||
DataTable dtP = DTConceptosPersonal.FiltraParametros("Tipo=1");
|
||||
DataTable dtD = DTConceptosPersonal.FiltraParametros("Tipo=2");
|
||||
var noP = dtP.Rows.Count;
|
||||
var noD = dtD.Rows.Count;
|
||||
var max = noP > noD ? noP : noD;
|
||||
TotalP = dtP.SUM("Importe").ToString().ToDecimal();
|
||||
TotalD = dtD.SUM("Importe").ToString().ToDecimal();
|
||||
for (int index = 0; index <= max; index++)
|
||||
{
|
||||
ConceptosPersonal obj = new ConceptosPersonal();
|
||||
if (index < noP)
|
||||
{
|
||||
obj.Importe = dtP.Rows[index]["Importe"].ToString().ToDecimal();
|
||||
obj.CveConcepto = dtP.Rows[index]["CveConcepto"].ToString().ToEntero();
|
||||
obj.Concepto = dtP.Rows[index]["Concepto"].ToString();
|
||||
obj.Estatus = dtP.Rows[index]["Estatus"].ToString().ToEntero();
|
||||
}
|
||||
else if (index == noP)
|
||||
{
|
||||
obj.Estatus = -1;
|
||||
obj.Concepto = "Agregar";
|
||||
}
|
||||
if (index < noD)
|
||||
{
|
||||
obj.ImporteD = dtD.Rows[index]["Importe"].ToString().ToDecimal();
|
||||
obj.CveConceptoD = dtD.Rows[index]["CveConcepto"].ToString().ToEntero();
|
||||
obj.ConceptoD = dtD.Rows[index]["Concepto"].ToString();
|
||||
obj.EstatusD = dtD.Rows[index]["Estatus"].ToString().ToEntero();
|
||||
}
|
||||
else if (index == noD)
|
||||
{
|
||||
obj.EstatusD = -1;
|
||||
obj.ConceptoD = "Agregar";
|
||||
}
|
||||
listaconceptos.Add(obj);
|
||||
}
|
||||
}
|
||||
listaconceptos.Add(new ConceptosPersonal());
|
||||
|
||||
|
||||
ConceptosPersonal objST = new ConceptosPersonal();
|
||||
objST.Importe = TotalP;
|
||||
objST.CveConcepto = 0;
|
||||
objST.Concepto = "Total Percepciones";
|
||||
objST.Estatus = -2;
|
||||
objST.ImporteD = TotalD;
|
||||
objST.CveConceptoD = 0;
|
||||
objST.ConceptoD = "Total Deducciones";
|
||||
objST.EstatusD = -2;
|
||||
|
||||
listaconceptos.Add(objST);
|
||||
|
||||
ConceptosPersonal objT = new ConceptosPersonal();
|
||||
|
||||
objT.CveConcepto = 0;
|
||||
objT.Concepto = "";
|
||||
objT.Estatus = -3;
|
||||
objT.ImporteD = objST.Importe + objST.ImporteD;
|
||||
objT.CveConceptoD = 0;
|
||||
objT.ConceptoD = "Total";
|
||||
objT.EstatusD = -3;
|
||||
listaconceptos.Add(objT);
|
||||
return listaconceptos;
|
||||
}
|
||||
}
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!Page.IsPostBack)
|
||||
{
|
||||
CargaDdlPersonal();
|
||||
CargaMotivoBaja();
|
||||
CvePeriodoFiniquito = 0;
|
||||
if (Request["CvePersonal"] != null && Request["CvePersonal"].ToString().ToEntero() > 0)
|
||||
{
|
||||
CvePersonal = Request["CvePersonal"].ToString().ToEntero();
|
||||
}
|
||||
else
|
||||
{
|
||||
CvePersonal = -1;
|
||||
}
|
||||
if (!CargaDatosFiniquito())
|
||||
{
|
||||
}
|
||||
RegistraScript("$('#ModalEmpleados').modal();");
|
||||
}
|
||||
|
||||
if (CvePersonal > 0 & CvePeriodoFiniquito > 0)
|
||||
{
|
||||
LtlEmpleadoCancelar.Visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void CargaMotivoBaja()
|
||||
{
|
||||
DdlMotivoBaja.DataSource = GlobalDTMotivoBaja.FiltraParametros("CveEmpresa = " + UsuarioActual.CveEmpresa);
|
||||
DdlMotivoBaja.DataBind();
|
||||
}
|
||||
private void CargaDdlPersonal()
|
||||
{
|
||||
ClsRH ObjPersonal = new ClsRH();
|
||||
if (ObjPersonal.GetPersonal(-1, UsuarioActual.CveEmpresa))
|
||||
{
|
||||
DdlPersonal.DataSource = ObjPersonal.DtResultados;
|
||||
DdlPersonal.DataBind();
|
||||
}
|
||||
ObjPersonal.Dispose();
|
||||
}
|
||||
|
||||
private bool CargaDatosFiniquito()
|
||||
{
|
||||
bool retorno = true;
|
||||
if (CvePersonal > 0)
|
||||
{
|
||||
DdlPersonal.SelectedValueExist(CvePersonal.ToString());
|
||||
string Nombre = "";
|
||||
string FechaBaja = "";
|
||||
string EstatusPersonal = "";
|
||||
CvePeriodoFiniquito = 0;
|
||||
CveTipoPeriodo = 0;
|
||||
esLiquidacion = false;
|
||||
pnlupValoresFiniquito.Visible = false;
|
||||
DdlMotivoBaja.SelectedValue = "-1";
|
||||
using (ClsRH ObjPersonal = new ClsRH())
|
||||
{
|
||||
if (ObjPersonal.GetPersonal(CvePersonal, UsuarioActual.CveEmpresa) && ObjPersonal.DtResultados.Rows.Count > 0)
|
||||
{
|
||||
DataRow prow = ObjPersonal.DtResultados.Rows[0];
|
||||
Nombre = prow["Nombre"].ToString();
|
||||
FechaBaja = string.Format("{0:dd/MM/yyyy}", ObjPersonal.FechaBaja);
|
||||
EstatusPersonal = string.Format("{0}", prow["EstatusPersonal"]);
|
||||
CveTipoPeriodo = prow["CveTipoPeriodo"].ToString().ToEntero();
|
||||
}
|
||||
if (ObjPersonal.GetPersonalAltas(CvePersonal) && ObjPersonal.DtResultados.Rows.Count > 0)
|
||||
{
|
||||
DataRow prow = ObjPersonal.DtResultados.Rows[0];
|
||||
CvePeriodoFiniquito = prow["CvePeriodoFiniquito"].ToString().ToEntero();
|
||||
FechaBaja = string.Format("{0:dd/MM/yyyy}", prow["FechaFin"]);
|
||||
DdlMotivoBaja.SelectedValueExist(prow["CveMotivoBaja"].ToString().ToEntero());
|
||||
var stringesliquidacion = prow["esLiquidacion"].ToString();
|
||||
esLiquidacion = (stringesliquidacion == "True" || stringesliquidacion == "1");
|
||||
ChkesLiquidacion.Checked = esLiquidacion;
|
||||
}
|
||||
}
|
||||
if (DdlMotivoBaja.SelectedValue.ToEntero() > 0)
|
||||
LblMotivoBaja.Text = DdlMotivoBaja.SelectedItem.Text;
|
||||
else
|
||||
LblMotivoBaja.Text = "";
|
||||
HypEmpleado.Text = Nombre;
|
||||
HypEmpleado.NavigateUrl = string.Format("/RH/Personal.aspx?CvePersonal={0}", CvePersonal);
|
||||
LblFechaBaja.Text = FechaBaja;
|
||||
LblEstatus.Text = EstatusPersonal;
|
||||
TxtFechaBaja.Text = FechaBaja;
|
||||
DdlTipoPeriodo_SelectedIndexChanged(null, null);
|
||||
LblPerido.Text = DdlPeriodo.SelectedItem.Text;
|
||||
if (CvePeriodoFiniquito <= 0)
|
||||
retorno = false;
|
||||
pnlupValoresFiniquito.Visible = true;
|
||||
using (ClsNominas ObjNom = new ClsNominas())
|
||||
{
|
||||
if (ObjNom.GetFiniquitosPersonal(CvePersonal, UsuarioActual.CveEmpresa))
|
||||
{
|
||||
DataRow finrow = ObjNom.DtResultados.Rows[0];
|
||||
TxtAntiguedad.Text = $"{finrow["Antiguedad"]}";
|
||||
TxtdiasVacaciones.Text = $"{finrow["Diasvacaciones"]}";
|
||||
TxtDiasLaborados.Text = $"{finrow["diaslaborados"]}";
|
||||
TxtDiasProporcion.Text = $"{finrow["diasProporcion"]}";
|
||||
|
||||
TxtVaciones.Text = $"{finrow["Vacaciones"]}";
|
||||
TxtDiasPago.Text = $"{finrow["Diasvacaciones"]}";
|
||||
TxtDiasPendientes.Text = $"{finrow["diasporpagar"]}";
|
||||
TxtVacacionesporPagar.Text = $"{finrow["VacacionesporPagar"]}";
|
||||
|
||||
TxtPorcentjePrima.Text = $"{finrow["PrimaPorcentaje"]}";
|
||||
TxtPrimaVacacional.Text = $"{finrow["PrimaVacacional"]}";
|
||||
TxtPrimaPagada.Text = $"{finrow["PrimaPagada"]}";
|
||||
TxtPrimaPorPagar.Text = $"{finrow["PrimaVacacionalPorPagar"]}";
|
||||
}
|
||||
}
|
||||
GvConceptos.DataSource = ConceptsPersonas;
|
||||
GvConceptos.DataBind();
|
||||
}
|
||||
else
|
||||
retorno = false;
|
||||
return retorno;
|
||||
}
|
||||
|
||||
|
||||
protected void LnkCampiarEmpleado_Click(object sender, EventArgs e)
|
||||
{
|
||||
CvePersonal = DdlPersonal.SelectedValue.ToEntero();
|
||||
|
||||
|
||||
using (ClsRH ObjPersonal = new ClsRH())
|
||||
{
|
||||
if (ObjPersonal.UpPersonalAltas(CvePersonal, "", TxtFechaBaja.Text.ToDateTime().ToString("yyyy/MM/dd"), DdlPeriodo.SelectedValue.ToEntero(), DdlMotivoBaja.SelectedValue.ToEntero(), ChkesLiquidacion.Checked) && ObjPersonal.DtResultados.Rows.Count > 0)
|
||||
{
|
||||
}
|
||||
}
|
||||
if (pnlupValoresFiniquito.Visible)
|
||||
{
|
||||
}
|
||||
if (!CargaDatosFiniquito())
|
||||
RegistraScript("$('#ModalEmpleados').modal('hide');");
|
||||
upDatos.Update();
|
||||
}
|
||||
protected void LnkCalcular_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
protected void LnkAutorizar_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
protected void LnkTimbrar_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
protected void LnkFormatoRenuncia_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
protected void DdlPersonal_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
Response.Redirect($"/Nomina/Finiquito.aspx?CvePersonal={DdlPersonal.SelectedValue}");
|
||||
}
|
||||
protected void DdlTipoPeriodo_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
int CveTipoPeriodoactual = DdlTipoPeriodo.SelectedValue.ToEntero() > 0 ? DdlTipoPeriodo.SelectedValue.ToEntero() : CveTipoPeriodo;
|
||||
string fechabaja = TxtFechaBaja.Text;
|
||||
DataTable dtperiodos = new DataTable();
|
||||
ClsNominas ObjPeriodos = new ClsNominas();
|
||||
if (ObjPeriodos.GetPeriodos(-1, UsuarioActual.CveEmpresa, -1, -1, -1))
|
||||
{
|
||||
dtperiodos = ObjPeriodos.DtResultados;
|
||||
if (Information.IsNothing(sender) && CvePeriodoFiniquito > 0)
|
||||
{
|
||||
DataRow row = dtperiodos.FiltroPrimero(string.Format("CvePeriodo={0} ", CvePeriodoFiniquito));
|
||||
if (!Information.IsNothing(row))
|
||||
{
|
||||
CveTipoPeriodoactual = row["CveTipoPeriodo"].ToString().ToEntero();
|
||||
DdlTipoPeriodo.SelectedValueExist(CveTipoPeriodoactual == 6 ? "6" : "-1");
|
||||
}
|
||||
}
|
||||
dtperiodos = ObjPeriodos.DtResultados.FiltraParametros(string.Format("(Estatus IN (1,2,3,4) AND CveTipoPeriodo={0}) ", CveTipoPeriodoactual));
|
||||
// FechaInicio, P.FechaFin
|
||||
DdlPeriodo.Items.Clear();
|
||||
DdlPeriodo.Items.Add(new ListItem("Seleccione", "-1"));
|
||||
DdlPeriodo.SelectedValue = "-1";
|
||||
DdlPeriodo.DataSource = dtperiodos;
|
||||
}
|
||||
else
|
||||
DdlPeriodo.DataSource = null;
|
||||
ObjPeriodos.Dispose();
|
||||
DdlPeriodo.DataBind();
|
||||
if (fechabaja.Length > 0 && dtperiodos.Rows.Count > 0)
|
||||
{
|
||||
if ((CvePeriodoFiniquito > 0) && Information.IsNothing(sender))
|
||||
DdlPeriodo.SelectedValueExist(CvePeriodoFiniquito);
|
||||
else
|
||||
{
|
||||
DataRow row = dtperiodos.FiltroPrimero(string.Format("(FechaInicio<='{0:yyyy/MM/dd}' AND FechaFin>='{0:yyyy/MM/dd}') ", fechabaja.ToDate()));
|
||||
if (!Information.IsNothing(row))
|
||||
DdlPeriodo.SelectedValueExist(row["CvePeriodo"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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("CveConcepto").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("Estatus").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;
|
||||
}
|
||||
}
|
||||
|
||||
protected void LnkConcepto_Click(object sender, EventArgs e)
|
||||
{
|
||||
GridViewRow gvRow = (GridViewRow)((LinkButton)sender).NamingContainer;
|
||||
GCEstatus = gvRow.DataKey("Estatus").ToEntero();
|
||||
GCCveConcepto = gvRow.DataKey("CveConcepto").ToEntero();
|
||||
GCImporte = gvRow.DataKey("Importe").ToDecimal();
|
||||
OpenModalConceptos(1);
|
||||
}
|
||||
protected void LnkConceptoD_Click(object sender, EventArgs e)
|
||||
{
|
||||
GridViewRow gvRow = (GridViewRow)((LinkButton)sender).NamingContainer;
|
||||
GCEstatus = gvRow.DataKey("Estatus").ToEntero();
|
||||
GCCveConcepto = gvRow.DataKey("CveConcepto").ToEntero();
|
||||
GCImporte = gvRow.DataKey("Importe").ToDecimal();
|
||||
OpenModalConceptos(2);
|
||||
}
|
||||
|
||||
private void OpenModalConceptos(int Tipo)
|
||||
{
|
||||
if (GCEstatus == -1)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
RegistraScript("$('#ModalConceptos').modal();");
|
||||
}
|
||||
|
||||
protected void LnkAceptarConceptos_Click(object sender, EventArgs e)
|
||||
{
|
||||
RegistraScript("$('#ModalConceptos').modal('hide');");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user