871 lines
36 KiB
C#
871 lines
36 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using Extensiones;
|
|
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 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();
|
|
CargaPersonal();
|
|
CargaMotivoBaja();
|
|
}
|
|
else
|
|
{
|
|
CargaDdlPersonal();
|
|
ViewState["CvePersonal"] = -1;
|
|
LtlEmpleadoCancelar.Visible = false;
|
|
RegistraScript("$('#ModalEmpleados').modal();");
|
|
}
|
|
}
|
|
}
|
|
|
|
private void CargaMotivoBaja()
|
|
{
|
|
DdlMotivoBaja.DataSource = GlobalDTMotivoBaja.FiltraParametros("CveEmpresa = " + 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()
|
|
{
|
|
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();
|
|
LblPuesto.Text = drow["Puesto"].ToString();
|
|
LblSalario.Text = drow["SalarioDiario"].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();
|
|
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)
|
|
{
|
|
LnkCancelar.Visible = true;
|
|
using (ClsNominas onom = new ClsNominas())
|
|
{
|
|
loadsobrerecibo(onom);
|
|
}
|
|
}
|
|
}
|
|
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();
|
|
decimal antiguedad = getyearsresult(fechafin, FechaInicio);
|
|
TxtAntiguedad.Text = string.Format("{0}", antiguedad);
|
|
TxtDiasTransAnio.Text = string.Format("{0}", fechafin.DayOfYear);
|
|
}
|
|
else
|
|
{
|
|
|
|
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 LnkImportexCalculo_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
int SRCveConcepto = ((LinkButton)sender).CommandArgument.ToEntero();
|
|
//CvePeriodoSeleccionado
|
|
//SRCvePersonal
|
|
if (SRCveConcepto > 0)
|
|
{
|
|
using (ClsNominas onom = new ClsNominas())
|
|
{
|
|
if (onom.DeleteNom_NominasDetalles(SRCveConcepto, CvePersonal, CvePeriodoIndemnizacion))
|
|
{
|
|
Alert("el importe sera tomado del calculo y no del valor fijo");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
protected void LnkConcepto_Click(object sender, EventArgs e)
|
|
{
|
|
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();
|
|
}
|
|
|
|
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");
|
|
|
|
//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 = isEditedP;
|
|
LnkImporteDxCalculo.Visible = isEditedD;
|
|
|
|
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;
|
|
}
|
|
}
|
|
//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 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} OR {0}=-1) AND CvePersonal > 0 AND NomAutorizado =0", CvePersonal), "", getcolumnas);
|
|
int CveNomina = dtr.Rows[0]["CveNomina"].ToString().ToEntero();
|
|
LogicNominas lognom = new LogicNominas();
|
|
|
|
string Msg = lognom.TimbrarNomina(CveNomina, CvePersonal, CvePeriodo, UsuarioActual);
|
|
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)
|
|
{
|
|
|
|
}
|
|
|
|
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)
|
|
{
|
|
continuar = onom.GetFiniquitosPersonal(CvePersonal, UsuarioActual.CveEmpresa);
|
|
}
|
|
if (continuar)
|
|
{
|
|
ObjPersonal.Commit();
|
|
}
|
|
else
|
|
{
|
|
ObjPersonal.RollBack();
|
|
}
|
|
if (continuar)
|
|
{ loadsobrerecibo(onom); }
|
|
}
|
|
|
|
}
|
|
UPDatos.Update();
|
|
}
|
|
public void loadsobrerecibo(ClsNominas objnom)
|
|
{
|
|
List<NConcepto> finordin = null;
|
|
List<NConcepto> finindem = null;
|
|
/*
|
|
DataTable dtConceptos = null;
|
|
DataTable dtempleadosConceptos = null;
|
|
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];
|
|
dtempleadosConceptos = objnom.DTSetResultados.Tables[4];
|
|
dtConceptos = objnom.DTSetResultados.Tables[0];
|
|
}
|
|
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)
|
|
{
|
|
dtempleados = objnom.DTSetResultados.Tables[3];
|
|
LnkAutorizar.Visible = (dtempleados.COUNT("CvePersonal", "NomAutorizado =0") > 0);
|
|
LnkGuardarDatos.Enabled = LnkAutorizar.Visible;
|
|
LnkTimbrar.Visible = !(LnkAutorizar.Visible) && (dtempleados.COUNT("CvePersonal", "SeTimbro=0") > 0);
|
|
UpAcciones.Update();
|
|
dtempleadosConceptos = objnom.DTSetResultados.Tables[4];
|
|
dtConceptos = objnom.DTSetResultados.Tables[0];
|
|
}
|
|
if (dtConceptos != null && dtempleadosConceptos != null && dtempleados != null)
|
|
{
|
|
finordin = cargasobrericiboconceptos(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.";
|
|
}
|
|
LnkAutorizar.Visible = true;
|
|
}
|
|
|
|
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", 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))
|
|
{
|
|
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();
|
|
|
|
}
|
|
}
|
|
} |