This commit is contained in:
JORGE LUIS CAUDILLO ESPARZA
2021-01-13 12:27:32 -07:00
parent d7a36b68a9
commit ba3f507c1d
17 changed files with 1994 additions and 883 deletions

View File

@@ -1,213 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualBasic;
using System.Data;
using Extensiones;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Extensiones;
partial class Nomina_Finiquito : ClsPaginas
public partial class Nomina_Finiquito : ClsPaginas
{
private class NConcepto
{
//Concepto,CveConcepto,Importe,Estatus,ConceptoD,CveConceptoD,ImporteD,EstatusD
public string NoConceptoP { get; set; }
public string ConceptoP { get; set; }
public string LabelValorP { get; set; }
public int CveConceptoP { get; set; }
public double ImporteP { get; set; }
public double ValorP { get; set; }
public int EstatusP { get; set; }
public bool isEditedP { get; set; }
public string NoConceptoD { get; set; }
public string ConceptoD { get; set; }
public string LabelValorD { get; set; }
public int CveConceptoD { get; set; }
public double ImporteD { get; set; }
public double ValorD { get; set; }
public int EstatusD { get; set; }
public bool isEditedD { get; set; }
}
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; }
//set { ViewState["CvePersonal"] = value; }
}
private int CveTipoPeriodo
private int CvePersonalAltas
{
get { return ViewState["CveTipoPeriodo"] != null ? ViewState["CveTipoPeriodo"].ToString().ToEntero() : 0; }
set
{
ViewState["CveTipoPeriodo"] = value;
}
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 int GCEstatus
private DateTime FechaInicio
{
get { return ViewState["GCEstatus"] != null ? ViewState["GCEstatus"].ToString().ToEntero() : 0; }
set { ViewState["GCEstatus"] = value; }
get { return ViewState["FechaInicio"] != null ? (DateTime)ViewState["FechaInicio"] : DateTime.Now; }
set { ViewState["FechaInicio"] = value; }
}
private int GCCveConcepto
private DataTable DtAltas
{
get { return ViewState["GCCveConcepto"] != null ? ViewState["GCCveConcepto"].ToString().ToEntero() : 0; }
set { ViewState["GCCveConcepto"] = value; }
get { return ViewState["DtAltas"] != null ? (DataTable)ViewState["DtAltas"] : null; }
set { ViewState["DtAltas"] = 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;
}
}
#endregion
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
CargaDdlPersonal();
CargaMotivoBaja();
CvePeriodoFiniquito = 0;
GvFinOrdinario.DataSource = new DataTable();
GVFinIndemnizacion.DataSource = new DataTable();
GvFinOrdinario.DataBind();
GVFinIndemnizacion.DataBind();
if (Request["CvePersonal"] != null && Request["CvePersonal"].ToString().ToEntero() > 0)
{
CvePersonal = Request["CvePersonal"].ToString().ToEntero();
ViewState["CvePersonal"] = Request["CvePersonal"].ToString().ToEntero();
CargaPersonal();
CargaMotivoBaja();
}
else
{
CvePersonal = -1;
CargaDdlPersonal();
ViewState["CvePersonal"] = -1;
LtlEmpleadoCancelar.Visible = false;
RegistraScript("$('#ModalEmpleados').modal();");
}
if (!CargaDatosFiniquito())
{
}
RegistraScript("$('#ModalEmpleados').modal();");
}
if (CvePersonal > 0 & CvePeriodoFiniquito > 0)
{
LtlEmpleadoCancelar.Visible = true;
}
}
@@ -218,222 +74,148 @@ partial class Nomina_Finiquito : ClsPaginas
}
private void CargaDdlPersonal()
{
ClsRH ObjPersonal = new ClsRH();
if (ObjPersonal.GetPersonal(-1, UsuarioActual.CveEmpresa))
using (ClsRH ObjPersonal = new ClsRH())
{
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(-1, UsuarioActual.CveEmpresa))
{
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();
}
DdlPersonal.DataSource = ObjPersonal.DtResultados;
DdlPersonal.DataBind();
}
}
}
private void CargaPersonal()
{
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();
LblPuesto.Text = drow["Puesto"].ToString();
LblSalario.Text = drow["SalarioDiario"].ToString();
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"]}";
}
if (ObjNom.DTSetResultados.Tables.Count > 5)
{
DataTable dtconceptos = ObjNom.DTSetResultados.Tables[1];
DataTable dtconpersonal = ObjNom.DTSetResultados.Tables[5];
int maxFila = dtconpersonal.MAX("Fila", "Tipo<3").ToEntero();
List<NConcepto> lfin = new List<NConcepto>();
if (maxFila > 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();
TxtFechaBaja.Text = string.Format("{0:dd/MM/yyyy}", da["FechaFin"]);
DdlMotivoBaja.SelectedValueExist(da["CveMotivoBaja"]);
ChkesLiquidacion.Checked = (da["esLiquidacion"].ToString() == "1" || da["esLiquidacion"].ToString().ToUpper() == "TRUE");
CvePeriodoIndemnizacion = da["CvePeriodoIndemnizacion"].ToString().ToEntero();
CvePeriodoFiniquito = da["CvePeriodoFiniquito"].ToString().ToEntero();
if (CvePeriodoIndemnizacion > 0)
{
DataRow conPerrow;
DataRow conrow;
NConcepto sr;
for (int i = 1; i <= maxFila; i++)
{
sr = new NConcepto();
conPerrow = dtconpersonal.FiltroPrimero(string.Format("Tipo=1 AND Fila ={0}", i));
if (conPerrow != null)
{
sr.CveConceptoP = conPerrow["CveConcepto"].ToString().ToEntero();
conrow = dtconceptos.FiltroPrimero(string.Format("CveConcepto ={0}", sr.CveConceptoP));
sr.ConceptoP = conrow["Concepto"].ToString();
sr.ValorP = conPerrow["Valor"].ToString().ToDouble();
sr.ImporteP = conPerrow["Importe"].ToString().ToDouble();
sr.NoConceptoP = conrow["Codigo"].ToString();
}
conPerrow = dtconpersonal.FiltroPrimero(string.Format("Tipo=2 AND Fila ={0}", i));
if (conPerrow != null)
{
sr.CveConceptoD = conPerrow["CveConcepto"].ToString().ToEntero();
conrow = dtconceptos.FiltroPrimero(string.Format("CveConcepto ={0}", sr.CveConceptoD));
sr.ConceptoD = conrow["Concepto"].ToString();
sr.ValorD= conPerrow["Valor"].ToString().ToDouble();
sr.ImporteD = conPerrow["Importe"].ToString().ToDouble();
sr.NoConceptoD = conrow["Codigo"].ToString();
}
lfin.Add(sr);
}
loadsobrerecibo();
}
GvConceptos.DataSource = lfin;
GvConceptos.DataBind();
}
CamposCalculados();
}
//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)
private void CamposCalculados()
{
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))
TxtSalarioMinimo.Text = "123.22";
if (TxtFechaBaja.Text.Length > 9)
{
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;
DateTime fechafin = TxtFechaBaja.Text.ToDateTime();
decimal antiguedad = getyearsresult(fechafin, FechaInicio);
TxtAntiguedad.Text = string.Format("{0}", antiguedad);
TxtDiasTransAnio.Text = string.Format("{0}", fechafin.DayOfYear);
}
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"]);
}
TxtAntiguedad.Text = "--";
TxtDiasTransAnio.Text = "--";
}
}
private decimal getyearsresult(DateTime fechafin, DateTime fechainicio)
{
decimal retorno = 0;
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 LnkConcepto_Click(object sender, EventArgs e)
{
//SRCveConcepto = ((LinkButton)sender).CommandArgument.ToEntero();
//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();
//}
//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);
//}
//DdlmcConceptos_SelectedIndexChanged(DdlmcConceptos, null);
//RegistraScript(string.Format("$('#ModalUpConcepto').on('shown.bs.modal', function () {{$('#{0}').trigger('focus')}});$('#ModalUpConcepto').modal();", TxtmcImporte.ClientID));
//UPpanelModalUpConcepto.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();
@@ -442,7 +224,11 @@ partial class Nomina_Finiquito : ClsPaginas
// 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");
@@ -452,63 +238,292 @@ partial class Nomina_Finiquito : ClsPaginas
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";
if (CveConcepto == 0 && (Estatus == 0 || Estatus == -1 || Estatus == -3))
LtlImporte.Text = "";
LtlImporte.Visible = true;
LtlImporteD.Visible = true;
}
LnkImporte.CommandArgument = (CveConcepto > 0 ? CveConcepto.ToString() : "P");
LnkImporteD.CommandArgument = (CveConceptoD > 0 ? CveConceptoD.ToString() : "D");
if (CveConceptoD == 0 && (EstatusD == 0 || EstatusD == -1))
LtlImporteD.Text = "";
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 (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;
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 LnkConcepto_Click(object sender, EventArgs e)
protected void LnkTimbrar_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);
Alert("El finiquito se ha timbrado satisfactoriamente");
LnkTimbrar.Visible = false;
}
private void OpenModalConceptos(int Tipo)
protected void LnkFormatoRenuncia_Click(object sender, EventArgs e)
{
if (GCEstatus == -1)
}
protected void LnkCambiarEmpleado_Click(object sender, EventArgs e)
{
CargaDdlPersonal();
this.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; }
}
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 ");
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 = dtempleados.SUM("SumaPercepciones", string.Format("CvePersonal = {0}", SRCvePersonal));
///Alert(SubTotales.ImporteP.ToString());
SubTotales.CveConceptoD = 0;
SubTotales.ConceptoD = "Total Deducciones";
SubTotales.EstatusD = -2;
SubTotales.ImporteD = dtempleados.SUM("SumaDeducciones", string.Format("CvePersonal = {0}", SRCvePersonal));
NConcepto Totales = new NConcepto();
Totales.CveConceptoD = 0;
Totales.ConceptoD = "Total";
Totales.EstatusD = -3;
Totales.ImporteD = dtempleados.SUM("Total", string.Format("CvePersonal = {0}", SRCvePersonal));
lconc.Add(SubTotales);
lconc.Add(Totales);
return lconc;
}
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 = false;
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)
{
DataRow da = ObjPersonal.DtResultados.Rows[0];
CvePeriodoIndemnizacion = da["CvePeriodoIndemnizacion"].ToString().ToEntero();
CvePeriodoFiniquito = da["CvePeriodoFiniquito"].ToString().ToEntero();
continuar = onom.GetFiniquitosPersonal(CvePersonal, UsuarioActual.CveEmpresa);
}
if (continuar)
{
ObjPersonal.Commit();
}
else
{
ObjPersonal.RollBack();
}
if (continuar) { loadsobrerecibo(); }
}
}
RegistraScript("$('#ModalConceptos').modal();");
}
public void loadsobrerecibo()
{
List<NConcepto> finordin = null;
List<NConcepto> finindem = null;
DataTable dtConceptos = null;
DataTable dtempleadosConceptos = null;
DataTable dtempleados = null;
using (ClsNominas objnom = new ClsNominas())
{
if (objnom.GetNominaEmpleado(-1, -1, -1, CvePeriodoFiniquito, UsuarioActual.CveEmpresa, 1, 3, CvePersonal) && objnom.DTSetResultados.Tables.Count > 1)
{
dtempleados = objnom.DTSetResultados.Tables[3];
dtempleadosConceptos = objnom.DTSetResultados.Tables[4];
dtConceptos = objnom.DTSetResultados.Tables[0];
}
if (dtConceptos != null && dtempleadosConceptos != null && dtempleados != null)
{
finordin = cargasobrericiboconceptos(dtConceptos, dtempleadosConceptos, dtempleados);
}
dtempleadosConceptos = null;
dtempleados = null;
if (objnom.GetNominaEmpleado(-1, -1, -1, CvePeriodoIndemnizacion, UsuarioActual.CveEmpresa, 1, 3, CvePersonal) && objnom.DTSetResultados.Tables.Count > 1)
{
dtempleados = objnom.DTSetResultados.Tables[3];
dtempleadosConceptos = objnom.DTSetResultados.Tables[4];
dtConceptos = objnom.DTSetResultados.Tables[0];
}
if (dtConceptos != null && dtempleadosConceptos != null && dtempleados != null)
{
finindem = cargasobrericiboconceptos(dtConceptos, dtempleadosConceptos, dtempleados);
}
}
GvFinOrdinario.DataSource = finordin;
GVFinIndemnizacion.DataSource = finindem;
GvFinOrdinario.DataBind();
GVFinIndemnizacion.DataBind();
LnkGuardarDatos.Enabled = false;
LnkGuardarDatos.CssClass = "btn btn-default";
LnkGuardarDatos.ToolTip = "el finiquito ha sido capturado.";
LnkAutorizar.Visible = true;
}
protected void LnkAceptarConceptos_Click(object sender, EventArgs e)
protected void LnkAutorizar_Click(object sender, EventArgs e)
{
RegistraScript("$('#ModalConceptos').modal('hide');");
Alert("El finiquito se ha autorizado satisfactoriamente.");
LnkAutorizar.Visible = false;
LnkTimbrar.Visible = true;
}
}
}