Beispiel #1
0
        /// <summary>
        /// Metodo com nome errado (repetido se renomear)
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="context"></param>
        /// <param name="columnsView"></param>
        /// <param name="tipo"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public static dynamic ShowDiaglogFindEntity <T>(DbContextIts context,
                                                        string[] columnsView, T tipo, string title = "Localizar:") where T : class
        {
            XFrmFindEntity xFrmFindEntity = initListaDinamica <T>(context, columnsView, title, tipo);

            xFrmFindEntity.ShowDialog();

            return(xFrmFindEntity.TEntity);
        }
Beispiel #2
0
        public static dynamic ShowDiaglogFindEntity <T>(DbContextIts context,
                                                        string[] columnsView, T tipo, string xmlFile, string title = "Localizar:") where T : class
        {
            XFrmFindEntity xFrmFindEntity = initListaDinamica <T>(context, columnsView, title, tipo);

            if (xmlFile != null)
            {
                xFrmFindEntity.gridViewResults.RestoreLayoutFromXml(xmlFile, OptionsLayoutBase.FullLayout);
            }

            xFrmFindEntity.ShowDialog();

            return(xFrmFindEntity.TEntity);
        }
Beispiel #3
0
        public static List <dynamic> ShowDialogFindListEntity <T>(DbContextIts context, string[] columnsView, T tipo,
                                                                  Stream layoutStream, string title = "Localizar:") where T : class
        {
            XFrmFindEntity xFrmFindEntity = initListaDinamica <T>(context, columnsView, title, tipo);

            xFrmFindEntity.gridViewResults.OptionsSelection.MultiSelect = true;

            if (layoutStream != null)
            {
                xFrmFindEntity.gridViewResults.RestoreLayoutFromStream(layoutStream, OptionsLayoutBase.FullLayout);
            }

            xFrmFindEntity.ShowDialog();

            return(xFrmFindEntity.gridViewResults.GetSelectedItens <dynamic>());
        }
Beispiel #4
0
        /// <summary>
        /// Passar uma array de string com as colunas que deseja exibir
        /// </summary>
        /// <typeparam name="T">Entidade</typeparam>
        /// <param name="context">Contexto</param>
        /// <param name="columnsView">Array de colunas</param>
        /// <param name="title">Titulo da janela</param>
        /// <returns></returns>
        public static dynamic ShowDiaglogFindEntity <T>(DbContextIts context,
                                                        string[] columnsView, T tipo, Stream layoutStream, string title = "Localizar:", Delegate action = null) where T : class
        {
            XFrmFindEntity xFrmFindEntity = initListaDinamica <T>(context, columnsView, title, tipo);

            if (layoutStream != null)
            {
                xFrmFindEntity.gridViewResults.RestoreLayoutFromStream(layoutStream, OptionsLayoutBase.FullLayout);
            }

            xFrmFindEntity.ShowDialog();

            xFrmFindEntity.setDelegateActionPerfomed(action);

            return(xFrmFindEntity.TEntity);
        }
Beispiel #5
0
        public static List <dynamic> ShowDialogFindListEntity <T>(List <T> lista, string xmlFile, string title = "Localizar:") where T : class
        {
            XFrmFindEntity xFrmFindEntity = new XFrmFindEntity();

            xFrmFindEntity.Text = title;
            xFrmFindEntity.gridControlResults.DataSource = lista;
            xFrmFindEntity.gridViewResults.OptionsSelection.MultiSelect = true;

            if (xmlFile != null)
            {
                xFrmFindEntity.gridViewResults.RestoreLayoutFromXml(xmlFile, OptionsLayoutBase.FullLayout);
            }

            xFrmFindEntity.ShowDialog();

            return(xFrmFindEntity.gridViewResults.GetSelectedItens <dynamic>());
        }
Beispiel #6
0
        public static T ShowDialogFindTEntity <T>(DbContextIts ctx, Stream layoutStream) where T : class
        {
            XFrmFindEntity xFrmFindEntity = new XFrmFindEntity();
            var            x = new GenericContextIts <T>(ctx.NameOrConnectionString);

            xFrmFindEntity.gridControlResults.DataSource = x.Dao.FindAll();
            xFrmFindEntity.TEntity = xFrmFindEntity.gridViewResults.GetFocusedRow() as T;

            if (layoutStream != null)
            {
                xFrmFindEntity.gridViewResults.RestoreLayoutFromStream(layoutStream, OptionsLayoutBase.FullLayout);
            }

            xFrmFindEntity.ShowDialog();

            return(xFrmFindEntity.gridViewResults.GetFocusedRow <T>());
        }
