Пример #1
0
        private void btnConsultar_Click_1(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));

                    if (rbOrcamento.Checked)
                    {
                        RowRelatorio.Add(new RowsFiltro("FLAGORCAMENTO", "System.String", "=", "S"));
                    }
                    else if (rbVenda.Checked)
                    {
                        RowRelatorio.Add(new RowsFiltro("FLAGORCAMENTO", "System.String", "=", "N"));
                    }

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

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

                    LIS_PEDIDOFESTAColl = LIS_PEDIDOFESTAP.ReadCollectionByParameter(RowRelatorio, "IDPEDIDOFESTA DESC");

                    PreencheGrid();
                }
                catch (Exception EX)
                {
                    MessageBox.Show("Erro na pesquisa!");
                    MessageBox.Show("Erro técnico: " + EX.Message);
                }
            }
        }
Пример #2
0
        private static LIS_PEDIDOFESTACollection ExecuteReader(ref LIS_PEDIDOFESTACollection collection, ref FbDataReader dataReader, FbCommand dbCommand)
        {
            using (dataReader = dbCommand.ExecuteReader())
            {
                collection = new LIS_PEDIDOFESTACollection();

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

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

            return(collection);
        }
Пример #3
0
        private void FrmRelatorioPedidoFesta_Load(object sender, EventArgs e)
        {
            this.MinimizeBox     = false;
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.reportViewer1.RefreshReport();


            EMPRESAProvider   EMPRESAP    = new EMPRESAProvider();
            EMPRESACollection EMPRESAColl = new EMPRESACollection();

            EMPRESAColl = EMPRESAP.ReadCollectionByParameter(null);

            NomeEmpresa = EMPRESAColl[0].NOMEFANTASIA;

            //Logomarca
            CONFISISTEMAProvider CONFISISTEMAP  = new CONFISISTEMAProvider();
            CONFISISTEMAEntity   CONFISISTEMAty = CONFISISTEMAP.Read(1);

            if (CONFISISTEMAty.FLAGLOGORELATORIO == "S")
            {
                if (CONFISISTEMAty.IDARQUIVOBINARIO1 != null)
                {
                    ARQUIVOBINARIOProvider   ARQUIVOBINARIOP    = new ARQUIVOBINARIOProvider();
                    ARQUIVOBINARIOCollection ARQUIVOBINARIOColl = new ARQUIVOBINARIOCollection();
                    RowRelatorio.Clear();
                    RowRelatorio.Add(new RowsFiltro("IDARQUIVOBINARIO", "System.Int32", "=", CONFISISTEMAty.IDARQUIVOBINARIO1.ToString()));
                    ARQUIVOBINARIOColl = ARQUIVOBINARIOP.ReadCollectionByParameter(RowRelatorio);
                    this.ARQUIVOBINARIOCollectionBindingSource.DataSource = ARQUIVOBINARIOColl;
                }
            }


            //Dados do Cliente
            RowRelatorio.Clear();
            RowRelatorio.Add(new RowsFiltro("IDCLIENTE", "System.Int32", "=", IDCLIENTE.ToString()));
            LIS_CLIENTEProvider LIS_CLIENTEP = new LIS_CLIENTEProvider();

            LIS_CLIENTEColl = LIS_CLIENTEP.ReadCollectionByParameter(RowRelatorio);
            string cpfcnpjPar = (LIS_CLIENTEColl[0].CNPJ == "  .   .   /    -" || LIS_CLIENTEColl[0].CNPJ == string.Empty) ? LIS_CLIENTEColl[0].CPF : LIS_CLIENTEColl[0].CNPJ;


            //Dados do Pedido
            RowRelatorio.Clear();
            RowRelatorio.Add(new RowsFiltro("IDPEDIDOFESTA", "System.Int32", "=", IDPEDIDOFESTA.ToString()));
            LIS_PEDIDOFESTAProvider LIS_PEDIDOFESTAP = new LIS_PEDIDOFESTAProvider();

            LIS_PEDIDOFESTAColl = LIS_PEDIDOFESTAP.ReadCollectionByParameter(RowRelatorio);

            //Dados do Produto
            RowRelatorio.Clear();
            RowRelatorio.Add(new RowsFiltro("IDPEDIDOFESTA", "System.Int32", "=", IDPEDIDOFESTA.ToString()));
            LIS_PRODUTOSPEDFESTAProvider   LIS_PRODUTOSPEDFESTAP    = new LIS_PRODUTOSPEDFESTAProvider();
            LIS_PRODUTOSPEDFESTACollection LIS_PRODUTOSPEDFESTAColl = new LIS_PRODUTOSPEDFESTACollection();

            LIS_PRODUTOSPEDFESTAColl = LIS_PRODUTOSPEDFESTAP.ReadCollectionByParameter(RowRelatorio);

            ///Dados do Servico
            RowRelatorio.Clear();
            RowRelatorio.Add(new RowsFiltro("IDPEDIDOFESTA", "System.Int32", "=", IDPEDIDOFESTA.ToString()));
            LIS_SERVICOPEDIDOFESTAProvider   LIS_SERVICOPEDIDOFESTAP    = new LIS_SERVICOPEDIDOFESTAProvider();
            LIS_SERVICOPEDIDOFESTACollection LIS_SERVICOPEDIDOFESTAColl = new LIS_SERVICOPEDIDOFESTACollection();

            LIS_SERVICOPEDIDOFESTAColl = LIS_SERVICOPEDIDOFESTAP.ReadCollectionByParameter(RowRelatorio);

            foreach (var item in LIS_SERVICOPEDIDOFESTAColl)
            {
                VisualizaServico      = "true";
                TotalServicoProdutos += Convert.ToDecimal(item.VALORTOTAL);
            }

            foreach (var item in LIS_PRODUTOSPEDFESTAColl)
            {
                VisualizaProduto      = "true";
                TotalServicoProdutos += Convert.ToDecimal(item.VALORTOTAL);
            }



            string titulo = "Nº PEDIDO " + IDPEDIDOFESTA.ToString().PadLeft(6, '0');

            if (LIS_PEDIDOFESTAColl[0].FLAGORCAMENTO.TrimEnd() == "S")
            {
                titulo = "Nº ORÇAMENTO " + IDPEDIDOFESTA.ToString().PadLeft(6, '0');
            }

            //setando os parametro
            Microsoft.Reporting.WinForms.ReportParameter[] p = new Microsoft.Reporting.WinForms.ReportParameter[6];
            p[0] = new Microsoft.Reporting.WinForms.ReportParameter("CPFCNPJ", cpfcnpjPar);
            p[1] = new Microsoft.Reporting.WinForms.ReportParameter("titulo", titulo.ToString().PadLeft(6, '0'));
            p[2] = new Microsoft.Reporting.WinForms.ReportParameter("nomeempresa", NomeEmpresa);
            p[3] = new Microsoft.Reporting.WinForms.ReportParameter("VisualizaProduto", VisualizaProduto);
            p[4] = new Microsoft.Reporting.WinForms.ReportParameter("TotalServicoProdutos", TotalServicoProdutos.ToString("n2"));
            p[5] = new Microsoft.Reporting.WinForms.ReportParameter("VisualizaServico", VisualizaServico);
            reportViewer1.LocalReport.SetParameters(p);


            this.LIS_CLIENTECollectionBindingSource.DataSource            = LIS_CLIENTEColl;
            this.EMPRESACollectionBindingSource.DataSource                = EMPRESAColl;
            this.LIS_PEDIDOFESTAEntityBindingSource.DataSource            = LIS_PEDIDOFESTAColl;
            this.LIS_PRODUTOSPEDFESTACollectionBindingSource.DataSource   = LIS_PRODUTOSPEDFESTAColl;
            this.LIS_SERVICOPEDIDOFESTACollectionBindingSource.DataSource = LIS_SERVICOPEDIDOFESTAColl;


            this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
            this.reportViewer1.ZoomMode = ZoomMode.Percent;
            this.reportViewer1.RefreshReport();


            this.reportViewer1.RefreshReport();
            this.reportViewer1.RefreshReport();
        }
Пример #4
0
        public LIS_PEDIDOFESTACollection ReadCollectionByParameter(List <RowsFiltro> RowsFiltro, string FieldOrder)
        {
            FbDataReader dataReader              = null;
            string       strSqlCommand           = String.Empty;
            LIS_PEDIDOFESTACollection collection = null;

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

            try
            {
                LIS_PEDIDOFESTACollection 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_PEDIDOFESTA", 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_PEDIDOFESTA", 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;
            }
        }