コード例 #1
0
        private void btnPesquisa_Click(object sender, EventArgs e)
        {
            if (Validacoes())
            {
                try
                {
                    RowRelatorio.Clear();
                    string DataInicial = Util.ConverStringDateSearch(msktDataInicial.Text);
                    string DataFinal   = Util.ConverStringDateSearch(msktDataFinal.Text);

                    if (Convert.ToInt32(cbFuncionario.SelectedValue) > 0)
                    {
                        RowRelatorio.Add(new RowsFiltro("IDVENDEDOR", "System.Int32", "=", Convert.ToInt32(cbFuncionario.SelectedValue).ToString()));
                    }

                    if (Convert.ToInt32(cbTransportador.SelectedValue) > 0)
                    {
                        RowRelatorio.Add(new RowsFiltro("IDTRANSPORTES", "System.Int32", "=", Convert.ToInt32(cbTransportador.SelectedValue).ToString()));
                    }


                    RowRelatorio.Add(new RowsFiltro("DTEMISSAO", "System.DateTime", ">=", DataInicial));
                    RowRelatorio.Add(new RowsFiltro("DTEMISSAO", "System.DateTime", "<=", DataFinal));

                    if (txtCidade1.Text.Trim() != string.Empty)
                    {
                        RowRelatorio.Add(new RowsFiltro("COD_MUN_IBGE", "System.Int32", "=", _COD_MUN_IBGE.ToString()));
                    }

                    if (Convert.ToInt32(cbStatus.SelectedValue) > 0)
                    {
                        RowRelatorio.Add(new RowsFiltro("IDSTATUS", "System.Int32", "=", Convert.ToInt32(cbStatus.SelectedValue).ToString()));
                    }

                    if (chkNFeEnviada.Checked)
                    {
                        RowRelatorio.Add(new RowsFiltro("FLAGENVIADA", "System.String", "=", "S"));
                        RowRelatorio.Add(new RowsFiltro("FLAGCANCELADA", "System.String", "=", "N"));
                    }

                    if (Convert.ToInt32(cbFuncionario.SelectedValue) > 0)
                    {
                        LIS_NOTAFISCALEColl = LIS_NOTAFISCALEP.ReadCollectionByParameter(RowRelatorio, "IDTRANSPORTES, IDPEDIDO");
                    }
                    else
                    {
                        LIS_NOTAFISCALEColl = LIS_NOTAFISCALEP.ReadCollectionByParameter(RowRelatorio);
                    }



                    PreencheGrid2();
                }
                catch (Exception EX)
                {
                    MessageBox.Show("Erro na pesquisa!");
                    MessageBox.Show("Erro técnico: " + EX.Message);
                }
            }
        }
コード例 #2
0
        private void ListaProdutosNF(string NOTAFISCAL)
        {
            try
            {
                LIS_NOTAFISCALEProvider LIS_NOTAFISCALEP = new LIS_NOTAFISCALEProvider();

                RowsFiltroCollection RowNF = new RowsFiltroCollection();
                RowNF.Add(new RowsFiltro("NFISCALE", "System.String", "=", Util.RetiraLetras(NOTAFISCAL).ToString()));
                LIS_NOTAFISCALEColl = LIS_NOTAFISCALEP.ReadCollectionByParameter(RowNF);

                int IDNOTAFISCAL = -1;
                if (LIS_NOTAFISCALEColl.Count > 0)
                {
                    IDNOTAFISCAL = Convert.ToInt32(LIS_NOTAFISCALEColl[0].IDNOTAFISCALE);
                }


                LIS_PRODUTONFEProvider LIS_PRODUTONFEP = new LIS_PRODUTONFEProvider();

                RowsFiltroCollection RowRelatorio = new RowsFiltroCollection();
                RowRelatorio.Add(new RowsFiltro("IDNOTAFISCALE", "System.String", "=", IDNOTAFISCAL.ToString()));

                LIS_PRODUTONFEColl = LIS_PRODUTONFEP.ReadCollectionByParameter(RowRelatorio);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro técnico: " + ex.Message);
            }
        }
