Пример #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);

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

                    RowRelatorio.Add(new RowsFiltro("FLAGENVIADA", "System.String", "=", "S"));
                    RowRelatorio.Add(new RowsFiltro("FLAGCANCELADA", "System.String", "=", "N"));

                    if (Convert.ToInt32(cbCFOP.SelectedValue) > 0)
                    {
                        RowRelatorio.Add(new RowsFiltro("IDCFOP", "System.String", "=", cbCFOP.SelectedValue.ToString()));
                    }

                    LIS_PRODUTONFEColl_1 = LIS_PRODUTONFEP.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_PRODUTONFECollection BuscaProdutoCFOP(int IDCFOP)
        {
            LIS_PRODUTONFECollection LIS_PRODUTONFEColl = new LIS_PRODUTONFECollection();

            try
            {
                LIS_PRODUTONFEProvider LIS_PRODUTONFEP = new LIS_PRODUTONFEProvider();
                RowRelatorio.Clear();
                string DataInicial = Util.ConverStringDateSearch(msktDataInicial.Text);
                string DataFinal   = Util.ConverStringDateSearch(msktDataFinal.Text);

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

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

                RowRelatorio.Add(new RowsFiltro("FLAGENVIADA", "System.String", "=", "S"));
                RowRelatorio.Add(new RowsFiltro("FLAGCANCELADA", "System.String", "=", "N"));


                LIS_PRODUTONFECollection LIS_PRODUTONFEColl_2 = new LIS_PRODUTONFECollection();
                LIS_PRODUTONFEColl_2 = LIS_PRODUTONFEP.ReadCollectionByParameter(RowRelatorio);
                return(LIS_PRODUTONFEColl_2);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro técnico: " + ex.Message);
                return(LIS_PRODUTONFEColl);
            }
        }
Пример #4
0
        private void PesquisaSaida()
        {
            CreaterCursor Cr = new CreaterCursor();

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

            try
            {
                //Filtra Produtos Nota Fiscal
                RowRelatorio.Clear();
                RowRelatorio.Add(new RowsFiltro("DTEMISSAO", "System.DateTime", ">=", Util.ConverStringDateSearch(msktDataInicial.Text)));
                RowRelatorio.Add(new RowsFiltro("DTEMISSAO", "System.DateTime", "<=", Util.ConverStringDateSearch(msktDataFinal.Text)));


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

                LIS_PRODUTONFE_2Coll = LIS_PRODUTONFEP.ReadCollectionByParameter(RowRelatorio, "NOTAFISCALE, DTEMISSAO");

                // Remove CFOP, Aliq. ICMS  e nota fiscal repetido
                LIS_PRODUTONFECollection LIS_PRODUTONFE_2_2Coll = new LIS_PRODUTONFECollection();
                foreach (LIS_PRODUTONFEEntity item in LIS_PRODUTONFE_2Coll)
                {
                    if (LIS_PRODUTONFE_2_2Coll.Find(delegate(LIS_PRODUTONFEEntity item2)
                                                    { return(item2.CODCFOP == item.CODCFOP && item2.ALICMS == item.ALICMS && item2.NOTAFISCALE == item.NOTAFISCALE); }) == null)
                    {
                        LIS_PRODUTONFE_2_2Coll.Add(item);
                    }
                }
                LIS_PRODUTONFE_2Coll.Clear();
                LIS_PRODUTONFE_2Coll = LIS_PRODUTONFE_2_2Coll;

                PreencheGrid2();

                this.Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show("Erro técnico: " + ex.Message);
            }
        }
