nominas y personal

This commit is contained in:
JORGE LUIS CAUDILLO ESPARZA
2020-06-26 16:40:01 -07:00
parent b02820d1b2
commit 06d856bcff
12 changed files with 1427 additions and 417 deletions

View File

@@ -87,9 +87,22 @@
<li>
<asp:HyperLink ID="HypAsistencia" NavigateUrl="/RH/Asistencias.aspx" runat="server"><i class="fa fa-list" aria-hidden="true"></i>Ir a asistencia</asp:HyperLink>
</li>
<li>
<asp:LinkButton ID="LnkFormatoTabular" OnClick="LnkFormatoTabular_Click" CssClass="" runat="server"><i class="fa fa-download"></i> Nomina tabular</asp:LinkButton>
</li>
<li>
<asp:LinkButton ID="LnkSimulador" OnClick="LnkSimulador_Click" runat="server"><i class="fa fa-calculator"></i> Simulador</asp:LinkButton>
</li>
<li>
<asp:HyperLink ID="HypSua" data-toggle="modal" data-target="#DModalValidacionMasiva" runat="server"><i class="fa fa-check"></i> Cargar archivoSua</asp:HyperLink>
</li>
<li>
<asp:LinkButton ID="LnkDownArchivosSua" OnClick="LnkDownArchivosSua_Click" runat="server"><i class="fa fa-download"></i> Descargar Archivos sua</asp:LinkButton>
</li>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="LnkListaRaya" />
<asp:PostBackTrigger ControlID="LnkFormatoTabular" />
</Triggers>
</asp:UpdatePanel>
@@ -212,7 +225,7 @@
</div>
</div>
<div class="portlet-body nomarginleftright form-horizontal form-row-sepe formnombottom ">
<asp:GridView ID="GvNominas" runat="server" DataKeyNames="CvePeriodo,CvePersonal,CveNomina,SeTimbro,SerieFolio,Nombre,Correo,Turno,SubProyecto,NomAutorizado" AutoGenerateColumns="False" OnRowDataBound="GvNominas_RowDataBound"
<asp:GridView ID="GvNominas" runat="server" DataKeyNames="CvePeriodo,CvePersonal,CveNomina,SeTimbro,SerieFolio,Nombre,Correo,Codigo,Turno,SubProyecto,NomAutorizado" AutoGenerateColumns="False" OnRowDataBound="GvNominas_RowDataBound"
CssClass="table table-striped table-advance table-hover mysmallbtn ScrollAD Widthall GvNominas" Style="text-align: center;" GridLines="None"
data-rows="1">
<Columns>
@@ -380,6 +393,70 @@
</asp:UpdatePanel>
<div id="DModalModAsistencia" class="modal ADS fade" role="dialog">
<asp:UpdatePanel ID="UpdatePanel1" class="modal-dialog" tabindex="-1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div class="modal-content rowpadding">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" runat="server" style="text-align: left">Modificar asistencia</h4>
</div>
<div class="modal-body">
<asp:Button ID="btnasis" OnClick="btnasis_Click" UseSubmitBehavior="false" CssClass="hidden" runat="server" Text="Button" />
<asp:TextBox ID="TxtasiscvePersonal" CssClass="hidden" runat="server"></asp:TextBox>
<asp:TextBox ID="TxtasisFecha" CssClass="hidden" runat="server"></asp:TextBox>
<div class="form-group form-md-line-input input-iconright">
<asp:TextBox CssClass="form-control" ID="TxtPersonal" runat="server" Text=""></asp:TextBox>
<asp:Label runat="server" AssociatedControlID="TxtPersonal" Text="Empleado"></asp:Label>
</div>
<div class="form-group form-md-line-input input-iconright">
<asp:DropDownList ID="DdlTipoAsistencias" runat="server" DataTextField="Tipo" DataValueField="CveAsistenciasInasistencias"
CssClass="form-control select2me" Style="width: 100% !important;" ValidationGroup="GrpGuardarAsistencia">
<asp:ListItem Selected="True" Text="Seleccione" Value="-1"></asp:ListItem>
</asp:DropDownList>
<asp:Label runat="server" AssociatedControlID="DdlTipoAsistencias" Text="Asistencia"></asp:Label>
</div>
<div class="form-group form-md-line-input input-iconright">
<asp:TextBox CssClass="form-control" ID="TxtPorPago" runat="server" Text=""></asp:TextBox>
<asp:Label runat="server" AssociatedControlID="TxtPorPago" Text="Porcentaje Pago"></asp:Label>
</div>
<div class="form-group form-md-line-input input-iconright">
<asp:TextBox CssClass="form-control " ID="TxtHorasDobles" runat="server" MaxLength="3" Text="0"></asp:TextBox></td>
<asp:Label runat="server" AssociatedControlID="TxtHorasDobles" Text="Horas Dobles"></asp:Label>
</div>
<div class="form-group form-md-line-input input-iconright">
<asp:TextBox CssClass="form-control " ID="TxtHorasTriples" runat="server" MaxLength="3" Text="0"></asp:TextBox></td>
<asp:Label runat="server" AssociatedControlID="TxtHorasTriples" Text="Horas Triples"></asp:Label>
</div>
<div class="form-group form-md-line-input input-iconright">
<asp:DropDownList ID="DdlMotivoHoraExtra" runat="server" AppendDataBoundItems="true" DataTextField="MotivoHoraExtra" DataValueField="CveMotivoHoraExtra"
CssClass="form-control select2me" Width="100%">
<asp:ListItem Selected="True" Text="Seleccione" Value="-1"></asp:ListItem>
</asp:DropDownList>
<asp:Label runat="server" AssociatedControlID="DdlMotivoHoraExtra" Text="Motivo Hora Extra"></asp:Label>
</div>
<div class="form-group form-md-line-input input-iconright">
<asp:TextBox CssClass="form-control" ID="TxtObservaciones" runat="server" MaxLength="150"></asp:TextBox>
<asp:Label runat="server" AssociatedControlID="TxtObservaciones" Text="Observaciones"></asp:Label>
</div>
</div>
<div class="modal-footer">
<asp:UpdatePanel runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:LinkButton ID="LnkGuardarASistencia" OnClick="LnkGuardarASistencia_Click" CssClass="btn btn-primary" runat="server">Guardar</asp:LinkButton>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<asp:Button ID="BtnImprimirsobrerecibo" OnClick="BtnImprimirsobrerecibo_Click" runat="server" Text="Imprimir" CssClass="btn btn-primary hidden" />
<div id="ModalConceptos" class="modal ADS fade" role="dialog">
@@ -395,7 +472,7 @@
<div class="portlet-title">
<div class="caption ">
<i class="fa fa-user font-yellow-gold"></i>
<span class="caption-subject bold font-black uppercase">Trabajador :<asp:Label ID="LblEmpleado" runat="server" Text=""></asp:Label></span>
<span class="caption-subject bold font-black uppercase">Trabajador :</span><asp:Label ID="LblEmpleado" runat="server" Text=""></asp:Label>
</div>
<div class="tools">
<a href="javascript:;" class="collapse" data-original-title="" title=""></a>
@@ -412,6 +489,16 @@
<asp:Label ID="LblDiasLaborados" runat="server"></asp:Label>
</div>
</div>
<div class="row">
<div class="col-md-2 bold">Puesto</div>
<div class="col-md-4">
<asp:Label ID="LblSRPuesto" runat="server"></asp:Label>
</div>
<div class="col-md-2 bold">Departamento </div>
<div class="col-md-4">
<asp:Label ID="LblSRDepartamento" runat="server"></asp:Label>
</div>
</div>
<div class="row">
<div class="col-md-2 bold">Afi IMSS </div>
<div class="col-md-4">
@@ -654,7 +741,7 @@
<div class="">
<asp:Label AssociatedControlID="DdlFonTipoAplicacion" CssClass="ddlInfolabel" runat="server" Text="Tipo Aplicación"></asp:Label>
<asp:DropDownList ID="DdlFonTipoAplicacion" runat="server" Class="form-control select2me" Width="100%">
<asp:DropDownList ID="DdlFonTipoAplicacion" runat="server" Class="form-control select2me" Width="100%">
<asp:ListItem Text="Seleccione" Value="-1"></asp:ListItem>
<asp:ListItem Text="Fonacot(Importe fijo)" Value="3001"></asp:ListItem>
<asp:ListItem Text="Fonacot(Por días Labarados)" Value="3002"></asp:ListItem>
@@ -1062,15 +1149,144 @@
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div id="DSimulador" class="modal ADS fade" role="dialog">
<asp:UpdatePanel ID="UpSimulador" class="modal-dialog" tabindex="-1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div class="modal-content rowpadding">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" runat="server" style="text-align: left">Simulador</h4>
</div>
<div class="modal-body">
<div class="portlet light xspadding bordered " id="pnlConceptosSimulador">
<div class="portlet-title">
<div class="caption ">
<i class="icon-pin font-yellow-gold"></i>
<span class="caption-subject font-yellow-gold bold uppercase">Sobre Recibo</span>
</div>
<div class="actions">
<div class="btn-group">
</div>
</div>
</div>
<div class="portlet-body " style="padding: 0px;">
<div class="form-group form-md-line-input">
<asp:DropDownList ID="DdlTipoPeriodoSim" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DdlTipoPeriodoSim_SelectedIndexChanged" DataTextField="TipoPeriodo" DataValueField="CveTipoPeriodo" Class="form-control select2me input-sm" Style="width: 100% !important;">
</asp:DropDownList>
<asp:Label runat="server" AssociatedControlID="DdlTipoPeriodoCM">Tipo Periodo:</asp:Label>
</div>
<%--<table class="table table-striped table-hover Widthall GvConceptossimulador">
</table>--%>
<asp:GridView ID="GvConceptossimulador" runat="server" AutoGenerateColumns="False" CssClass="table table-striped table-hover Widthall GvConceptossimulador"
Style="text-align: center;" GridLines="None" OnRowDataBound="GvConceptos_RowDataBound" ShowHeaderWhenEmpty="true"
DataKeyNames="ConceptoP,CveConceptoP,ImporteP,ValorP,EstatusP,ConceptoD,CveConceptoD,ImporteD,EstatusD,ValorD">
<Columns>
<asp:TemplateField HeaderText="Concepto">
<ItemTemplate>
<asp:Label ID="LtlConcepto" runat="server" Text='<%# Eval("ConceptoP") %>' Style="word-break: break-all;"></asp:Label>
<asp:LinkButton ID="LnkConcepto" OnClick="LnkConcepto_Click" runat="server" Text='<%# Eval("ConceptoP") %>'></asp:LinkButton>
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" Width="37%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Valor">
<ItemTemplate>
<asp:Label ID="LtlValorP" runat="server" Text='<%# Eval("ValorP", "{0:##,###.##}") %>' Style="word-break: break-all;"></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Right" Width="13%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Importe">
<ItemTemplate>
<asp:Label ID="LtlImporte" runat="server" Text='<%# Eval("ImporteP", "${0:N}") %>' Style="word-break: break-all;"></asp:Label>
<asp:LinkButton ID="LnkImporte" OnClick="LnkConcepto_Click" runat="server" Text='<%# Eval("ImporteP", "${0:N}") %>'></asp:LinkButton>
</ItemTemplate>
<ItemStyle HorizontalAlign="Right" Width="13%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Concepto">
<ItemTemplate>
<asp:Label ID="LtlConceptoD" runat="server" Text='<%# Eval("ConceptoD") %>' Style="word-break: break-all;"></asp:Label>
<asp:LinkButton ID="LnkConceptoD" OnClick="LnkConceptoD_Click" runat="server" Text='<%# Eval("ConceptoD") %>'></asp:LinkButton>
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" Width="37%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Valor">
<ItemTemplate>
<asp:Label ID="LtlValorD" runat="server" Text='<%# Eval("ValorD", "{0:##,###.##}") %>' Style="word-break: break-all;"></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Right" Width="13%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Importe">
<ItemTemplate>
<asp:Label ID="LtlImporteD" runat="server" Text='<%# Eval("ImporteD", "${0:N}") %>' Style="word-break: break-all;"></asp:Label>
<asp:LinkButton ID="LnkImporteD" OnClick="LnkConceptoD_Click" runat="server" Text='<%# Eval("ImporteD", "${0:N}") %>'></asp:LinkButton>
</ItemTemplate>
<ItemStyle HorizontalAlign="Right" Width="13%" />
</asp:TemplateField>
</Columns>
<HeaderStyle CssClass="SearchADHeader" />
</asp:GridView>
<table>
<%-- <tr id="Totalesperdeduccion">
<td colspan="2" class="text-left">TOTAL</td>
<td colspan="1">0.00</td>
<td colspan="2" class="text-left">TOTAL</td>
<td colspan="1">0.00</td>
</tr>--%>
<tr>
</tr>
<tr id="trnetoapagar">
<td colspan="5" class="text-left">Neto a pagar</td>
<td colspan="1">
<asp:TextBox ID="TxtNetoaPagar" CssClass="maskedmoney" runat="server"></asp:TextBox></td>
</tr>
</table>
</div>
</div>
</div>
<div class="modal-footer">
<asp:UpdatePanel runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:LinkButton ID="LnkSimularXNeto" OnClick="LnkSimularXNeto_Click" CssClass="btn btn-primary" runat="server">Calcular</asp:LinkButton>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</asp:Content>
<asp:Content ID="Content8" ContentPlaceHolderID="JS" runat="Server">
<script>
function openasis(cvePersonal, Fecha) {
<%= String.Format("$('#{0}').val(cvePersonal);", TxtasiscvePersonal.ClientID) %>
<%= String.Format("$('#{0}').val(Fecha);", TxtasisFecha.ClientID) %>
<%= String.Format("$('#{0}').click();", btnasis.ClientID) %>
}
function ADSBegin() {
if ($('.thTituloConcepto').length == 0) {
if ($('.GvConceptos .thTituloConcepto').length == 0) {
$('.GvConceptos').prepend("<tr class=\"thTituloConcepto\"> <th scope=\"col\" colspan=\"3\">Percepciones</th><th scope=\"col\" colspan=\"3\">Deducciones</th> </tr>");
}
if ($('.GvConceptossimulador .thTituloConcepto').length == 0) {
$('.GvConceptossimulador').prepend("<tr class=\"thTituloConcepto\"> <th scope=\"col\" colspan=\"3\">Percepciones</th><th scope=\"col\" colspan=\"3\">Deducciones</th> </tr>");
}
//$('.GvConceptossimulador').append($('#Totalesperdeduccion'));
$('.GvConceptossimulador').append($('#trnetoapagar'));
}
function FiltrarTabla(idtxt, idtable, idcontador) {
if ($('' + idtxt).val() == '') { $('table' + idtable + ' tr').css('display', ''); }

View File

@@ -189,6 +189,8 @@ public partial class Nomina_Nomina2 : ClsPaginas
{
DdlTipoPeriodo.DataSource = GlobalDTTipoPeriodo.FiltraParametros("Estatus = 'Activo'");
DdlTipoPeriodoCM.DataSource = DdlTipoPeriodo.DataSource;
DdlTipoPeriodoSim.DataSource = DdlTipoPeriodo.DataSource;
DdlTipoPeriodoSim.DataBind();
DdlTipoPeriodoCM.DataBind();
DdlTipoPeriodo.DataBind();
DdlTipoPeriodo.Items.Insert(0, new ListItem("Seleccione", "-1"));
@@ -337,7 +339,8 @@ public partial class Nomina_Nomina2 : ClsPaginas
field = (BoundField)GvNominas.Columns[CurrentColumn];
field.HeaderText = "Total";
field.DataField = "Total";
field.ItemStyle.BackColor = System.Drawing.Color.LightGray;
field.ItemStyle.BackColor = System.Drawing.Color.DarkGray;
field.ItemStyle.ForeColor = System.Drawing.Color.White;
GvNominas.Columns[CurrentColumn].Visible = true;
CurrentColumn++;
}
@@ -585,24 +588,37 @@ public partial class Nomina_Nomina2 : ClsPaginas
gvasistencia.Append("</tr>");
}
string tipo = "";
foreach (DataRow rempl in dtempleados.Rows)
foreach (DataRow rempl in dtempleados.FiltraParametros("CvePersonal>0").Rows)
{
int CvePersonal = rempl["CvePersonal"].ToString().ToEntero();
string nombre = rempl["Nombre"].ToString();
DateTime fecha = FechaInicio;
string Codigo = rempl["Codigo"].ToString();
DateTime fecha = FechaInicio; int HorasDobles, HorasTriples;
gvasistencia.Append("<tr>");
gvasistencia.AppendFormat("<td>{0}</td>", nombre);
gvasistencia.AppendFormat("<td>{1}<br/>{0}</td>", nombre, Codigo);
while (fecha <= FechaFin)
{
DataRow drow = dtasistencia.FiltroPrimero(string.Format("Fecha='{0:yyyy/MM/dd}' AND CvePersonal={1}", fecha, CvePersonal));
fecha = fecha.AddDays(1);
tipo = "-";
if (drow != null)
{
tipo = string.Format("{0} ({1}%)", drow["Tipo"], drow["PorcentajePago"]);
HorasDobles = drow["HorasDobles"].ToString().ToEntero();
HorasTriples = drow["HorasTriples"].ToString().ToEntero();
if (HorasDobles > 0)
{
tipo = string.Format("{0}<br/>{1} horas dobles", tipo, HorasDobles);
}
if (HorasTriples > 0)
{
tipo = string.Format("{0}<br/>{1} horas triple", tipo, HorasTriples);
}
drow.Delete();
}
gvasistencia.AppendFormat("<td>{0}</td>", tipo);
gvasistencia.AppendFormat("<td> <a onclick=\"openasis({1},'{2}')\"> {0} </a></td>", tipo, CvePersonal, fecha);
fecha = fecha.AddDays(1);
}
gvasistencia.Append("</tr>");
}
@@ -627,12 +643,13 @@ public partial class Nomina_Nomina2 : ClsPaginas
string SeTimbro = e.Row.DataKey("SeTimbro").ToString();
string NomAutorizado = e.Row.DataKey("NomAutorizado").ToString();
string Nombre = e.Row.DataKey("Nombre").ToString();
string Codigo = e.Row.DataKey("Codigo").ToString();
string Turno = e.Row.DataKey("Turno").ToString();
string SubProyecto = e.Row.DataKey("SubProyecto").ToString();
LnkTimbrar.Visible = false;
if (cvePersonal > 0)
{
LtlNombre.Text = String.Format("<a class=\"Texto\" href=\"/RH/Personal.aspx?CvePersonal={0}\">{1}</a>", cvePersonal, Nombre);
LtlNombre.Text = String.Format("<a class=\"Texto\" href=\"/RH/Personal.aspx?CvePersonal={0}\">{2}<br/>{1}</a>", cvePersonal, Nombre, Codigo);
if (CveNomina > 0)
{
if (NomAutorizado == "False")
@@ -660,6 +677,7 @@ public partial class Nomina_Nomina2 : ClsPaginas
else
{
LtlNombre.Text = "Total General";
e.Row.FindControl("LnkTimbrar").Visible = false;
if (Turno.Length == 0 && SubProyecto.Length > 0)
{
LtlNombre.Text = String.Format("<b>Sub Proyecto: {0}<b>", SubProyecto);
@@ -963,6 +981,8 @@ public partial class Nomina_Nomina2 : ClsPaginas
string FechaFin = "";
string DiasRetardos = "";
string DiasIncapacidad = "";
string Puesto = "";
string Departamento = "";
DataRow drow = dtempleados.FiltroPrimero(string.Format("CvePersonal = {0}", SRCvePersonal));
if (drow != null)
{
@@ -986,6 +1006,8 @@ public partial class Nomina_Nomina2 : ClsPaginas
CURP = erow["CURP"].ToString();
TipoPeriodo = erow["TipoPeriodo"].ToString();
NSS = erow["NSS"].ToString();
Puesto = erow["Puesto"].ToString();
Departamento = erow["Departamento"].ToString();
}
}
LblCodigoEmpleado.Text = CodigoEmpleado;
@@ -1000,6 +1022,8 @@ public partial class Nomina_Nomina2 : ClsPaginas
LblFecha.Text = string.Format("{0} al {1}", FechaInicio, FechaFin);
LblDiasRetardos.Text = DiasRetardos;
LblDiasIncapacidad.Text = DiasIncapacidad;
LblSRPuesto.Text = Puesto;
LblSRDepartamento.Text = Departamento;
#endregion
#region "Sobre Recibo"
{
@@ -1339,6 +1363,120 @@ public partial class Nomina_Nomina2 : ClsPaginas
Alert("Se actualizo el calculo de infonavit");
}
}
protected void LnkFormatoTabular_Click(object sender, EventArgs e)
{
try
{
ClosedXML.Excel.XLWorkbook wb = new ClosedXML.Excel.XLWorkbook();
var libro = wb.AddWorksheet("Nomina");
int column = 1;
//libro.Row(1).Hide();
//libro.Column(1).Hide();
//libro.Cell(1, column).Value = "CvePersonal";
//libro.Cell(2, column).Value = "CvePersonal";
//column++;
libro.Cell(1, column).Value = "Codigo";
//libro.Cell(2, column).Value = "Codigo";
column++;
libro.Cell(1, column).Value = "Empleado";
//libro.Cell(2, column).Value = "Empleado";
libro.Column(column).Width = 35;
foreach (DataRow row in dtConceptos.FiltraParametros("Tipo IN ('P','D','O') AND EsPadre = 1 ").Rows)
{
column++;
string CveConcepto = row["CveConcepto"].ToString();
string Concepto = row["Concepto"].ToString();
//libro.Cell(1, column).Value = CveConcepto;
libro.Cell(1, column).Value = Concepto;
libro.Column(column).Width = 15;
//column++;
//CveConcepto = string.Format("E{0}", row["CveConcepto"]);
//Concepto = string.Format("Exento {0}", row["Concepto"]);
//libro.Cell(1, column).Value = CveConcepto;
//libro.Cell(2, column).Value = Concepto;
//libro.Column(column).Width = 15;
}
libro.Row(1).CellsUsed().Style.Font.FontColor = ClosedXML.Excel.XLColor.White;
libro.Row(1).CellsUsed().Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189));
//libro.Row(1).Cell(13).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(247, 150, 70));
//libro.Row(1).Cell(14).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(0, 176, 240));
//libro.Row(1).Cell(15).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(177, 160, 199));
//libro.Cell(3, 1).Value = 0;
//libro.Range(3, 2, 3, 3).Merge().Value = "¿Modificar SI(S)/NO(N)?";
//column = 3;
//foreach (DataRow row in dtConceptos.FiltraParametros("Tipo IN ('P','D','O') AND EsPadre = 1 ").Rows)
//{
// column++;
// string Concepto = string.Format("V_{0}", row["CveConcepto"]);
// libro.Cell(3, column).Value = "N";
// //column++;
// //string ConceptoG = string.Format("VG_{0}", row["CveConcepto"]);
// //libro.Cell(3, column).Value = "N";
//}
//libro.Row(3).CellsUsed().Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(177, 160, 199));
int Fila = 1;
foreach (DataRow erow in dtempleados.Rows)
{
Fila++;
column = 1;
//libro.Cell(Fila, column).Value = erow["CvePersonal"];
//column++;
libro.Cell(Fila, column).Value = erow["Codigo"];
column++;
libro.Cell(Fila, column).Value = erow["Nombre"];
foreach (DataRow row in dtConceptos.FiltraParametros("Tipo IN ('P','D','O') AND EsPadre = 1 ").Rows)
{
column++;
string Concepto = string.Format("V_{0}", row["CveConcepto"]);
libro.Cell(Fila, column).Value = erow[Concepto];
//libro.Cell(Fila, column).Style.NumberFormat
//column++;
//string ConceptoG = string.Format("VG_{0}", row["CveConcepto"]);
//libro.Cell(Fila, column).Value = erow[Concepto].ToString().ToDecimal() - erow[ConceptoG].ToString().ToDecimal();
}
}
//libro.Row(2).SetAutoFilter();
libro.Row(2).CellsUsed().Style.Font.FontColor = ClosedXML.Excel.XLColor.White;
libro.Row(2).Cell(1).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189));
libro.Row(2).CellsUsed().Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189));
System.IO.Stream fs = new System.IO.MemoryStream();
wb.SaveAs(fs);
fs.Position = 0;
System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();
using (System.IO.Stream input = fs)
{
input.CopyTo(memoryStream);
}
memoryStream.Position = 0;
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.xlsx", "FormatoCargaNominas"));
Response.BinaryWrite(memoryStream.ToArray());
Response.End();
}
catch (Exception ex)
{
Alert("Ocurrio un error al generar el Formato de nominas" + ex.ToString());
}
}
protected void LnkFormato_Click(object sender, EventArgs e)
{
try
@@ -3328,4 +3466,264 @@ public partial class Nomina_Nomina2 : ClsPaginas
{
}
protected void LnkGuardarASistencia_Click(object sender, EventArgs e)
{
int CvePersonal = TxtasiscvePersonal.Text.ToEntero();
DateTime fecha = TxtasisFecha.Text.ToDate();
using (ClsRH objpersonal = new ClsRH())
{
if (objpersonal.AddAsistencia(CvePersonal, -1, -1, fecha, DdlTipoAsistencias.SelectedValue.ToEntero(), TxtPorPago.Text.Trim().ToDouble(), TxtHorasDobles.Text.Trim().ToDouble(),
TxtHorasTriples.Text.Trim().ToDouble(), DdlMotivoHoraExtra.SelectedValue.ToEntero(), TxtObservaciones.Text.Trim(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa))
{
}
Alert("se ha guardado la asistencia satisfactoriamente");
}
}
protected void btnasis_Click(object sender, EventArgs e)
{
int CvePersonal = TxtasiscvePersonal.Text.ToEntero();
DateTime fecha = TxtasisFecha.Text.ToDate();
DataRow drow = dtempleados.FiltroPrimero(string.Format("CvePersonal={0}", CvePersonal));
TxtPersonal.Text = drow["nombre"].ToString();
if (DdlTipoAsistencias.Items.Count == 1)
{
DdlTipoAsistencias.DataSource = GlobalDTAsistenciasInasistencias.FiltraParametros(string.Format("CveEmpresa = {0}", UsuarioActual.CveEmpresa));
DdlTipoAsistencias.DataBind();
}
if (DdlMotivoHoraExtra.Items.Count == 1)
{
DdlMotivoHoraExtra.DataSource = GlobalDTMotivosHorasExtras.FiltraParametros(string.Format("CveEmpresa = {0}", UsuarioActual.CveEmpresa));
DdlMotivoHoraExtra.DataBind();
}
using (ClsRH objpersonal = new ClsRH())
{
if (objpersonal.GetAsistencias(CvePersonal, -1, -1, -1, -1, -1, fecha, fecha, UsuarioActual.CveEmpresa))
{
if (objpersonal.DtResultados.Rows.Count > 0)
{
DataRow dr = objpersonal.DtResultados.Rows[0];
DdlTipoAsistencias.SelectedValueExist(dr["CveAsistenciasInasistencias"].ToString());
TxtPorPago.Text = dr["PorcentajePago"].ToString();
TxtHorasDobles.Text = dr["HorasDobles"].ToString();
TxtHorasTriples.Text = dr["HorasTriples"].ToString();
DdlMotivoHoraExtra.SelectedValueExist(dr["CveMotivoHoraExtra"].ToString());
TxtPorPago.Text = dr["Observacion"].ToString();
// CveAsistenciasInasistencias
// PorcentajePago
// HorasDobles
// HorasTriples
//CveMotivoHoraExtra
//Observacion
//
}
}
}
RegistraScript("$('#DModalModAsistencia').modal();");
}
protected void LnkSimulador_Click(object sender, EventArgs e)
{
GvConceptossimulador.DataSource = new DataTable();
GvConceptossimulador.DataBind();
RegistraScript("$('#DSimulador').modal()");
UpSimulador.Update();
}
protected void LnkSimularXNeto_Click(object sender, EventArgs e)
{
int CveProyecto = -1;
int CveSubProyecto = 1;
int CveTurno = -1;
int CvePeriodo = 12551;
int CveEmpresa = UsuarioActual.CveEmpresa;
int Agrupador = -1;
decimal Neto = TxtNetoaPagar.Text.ToDecimal();
decimal NetoSimulado = 0;
decimal SDI = Neto / 15;
decimal SDIOLD = 0;
decimal sumador = 100;
decimal multiplicador = 1;
bool ismayor = false;
bool isfirst = true;
bool continuarV = true;
DataTable dtPeriodo = new DataTable();
DataTable dtasistencia = new DataTable();
DataTable dtConceptos = new DataTable();
DataTable dtempleados = new DataTable();
DataTable dtempleadosConceptos = new DataTable();
bool continuar = false;
using (ClsNominas objnom = new ClsNominas())
{
while (Neto != NetoSimulado && continuarV)
{
if (objnom.GetNominaEmpleadoSimulador(CveProyecto, CveSubProyecto, CveTurno, CvePeriodo, CveEmpresa, Agrupador, SDI) && objnom.DTSetResultados.Tables.Count > 1)
{
dtempleados = objnom.DTSetResultados.Tables[3];
dtempleadosConceptos = objnom.DTSetResultados.Tables[4];
dtConceptos = objnom.DTSetResultados.Tables[0];
dtPeriodo = objnom.DTSetResultados.Tables[1];
dtasistencia = objnom.DTSetResultados.Tables[2];
continuar = true;
NetoSimulado = dtempleados.SUM("Total", string.Format("CvePersonal = {0}", 1)).ToString().ToDecimal();
}
if (continuar)
{
if (isfirst)
{
if (Neto > NetoSimulado)
{
ismayor = true;
}
else
{
ismayor = false;
}
isfirst = false;
}
else
{
if (!((Neto > NetoSimulado) == ismayor))
{
SDI = SDIOLD;
sumador = sumador * 0.1M;
if (sumador < .00000001M)
{
continuarV = false;
}
}
}
multiplicador = (Neto > NetoSimulado) ? 1 : -1;
SDIOLD = SDI;
SDI = SDI + (multiplicador * sumador);
}
else
{
continuarV = false;
}
}
}
if (continuar)
{
{
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}", 1));
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}", 1));
}
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}", 1));
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}", 1));
}
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}", 1));
///Alert(SubTotales.ImporteP.ToString());
SubTotales.CveConceptoD = 0;
SubTotales.ConceptoD = "Total Deducciones";
SubTotales.EstatusD = -2;
SubTotales.ImporteD = dtempleados.SUM("SumaDeducciones", string.Format("CvePersonal = {0}", 1));
//NConcepto Totales = new NConcepto();
//Totales.CveConceptoD = 0;
//Totales.ConceptoD = "Total";
//Totales.EstatusD = -3;
//Totales.ImporteD = dtempleados.SUM("Total", string.Format("CvePersonal = {0}", 1));
lconc.Add(SubTotales);
//lconc.Add(Totales);
GvConceptossimulador.DataSource = lconc;
GvConceptossimulador.DataBind();
}
}
UpSimulador.Update();
}
protected void DdlTipoPeriodoSim_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void LnkDownArchivosSua_Click(object sender, EventArgs e)
{
Alert("Ocurrio un error al generar archivos sua", ModExtensiones.TipoMensaje.MsgAdvertencia);
}
}