Example #1
0
        public List <cMaestrosDetalleDesktop> CargarLista(Int64 pId)
        {
            List <cMaestrosDetalleDesktop> result = new List <cMaestrosDetalleDesktop>();

            try
            {
                svcMOM.MasterOfMasterSvcClient svc = new svcMOM.MasterOfMasterSvcClient();
                var lista = svc.ConsultarMaestroDetalle(-1, pId, "", null, "0001-01-01", "9999-12-31");
                foreach (MasterOfMasterModels.cMaestrosDetalle MD in lista)
                {
                    cMaestrosDetalleDesktop datos = new cMaestrosDetalleDesktop();
                    datos.idMaestroDetalle   = MD.idMaestroDetalle;
                    datos.descripcion        = MD.descripcion;
                    datos.idMaestroCabecera  = MD.idMaestroCabecera;
                    datos.idUsuarioActualiza = MD.idUsuarioActualiza;
                    datos.idUsuarioCreador   = MD.idUsuarioCreador;
                    datos.indActivo          = MD.indActivo;
                    datos.fechaCreacion      = MD.fechaCreacion.ToShortDateString();
                    datos.fechaOcurrencia    = MD.fechaOcurrencia.ToShortDateString();
                    result.Add(datos);
                }
            }
            catch (Exception Ex)
            {
                Console.WriteLine(Ex.Message);
                Log.Error(Ex.Message);
            }
            return(result);
        }
Example #2
0
        /// <summary>
        /// @Autor:Simon Vera, Jose Perez , Pedro Marval
        /// @Fecha:12/09/2018
        /// @Descripcion: método para retornar los maestros detalles que coincidan con los parámetros de búsquedas que se le pasen
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnBuscar_Click(object sender, RoutedEventArgs e)
        {
            bool?  bandera = null;
            string desde;
            string hasta;

            try
            {
                if (!(BtnBDia.IsVisible))
                {
                    desde = hasta = dpFecha.Text != "" ? dpFecha.Text : "0001-01-01";

                    if (cmbIndActivo.Text == "Activo")
                    {
                        bandera = true;
                    }
                    if (cmbIndActivo.Text == "Inactivo")
                    {
                        bandera = false;
                    }
                    List <cMaestrosDetalleDesktop> result = new List <cMaestrosDetalleDesktop>();
                    var lista = svc.ConsultarMaestroDetalle(-1, id, txtBuscarDescripcion.Text, bandera, desde, hasta);
                    foreach (MasterOfMasterModels.cMaestrosDetalle MD in lista)
                    {
                        cMaestrosDetalleDesktop datos = new cMaestrosDetalleDesktop();
                        datos.idMaestroDetalle   = MD.idMaestroDetalle;
                        datos.descripcion        = MD.descripcion;
                        datos.idMaestroCabecera  = MD.idMaestroCabecera;
                        datos.idUsuarioActualiza = MD.idUsuarioActualiza;
                        datos.idUsuarioCreador   = MD.idUsuarioCreador;
                        datos.indActivo          = MD.indActivo;
                        datos.fechaCreacion      = MD.fechaCreacion.ToShortDateString();
                        datos.fechaOcurrencia    = MD.fechaOcurrencia.ToShortDateString();
                        result.Add(datos);
                    }

                    if (!(result.Count > 0))
                    {
                        MessageBox.Show("No se encontraron resultados", "Información ");
                    }

                    listaMaestrosDetalle.ItemsSource = result;
                }



                else
                {
                    desde = dpFechaInicial.Text;
                    hasta = dpFechaFinal.Text;
                    bool flag = true;

                    if (desde == "" && hasta != "")
                    {
                        flag = false;
                        MessageBox.Show("Debe ingresar la fecha de inicio", "Alerta");
                    }

                    if (desde != "" && hasta == "")
                    {
                        flag = false;
                        MessageBox.Show("Debe ingresar la fecha fin", "Alerta");
                    }

                    if (Convert.ToDateTime(desde) > Convert.ToDateTime(hasta))
                    {
                        flag = false;
                        MessageBox.Show("La fecha de inicio (Desde) debe ser menor a la fecha fin (Hasta)", "Alerta");
                    }

                    if (flag)
                    {
                        if (cmbIndActivo.Text == "Activo")
                        {
                            bandera = true;
                        }
                        if (cmbIndActivo.Text == "Inactivo")
                        {
                            bandera = false;
                        }
                        List <cMaestrosDetalleDesktop> result = new List <cMaestrosDetalleDesktop>();
                        var lista = svc.ConsultarMaestroDetalle(-1, id, txtBuscarDescripcion.Text, bandera, desde, hasta);
                        foreach (MasterOfMasterModels.cMaestrosDetalle MD in lista)
                        {
                            cMaestrosDetalleDesktop datos = new cMaestrosDetalleDesktop();
                            datos.idMaestroDetalle   = MD.idMaestroDetalle;
                            datos.descripcion        = MD.descripcion;
                            datos.idMaestroCabecera  = MD.idMaestroCabecera;
                            datos.idUsuarioActualiza = MD.idUsuarioActualiza;
                            datos.idUsuarioCreador   = MD.idUsuarioCreador;
                            datos.indActivo          = MD.indActivo;
                            datos.fechaCreacion      = MD.fechaCreacion.ToShortDateString();
                            datos.fechaOcurrencia    = MD.fechaOcurrencia.ToShortDateString();
                            result.Add(datos);
                        }


                        if (!(result.Count > 0))
                        {
                            MessageBox.Show("No se encontraron resultados", "Información ");
                        }

                        listaMaestrosDetalle.ItemsSource = result;
                    }
                }
            }
            catch (Exception Ex)
            {
                Console.WriteLine(Ex.Message);
                Log.Error(Ex.Message);
            }
        }