Пример #5
0
        private static LIS_PRODUTONFECollection ExecuteReader(ref LIS_PRODUTONFECollection collection, ref FbDataReader dataReader, FbCommand dbCommand)
        {
            using (dataReader = dbCommand.ExecuteReader())
            {
                collection = new LIS_PRODUTONFECollection();

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

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

            return(collection);
        }
Пример #6
0
        private decimal RetornaQuantSaida(int Idproduto)
        {
            decimal result = 0;

            if (chkNFe.Checked)
            {
                LIS_PRODUTONFECollection LIS_PRODUTONFEColl2 = new LIS_PRODUTONFECollection();

                RowRelatorio.Clear();

                if (msktDataInicial.Text != "  /  /")
                {
                    RowRelatorio.Add(new RowsFiltro("DTEMISSAO", "System.DateTime", ">=", Util.ConverStringDateSearch(msktDataInicial.Text)));
                }

                if (msktDataFinal.Text != "  /  /")
                {
                    RowRelatorio.Add(new RowsFiltro("DTEMISSAO", "System.DateTime", "<=", Util.ConverStringDateSearch(msktDataFinal.Text)));
                }

                RowRelatorio.Add(new RowsFiltro("IDPRODUTO", "System.Int32", "=", Idproduto.ToString()));
                RowRelatorio.Add(new RowsFiltro("FLAGENVIADA", "System.String", "=", "S"));
                RowRelatorio.Add(new RowsFiltro("FLAGCANCELADA", "System.String", "=", "N"));

                LIS_PRODUTONFEColl2 = LIS_PRODUTONFEP.ReadCollectionByParameter(RowRelatorio, "IDNOTAFISCALE DESC");

                NOTAFISCALEProvider NOTAFISCALEP = new NOTAFISCALEProvider();
                foreach (LIS_PRODUTONFEEntity item in LIS_PRODUTONFEColl2)
                {
                    if (NOTAFISCALEP.Read(Convert.ToInt32(item.IDNOTAFISCALE)).FLAGCANCELADA.TrimEnd() == "N" && NOTAFISCALEP.Read(Convert.ToInt32(item.IDNOTAFISCALE)).FLAGENVIADA.TrimEnd() == "S")//Desconsidera nota fiscal cancelada
                    {
                        result += Convert.ToDecimal(item.QUANTIDADE);
                    }
                }
            }

            //Saida pelo Pedido de Venda
            if (chkSaidaPedido.Checked)
            {
                LIS_PRODUTOSPEDIDOCollection LIS_PRODUTOSPEDIDOColl = new LIS_PRODUTOSPEDIDOCollection();
                LIS_PRODUTOSPEDIDOProvider   LIS_PRODUTOSPEDIDOP    = new LIS_PRODUTOSPEDIDOProvider();

                RowRelatorio.Clear();
                RowRelatorio.Add(new RowsFiltro("IDPRODUTO", "System.Int32", "=", Idproduto.ToString()));

                if (msktDataInicial.Text != "  /  /")
                {
                    RowRelatorio.Add(new RowsFiltro("DTEMISSAO", "System.DateTime", ">=", Util.ConverStringDateSearch(msktDataInicial.Text)));
                }

                if (msktDataFinal.Text != "  /  /")
                {
                    RowRelatorio.Add(new RowsFiltro("DTEMISSAO", "System.DateTime", "<=", Util.ConverStringDateSearch(msktDataFinal.Text)));
                }

                LIS_PRODUTOSPEDIDOColl = LIS_PRODUTOSPEDIDOP.ReadCollectionByParameter(RowRelatorio);
                PEDIDOProvider PEDIDOP = new PEDIDOProvider();

                foreach (LIS_PRODUTOSPEDIDOEntity item2 in LIS_PRODUTOSPEDIDOColl)
                {
                    if (PEDIDOP.Read(Convert.ToInt32(item2.IDPEDIDO)).FLAGORCAMENTO.TrimEnd() == "N")
                    {
                        result += Convert.ToDecimal(item2.QUANTIDADE);
                    }
                }
            }


            //Saida Pedido2
            LIS_PRODUTOSPEDIDOMTQCollection LIS_PRODUTOSPEDIDOMTQColl = new LIS_PRODUTOSPEDIDOMTQCollection();
            LIS_PRODUTOSPEDIDOMTQProvider   LIS_PRODUTOSPEDIDOMTQP    = new LIS_PRODUTOSPEDIDOMTQProvider();

            RowRelatorio.Clear();
            RowRelatorio.Add(new RowsFiltro("IDPRODUTO", "System.Int32", "=", Idproduto.ToString()));

            if (msktDataInicial.Text != "  /  /")
            {
                RowRelatorio.Add(new RowsFiltro("DTEMISSAO", "System.DateTime", ">=", Util.ConverStringDateSearch(msktDataInicial.Text)));
            }

            if (msktDataFinal.Text != "  /  /")
            {
                RowRelatorio.Add(new RowsFiltro("DTEMISSAO", "System.DateTime", "<=", Util.ConverStringDateSearch(msktDataFinal.Text)));
            }

            LIS_PRODUTOSPEDIDOMTQColl = LIS_PRODUTOSPEDIDOMTQP.ReadCollectionByParameter(RowRelatorio);

            foreach (LIS_PRODUTOSPEDIDOMTQEntity item2 in LIS_PRODUTOSPEDIDOMTQColl)
            {
                if (item2.FLAGORCAMENTO.TrimEnd() == "N")
                {
                    result += Convert.ToDecimal(item2.MT2) * Convert.ToDecimal(item2.QUANTIDADE);
                }
            }

            ////Estoque Digisat
            CONFISISTEMAProvider CONFISISTEMAP = new CONFISISTEMAProvider();

            if (CONFISISTEMAP.Read(1).FLAGCPDIGISAT.TrimEnd() == "S")
            {
                ITEVENDAS_ECFCollection ITEVENDAS_ECFColl = new ITEVENDAS_ECFCollection();
                ITEVENDAS_ECFProvider   ITEVENDAS_ECFP    = new ITEVENDAS_ECFProvider();

                RowRelatorio.Clear();
                RowRelatorio.Add(new RowsFiltro("CANCELADO", "System.Int32", "=", "0"));
                RowRelatorio.Add(new RowsFiltro("CODIGO", "System.Int32", "=", Idproduto.ToString()));

                ITEVENDAS_ECFColl = ITEVENDAS_ECFP.ReadCollectionByParameter(RowRelatorio, "CUPOM DESC");
                foreach (ITEVENDAS_ECFEntity item in ITEVENDAS_ECFColl)
                {
                    result += Convert.ToDecimal(item.QTD);
                }
            }

            return(result);
        }
Пример #7
0
        public LIS_PRODUTONFECollection ReadCollectionByParameter(List <RowsFiltro> RowsFiltro, string FieldOrder)
        {
            FbDataReader             dataReader    = null;
            string                   strSqlCommand = String.Empty;
            LIS_PRODUTONFECollection collection    = null;

            try
            {
                if (RowsFiltro != null)
                {
                    if (RowsFiltro.Count > 0)
                    {
                        strSqlCommand = "SELECT * FROM LIS_PRODUTONFE 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_PRODUTONFE  order by  " + FieldOrder;
                    }
                }
                else
                {
                    strSqlCommand = "SELECT * FROM LIS_PRODUTONFE 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;
            }
        }
Пример #8
0
        public LIS_PRODUTONFECollection ReadCollection()
        {
            FbDataReader dataReader = null;

            try
            {
                LIS_PRODUTONFECollection 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_PRODUTONFE", 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_PRODUTONFE", 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;
            }
        }
Пример #9
0
        private decimal TotalValorProdutoAgrupado(int IDPRODUTO, int COD_MUN_IBGE)
        {
            decimal result = 0;

            LIS_PRODUTONFECollection LIS_PRODUTONFEColl = new LIS_PRODUTONFECollection();
            LIS_PRODUTONFEProvider   LIS_PRODUTONFEP    = new LIS_PRODUTONFEProvider();

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

            RowRelatorio.Add(new RowsFiltro("IDPRODUTO", "System.Int32", "=", IDPRODUTO.ToString()));
            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(cbProduto.SelectedValue) > 0)
            {
                RowRelatorio.Add(new RowsFiltro("IDPRODUTO", "System.Int32", "=", Convert.ToInt32(cbProduto.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"));
            }

            if (Convert.ToInt32(cbFuncionario.SelectedValue) > 0)
            {
                LIS_PRODUTONFEColl = LIS_PRODUTONFEP.ReadCollectionByParameter(RowRelatorio, "NOMEPRODUTO, NOTAFISCALE");
            }
            else
            {
                LIS_PRODUTONFEColl = LIS_PRODUTONFEP.ReadCollectionByParameter(RowRelatorio, "NOMEPRODUTO, NOTAFISCALE");
            }

            foreach (var item in LIS_PRODUTONFEColl)
            {
                result += Convert.ToDecimal(item.VALORTOTAL);
            }


            return(result);
        }
Пример #10
0
        private LIS_PRODUTONFECollection BuscaProdutoNFePelaCidade(int COD_MUN_IBGE)
        {
            LIS_PRODUTONFECollection LIS_PRODUTONFEColl = new LIS_PRODUTONFECollection();

            try
            {
                LIS_PRODUTONFEProvider LIS_PRODUTONFEP = new LIS_PRODUTONFEProvider();
                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(cbProduto.SelectedValue) > 0)
                {
                    RowRelatorio.Add(new RowsFiltro("IDPRODUTO", "System.Int32", "=", Convert.ToInt32(cbProduto.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_PRODUTONFEColl = LIS_PRODUTONFEP.ReadCollectionByParameter(RowRelatorio, "NOMEPRODUTO, NOTAFISCALE");
                }
                else
                {
                    LIS_PRODUTONFEColl = LIS_PRODUTONFEP.ReadCollectionByParameter(RowRelatorio, "NOMEPRODUTO, NOTAFISCALE");
                }


                LIS_PRODUTONFECollection LIS_PRODUTONFEColl_2 = new LIS_PRODUTONFECollection();
                if (chkAgruparProduto.Checked)
                {
                    //Remove os produtos Repetidos
                    foreach (LIS_PRODUTONFEEntity item in LIS_PRODUTONFEColl)
                    {
                        if (LIS_PRODUTONFEColl_2.Find(delegate(LIS_PRODUTONFEEntity item2) { return(item2.IDPRODUTO == item.IDPRODUTO); }) == null)
                        {
                            LIS_PRODUTONFEColl_2.Add(item);
                        }
                    }

                    LIS_PRODUTONFEColl = LIS_PRODUTONFEColl_2;
                }

                return(LIS_PRODUTONFEColl);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro técnico: " + ex.Message);
                return(LIS_PRODUTONFEColl);
            }
        }
Пример #11
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;
        }
Пример #12
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_PRODUTONFECollection LIS_PRODUTONFEColl_2 = new LIS_PRODUTONFECollection();

            foreach (LIS_PRODUTONFEEntity item in LIS_PRODUTONFEColl_1)
            {
                if (LIS_PRODUTONFEColl_2.Find(delegate(LIS_PRODUTONFEEntity item2) { return(item2.IDCFOP == item.IDCFOP); }) == null)
                {
                    LIS_PRODUTONFEColl_2.Add(item);
                }
            }

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

            row1_2.CreateCells(DataGriewDados, "CFOP:", "", "", "", "");
            row1_2.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
            DataGriewDados.Rows.Add(row1_2);

            foreach (var LIS_PRODUTONFETy in LIS_PRODUTONFEColl_2)
            {
                //Busca Dados do produto por cidade
                LIS_PRODUTONFECollection LIS_PRODUTONFEColl3 = new LIS_PRODUTONFECollection();
                LIS_PRODUTONFEColl3 = BuscaProdutoCFOP(Convert.ToInt32(LIS_PRODUTONFETy.IDCFOP));

                DataGridViewRow row_header = new DataGridViewRow();
                row_header.CreateCells(DataGriewDados, LIS_PRODUTONFETy.CODCFOP, "", "", "", "");
                row_header.DefaultCellStyle.Font = new Font("Arial", 8);
                DataGriewDados.Rows.Add(row_header);

                DataGridViewRow row_header2 = new DataGridViewRow();
                row_header2.CreateCells(DataGriewDados, "Produto", "Quant.", "DT Emissão", "Nota Fiscal", "Total");
                row_header2.DefaultCellStyle.Font = new Font("Arial", 8);
                DataGriewDados.Rows.Add(row_header2);

                SubTotal = 0;
                foreach (var LIS_PRODUTONFETy_3 in LIS_PRODUTONFEColl3)
                {
                    string DataEmissao  = Convert.ToDateTime(LIS_PRODUTONFETy_3.DTEMISSAO).ToString("dd/MM/yyyy");
                    string NomeProduto  = LIS_PRODUTONFETy_3.NOMEPRODUTO;
                    string QuantProduto = LIS_PRODUTONFETy_3.QUANTIDADE.ToString();
                    TotalQuantidade += Convert.ToDecimal(LIS_PRODUTONFETy_3.QUANTIDADE);
                    string NumNF        = LIS_PRODUTONFETy_3.NOTAFISCALE.ToString().PadLeft(6, '0');
                    string TotalProduto = Convert.ToDecimal(LIS_PRODUTONFETy_3.VALORTOTAL).ToString("n2");
                    SubTotal   += Convert.ToDecimal(LIS_PRODUTONFETy_3.VALORTOTAL);
                    TotalGeral += Convert.ToDecimal(LIS_PRODUTONFETy_3.VALORTOTAL);

                    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;
        }