Beispiel #1
0
        public void GetColumSelec(string Nometela, string NomeGrid)
        {
            NometelaSelec = Nometela;
            NomeGridSelec = NomeGrid;
            RowsFiltroCollection RowRelatorio = new RowsFiltroCollection();

            RowRelatorio.Add(new RowsFiltro("Nometela", "System.String", "=", Nometela, "and"));
            RowRelatorio.Add(new RowsFiltro("NomeGrid", "System.String", "=", NomeGrid, "and"));
            RowRelatorio.Add(new RowsFiltro("IDFUNCIONARIO", "System.Int32", "=", Convert.ToInt32(USUARIOP.Read(FrmLogin._IdUsuario).IDFUNCIONARIO).ToString()));

            IMPRGRIDColl = IMPRGRIDP.ReadCollectionByParameter(RowRelatorio, "IDIMPRGRID DESC");

            if (IMPRGRIDColl.Count > 0)
            {
                ctlPrintToFitPageWidthCHK.Checked = IMPRGRIDColl[0].FLAGAJUSTA == "S" ? true: false;
                chkPaisagem.Checked = IMPRGRIDColl[0].FLAGMODOPAISAGEM == "S" ? true : false;
                chkData.Checked     = IMPRGRIDColl[0].FLAGEXIBIRDATA == "S" ? true : false;

                //Armazena os campos do Banco de dados
                string[] CampoSelec = IMPRGRIDColl[0].CAMPOSSELECIONADOS.Split(',');

                ctlColumnsToPrintCHKLBX.Items.Clear();
                foreach (string column in AvailableColumnsOptions)
                {
                    if (VerificaSelec(column.ToString(), CampoSelec))
                    {
                        ctlColumnsToPrintCHKLBX.Items.Add(column, true);
                    }
                    else
                    {
                        ctlColumnsToPrintCHKLBX.Items.Add(column, false);
                    }
                }
            }
        }
