This commit is contained in:
@@ -1,25 +1,57 @@
|
||||
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 System.Xml.Linq;
|
||||
using Extensiones;
|
||||
|
||||
public partial class Nomina_CalculoISRAnual : ClsPaginas
|
||||
{
|
||||
|
||||
protected int CvePersonal
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ViewState["CvePersonal"] == null) { return 0; }
|
||||
else { return ViewState["CvePersonal"].ToString().ToEntero(); }
|
||||
}
|
||||
|
||||
set { ViewState["CvePersonal"] = value; }
|
||||
}
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
cargaddls();
|
||||
CargaCalculoISRAnual();
|
||||
}
|
||||
}
|
||||
public void cargaddls()
|
||||
{
|
||||
|
||||
DataTable dtejercicio = new DataTable();
|
||||
using (ClsNominas objnom = new ClsNominas())
|
||||
{
|
||||
if (objnom.GetEjercicios(UsuarioActual.CveEmpresa))
|
||||
{
|
||||
dtejercicio = objnom.DtResultados;
|
||||
}
|
||||
}
|
||||
DdlEjercicios.DataSource = dtejercicio;
|
||||
DdlEjercicios.DataBind();
|
||||
string anio = DateTime.Now.Year.ToString();
|
||||
DdlEjercicios.SelectedValueExistInsert(anio, anio);
|
||||
}
|
||||
|
||||
protected void CargaCalculoISRAnual()
|
||||
{
|
||||
using (ClsNominas onom = new ClsNominas())
|
||||
{
|
||||
onom.CalculoISRAnual(2021, UsuarioActual.Empresa.CveEmpresa);
|
||||
onom.CalculoISRAnual(DdlEjercicios.SelectedValue.ToEntero(), UsuarioActual.Empresa.CveEmpresa);
|
||||
GVCalculoISRAnual.DataSource = onom.DtResultados;
|
||||
|
||||
}
|
||||
@@ -27,8 +59,185 @@ public partial class Nomina_CalculoISRAnual : ClsPaginas
|
||||
upDatos.Update();
|
||||
}
|
||||
|
||||
protected void LnkConsultar_Click(object sender, EventArgs e)
|
||||
{
|
||||
CargaCalculoISRAnual();
|
||||
}
|
||||
protected void LnkdownExcel_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
//DataTable dtCon = generateTable("\r\n");
|
||||
|
||||
|
||||
ClosedXML.Excel.XLWorkbook wb = new ClosedXML.Excel.XLWorkbook();
|
||||
var libro = wb.AddWorksheet("Asistencia");
|
||||
int column = 1;
|
||||
|
||||
int row = 1;
|
||||
|
||||
libro.Cell(row, column++).Value = "Aplica";
|
||||
libro.Cell(row, column++).Value = "Causa";
|
||||
libro.Cell(row, column++).Value = "Código";
|
||||
libro.Cell(row, column++).Value = "Nombre";
|
||||
libro.Cell(row, column++).Value = "Tipo ingreso";
|
||||
libro.Cell(row, column++).Value = "Ingresos totales";
|
||||
libro.Cell(row, column++).Value = "Base gravada";
|
||||
libro.Cell(row, column++).Value = "Base exenta";
|
||||
libro.Cell(row, column++).Value = "ISR retenido";
|
||||
libro.Cell(row, column++).Value = "Art 152";
|
||||
libro.Cell(row, column++).Value = "Subs. Correspondiente";
|
||||
libro.Cell(row, column++).Value = "Impuesto anual";
|
||||
libro.Cell(row, column++).Value = "A cargo";
|
||||
libro.Cell(row, column++).Value = "A compensar";
|
||||
libro.Range(row, 1, row, column - 1).CellsUsed().Style.Font.FontColor = ClosedXML.Excel.XLColor.White;
|
||||
libro.Range(row, 1, row, column - 1).CellsUsed().Style.Fill.SetBackgroundColor(ClosedXML.Excel.XLColor.FromArgb(79, 129, 189));
|
||||
row++;
|
||||
using (ClsNominas onom = new ClsNominas())
|
||||
{
|
||||
if (onom.CalculoISRAnual(DdlEjercicios.SelectedValue.ToEntero(), UsuarioActual.Empresa.CveEmpresa) && onom.DtResultados.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow drow in onom.DtResultados.Rows)
|
||||
{
|
||||
|
||||
column = 1;
|
||||
libro.Cell(row, column++).Value = drow["Aplica"].ToString()=="1"?"Si":"No";
|
||||
libro.Cell(row, column++).Value = drow["causa"];
|
||||
libro.Cell(row, column++).Value = drow["Codigo"];
|
||||
libro.Cell(row, column++).Value = drow["NombreCompleto"];
|
||||
libro.Cell(row, column++).Value = string.Format("{0} - {1:dd/MM/yyyy}", drow["TipoIngreso"], drow["FechaInicio"]);
|
||||
libro.Cell(row, column++).Value = drow["IngresosTotales"];
|
||||
libro.Cell(row, column++).Value = drow["BaseGravada"];
|
||||
libro.Cell(row, column++).Value = drow["BaseExcenta"];
|
||||
libro.Cell(row, column++).Value = drow["ISRRetenido"];
|
||||
libro.Cell(row, column++).Value = drow["Art152"];
|
||||
libro.Cell(row, column++).Value = drow["SubsCorrespondiente"];
|
||||
libro.Cell(row, column++).Value = drow["ImpuestoAnual"];
|
||||
libro.Cell(row, column++).Value = drow["Acargo"];
|
||||
libro.Cell(row, column++).Value = drow["Acompensar"];
|
||||
row++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
libro.SheetView.Freeze(1, 4);
|
||||
libro.ColumnsUsed().AdjustToContents();
|
||||
libro.Range(1, 6, 1, column).Style.Alignment.Horizontal = ClosedXML.Excel.XLAlignmentHorizontalValues.Center;
|
||||
libro.Range(2, 6, row, column).Style.Alignment.Horizontal = ClosedXML.Excel.XLAlignmentHorizontalValues.Right;
|
||||
libro.Range(2, 6, row, column).SetDataType(ClosedXML.Excel.XLDataType.Number);
|
||||
libro.Range(2, 6, row, column).Style.NumberFormat.Format = "$#,###,###,###,###,###,0.00";
|
||||
|
||||
|
||||
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", "Calculo Anual"));
|
||||
Response.BinaryWrite(memoryStream.ToArray());
|
||||
Response.End();
|
||||
}
|
||||
|
||||
|
||||
protected void LnkAplicar_Click(object sender, EventArgs e)
|
||||
{
|
||||
GridViewRow gvrow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
||||
CvePersonal = gvrow.DataKey("CvePersonal").ToString().ToEntero();
|
||||
using (ClsNominas onom = new ClsNominas())
|
||||
{
|
||||
if (onom.PersonalAplicaCalculoAnual(UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, CvePersonal, 1, ""))
|
||||
{
|
||||
Alert("El empleado sera incluido al calculo anual");
|
||||
CargaCalculoISRAnual();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void LnkCancelar_Click(object sender, EventArgs e)
|
||||
{
|
||||
GridViewRow gvrow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
||||
CvePersonal = gvrow.DataKey("CvePersonal").ToString().ToEntero();
|
||||
RegistraScript("$('#DModalcancelarEmpleado').modal();");
|
||||
}
|
||||
|
||||
protected void LnkGuardarCancelarAplica_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (ClsNominas onom = new ClsNominas())
|
||||
{
|
||||
if(onom.PersonalAplicaCalculoAnual(UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, CvePersonal, 0, TxtMotivo.Text))
|
||||
{
|
||||
Alert("El empleado sera omitido del calculo anual");
|
||||
RegistraScript("$('#DModalcancelarEmpleado').modal('hide');");
|
||||
CargaCalculoISRAnual();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void LnkOpenModalAutoriza_Click(object sender, EventArgs e)
|
||||
{
|
||||
using(ClsNominas onom = new ClsNominas())
|
||||
{
|
||||
if (onom.GetConceptos(UsuarioActual.CveEmpresa, "-1", -1, -1, -1))
|
||||
{
|
||||
DdlConceptoCargo.DataSource = onom.DtResultados;
|
||||
DdlConceptoCompensar.DataSource = onom.DtResultados;
|
||||
DdlConceptoCargo.DataBind();
|
||||
DdlConceptoCompensar.DataBind();
|
||||
DataRow drow = onom.DtResultados.FiltroPrimero(string.Format("CveSistema ={0}",46));
|
||||
if (drow != null)
|
||||
{
|
||||
DdlConceptoCargo.SelectedValueExist(drow["CveConcepto"]);
|
||||
}
|
||||
drow = null; drow = onom.DtResultados.FiltroPrimero(string.Format("CveSistema ={0}", 49));
|
||||
if (drow != null)
|
||||
{
|
||||
DdlConceptoCompensar.SelectedValueExist(drow["CveConcepto"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
RegistraScript("$('#DModalAutoriza').modal();");
|
||||
UpAutorizaCalculo.Update();
|
||||
}
|
||||
|
||||
protected void LnkAutoriza_Click(object sender, EventArgs e)
|
||||
{
|
||||
bool continuar = true;
|
||||
|
||||
|
||||
System.Xml.Linq.XDocument xmlarchivos = new System.Xml.Linq.XDocument();
|
||||
XElement xfolder = new XElement("personal");
|
||||
foreach (GridViewRow item in GVCalculoISRAnual.Rows )
|
||||
{
|
||||
XElement xempleado = new XElement("empleado");
|
||||
xempleado.SetAttributeValue("CvePersonal", item.DataKey("CvePersonal"));
|
||||
xempleado.SetAttributeValue("ACarago", item.DataKey("Acargo"));
|
||||
xempleado.SetAttributeValue("ACompensar", item.DataKey("Acompensar"));
|
||||
|
||||
xfolder.Add(xempleado);
|
||||
}
|
||||
xmlarchivos.Add(xfolder);
|
||||
string xmlpeople= xmlarchivos.ToString();
|
||||
|
||||
using (ClsNominas onom = new ClsNominas())
|
||||
{
|
||||
continuar = onom.AutorizaCalculoAnual(UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, xmlpeople);
|
||||
}
|
||||
if (continuar)
|
||||
{
|
||||
Alert("El calculo a sido autorizado");
|
||||
RegistraScript("$('#DModalAutoriza').modal('hide');");
|
||||
}
|
||||
|
||||
RegistraScript(string.Format("console.log('{0}');debugger", xmlpeople));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user