This commit is contained in:
JORGE LUIS CAUDILLO ESPARZA
2023-02-21 17:25:03 -07:00
parent 3a855248d4
commit 1a1ccd5bc6
10 changed files with 346 additions and 135 deletions

View File

@@ -391,6 +391,75 @@ public partial class RH_CalculoSBC : ClsPaginas
Alert("Ocurrio un error al generar el Formato de nominas" + ex.ToString(), TipoMensaje.MsgAdvertencia);
}
}
protected void LnkFormatocMasivaTS_Click(object sender, EventArgs e)
{
try
{
bool continuar = true;
string msgerror = "";
if (dtsalario == null || dtsalario.Rows.Count == 0)
{
msgerror = "favor de calcular primero";
continuar = false;
}
if (continuar)
{
ClosedXML.Excel.XLWorkbook wb = new ClosedXML.Excel.XLWorkbook();
var libro = wb.AddWorksheet("Salario");
int column = 1;
libro.Cell(1, column).Value = "Codigo";
column++;
libro.Cell(1, column).Value = "Empleado";
column++;
libro.Cell(1, column).Value = "TipodeSalario";
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));
int Fila = 1;
foreach (DataRow erow in dtsalario.Rows)
{
Fila++;
column = 1;
libro.Cell(Fila, column).Value = string.Format("'{0}", erow["Codigo"]);
column++;
libro.Cell(Fila, column).Value = erow["Nombre"];
column++;
libro.Cell(Fila, column).Value = erow["TipodeSalario"];
}
libro.Columns().AdjustToContents();
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", "Plantilla Salario "));
Response.BinaryWrite(memoryStream.ToArray());
Response.End();
}
else
{
Alert(msgerror, TipoMensaje.MsgAdvertencia);
}
}
catch (Exception ex)
{
Alert("Ocurrio un error al generar el Formato de nominas" + ex.ToString(), TipoMensaje.MsgAdvertencia);
}
}
protected void LnkProcesarArchvo_Click(object sender, EventArgs e)
{
@@ -475,7 +544,7 @@ public partial class RH_CalculoSBC : ClsPaginas
StringBuilder str = new StringBuilder();
bool rollback = false;
using (ClsClaseBase objNomina = new ClsClaseBase( ))
using (ClsClaseBase objNomina = new ClsClaseBase())
using (ClsRH objpersonal = new ClsRH())
{
@@ -483,7 +552,7 @@ public partial class RH_CalculoSBC : ClsPaginas
{
string Codigo = row["Codigo"].ToString();
int CvePersonal = -1; // row["CvePersonal"].ToString().ToEntero();
string RegistroPatronal = row["RegistroPatronal"].ToString() ;
string RegistroPatronal = row["RegistroPatronal"].ToString();
int CveMetodoPago = 0;
if (Codigo != "-1" && objpersonal.GetPersonal(CvePersonal, Codigo, "-1", "-1", "-1", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "-1", -1, -1, -1, -1, -1, -1, "-1", "-1", "-1", "-1", UsuarioActual.CveEmpresa) &&
objpersonal.DtResultados.Rows.Count == 1)
@@ -501,7 +570,47 @@ public partial class RH_CalculoSBC : ClsPaginas
objNomina.runQuerystr(string.Format("EXEC PA_RH_PersonalRPUpdate {0},'{1}'", CvePersonal, RegistroPatronal));
}
}
}
}
if (ddltipoCarga.SelectedValue.ToEntero() == 3)
{
List<Archivo> Filesgral = TxtArchivoNomina.getfiles().Archivos;
Archivo fileItem = Filesgral.Count > 0 ? Filesgral[0] : null;
DataTable DTEXcel = Extensiones.ModExtensiones.ReadExcelFile(fileItem.FileUrl, true);
StringBuilder str = new StringBuilder();
bool rollback = false;
using (ClsClaseBase objNomina = new ClsClaseBase())
using (ClsRH objpersonal = new ClsRH())
{
foreach (DataRow row in DTEXcel.FiltraParametros("LEN(Codigo)>0 ").Rows)
{
string Codigo = row["Codigo"].ToString();
int CvePersonal = -1; // row["CvePersonal"].ToString().ToEntero();
string TipodeSalario = row["TipodeSalario"].ToString();
int CveMetodoPago = 0;
if (Codigo != "-1" && objpersonal.GetPersonal(CvePersonal, Codigo, "-1", "-1", "-1", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "-1", -1, -1, -1, -1, -1, -1, "-1", "-1", "-1", "-1", UsuarioActual.CveEmpresa) &&
objpersonal.DtResultados.Rows.Count == 1)
{
CvePersonal = objpersonal.CvePersonal;
CveMetodoPago = objpersonal.CveMetodoPago;
}
else
{
CvePersonal = 0;
str.AppendLine(string.Format("No se encontro el codigo {0}<br>", Codigo));
}
if (CvePersonal > 0)
{
objNomina.runQuerystr(string.Format("EXEC PA_RH_PersonalTSUpdate {0},'{1}'", CvePersonal, TipodeSalario));
}
}
}