private void GuardarEtnia()
        {
            try
            {
                cEtnia etnia = new cEtnia();
                if (Clave > 0)
                {
                    //Actualizar
                    SelectedItem.DESCR   = Descripcion;
                    SelectedItem.ESTATUS = SelectedEstatus.CLAVE;
                    //tatuaje.Actualizar(SelectedItem);

                    etnia.Actualizar(new ETNIA {
                        ID_ETNIA = Clave, DESCR = SelectedItem.DESCR, ESTATUS = SelectedEstatus.CLAVE
                    });
                }
                else
                {   //Agregar
                    etnia.Insertar(new ETNIA {
                        ID_ETNIA = Clave, DESCR = Descripcion, ESTATUS = SelectedEstatus.CLAVE
                    });
                }
                //Limpiamos las variables
                Clave           = 0;
                Descripcion     = string.Empty;
                Busqueda        = string.Empty;
                SelectedEstatus = null;
                //Mostrar Listado
                GetEtnias();
            }
            catch (Exception ex)
            {
                StaticSourcesViewModel.ShowMessageError("Algo pasó...", "Ocurrió un error al guardar.", ex);
            }
        }
 private bool EliminarEtnia()
 {
     try
     {
         if (SelectedItem != null || SelectedItem.ID_ETNIA >= 100)
         {
             cEtnia etnia = new cEtnia();
             if (!etnia.Eliminar(SelectedItem.ID_ETNIA))
             {
                 return(false);
             }
             Clave           = 0;
             Descripcion     = string.Empty;
             SelectedEstatus = null;
             Busqueda        = string.Empty;
             this.GetEtnias();
         }
         return(true);
     }
     catch (Exception ex)
     {
         StaticSourcesViewModel.ShowMessageError("Algo pasó...", "Ocurrió un error al eliminar.", ex);
         return(false);
     }
 }
        private void GenerarReporteQuery()
        {
            try
            {
                Application.Current.Dispatcher.Invoke((Action)(delegate
                {
                    Reporte.Reset();
                    Reporte.RefreshReport();
                }));
                var lst_imp_grafica   = new List <cGraficaPoblacionIndigenaM>();
                var lst_imp_grafica_f = new List <cGraficaPoblacionIndigenaF>();
                var datosReporte      = new List <cReporteDatos>();
                datosReporte.Add(new cReporteDatos()
                {
                    Encabezado1 = Parametro.ENCABEZADO1,
                    Encabezado2 = Parametro.ENCABEZADO2,
                    Encabezado3 = Parametro.ENCABEZADO3,
                    Logo1       = Parametro.REPORTE_LOGO1,
                    Logo2       = Parametro.REPORTE_LOGO2,
                    Titulo      = "Población Indígena"
                });

                var reporte = new cEtnia().ObtenerPoblacionIndigena(GlobalVar.gCentro).Select(w => new cReportePoblacionIndigena()
                {
                    Etnia          = w.ETNIA,
                    ComunDiscMasc  = w.M_DISCRECIONAL,
                    ComunImpFem    = w.F_IMPUTADO_COMUN,
                    ComunImpMasc   = w.M_IMPUTADO_COMUN,
                    ComunIndicFem  = w.F_INDICIADO_COMUN,
                    ComunIndicMasc = w.M_INDICIADO_COMUN,
                    ComunProcFem   = w.F_PROCESADO_COMUN,
                    ComunProcMasc  = w.M_PROCESADO_COMUN,
                    ComunSentFem   = w.F_SENTENCIADO_COMUN,
                    ComunSentMasc  = w.M_SENTENCIADO_COMUN,

                    FederalIndicMasc = w.M_INDICIADO_FEDERAL,
                    FederalProcFem   = w.F_PROCESADO_FEDERAL,
                    FederalProcMasc  = w.M_PROCESADO_FEDERAL,
                    FederalSentFem   = w.F_SENTENCIADO_FEDERAL,
                    FederalSentMasc  = w.M_SENTENCIADO_FEDERAL,

                    SinFueroDiscIndef = w.DISCRECIONAL_SIN_FUERO,
                    SinFueroIndicFem  = w.F_INDICIADO_SIN_FUERO,
                    SinFueroIndicMasc = w.M_INDICIADO_SIN_FUERO,
                    SinFueroProcMasc  = w.M_PROCESADO_SIN_FUERO,
                });

                if (reporte != null)
                {
                    foreach (var r in reporte)
                    {
                        lst_imp_grafica.Add(new cGraficaPoblacionIndigenaM()
                        {
                            Etnia    = r.Etnia,
                            Comun    = (r.ComunDiscMasc + r.ComunImpMasc + r.ComunIndicMasc + r.ComunProcMasc + r.ComunSentMasc),
                            Federal  = (r.FederalIndicMasc + r.FederalProcMasc + r.FederalSentMasc),
                            SinFuero = (r.SinFueroIndicMasc + r.SinFueroProcMasc)
                        });

                        lst_imp_grafica_f.Add(new cGraficaPoblacionIndigenaF()
                        {
                            Etnia    = r.Etnia,
                            Comun    = (r.ComunImpFem + r.ComunIndicFem + r.ComunProcFem + r.ComunSentFem),
                            Federal  = (r.FederalProcFem + r.FederalSentFem),
                            SinFuero = (r.SinFueroIndicFem)
                        });
                    }
                }

                Reporte.LocalReport.ReportPath = "Reportes/rPoblacionIndigena.rdlc";
                Reporte.LocalReport.DataSources.Clear();

                ReportDataSource rds1 = new ReportDataSource();
                rds1.Name  = "DataSet1";
                rds1.Value = datosReporte;
                Reporte.LocalReport.DataSources.Add(rds1);

                ReportDataSource rds2 = new ReportDataSource();
                rds2.Name  = "DataSet2";
                rds2.Value = reporte;
                Reporte.LocalReport.DataSources.Add(rds2);

                ReportDataSource rds3 = new ReportDataSource();
                rds3.Name  = "DataSet3";
                rds3.Value = lst_imp_grafica;
                Reporte.LocalReport.DataSources.Add(rds3);

                ReportDataSource rds4 = new ReportDataSource();
                rds4.Name  = "DataSet4";
                rds4.Value = lst_imp_grafica_f;
                Reporte.LocalReport.DataSources.Add(rds4);

                Application.Current.Dispatcher.Invoke((Action)(delegate
                {
                    Reporte.Refresh();
                    Reporte.RefreshReport();
                }));
            }
            catch (Exception ex)
            {
                Application.Current.Dispatcher.Invoke((Action)(delegate
                {
                    ReportViewerVisible = Visibility.Collapsed;
                }));
                StaticSourcesViewModel.ShowMessageError("Algo pasó...", "Ocurrió un error al generar reporte.", ex);
            }
        }