コード例 #3
0
        private LIS_NOTAFISCALECollection BuscaNFePelaCidade(int COD_MUN_IBGE)
        {
            LIS_NOTAFISCALECollection LIS_NOTAFISCALEColl4 = new LIS_NOTAFISCALECollection();

            RowRelatorio.Clear();
            string DataInicial = Util.ConverStringDateSearch(msktDataInicial.Text);
            string DataFinal   = Util.ConverStringDateSearch(msktDataFinal.Text);

            RowRelatorio.Add(new RowsFiltro("COD_MUN_IBGE", "System.Int32", "=", COD_MUN_IBGE.ToString()));

            if (Convert.ToInt32(cbFuncionario.SelectedValue) > 0)
            {
                RowRelatorio.Add(new RowsFiltro("IDVENDEDOR", "System.Int32", "=", Convert.ToInt32(cbFuncionario.SelectedValue).ToString()));
            }

            if (Convert.ToInt32(cbTransportador.SelectedValue) > 0)
            {
                RowRelatorio.Add(new RowsFiltro("IDTRANSPORTES", "System.Int32", "=", Convert.ToInt32(cbTransportador.SelectedValue).ToString()));
            }


            RowRelatorio.Add(new RowsFiltro("DTEMISSAO", "System.DateTime", ">=", DataInicial));
            RowRelatorio.Add(new RowsFiltro("DTEMISSAO", "System.DateTime", "<=", DataFinal));

            if (Convert.ToInt32(cbStatus.SelectedValue) > 0)
            {
                RowRelatorio.Add(new RowsFiltro("IDSTATUS", "System.Int32", "=", Convert.ToInt32(cbStatus.SelectedValue).ToString()));
            }

            if (txtCidade1.Text.Trim() != string.Empty)
            {
                RowRelatorio.Add(new RowsFiltro("COD_MUN_IBGE", "System.Int32", "=", _COD_MUN_IBGE.ToString()));
            }

            if (chkNFeEnviada.Checked)
            {
                RowRelatorio.Add(new RowsFiltro("FLAGENVIADA", "System.String", "=", "S"));
                RowRelatorio.Add(new RowsFiltro("FLAGCANCELADA", "System.String", "=", "N"));
            }

            if (Convert.ToInt32(cbFuncionario.SelectedValue) > 0)
            {
                LIS_NOTAFISCALEColl4 = LIS_NOTAFISCALEP.ReadCollectionByParameter(RowRelatorio, "IDTRANSPORTES, IDPEDIDO");
            }
            else
            {
                LIS_NOTAFISCALEColl4 = LIS_NOTAFISCALEP.ReadCollectionByParameter(RowRelatorio);
            }

            return(LIS_NOTAFISCALEColl4);
        }
コード例 #4
0
        private void AtualizaDadosNFE()
        {
            try
            {
                CreaterCursor Cr = new CreaterCursor();
                this.Cursor = Cr.CreateCursor(Cr.btmap, 0, 0);

                NOTAFISCALEProvider       NOTAFISCALEP         = new NOTAFISCALEProvider();
                LIS_NOTAFISCALEProvider   LIS_NOTAFISCALEP     = new LIS_NOTAFISCALEProvider();
                LIS_NOTAFISCALECollection LIS_NOTAFISCALEColl2 = new LIS_NOTAFISCALECollection();
                RowsFiltroCollection      RowRelatorio         = new RowsFiltroCollection();
                RowRelatorio.Add(new RowsFiltro("NFISCALE", "System.String", ">=", txtIni.Text.PadLeft(8, '0')));
                RowRelatorio.Add(new RowsFiltro("NFISCALE", "System.String", "<=", txtFim.Text.PadLeft(8, '0')));
                RowRelatorio.Add(new RowsFiltro("FLAGENVIADA", "System.String", "=", "N"));

                LIS_NOTAFISCALEColl2 = LIS_NOTAFISCALEP.ReadCollectionByParameter(RowRelatorio);

                if (LIS_NOTAFISCALEColl2.Count > 0)
                {
                    foreach (LIS_NOTAFISCALEEntity item in LIS_NOTAFISCALEColl2)
                    {
                        NOTAFISCALEEntity NOTAFISCALETy = new NOTAFISCALEEntity();
                        NOTAFISCALETy = NOTAFISCALEP.Read(Convert.ToInt32(item.IDNOTAFISCALE));
                        NOTAFISCALETy.FLAGINUTILIZADO = "S";
                        NOTAFISCALEP.Save(NOTAFISCALETy);
                    }

                    this.Cursor = Cursors.Default;
                }
                else
                {
                    this.Cursor = Cursors.Default;
                    MessageBox.Show("Não foi possível alterar as notas selecionadas!!");
                }

                this.Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show("Erro técnico: " + ex.Message);
            }
        }