Beispiel #7
0
        //REVISADO EM 31/07/2017 - Gercy Campos, task 140
        /// <summary>
        /// Chama a tela de pesquisa de objetos. Montar os parametros através da classe ParamsFindEntity
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static dynamic ShowDialogFindEntity <T>(ParamsFindEntity parameters) where T : class
        {
            XFrmFindEntity xFrmFindEntity = initListaDinamica <T>(
                context: parameters.Context,
                columnsView: parameters.Columns,
                orderBy: parameters.Order,
                whereConditions: parameters.WhereCondition,
                title: parameters.Title,
                tipo: parameters.DynamicObject);

            if (parameters.Layout != null)
            {
                xFrmFindEntity.gridViewResults.RestoreLayoutFromStream(parameters.Layout, OptionsLayoutBase.FullLayout);
            }


            xFrmFindEntity.ShowDialog();

            return(xFrmFindEntity.TEntity);
        }
Beispiel #8
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="lista"></param>A lista a ser exibida no grid
        /// <param name="layoutStream"></param>Layout
        /// <param name="title"></param>Titulo
        /// <param name="action"></param>Ação a ser disparada pelo botão extra
        /// <returns></returns>A entidade selecionada no grid
        public static T ShowDiaglogFindEntityFromList <T>(List <T> lista, Stream layoutStream, string title = "Localizar:",
                                                          Delegate action = null) where T : class
        {
            XFrmFindEntity xFrmFindEntity = new XFrmFindEntity();

            xFrmFindEntity.gridControlResults.DataSource = lista;
            if (layoutStream != null)
            {
                xFrmFindEntity.gridViewResults.RestoreLayoutFromStream(layoutStream, OptionsLayoutBase.FullLayout);
            }

            xFrmFindEntity.ShowDialog();

            xFrmFindEntity.setDelegateActionPerfomed(action);

            if (xFrmFindEntity.IsCancel)
            {
                return(null);
            }

            return(xFrmFindEntity.gridViewResults.GetFocusedRow <T>());
        }
Beispiel #9
0
        /// <summary>
        /// Faz a chamada da lista dinamica, este metodo requer uma string com as condicoes (WHERE)
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="context"></param>
        /// <param name="columnsView"></param>
        /// <param name="orderBy"></param>
        /// <param name="whereConditions"></param>
        /// <param name="title"></param>
        /// <param name="tipo"></param>
        /// <returns></returns>
        private static XFrmFindEntity initListaDinamica <T>(DbContextIts context,
                                                            string[] columnsView, string orderBy, string whereConditions, string title, T tipo) where T : class
        {
            XFrmFindEntity xFrmFindEntity = new XFrmFindEntity();
            IQueryable     query;

            //Colunas que serão exibidas no grid
            var filter = "new ({0})";
            var cols   = "";

            foreach (var c in columnsView)
            {
                if (columnsView.Count() > 1)
                {
                    if (c != columnsView.Last())
                    {
                        cols += "TEntity." + c + ",";
                    }
                    else
                    {
                        cols += "TEntity." + c;
                    }
                }
                else
                {
                    cols += "TEntity." + c;
                }
            }

            filter = String.Format(filter, cols);


            //se recebeu as condicoes, aplique-as
            if (!whereConditions.IsNullOrEmpty())
            {
                query = (from TEntity in context.Set <T>().Where(whereConditions)
                         select new { TEntity }).AsQueryable();
            }
            else
            {
                query = (from TEntity in context.Set <T>()
                         select new { TEntity }).AsQueryable();
            }

            //Selecionando somente as colunas que quero exibir
            IQueryable iq = query.Select(filter);

            //ordenacao da lista - task 122 - gercy 10/10/2017
            if (!orderBy.IsNullOrEmpty())
            {
                iq = iq.OrderBy(orderBy);
            }

            //Lista tipada dinamica
            List <dynamic> list = new List <dynamic>();

            //Fill List
            foreach (var item in iq)
            {
                list.Add(item);
                //guarda a referencia da lista carregada
                xFrmFindEntity.TList.Add(item);
            }

            //Cria uma linha tipada pro grid
            //guarda a referencia da lista carrega em uma lista tipada
            if (tipo != null)
            {
                var lista = new List <T>();

                //adiciona o tipo informado
                lista.Add(tipo);

                //novo query
                query = (from TEntity in lista select new { TEntity }).AsQueryable();

                //atualizando dados
                iq = query.Select(filter);

                //atualizando a lista
                list.Clear();

                //reindexando
                foreach (var item in iq)
                {
                    list.Add(item);
                }
            }
            //seta o elemento
            xFrmFindEntity.Text = title;
            xFrmFindEntity.gridControlResults.DataSource = list;
            xFrmFindEntity.gridViewResults.BestFitColumns();
            xFrmFindEntity.TEntity = xFrmFindEntity.gridViewResults.GetFocusedRow();

            return(xFrmFindEntity);
        }
Beispiel #10
0
 public static List <dynamic> ShowDialogFindListEntity <T>(DbContextIts context, string[] columnsView,
                                                           Stream layoutStream, string title = "Localizar:") where T : class
 {
     //sobre carga do metodo acima
     return(XFrmFindEntity.ShowDialogFindListEntity <T>(context, columnsView, null, layoutStream, title));
 }