Nominas
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using ClosedXML.Excel;
|
||||
using Extensiones;
|
||||
|
||||
public partial class Nomina_RepMovtosPermanentes : ClsPaginas
|
||||
@@ -48,7 +51,7 @@ public partial class Nomina_RepMovtosPermanentes : ClsPaginas
|
||||
{
|
||||
get { return TxtRpdFechaFin.Text; }
|
||||
set { TxtRpdFechaFin.Text = value; }
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
@@ -60,7 +63,7 @@ public partial class Nomina_RepMovtosPermanentes : ClsPaginas
|
||||
RcveEstatus = Request["cveEstatus"] != null ? Convert.ToInt32(Request["cveEstatus"]) : -1;
|
||||
RcveConcepto = Request["cveConcepto"] != null ? Convert.ToInt32(Request["cveConcepto"]) : -1;
|
||||
fechaInicio = DateTime.Now.ToString("01/MM/yyyy");
|
||||
fechaFin=DateTime.Now.ToString("01/MM/yyyy").ToDateTime().AddMonths(1).AddDays(1).ToString("01/MM/yyyy");
|
||||
fechaFin = DateTime.Now.ToString("01/MM/yyyy").ToDateTime().AddMonths(1).AddDays(1).ToString("01/MM/yyyy");
|
||||
CargaCombos();
|
||||
cargardatos();
|
||||
|
||||
@@ -85,11 +88,11 @@ public partial class Nomina_RepMovtosPermanentes : ClsPaginas
|
||||
}
|
||||
DDLConcepto.DataBind();
|
||||
}
|
||||
DDlPersonal.SelectedValueExist( RcvePersonal.ToString());
|
||||
DDlTipo.SelectedValueExist( RcveTipo.ToString());
|
||||
DDLSaldo.SelectedValueExist( RcveSaldo.ToString());
|
||||
DDLEstatus.SelectedValueExist( RcveEstatus.ToString());
|
||||
DDLConcepto.SelectedValueExist( RcveConcepto.ToString());
|
||||
DDlPersonal.SelectedValueExist(RcvePersonal.ToString());
|
||||
DDlTipo.SelectedValueExist(RcveTipo.ToString());
|
||||
DDLSaldo.SelectedValueExist(RcveSaldo.ToString());
|
||||
DDLEstatus.SelectedValueExist(RcveEstatus.ToString());
|
||||
DDLConcepto.SelectedValueExist(RcveConcepto.ToString());
|
||||
}
|
||||
protected void cargardatos()
|
||||
{
|
||||
@@ -97,7 +100,7 @@ public partial class Nomina_RepMovtosPermanentes : ClsPaginas
|
||||
{
|
||||
//string fechaInicio = "";
|
||||
//string fechaFin = "";
|
||||
ObjGetM.GetMovtoPermanenteRepFechas(RcvePersonal, UsuarioActual.CveEmpresa, RcveTipo, RcveSaldo, RcveEstatus, RcveConcepto, fechaInicio, fechaFin);
|
||||
ObjGetM.GetMovtoPermanenteRepFechas(RcvePersonal, UsuarioActual.CveEmpresa, RcveTipo, RcveSaldo, RcveEstatus, RcveConcepto, fechaInicio.ToDateTime().ToString("yyyy-MM-dd"), fechaFin.ToDateTime().ToString("yyyy-MM-dd"));
|
||||
GVGetMovtoPermanenteRep.DataSource = ObjGetM.DtResultados;
|
||||
GVGetMovtoPermanenteRep.DataBind();
|
||||
|
||||
@@ -119,8 +122,8 @@ public partial class Nomina_RepMovtosPermanentes : ClsPaginas
|
||||
{
|
||||
|
||||
if (e.Row.RowType == DataControlRowType.Header)
|
||||
{
|
||||
e.Row.CssClass = "headerHide";
|
||||
{
|
||||
e.Row.CssClass = "headerHide";
|
||||
}
|
||||
if (e.Row.RowType == DataControlRowType.DataRow)
|
||||
{
|
||||
@@ -137,7 +140,7 @@ public partial class Nomina_RepMovtosPermanentes : ClsPaginas
|
||||
//e.Row.Cells[1].Attributes.Add("colspan", "7");
|
||||
cssclass = string.Format("{0} cvetipo0", cssclass);
|
||||
}
|
||||
e.Row.CssClass = cssclass;
|
||||
e.Row.CssClass = cssclass;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,7 +174,84 @@ public partial class Nomina_RepMovtosPermanentes : ClsPaginas
|
||||
|
||||
protected void LnkFormatoxls_Click(object sender, EventArgs e)
|
||||
{
|
||||
GVGetMovtoPermanenteRep.ExportToExcelX("Movimientos Permanente");
|
||||
using (ClsNominas ObjGetM = new ClsNominas())
|
||||
{
|
||||
//string fechaInicio = "";
|
||||
//string fechaFin = "";
|
||||
ObjGetM.GetMovtoPermanenteRepFechas(RcvePersonal, UsuarioActual.CveEmpresa, RcveTipo, RcveSaldo, RcveEstatus, RcveConcepto, fechaInicio.ToDateTime().ToString("yyyy-MM-dd"), fechaFin.ToDateTime().ToString("yyyy-MM-dd"));
|
||||
ExportarExcel(ObjGetM.DtResultados);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected void ExportarExcel(DataTable dt)
|
||||
{
|
||||
using (var wb = new XLWorkbook())
|
||||
{
|
||||
var ws = wb.Worksheets.Add("Descuentos");
|
||||
|
||||
// Encabezados
|
||||
ws.Cell(1, 1).Value = "Código";
|
||||
ws.Cell(1, 2).Value = "Nombre Completo";
|
||||
ws.Cell(1, 3).Value = "Descuento Acordado";
|
||||
ws.Cell(1, 4).Value = "Descuento Aplicado";
|
||||
ws.Cell(1, 5).Value = "Acumulado";
|
||||
|
||||
// Estilo del encabezado
|
||||
var headerRange = ws.Range("A1:E1");
|
||||
headerRange.Style.Fill.BackgroundColor = XLColor.LightGray;
|
||||
headerRange.Style.Font.Bold = true;
|
||||
headerRange.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
|
||||
int row = 2;
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
int cveTipo = Convert.ToInt32(dr["CveTipo"]);
|
||||
|
||||
string codigo = dr["Codigo"].ToString();
|
||||
string nombre = cveTipo == 0 ? dr["Concepto"].ToString() : dr["NombreCompleto"].ToString();
|
||||
decimal valor = Convert.ToDecimal(dr["Valor"]);
|
||||
decimal aplicado = Convert.ToDecimal(dr["MontoAplicado"]);
|
||||
decimal acumulado = Convert.ToDecimal(dr["Acumulado"]);
|
||||
|
||||
ws.Cell(row, 1).Value = codigo;
|
||||
ws.Cell(row, 2).Value = nombre;
|
||||
ws.Cell(row, 3).Value = valor;
|
||||
ws.Cell(row, 4).Value = aplicado;
|
||||
ws.Cell(row, 5).Value = acumulado;
|
||||
|
||||
// Formato numérico a columnas de dinero
|
||||
ws.Cell(row, 3).Style.NumberFormat.Format = "#,##0.00";
|
||||
ws.Cell(row, 4).Style.NumberFormat.Format = "#,##0.00";
|
||||
ws.Cell(row, 5).Style.NumberFormat.Format = "#,##0.00";
|
||||
|
||||
// Color especial si CveTipo = 0
|
||||
if (cveTipo == 0)
|
||||
{
|
||||
var range = ws.Range(row, 1, row, 5);
|
||||
range.Style.Fill.BackgroundColor = XLColor.FromArgb(221, 221, 221);
|
||||
range.Style.Font.Bold = true;
|
||||
}
|
||||
|
||||
row++;
|
||||
}
|
||||
|
||||
// Ajustar columnas al contenido
|
||||
ws.Columns().AdjustToContents();
|
||||
|
||||
// Exportar el archivo
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
wb.SaveAs(ms);
|
||||
Response.Clear();
|
||||
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
||||
Response.AddHeader("content-disposition", "attachment;filename=Movimietnospermanenetea.xlsx");
|
||||
Response.BinaryWrite(ms.ToArray());
|
||||
Response.End();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user