コード例 #5
0
        private static LIS_NOTAFISCALECollection ExecuteReader(ref LIS_NOTAFISCALECollection collection, ref FbDataReader dataReader, FbCommand dbCommand)
        {
            using (dataReader = dbCommand.ExecuteReader())
            {
                collection = new LIS_NOTAFISCALECollection();

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

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

            return(collection);
        }
コード例 #6
0
        public LIS_NOTAFISCALECollection ReadCollectionByParameter(List <RowsFiltro> RowsFiltro, string FieldOrder)
        {
            FbDataReader dataReader              = null;
            string       strSqlCommand           = String.Empty;
            LIS_NOTAFISCALECollection collection = null;

            try
            {
                if (RowsFiltro != null)
                {
                    if (RowsFiltro.Count > 0)
                    {
                        strSqlCommand = "SELECT * FROM LIS_NOTAFISCALE 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 LIS_NOTAFISCALE  order by  " + FieldOrder;
                    }
                }
                else
                {
                    strSqlCommand = "SELECT * FROM LIS_NOTAFISCALE order by  " + FieldOrder;
                }

                //Verificando a existência de um transação aberta
                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;
            }
        }
コード例 #7
0
        public LIS_NOTAFISCALECollection ReadCollection()
        {
            FbDataReader dataReader = null;

            try
            {
                LIS_NOTAFISCALECollection collection = null;

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

                    dbCommand             = new FbCommand("SELECT * FROM LIS_NOTAFISCALE", dbCnn);
                    dbCommand.Transaction = ((FbTransaction)(dbTransaction));
                }
                else
                {
                    if (dbCnn == null)
                    {
                        dbCnn = ((FbConnection)GetConnectionDB());
                    }

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

                    dbCommand             = new FbCommand("SELECT * FROM LIS_NOTAFISCALE", dbCnn);
                    dbCommand.Transaction = dbCnn.BeginTransaction(IsolationLevel.ReadCommitted);
                }

                // Tipo do comando de banco Procedure ou SQL
                dbCommand.CommandType = CommandType.Text;

                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;
            }
        }
