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(); HypCodigo.NavigateUrl = $"/RH/Personal.aspx?CvePersonal={CvePersonal}"; HypEmpleado.NavigateUrl = $"/RH/Personal.aspx?CvePersonal={CvePersonal}"; CargaMotivoBaja(); CargaPersonal(); } else { CargaDdlPersonal(); ViewState["CvePersonal"] = -1; 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); DdlMotivoBaja.DataBind(); } private void CargaDdlPersonal() { using (ClsRH ObjPersonal = new ClsRH()) { if (ObjPersonal.GetPersonal(-1, UsuarioActual.CveEmpresa)) { DdlPersonal.DataSource = ObjPersonal.DtResultados; DdlPersonal.DataBind(); } } } private void CargaPersonal() { LnkFormatoRenuncia.Visible = false; LnkCancelar.Visible = false; using (ClsRH ObjPersonal = new ClsRH()) { if (ObjPersonal.GetPersonal(CvePersonal, UsuarioActual.CveEmpresa) && ObjPersonal.DtResultados.Rows.Count > 0) { DataRow drow = ObjPersonal.DtResultados.Rows[0]; HypCodigo.Text = drow["Codigo"].ToString(); HypEmpleado.Text = drow["NombreCompleto"].ToString(); HypCodigo.NavigateUrl = $"/RH/Personal.aspx?CvePersonal={drow["CvePersonal"]}"; LblPuesto.Text = drow["Puesto"].ToString(); LblSalario.Text = drow["SalarioDiario"].ToString(); LtlAreaGeografica.Text = drow["AreaGeografica"].ToString(); if (ObjPersonal.GetPersonalAltas(CvePersonal) && ObjPersonal.DtResultados.Rows.Count > 0) { DtAltas = ObjPersonal.DtResultados.FiltraParametros("", "FechaInicio"); DataRow da = ObjPersonal.DtResultados.Rows[0]; CvePersonalAltas = da["CvePersonalAltas"].ToString().ToEntero(); LblFechaAlta.Text = string.Format("{0:dd/MM/yyyy}", da["FechaInicio"]); FechaInicio = LblFechaAlta.Text.ToDateTime(); 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(); if (CvePeriodoFiniquito > 0) { LnkCancelar.Visible = true; LnkSimular.Visible = false; 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; decimal mes = 12; retorno = (fechafin.Year - fechainicio.Year) - (fechafin.Month > fechainicio.Month ? 0 : (fechafin.Month == fechainicio.Month && fechafin.Day > fechainicio.Day ? 0 : 1)); retorno += (((fechafin.Month == fechainicio.Month && fechafin.Day > fechainicio.Day ? fechainicio.Month : fechafin.Month + (fechafin.Month > fechainicio.Month ? 0 : 12)) - fechainicio.Month) / mes); /* DateTime zeroTime = new DateTime(1, 1, 1); TimeSpan span; if (fechainicio < fechafin) { span = fechafin - fechainicio; decimal years = (zeroTime + span).Year - 1; retorno = Math.Round(years + (span.TotalDays.ToString().ToDecimal() / 365), 4); }*/ return retorno; } protected void LnkImportexCalculo_Click(object sender, EventArgs e) { int SRCveConcepto = ((LinkButton)sender).CommandArgument.ToEntero(); //CvePeriodoSeleccionado //SRCvePersonal if (SRCveConcepto > 0) { using (ClsNominas onom = new ClsNominas()) { if (onom.DeleteNom_NominasDetalles(SRCveConcepto, CvePersonal, CvePeriodoFiniquito)) { Alert("el importe sera tomado del calculo y no del valor fijo"); loadsobrerecibo(onom); UPDatos.Update(); } } } } 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(); } 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) { 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 ? "" : "")); LnkImporteD.Text = (CveConceptoD > 0 ? string.Format("${0:N2}", e.Row.DataKey("ImporteD").ToDecimal()) : (CveConceptoDolgvc > 0 ? "" : "")); 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 ? "" : "")); // LnkImporteD.Text = (CveConceptoD > 0 ? string.Format("${0:N2}", e.Row.DataKey("ImporteD").ToDecimal()) : (CveConceptoDolgvc > 0 ? "" : "")); // 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) { if (dtConceptos != null) { DataTable dtper = dtConceptos.FiltraParametros("Tipo IN ('P') AND EsPadre = 1 AND SoloVisible =0"); DataTable dtded = dtConceptos.FiltraParametros("Tipo IN ('D') AND EsPadre = 1 AND SoloVisible =0"); dtper.Columns.Add("BorradoLogico", typeof(int)); dtded.Columns.Add("BorradoLogico", typeof(int)); foreach (DataRow row in dtper.Rows) { int BorradoLogico = 0; int CveConcepto = row["CveConcepto"].ToString().ToEntero(); if (!(dtempleados.SUM(string.Format("[V_{0}]", CveConcepto), string.Format("CvePersonal = {0}", CvePersonal)) != 0)) { BorradoLogico = 1; } row["BorradoLogico"] = BorradoLogico; } dtper.AcceptChanges(); foreach (DataRow row in dtded.Rows) { int BorradoLogico = 0; int CveConcepto = row["CveConcepto"].ToString().ToEntero(); if (!(dtempleados.SUM(string.Format("[V_{0}]", CveConcepto), string.Format("CvePersonal = {0}", CvePersonal)) != 0)) { BorradoLogico = 1; } row["BorradoLogico"] = BorradoLogico; } dtded.AcceptChanges(); dtper = dtper.FiltraParametros("BorradoLogico=0"); dtded = dtded.FiltraParametros("BorradoLogico=0"); int maxper = dtper.Rows.Count; int maxded = dtded.Rows.Count; int i = 0; List lconc = new List(); for (i = 0; i < maxper || i < maxded; i++) { NConcepto nConcepto = new NConcepto(); DataRow row; if (maxper > i) { row = dtper.Rows[i]; int CveConcepto = row["CveConcepto"].ToString().ToEntero(); string Concepto = row["Concepto"].ToString(); string Codigo = row["Codigo"].ToString(); //bool visible = (dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) > 0); double Importe = dtempleados.SUM(string.Format("[V_{0}]", CveConcepto), string.Format("CvePersonal = {0}", CvePersonal)); nConcepto.CveConceptoP = CveConcepto; nConcepto.ConceptoP = Concepto; nConcepto.NoConceptoP = Codigo; nConcepto.ImporteP = Importe; nConcepto.ValorP = dtempleados.SUM(string.Format("[VAL_{0}]", CveConcepto), string.Format("CvePersonal = {0}", CvePersonal)); } if (maxded > i) { row = dtded.Rows[i]; int CveConcepto = row["CveConcepto"].ToString().ToEntero(); string Concepto = row["Concepto"].ToString(); string Codigo = row["Codigo"].ToString(); //bool visible = (dtempleados.SUM(string.Format("[V_{0}]", CveConcepto)) > 0); double Importe = dtempleados.SUM(string.Format("[V_{0}]", CveConcepto), string.Format("CvePersonal = {0}", CvePersonal)); nConcepto.CveConceptoD = CveConcepto; nConcepto.ConceptoD = Concepto; nConcepto.NoConceptoD = Codigo; nConcepto.ImporteD = Importe; nConcepto.ValorD = dtempleados.SUM(string.Format("[VAL_{0}]", CveConcepto), string.Format("CvePersonal = {0}", CvePersonal)); } lconc.Add(nConcepto); } lconc.Add(new NConcepto()); NConcepto SubTotales = new NConcepto(); SubTotales.CveConceptoP = 0; SubTotales.ConceptoP = "Total Percepciones"; SubTotales.EstatusP = -2; SubTotales.ImporteP = dtempleados.SUM("SumaPercepciones", string.Format("CvePersonal = {0}", CvePersonal)); ///Alert(SubTotales.ImporteP.ToString()); SubTotales.CveConceptoD = 0; SubTotales.ConceptoD = "Total Deducciones"; SubTotales.EstatusD = -2; SubTotales.ImporteD = dtempleados.SUM("SumaDeducciones", string.Format("CvePersonal = {0}", CvePersonal)); NConcepto Totales = new NConcepto(); Totales.CveConceptoD = 0; Totales.ConceptoD = "Total"; Totales.EstatusD = -3; Totales.ImporteD = dtempleados.SUM("Total", string.Format("CvePersonal = {0}", CvePersonal)); lconc.Add(SubTotales); lconc.Add(Totales); DataTable dtCon = new DataTable(); dtCon.Columns.Add(new DataColumn("NoConceptoP", typeof(string))); dtCon.Columns.Add(new DataColumn("ConceptoP", typeof(string))); dtCon.Columns.Add(new DataColumn("LabelValorP", typeof(string))); dtCon.Columns.Add(new DataColumn("CveConceptoP", typeof(int))); dtCon.Columns.Add(new DataColumn("ImporteP", typeof(double))); dtCon.Columns.Add(new DataColumn("ValorP", typeof(double))); dtCon.Columns.Add(new DataColumn("EstatusP", typeof(int))); dtCon.Columns.Add(new DataColumn("isEditedP", typeof(int))); dtCon.Columns.Add(new DataColumn("isOnlyBisibleP", typeof(int))); dtCon.Columns.Add(new DataColumn("NoConceptoD", typeof(string))); dtCon.Columns.Add(new DataColumn("ConceptoD", typeof(string))); dtCon.Columns.Add(new DataColumn("LabelValorD", typeof(string))); dtCon.Columns.Add(new DataColumn("CveConceptoD", typeof(int))); dtCon.Columns.Add(new DataColumn("ImporteD", typeof(double))); dtCon.Columns.Add(new DataColumn("ValorD", typeof(double))); dtCon.Columns.Add(new DataColumn("EstatusD", typeof(int))); dtCon.Columns.Add(new DataColumn("isEditedD", typeof(int))); dtCon.Columns.Add(new DataColumn("isOnlyBisibleD", typeof(int))); foreach (NConcepto itc in lconc) { DataRow dr = dtCon.NewRow(); dr["NoConceptoP"] = itc.NoConceptoP; dr["ConceptoP"] = itc.ConceptoP; dr["LabelValorP"] = itc.LabelValorP; dr["CveConceptoP"] = itc.CveConceptoP; dr["ImporteP"] = itc.ImporteP; dr["ValorP"] = itc.ValorP; dr["EstatusP"] = itc.EstatusP; dr["isEditedP"] = itc.isEditedP; dr["isOnlyBisibleP"] = itc.isOnlyBisibleP; dr["NoConceptoD"] = itc.NoConceptoD; dr["ConceptoD"] = itc.ConceptoD; dr["LabelValorD"] = itc.LabelValorD; dr["CveConceptoD"] = itc.CveConceptoD; dr["ImporteD"] = itc.ImporteD; dr["ValorD"] = itc.ValorD; dr["EstatusD"] = itc.EstatusD; dr["isEditedD"] = itc.isEditedD; dr["isOnlyBisibleD"] = itc.isOnlyBisibleD; dtCon.Rows.Add(dr); } dtCon.AcceptChanges(); List lrds = new List(); Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource(); rds.Name = "DataSet1"; rds.Value = dtCon;// lconc; lrds.Add(rds); List parametros = new List(); string CodigoEmpleado = ""; string NombreCompleto = ""; string RFC = ""; string CURP = ""; string TipoPeriodo = ""; string NSS = ""; string DiasLaborados = ""; string DiasFaltados = ""; string DiasVacaciones = ""; string FechaInicio = ""; string FechaFin = ""; string DiasRetardos = ""; string DiasIncapacidad = ""; string SubProyecto = ""; string Usuario = UsuarioActual.Nombre; string FolioFiscal = ""; { DataRow drow = dtempleados.FiltroPrimero(string.Format("CvePersonal = {0}", CvePersonal)); if (drow != null) { SubProyecto = drow["SubProyecto"].ToString(); FolioFiscal = string.Format("{0}", drow["FolioFiscal"]); DiasLaborados = string.Format("{0}", drow["DiasLaborados"].ToString().ToEntero()); DiasFaltados = string.Format("{0}", drow["DiasFaltados"].ToString().ToEntero()); DiasVacaciones = string.Format("{0}", drow["DiasVacaciones"].ToString().ToEntero()); FechaInicio = string.Format("{0:dd/MM/yyyy}", drow["FechaInicio"]); FechaFin = string.Format("{0:dd/MM/yyyy}", drow["FechaFin"]); DiasRetardos = string.Format("{0}", drow["DiasRetardos"].ToString().ToEntero()); DiasIncapacidad = string.Format("{0}", drow["DiasIncapacidad"].ToString().ToEntero()); } } //string Codigo = ""; using (ClsRH objrh = new ClsRH()) { if (objrh.GetPersonal(CvePersonal, UsuarioActual.CveEmpresa) && objrh.DtResultados.Rows.Count > 0) { DataRow drow = objrh.DtResultados.Rows[0]; CodigoEmpleado = drow["Codigo"].ToString(); NombreCompleto = drow["NombreCompleto"].ToString(); RFC = drow["RFC"].ToString(); CURP = drow["CURP"].ToString(); TipoPeriodo = drow["TipoPeriodo"].ToString(); NSS = drow["NSS"].ToString(); } } parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("DiasIncapacidad", DiasIncapacidad)); parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("Codigo", CodigoEmpleado)); parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("NombreCompleto", NombreCompleto)); parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("RFC", RFC)); parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("CURP", "")); parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("TipoPeriodo", TipoPeriodo)); parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("NSS", NSS)); parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("DiasLaborados", DiasLaborados)); parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("DiasFaltados", DiasFaltados)); parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("DiasVacaciones", DiasVacaciones)); parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("FechaInicio", FechaInicio)); parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("FechaFin", FechaFin)); parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("DiasRetardos", DiasRetardos)); parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("Empresa", UsuarioActual.Empresa.Empresa)); parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("SubProyecto", SubProyecto)); parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("FechaPago", "")); parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("FolioFiscal", FolioFiscal)); parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("Usuario", Usuario)); //parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("", "")); //parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("", "")); //parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("", "")); string urlfile = System.IO.Path.Combine(string.Format("{0}Formatos/SobreReciboFiniquito.rdlc", UsuarioActual.Empresa.Ruta)); if (!System.IO.File.Exists(urlfile)) { urlfile = System.IO.Path.Combine(ModExtensiones.DirectorioBaseEmpresas, "Empresas/Grales/Formatos/SobreReciboFiniquito.rdlc"); } ImprimirPDF(urlfile, lrds, parametros, "SobreRecibo", "PDF", null); } else { Alert("sin información disponible."); } } 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 cargasobrericiboconceptos(DataTable dtConceptos, DataTable dtempleadosConceptos, DataTable dtempleados) { int SRCvePersonal = this.CvePersonal; DataTable dtper = dtConceptos.FiltraParametros("Tipo IN ('P') AND EsPadre = 1 And CveSistema NOT IN(10,11,32) "); DataTable dtded = dtConceptos.FiltraParametros("Tipo IN ('D') AND EsPadre = 1 AND CveSistema <> 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 lconc = new List(); 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)) - percepcionesindem; ///Alert(SubTotales.ImporteP.ToString()); SubTotales.CveConceptoD = 0; SubTotales.ConceptoD = "Total Deducciones"; SubTotales.EstatusD = -2; SubTotales.ImporteD = dtempleados.SUM("SumaDeducciones", string.Format("CvePersonal = {0}", SRCvePersonal)) - deduccionesindem; double neto = SubTotales.ImporteP - SubTotales.ImporteD; NConcepto Totales = new NConcepto(); Totales.CveConceptoD = 0; Totales.ConceptoD = "Total"; Totales.EstatusD = -3; Totales.ImporteD = neto; lconc.Add(SubTotales); lconc.Add(Totales); return lconc; } private List 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 lconc = new List(); 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); 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 (continuar = 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(); CvePeriodoFiniquito = da["CvePeriodoFiniquito"].ToString().ToEntero(); } if (continuar) { continuar = onom.GetFiniquitosPersonal(CvePersonal, UsuarioActual.CveEmpresa, diasindemnizacion: Txtdiasindemnizacion.Text.ToEntero()); } if (continuar) { ObjPersonal.Commit(); } else { ObjPersonal.RollBack(); } if (continuar) { loadsobrerecibo(onom); LnkCancelar.Visible = true; LnkSimular.Visible = false; } } } UPDatos.Update(); } public void loadsobrerecibo(ClsNominas objnom) { List finordin = null; List 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); LnkFormatoRenuncia.Visible = true; 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); finindem = cargasobrericiboconceptosIndemnizacion(dtConceptos, dtempleadosConceptos, dtempleados); } GvFinOrdinario.DataSource = finordin; GVFinIndemnizacion.DataSource = finindem; GvFinOrdinario.DataBind(); GVFinIndemnizacion.DataBind(); //LnkGuardarDatos.Enabled = false; if (!(LnkGuardarDatos.Enabled)) { LnkGuardarDatos.CssClass = "btn btn-default"; LnkGuardarDatos.ToolTip = "el finiquito ha sido capturado."; } 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 OR Valor <>0)", CvePersonal)); foreach (DataRow rcon in dtconp.Rows) { CveConcepto = rcon["CveConcepto"].ToString().ToEntero(); ImporteConcepto = rcon["Importe"].ToString().ToDecimal(); ImporteGravadoConcepto = rcon["ImporteGravado"].ToString().ToDecimal(); ImporteExentoConcepto = ImporteConcepto - ImporteGravadoConcepto; ImporteValor = rcon["Valor"].ToString().ToDecimal(); if (continuar) { if (!objNomina.AddUPNom_NominasDetalles(CveNomina, CvePeriodoSeleccionado, CvePersonal, CveConcepto, ImporteConcepto, ImporteGravadoConcepto, ImporteExentoConcepto, ImporteValor, UsuarioActual.CveUsuario, false, 1, 1, 1)) { continuar = false; } } } } if (continuar) { decimal SalarioDiario = rtemp["SalarioDiario"].ToString().ToEntero(); decimal SalarioDiarioIMSS = rtemp["SalarioDiarioIMSS"].ToString().ToEntero(); decimal SalarioDiarioIntegrado = rtemp["SalarioDiarioIntegrado"].ToString().ToEntero(); int DiasLaborados = rtemp["DiasLaborados"].ToString().ToEntero(); int DiasFaltados = rtemp["DiasFaltados"].ToString().ToEntero(); int DiasVacaciones = rtemp["DiasVacaciones"].ToString().ToEntero(); int DiasIncapacidad = rtemp["DiasIncapacidad"].ToString().ToEntero(); continuar = objNomina.PA_Nom_NominasAutorizarUP(CvePersonal, CvePeriodoSeleccionado, SalarioDiario, SalarioDiarioIMSS, SalarioDiarioIntegrado, 0, 0, Total, SubTotal, DiasLaborados, DiasFaltados, DiasVacaciones, DiasIncapacidad); } } } if (continuar) { objNomina.Commit(); LnkAutorizar.Visible = false; LnkTimbrar.Visible = true; LnkGuardarDatos.Enabled = false; LnkGuardarDatos.CssClass = "btn btn-default"; LnkGuardarDatos.ToolTip = "el finiquito ha sido capturado."; Alert("La nomina se autorizó correctamente."); } else { objNomina.RollBack(); } } if (dtr != null) { dtr.Dispose(); } if (dtconp != null) { dtconp.Dispose(); } } protected void LnkCancelar_Click(object sender, EventArgs e) { LnkFormatoRenuncia.Visible = false; using (ClsNominas onom = new ClsNominas()) { if (onom.RemoveFiniquito(CvePersonal, UsuarioActual.CveEmpresa, CvePersonalAltas)) { loadsobrerecibo(onom); Alert("se ha eliminado el proceso de finiquito"); UPDatos.Update(); } } } protected void LnkSimular_Click(object sender, EventArgs e) { if (LblFechaAlta.Text.ToDate() > TxtFechaBaja.Text.ToDate()) { Alert("la fecha de baja no puede ser menor a la fecha alta", ModExtensiones.TipoMensaje.MsgAdvertencia); } else { bool continuar = false; using (ClsRH ObjPersonal = new ClsRH()) using (ClsNominas onom = new ClsNominas(ObjPersonal.IniciaTransacSQL())) { if (continuar = 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(); CvePeriodoFiniquito = da["CvePeriodoFiniquito"].ToString().ToEntero(); } if (continuar) { continuar = onom.GetFiniquitosPersonal(CvePersonal, UsuarioActual.CveEmpresa, diasindemnizacion: Txtdiasindemnizacion.Text.ToEntero()); } if (continuar) { loadsobrerecibo(onom); } if (continuar) { ObjPersonal.RollBack(); } else { ObjPersonal.RollBack(); } } } UPDatos.Update(); } protected void BtnAceptarMC_Click(object sender, EventArgs e) { int chkImporte = 1; int chkImporteGravado = 1; int chkImporteValor = 1; bool continuar = true; int CveNomina = 0; double Total = 0; int CveMoneda = 1; int CveMetodoPago = 0; int CveConcepto = DdlmcConceptos.SelectedValue.ToEntero(); if (CveConcepto > 0 && CvePersonal > 0) { decimal ImporteConcepto = TxtmcImporte.Text.Replace("$", "").Replace(",", "").ToDecimal(); decimal ImporteGravadoConcepto = TxtmcImporteGrabado.Text.Replace("$", "").Replace(",", "").ToDecimal(); decimal ImporteExentoConcepto = ImporteConcepto - ImporteGravadoConcepto; decimal ImporteValor = Txtmcvalor.Text.Replace("$", "").Replace(",", "").ToDecimal(); using (ClsNominas objNomina = new ClsNominas()) { objNomina.IniciaTransacSQL(); if (continuar) { if (objNomina.GetNom_Nominas(-1, CvePersonal, CvePeriodoFiniquito, -1, UsuarioActual.CveEmpresa)) { if (objNomina.DtResultados.Rows.Count > 0) { CveNomina = objNomina.CveNomina; } else { if (objNomina.AddNom_Nominas(-1, 1, CvePersonal, CvePeriodoFiniquito, Total, 0, 0, Total, CveMoneda, 1, CveMetodoPago, DateTime.Now, "Deducciones nómina", "", "", "", "", 0, 0, 0, new DateTime(), new DateTime(), new DateTime(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, false)) { CveNomina = objNomina.CveNomina; } else { continuar = false; } } } } if (CveNomina == 0) { continuar = false; } if (continuar) { if (continuar) { if (!objNomina.AddUPNom_NominasDetalles(CveNomina, CvePeriodoFiniquito, CvePersonal, CveConcepto, ImporteConcepto, ImporteGravadoConcepto, ImporteExentoConcepto, ImporteValor, UsuarioActual.CveUsuario, true, chkImporte, chkImporteGravado, chkImporteValor)) { continuar = false; } } } if (continuar) { objNomina.Commit(); } else { objNomina.RollBack(); } } if (continuar) { using (ClsNominas objNomina = new ClsNominas()) { loadsobrerecibo(objNomina); } Alert("El cambio se ha guardado correctamente."); } } else { if (CveConcepto > 0) { Alert("Debe seleccionar un empleado.", TipoMensaje.MsgAdvertencia); } else { Alert("Debe seleccionar un concepto.", TipoMensaje.MsgAdvertencia); } } UPDatos.Update(); } }