Beispiel #2
0
        public void GetColumSelec(string Nometela, string NomeGrid)
        {
            try
            {
                NometelaSelec = Nometela;
                NomeGridSelec = NomeGrid;
                RowsFiltroCollection RowRelatorio = new RowsFiltroCollection();
                RowRelatorio.Add(new RowsFiltro("Nometela", "System.String", "=", Nometela, "and"));
                RowRelatorio.Add(new RowsFiltro("NomeGrid", "System.String", "=", NomeGrid, "and"));
                RowRelatorio.Add(new RowsFiltro("IDFUNCIONARIO", "System.Int32", "=", Convert.ToInt32(USUARIOP.Read(FrmLogin._IdUsuario).IDFUNCIONARIO).ToString()));

                IMPRGRIDColl = IMPRGRIDP.ReadCollectionByParameter(RowRelatorio, "IDIMPRGRID DESC");

                if (IMPRGRIDColl.Count > 0)
                {
                    if (IMPRGRIDColl[0].FLAGEXIBIRDATA == "S")
                    {
                        chkExibirData.Checked = true;
                    }
                    else
                    {
                        chkExibirData.Checked = false;
                    }
                }

                string[] CampoSelec = IMPRGRIDColl[0].CAMPOSSELECIONADOS.Split(',');
                foreach (string s in CampoSelec)
                {
                    for (int i = 0; i < ctlColumnsToPrintCHKLBX.Items.Count; i++)
                    {
                        if (ctlColumnsToPrintCHKLBX.Items[i].ToString() == s)
                        {
                            ctlColumnsToPrintCHKLBX.SetItemCheckState(i, CheckState.Checked);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro técnico: " + ex.Message);
            }
        }
Beispiel #3
0
        private static IMPRGRIDCollection ExecuteReader(ref IMPRGRIDCollection collection, ref FbDataReader dataReader, FbCommand dbCommand)
        {
            using (dataReader = dbCommand.ExecuteReader())
            {
                collection = new IMPRGRIDCollection();

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

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

            return(collection);
        }
Beispiel #4
0
        public IMPRGRIDCollection ReadCollectionByParameter(List <RowsFiltro> RowsFiltro, string FieldOrder)
        {
            FbDataReader       dataReader = null;
            IMPRGRIDCollection collection = null;

            string strSqlCommand = String.Empty;

            try
            {
                if (RowsFiltro != null)
                {
                    if (RowsFiltro.Count > 0)
                    {
                        strSqlCommand = "SELECT * FROM IMPRGRID WHERE (";

                        ArrayList _rowsFiltro = new ArrayList();
                        RowsFiltro.ForEach(delegate(RowsFiltro i)
                        {
                            string[] item = { i.Condicao.ToString(), i.Campo.ToString(), i.Tipo.ToString(), i.Operador.ToString(), i.Valor.ToString() };
                            _rowsFiltro.Add(item);
                        });

                        int _count = 1;
                        foreach (string[] item in _rowsFiltro)
                        {
                            strSqlCommand += "(" + item[1] + " " + item[3];
                            switch (item[2])
                            {
                            case ("System.String"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " '" + item[4] + "')";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Int16"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " " + item[4] + ")";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Int32"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " " + item[4] + ")";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Int64"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " " + item[4] + ")";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Double"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " " + item[4] + ")";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Decimal"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " " + item[4] + ")";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Float"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " " + item[4] + ")";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Byte"):
                                strSqlCommand += " " + item[4] + ")";
                                break;

                            case ("System.SByte"):
                                strSqlCommand += " " + item[4] + ")";
                                break;

                            case ("System.Char"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " '" + item[4] + "')";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.DateTime"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " '" + item[4] + "')";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Guid"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " '" + item[4] + "')";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Boolean"):
                                strSqlCommand += " " + item[4] + ")";
                                break;
                            }
                            if (_rowsFiltro.Count > 1)
                            {
                                if (_count < _rowsFiltro.Count)
                                {
                                    strSqlCommand += " " + item[0] + " ";
                                }
                                _count++;
                            }
                        }
                        strSqlCommand += ")  order by  " + FieldOrder;
                    }
                    else
                    {
                        strSqlCommand = "SELECT * FROM IMPRGRID  order by  " + FieldOrder;
                    }
                }
                else
                {
                    strSqlCommand = "SELECT * FROM IMPRGRID  order by " + FieldOrder;
                }

                //Verificando a existência de um transação
                if (dbTransaction != null)
                {
                    if (dbCnn.State == ConnectionState.Closed)
                    {
                        dbCnn.Open();
                    }

                    dbCommand             = new FbCommand(strSqlCommand, dbCnn);
                    dbCommand.CommandType = CommandType.Text;
                    dbCommand.Transaction = ((FbTransaction)(dbTransaction));
                }
                else
                {
                    if (dbCnn == null)
                    {
                        dbCnn = new FbConnection(connectionString);
                    }

                    if (dbCnn.State == ConnectionState.Closed)
                    {
                        dbCnn.Open();
                    }

                    dbCommand             = new FbCommand(strSqlCommand, dbCnn);
                    dbCommand.CommandType = CommandType.Text;
                    dbCommand.Transaction = dbCnn.BeginTransaction(IsolationLevel.ReadCommitted);
                }


                collection = ExecuteReader(ref collection, ref dataReader, dbCommand);

                if (dataReader != null)
                {
                    dataReader.Close();
                    dataReader.Dispose();
                }

                if (dbTransaction == null)
                {
                    dbCommand.Transaction.Commit();
                    dbCnn.Close();
                }

                return(collection);
            }
            catch (Exception ex)
            {
                // Deleta reader
                if (dataReader != null)
                {
                    dataReader.Close();
                    dataReader.Dispose();
                }

                if (dbTransaction != null)
                {
                    this.RollbackTransaction();
                }
                else
                {
                    if (dbCommand.Transaction != null)
                    {
                        dbCommand.Transaction.Rollback();
                    }
                    if (dbCnn.State == ConnectionState.Open)
                    {
                        dbCnn.Close();
                    }
                }

                throw ex;
            }
        }