private void btnVerDetalle_Click(object sender, RoutedEventArgs e) { if ((cboEmpleado.SelectedItem != null) && (cboLiquidacion.SelectedItem != null)) { Empleado ee = (Empleado)cboEmpleado.SelectedItem; Liquidacion_Mensual ll = (Liquidacion_Mensual)cboLiquidacion.SelectedItem; var liquidacionDetalle = datos.Liquidacion_Mensual_Detalle.ToList().FindAll(x => x.Liquidacion_Id == ll.Id_Liquidacion && x.Empleado_Id == ee.Id_Empleado); dgDetalle.ItemsSource = liquidacionDetalle; var resumenLiquidacion = datos.ResumenLiquidacion.ToList().FindAll(x => x.Id_Liquidacion == ll.Id_Liquidacion && x.Id_Empleado == ee.Id_Empleado); if (resumenLiquidacion.Count == 1) { foreach (ResumenLiquidacion rr in resumenLiquidacion) { lblEgresos.Content = rr.MontoEgreso.ToString(); lblIngresos.Content = rr.MontoIngreso.ToString(); lblTotal.Content = (rr.MontoIngreso - rr.MontoEgreso).ToString(); } } else { MessageBox.Show("Error, favor comuniquese con informatica.", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Debe seleccionar el Empleado y la Liquidacion para visualizar el detalle.", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void dgLiquidaciones_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (dgLiquidaciones.SelectedItem != null) { liquidacionSeleccionada = (Liquidacion_Mensual)dgLiquidaciones.SelectedItem; txtLiquidacionSeleccionada.Text = liquidacionSeleccionada.Anho.ToString() + "/" + liquidacionSeleccionada.Mes.ToString().PadLeft(2, '0'); getDetalleLiquidacion(); } }
private void btnAgregar_Click(object sender, RoutedEventArgs e) { try { Liquidacion_Mensual aa = new Liquidacion_Mensual(); aa.Anho = short.Parse(txtAño.Text); aa.Fecha_Generacion = DateTime.Now; aa.Estado = "A"; aa.Mes = short.Parse(txtMes.Text); aa.Usuario_Id = ProyectoNomina.Properties.Settings.Default.usuarioLogin; datos.Liquidacion_Mensual.Add(aa); datos.SaveChanges(); MessageBox.Show("Planilla de Liquidación insertada correctamente.", "PROCESO FINALIZADO", MessageBoxButton.OK, MessageBoxImage.Information); cargarGrilla(); } catch (Exception ex) { MessageBox.Show("Ocurrió el siguiente error: " + ex.ToString(), "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void btnProcesar_Click(object sender, RoutedEventArgs e) { if (dgLiquidaciones.ItemsSource != null) { Liquidacion_Mensual dd = (Liquidacion_Mensual)dgLiquidaciones.SelectedItem; if (dd.Estado.ToString() == "A") { var lstEmpleado = datos.Empleado.ToList(); foreach (Empleado ee in lstEmpleado) { int vIngreso = 0; int vEgresos = 0; int vTotal = 0; int vIps = 0; var detalleLiquidacion = ee.Liquidacion_Mensual_Detalle.ToList().FindAll(x => x.Liquidacion_Id == dd.Id_Liquidacion); vIngreso = vIngreso + ee.Salario_Basico; if (detalleLiquidacion.Count > 0) { foreach (Liquidacion_Mensual_Detalle det in detalleLiquidacion) { if (det.Monto > 0) { vIngreso = vIngreso + det.Monto; } else { vEgresos = vEgresos + det.Monto * -1; } } } vIps = (vIngreso * 9) / 100; Liquidacion_Mensual_Detalle nuevoIps = new Liquidacion_Mensual_Detalle(); nuevoIps.Concepto_Id = 1; nuevoIps.Empleado = ee; nuevoIps.Liquidacion_Mensual = dd; nuevoIps.Monto = vIps * -1; datos.Liquidacion_Mensual_Detalle.Add(nuevoIps); datos.SaveChanges(); var adelantos = ee.Anticipo.ToList().FindAll(x => DateTime.Parse(x.Fecha_Definicion.ToString()).Month == dd.Mes && DateTime.Parse(x.Fecha_Definicion.ToString()).Year == dd.Anho && x.Estado == "A"); if (adelantos.Count > 0) { int vAnticipo = 0; foreach (Anticipo an in adelantos) { vEgresos = vEgresos + an.Monto_Aprobado; vAnticipo = vAnticipo + an.Monto_Aprobado; } Liquidacion_Mensual_Detalle anticipo = new Liquidacion_Mensual_Detalle(); anticipo.Concepto_Id = 2; anticipo.Empleado = ee; anticipo.Liquidacion_Mensual = dd; anticipo.Monto = vAnticipo * -1; datos.Liquidacion_Mensual_Detalle.Add(anticipo); datos.SaveChanges(); } vEgresos = vEgresos + int.Parse(vIps.ToString()); vTotal = vIngreso - vEgresos; ResumenLiquidacion resumen = new ResumenLiquidacion(); resumen.Empleado = ee; resumen.Liquidacion_Mensual = dd; resumen.MontoEgreso = vEgresos; resumen.MontoIngreso = vIngreso; datos.ResumenLiquidacion.Add(resumen); datos.SaveChanges(); } dd.Estado = "C"; datos.Entry(dd).State = System.Data.Entity.EntityState.Modified; datos.SaveChanges(); MessageBox.Show("Se proceso la liquidación del mes: " + dd.Mes.ToString().PadLeft(2, '0') + "/" + dd.Anho.ToString(), "PROCESO COMPLETADO", MessageBoxButton.OK, MessageBoxImage.Information); cargarGrilla(); } else { MessageBox.Show("Solo puede procesar una liquidacion con estado 'A'", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Debe seleccionar un registro para procesar la liquidación.", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); } }