コード例 #8
0
        private void PreencheGrid2()
        {
            TotalGeral      = 0;
            TotalQuantidade = 0;
            SubTotal        = 0;

            CreaterCursor Cr = new CreaterCursor();

            this.Cursor = Cr.CreateCursor(Cr.btmap, 0, 0);

            DataGriewDados.Rows.Clear();

            //Remove as Cidades Repetidas
            LIS_NOTAFISCALECollection LIS_NOTAFISCALEColl_2 = new LIS_NOTAFISCALECollection();

            foreach (LIS_NOTAFISCALEEntity item in LIS_NOTAFISCALEColl)
            {
                if (LIS_NOTAFISCALEColl_2.Find(delegate(LIS_NOTAFISCALEEntity item2) { return(item2.COD_MUN_IBGE == item.COD_MUN_IBGE); }) == null)
                {
                    LIS_NOTAFISCALEColl_2.Add(item);
                }
            }

            //Cabeçalho Nome Cidade
            DataGridViewRow row1_2 = new DataGridViewRow();

            row1_2.CreateCells(DataGriewDados, "CIDADE/UF", "", "", "", "");
            row1_2.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
            DataGriewDados.Rows.Add(row1_2);

            foreach (var LIS_NOTAFISCALETy in LIS_NOTAFISCALEColl_2)
            {
                //Busca Dados do produto por cidade
                LIS_PRODUTONFECollection LIS_PRODUTONFEColl3 = new LIS_PRODUTONFECollection();
                LIS_PRODUTONFEColl3 = BuscaProdutoNFePelaCidade(Convert.ToInt32(LIS_NOTAFISCALETy.COD_MUN_IBGE));

                if (LIS_PRODUTONFEColl3.Count > 0)
                {
                    TotalQuantidade = 0;
                    SubTotal        = 0;

                    LIS_MUNICIPIOSCollection LIS_MUNICIPIOSColl = new LIS_MUNICIPIOSCollection();
                    LIS_MUNICIPIOSProvider   LIS_MUNICIPIOSP    = new LIS_MUNICIPIOSProvider();
                    RowRelatorio.Clear();
                    RowRelatorio.Add(new RowsFiltro("COD_MUN_IBGE", "System.Int32", "=", LIS_NOTAFISCALETy.COD_MUN_IBGE.ToString()));
                    LIS_MUNICIPIOSColl = LIS_MUNICIPIOSP.ReadCollectionByParameter(RowRelatorio);

                    DataGridViewRow row1_3 = new DataGridViewRow();
                    row1_3.CreateCells(DataGriewDados, LIS_MUNICIPIOSColl[0].MUNIUF, "", "", "", "");
                    row1_3.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                    DataGriewDados.Rows.Add(row1_3);

                    DataGridViewRow row1_4 = new DataGridViewRow();
                    row1_4.CreateCells(DataGriewDados, "PRODUTO", "QUANT.", "DATA", "NOTA FISCAL", "TOTAL");
                    row1_4.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                    DataGriewDados.Rows.Add(row1_4);
                }

                foreach (var LIS_PRODUTONFETy_3 in LIS_PRODUTONFEColl3)
                {
                    CLIENTEEntity   CLIENTEtY = new CLIENTEEntity();
                    CLIENTEProvider CLIENTEP  = new CLIENTEProvider();
                    CLIENTEtY = CLIENTEP.Read(Convert.ToInt32(LIS_PRODUTONFETy_3.IDCLIENTE));

                    string DataEmissao = Convert.ToDateTime(LIS_PRODUTONFETy_3.DTEMISSAO).ToString("dd/MM/yyyy");
                    if (chkAgruparProduto.Checked)
                    {
                        DataEmissao = string.Empty;
                    }

                    string NomeProduto = LIS_PRODUTONFETy_3.NOMEPRODUTO;

                    string QuantProduto = LIS_PRODUTONFETy_3.QUANTIDADE.ToString();
                    if (chkAgruparProduto.Checked)
                    {
                        QuantProduto     = TotalQuantProdutoAgrupado(Convert.ToInt32(LIS_PRODUTONFETy_3.IDPRODUTO), Convert.ToInt32(LIS_PRODUTONFETy_3.COD_MUN_IBGE)).ToString();
                        TotalQuantidade += Convert.ToDecimal(QuantProduto);
                    }
                    else
                    {
                        TotalQuantidade += Convert.ToDecimal(LIS_PRODUTONFETy_3.QUANTIDADE);
                    }

                    string NumNF = LIS_PRODUTONFETy_3.NOTAFISCALE.ToString().PadLeft(6, '0');
                    if (chkAgruparProduto.Checked)
                    {
                        NumNF = string.Empty;
                    }

                    string TotalProduto = Convert.ToDecimal(LIS_PRODUTONFETy_3.VALORTOTAL).ToString("n2");
                    if (chkAgruparProduto.Checked)
                    {
                        TotalProduto = TotalValorProdutoAgrupado(Convert.ToInt32(LIS_PRODUTONFETy_3.IDPRODUTO), Convert.ToInt32(LIS_PRODUTONFETy_3.COD_MUN_IBGE)).ToString("n2");
                        SubTotal    += Convert.ToDecimal(TotalProduto);
                        TotalGeral  += Convert.ToDecimal(TotalProduto);
                    }
                    else
                    {
                        SubTotal   += Convert.ToDecimal(LIS_PRODUTONFETy_3.VALORTOTAL);
                        TotalGeral += Convert.ToDecimal(LIS_PRODUTONFETy_3.VALORTOTAL);
                    }


                    string TELEFONE1 = CLIENTEtY.TELEFONE1;

                    DataGridViewRow row2 = new DataGridViewRow();
                    row2.CreateCells(DataGriewDados, NomeProduto, QuantProduto, DataEmissao, NumNF, TotalProduto);
                    row2.DefaultCellStyle.Font = new Font("Arial", 8);
                    DataGriewDados.Rows.Add(row2);
                }

                if (LIS_PRODUTONFEColl3.Count > 0)
                {
                    DataGridViewRow row1_5 = new DataGridViewRow();
                    row1_5.CreateCells(DataGriewDados, "-------------------------------------------------------", TotalQuantidade.ToString(), "---------", "Sub-Total", SubTotal.ToString("n2"));
                    row1_5.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                    DataGriewDados.Rows.Add(row1_5);
                }
            }

            DataGridViewRow rowLinha = new DataGridViewRow();

            rowLinha.CreateCells(DataGriewDados, "-------------------------------------------------------", "---------", "---------", "Total geral:", TotalGeral.ToString("n2"));
            rowLinha.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
            DataGriewDados.Rows.Add(rowLinha);

            this.Cursor = Cursors.Default;
        }
