示例#1
0
        private void AddColPersonalizada()
        {
            DataGridPerson.DataSource          = null;
            DataGridPerson.AutoGenerateColumns = false;
            int i = 0;

            foreach (LIS_CAMPOSRELATPERSEntity item in LIS_CAMPOSRELATPERSColl)
            {
                DataGridPerson.Columns.Add(item.NOMEBANCODADOS, item.NOMECAMPOS);

                if (item.SOMATORIO == "1")
                {
                    listColunaSumn.Add(i);
                }

                if (item.ORDEM == 1)
                {
                    CampoOrdenar = item.NOMEBANCODADOS;
                }

                DataGridPerson.Columns[i].DataPropertyName = item.NOMEBANCODADOS;
                DataGridPerson.Columns[i].Width            = Convert.ToInt32(item.TAMANHO);

                //Formatando as celulas
                string TypeField = ReturnTypeField(Convert.ToInt32(item.IDCAMPO));
                switch (TypeField)
                {
                case "NUMERIC":
                    DataGridPerson.Columns[i].DefaultCellStyle.Format    = "N2";
                    DataGridPerson.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                    break;

                case "INTEGER":
                    DataGridPerson.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                    break;
                }
                i++;
            }

            //Ordenar o campos selecionado
            if (CampoOrdenar != string.Empty)
            {
                string orderBy = CampoOrdenar;
                Phydeaux.Utilities.DynamicComparer <LIS_ORCAMENTOEntity> comparer = new Phydeaux.Utilities.DynamicComparer <LIS_ORCAMENTOEntity>(orderBy);
                LIS_ORCAMENTOCollRelatPers.Sort(comparer.Comparer);
            }

            ////adiciona uma linha no rodape do grid
            LIS_ORCAMENTOEntity AddLinha = new LIS_ORCAMENTOEntity();

            AddLinha.IDORCAMENTO = null;
            LIS_ORCAMENTOCollRelatPers.Add(AddLinha);

            DataGridPerson.DataSource = LIS_ORCAMENTOCollRelatPers;
            PercorreDataGrid();
        }
示例#2
0
        private static LIS_ORCAMENTOCollection ExecuteReader(ref LIS_ORCAMENTOCollection collection, ref FbDataReader dataReader, FbCommand dbCommand)
        {
            using (dataReader = dbCommand.ExecuteReader())
            {
                collection = new LIS_ORCAMENTOCollection();

                if (dataReader.HasRows)
                {
                    while (dataReader.Read())
                    {
                        collection.Add(FillEntityObject(ref dataReader));
                    }
                }

                if (!(dataReader.IsClosed))
                {
                    dataReader.Close();
                }
                dataReader.Dispose();
            }

            return(collection);
        }