This commit is contained in:
JORGE LUIS CAUDILLO ESPARZA
2020-07-09 11:26:09 -07:00
parent 5cda2592ec
commit 178bdd4701
4 changed files with 230 additions and 47 deletions

View File

@@ -52,6 +52,16 @@ public partial class Nomina_Nomina2 : ClsPaginas
set { ViewState["dtempleados"] = value; }
}
private DataTable DtSuaProcesado
{
get
{
if (ViewState["dtempleados"] == null) { return null; }
else { return (DataTable)ViewState["dtempleados"]; }
}
set { ViewState["dtempleados"] = value; }
}
protected bool PermisoCancelarEmitido
{
@@ -3858,7 +3868,14 @@ public partial class Nomina_Nomina2 : ClsPaginas
{
if (ObjPersonal.ProcesarSUA(SuaFiletext, UsuarioActual.CveEmpresa))
{
GVProcesarSUA.DataSource = ObjPersonal.DTSetResultados.Tables[3];
if (ObjPersonal.DTSetResultados.Tables.Count > 4)
{
DateTime dateperiodo;
DateTime.TryParseExact( string.Format ("{0}01",ObjPersonal.DTSetResultados.Tables[1].Rows[0]["Periodo"]), "yyyyMMdd", new System.Globalization.CultureInfo("es-MX"), System.Globalization.DateTimeStyles.None,out dateperiodo);
LtlPeriodo.Text = dateperiodo.Date.ToString("MMMM yyyy", new System.Globalization.CultureInfo("es-MX"));
DtSuaProcesado = ObjPersonal.DTSetResultados.Tables[3];
GVProcesarSUA.DataSource = ObjPersonal.DTSetResultados.Tables[3];
}
}
}
@@ -3876,13 +3893,7 @@ public partial class Nomina_Nomina2 : ClsPaginas
if (e.Row.RowType == DataControlRowType.DataRow)
{
//CvePersonal,CodigoNombreCompleto,,,,,
//,,,,,,
//,,,,,,,
//Literal LtlNombre = e.Row.FCLiteral("LtlNombre");
//LinkButton LnkTimbrar = (LinkButton)e.Row.FindControl("LnkTimbrar");
string SalarioSUA = string.Format("{0:N2}",e.Row.DataKey("SalarioSUA").ToDecimal());
string SalarioSUA = string.Format("{0:N2}", e.Row.DataKey("SalarioSUA").ToDecimal());
string SalarioSIG = string.Format("{0:N2}", e.Row.DataKey("SalarioSIG").ToDecimal());
int celda = 1;
if (SalarioSUA != SalarioSIG)
@@ -3957,4 +3968,115 @@ public partial class Nomina_Nomina2 : ClsPaginas
}
}
protected void LnkDownExcelSua_Click(object sender, EventArgs e)
{
ClosedXML.Excel.XLWorkbook wb = new ClosedXML.Excel.XLWorkbook();
var libro = wb.AddWorksheet("SUA");
int Fila = 1;
libro.Column(1).Width = 50;
ClosedXML.Excel.IXLRange range = libro.Range(Fila, 2, Fila, 3);
range.Merge();
range.Value = "Salario";
range = libro.Range(Fila,4, Fila, 5);
range.Merge();
range.Value = "Cuota Fija";
range = libro.Range(Fila, 6, Fila,7 );
range.Merge();
range.Value = "Cuota Excedente";
range = libro.Range(Fila,8, Fila, 9);
range.Merge();
range.Value = "Prestaciones en Dinero";
range = libro.Range(Fila, 10, Fila,11 );
range.Merge();
range.Value = "Gastos Medicos";
range = libro.Range(Fila, 12, Fila, 13);
range.Merge();
range.Value = "Riesgos de Trabajo";
range = libro.Range(Fila, 14, Fila,15 );
range.Merge();
range.Value = "Invalidez y Vida";
range = libro.Range(Fila,16 , Fila, 17);
range.Merge();
range.Value = "Guarderia";
range = libro.Range(Fila, 18, Fila, 19);
range.Merge();
range.Value = "Retiro";
Fila = Fila + 1;
libro.Cell(Fila, 1).Value = "Empleado";
libro.Cell(Fila, 2).Value = "SUA"; //SalarioSUA
libro.Cell(Fila, 3).Value = "SIG";//SalarioSIG
libro.Cell(Fila, 4).Value = "SUA";//CuotaFijaSUA
libro.Cell(Fila, 5).Value = "SIG";//CuotaFijaSIG
libro.Cell(Fila, 6).Value = "SUA";//CuotaExcedenteSUA
libro.Cell(Fila, 7).Value = "SIG";//CuotaExcedenteSIG
libro.Cell(Fila, 8).Value = "SUA";//PrestacionesDineroSUA
libro.Cell(Fila, 9).Value = "SIG";//PrestacionesSIG
libro.Cell(Fila, 10 ).Value = "SUA";//GastosMedPenSUA
libro.Cell(Fila, 11 ).Value = "SIG";//GastosMedicosSIG
libro.Cell(Fila, 12 ).Value = "SUA";//RiesgosdeTrabajoSUA
libro.Cell(Fila, 13 ).Value = "SIG";//RiesgoTrabajoSIG
libro.Cell(Fila, 14 ).Value = "SUA";//InvalidezyVidaSUA
libro.Cell(Fila, 15 ).Value = "SIG";//InvalidezyVidaSIG
libro.Cell(Fila, 16 ).Value = "SUA";//GuarderiaSUA
libro.Cell(Fila, 17 ).Value = "SIG";//GuarderiaSIG
libro.Cell(Fila, 18 ).Value = "SUA";//RetiroSUA
libro.Cell(Fila, 19 ).Value = "SIG";//RetiroSIG
libro.Cell(1, 1).Style.Font.FontColor = ClosedXML.Excel.XLColor.White;
libro.Cell(1, 1).Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189));
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(2).CellsUsed().Style.Font.FontColor = ClosedXML.Excel.XLColor.White;
libro.Row(2).CellsUsed().Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189));
foreach (DataRow erow in DtSuaProcesado.Rows)
{
Fila++;
libro.Cell(Fila, 1).Value = erow["CodigoNombreCompleto"];
libro.Cell(Fila, 2).Value = string.Format("{0:N2}",erow["SalarioSUA"]);
libro.Cell(Fila, 3).Value = string.Format("{0:N2}",erow["SalarioSIG"]);
libro.Cell(Fila, 4).Value = string.Format("{0:N2}",erow["CuotaFijaSUA"]);
libro.Cell(Fila, 5).Value = string.Format("{0:N2}", erow["CuotaFijaSIG"]);
libro.Cell(Fila, 6).Value = string.Format("{0:N2}",erow["CuotaExcedenteSUA"]);
libro.Cell(Fila, 7).Value = string.Format("{0:N2}",erow["CuotaExcedenteSIG"]);
libro.Cell(Fila, 8).Value = string.Format("{0:N2}",erow["PrestacionesDineroSUA"]);
libro.Cell(Fila, 9).Value = string.Format("{0:N2}",erow["PrestacionesSIG"]);
libro.Cell(Fila, 10).Value = string.Format("{0:N2}",erow["GastosMedPenSUA"]);
libro.Cell(Fila, 11).Value = string.Format("{0:N2}",erow["GastosMedicosSIG"]);
libro.Cell(Fila, 12).Value = string.Format("{0:N2}",erow["RiesgosdeTrabajoSUA"]);
libro.Cell(Fila, 13).Value = string.Format("{0:N2}",erow["RiesgoTrabajoSIG"]);
libro.Cell(Fila, 14).Value = string.Format("{0:N2}",erow["InvalidezyVidaSUA"]);
libro.Cell(Fila, 15).Value = string.Format("{0:N2}",erow["InvalidezyVidaSIG"]);
libro.Cell(Fila, 16).Value = string.Format("{0:N2}",erow["GuarderiaSUA"]);
libro.Cell(Fila, 17).Value = string.Format("{0:N2}",erow["GuarderiaSIG"]);
libro.Cell(Fila, 18).Value = string.Format("{0:N2}",erow["RetiroSUA"]);
libro.Cell(Fila, 19).Value = string.Format("{0:N2}",erow["RetiroSIG"]);
}
//libro.Row(2).SetAutoFilter();
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();
}
}