コード例 #9
0
        private void PreencheGrid2()
        {
            TotalGeral = 0;

            CreaterCursor Cr = new CreaterCursor();

            this.Cursor = Cr.CreateCursor(Cr.btmap, 0, 0);

            DataGriewDados.Rows.Clear();

            //Remove as Cidades Repetidas
            LIS_NOTAFISCALECollection LIS_NOTAFISCALEColl_2 = new LIS_NOTAFISCALECollection();

            foreach (LIS_NOTAFISCALEEntity item in LIS_NOTAFISCALEColl)
            {
                if (LIS_NOTAFISCALEColl_2.Find(delegate(LIS_NOTAFISCALEEntity item2) { return(item2.COD_MUN_IBGE == item.COD_MUN_IBGE); }) == null)
                {
                    LIS_NOTAFISCALEColl_2.Add(item);
                }
            }

            //Cabeçalho Nome Cidade
            DataGridViewRow row1_2 = new DataGridViewRow();

            row1_2.CreateCells(DataGriewDados, "CIDADE/UF", "", "", "", "");
            row1_2.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
            DataGriewDados.Rows.Add(row1_2);

            foreach (var LIS_NOTAFISCALETy in LIS_NOTAFISCALEColl_2)
            {
                LIS_NOTAFISCALECollection LIS_NOTAFISCALEColl3 = new LIS_NOTAFISCALECollection();
                LIS_NOTAFISCALEColl3 = BuscaNFePelaCidade(Convert.ToInt32(LIS_NOTAFISCALETy.COD_MUN_IBGE));

                LIS_MUNICIPIOSCollection LIS_MUNICIPIOSColl = new LIS_MUNICIPIOSCollection();
                LIS_MUNICIPIOSProvider   LIS_MUNICIPIOSP    = new LIS_MUNICIPIOSProvider();
                RowRelatorio.Clear();
                RowRelatorio.Add(new RowsFiltro("COD_MUN_IBGE", "System.Int32", "=", LIS_NOTAFISCALETy.COD_MUN_IBGE.ToString()));
                LIS_MUNICIPIOSColl = LIS_MUNICIPIOSP.ReadCollectionByParameter(RowRelatorio);

                DataGridViewRow row1_3 = new DataGridViewRow();
                row1_3.CreateCells(DataGriewDados, LIS_MUNICIPIOSColl[0].MUNIUF, "", "", "", "");
                row1_3.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                DataGriewDados.Rows.Add(row1_3);

                DataGridViewRow row1_4 = new DataGridViewRow();
                row1_4.CreateCells(DataGriewDados, "CLIENTE", "TELEFONE", "DATA", "Nº PEDIDO", "TOTAL");
                row1_4.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                DataGriewDados.Rows.Add(row1_4);



                foreach (var LIS_NOTAFISCALETy_3 in LIS_NOTAFISCALEColl3)
                {
                    CLIENTEEntity   CLIENTEtY = new CLIENTEEntity();
                    CLIENTEProvider CLIENTEP  = new CLIENTEProvider();
                    CLIENTEtY = CLIENTEP.Read(Convert.ToInt32(LIS_NOTAFISCALETy_3.IDCLIENTE));

                    string DataEmissao = Convert.ToDateTime(LIS_NOTAFISCALETy_3.DTEMISSAO).ToString("dd/MM/yyyy");
                    string NomeCliente = LIS_NOTAFISCALETy_3.NOMECLIENTE;
                    string NumPedido   = LIS_NOTAFISCALETy_3.NFISCALE.ToString().PadLeft(6, '0');;
                    string TotalPedido = Convert.ToDecimal(LIS_NOTAFISCALETy_3.TOTALNOTA).ToString("n2");
                    string TELEFONE1   = CLIENTEtY.TELEFONE1;

                    DataGridViewRow row2 = new DataGridViewRow();
                    row2.CreateCells(DataGriewDados, NomeCliente, TELEFONE1, DataEmissao, NumPedido, TotalPedido);
                    row2.DefaultCellStyle.Font = new Font("Arial", 8);
                    DataGriewDados.Rows.Add(row2);

                    TotalGeral += Convert.ToDecimal(LIS_NOTAFISCALETy_3.TOTALNOTA);
                }

                DataGridViewRow row1_5 = new DataGridViewRow();
                row1_5.CreateCells(DataGriewDados, "-------------------------------------------------------", "---------", "---------", "---------", "---------");
                row1_5.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                DataGriewDados.Rows.Add(row1_5);
            }

            DataGridViewRow rowLinha = new DataGridViewRow();

            rowLinha.CreateCells(DataGriewDados, "-------------------------------------------------------", "---------", "---------", "Total geral:", TotalGeral);
            rowLinha.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
            DataGriewDados.Rows.Add(rowLinha);

            this.Cursor = Cursors.Default;
        }